aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt35
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs29
-rw-r--r--test/command/4805-beamer-columns-alignment.md40
3 files changed, 99 insertions, 5 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index db658536b..972a7d918 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -5379,6 +5379,41 @@ containers with class `column` and a `width` attribute:
:::
::::::::::::::
+### Additional columns attributes in beamer
+
+The div containers with classes `columns` and `column` can optionally have
+an `align` attribute.
+The class `columns` can optionally have a `totalwidth` attribute or an
+`onlytextwidth` class.
+
+ :::::::::::::: {.columns align=center totalwidth=8em}
+ ::: {.column width="40%"}
+ contents...
+ :::
+ ::: {.column width="60%" align=bottom}
+ contents...
+ :::
+ ::::::::::::::
+
+The `align` attributes on `columns` and `column` can be used with the
+values `top`, `top-baseline`, `center` and `bottom` to vertically align
+the columns. It defaults to `top` in `columns`.
+
+The `totalwidth` attribute limits the width of the columns to the given value.
+
+ :::::::::::::: {.columns align=top .onlytextwidth}
+ ::: {.column width="40%" align=center}
+ contents...
+ :::
+ ::: {.column width="60%"}
+ contents...
+ :::
+ ::::::::::::::
+
+The class `onlytextwidth` sets the `totalwidth` to `\textwidth`.
+
+See Section 12.7 of the [Beamer User's Guide] for more details.
+
## Frame attributes in beamer
Sometimes it is necessary to add the LaTeX `[fragile]` option to
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 6ac79f00e..021ef2645 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1031,6 +1031,14 @@ sectionHeader classes ident level lst = do
braces txtNoNotes
else empty
+mapAlignment :: Text -> Text
+mapAlignment a = case a of
+ "top" -> "T"
+ "top-baseline" -> "t"
+ "bottom" -> "b"
+ "center" -> "c"
+ _ -> a
+
wrapDiv :: PandocMonad m => Attr -> Doc Text -> LW m (Doc Text)
wrapDiv (_,classes,kvs) t = do
beamer <- gets stBeamer
@@ -1038,14 +1046,25 @@ wrapDiv (_,classes,kvs) t = do
lang <- toLang $ lookup "lang" kvs
let wrapColumns = if beamer && "columns" `elem` classes
then \contents ->
- inCmd "begin" "columns" <> brackets "T"
- $$ contents
- $$ inCmd "end" "columns"
+ let valign = maybe "T" mapAlignment (lookup "align" kvs)
+ totalwidth = maybe [] (\x -> ["totalwidth=" <> x])
+ (lookup "totalwidth" kvs)
+ onlytextwidth = filter ((==) "onlytextwidth") classes
+ options = text $ T.unpack $ T.intercalate "," $
+ valign : totalwidth ++ onlytextwidth
+ in inCmd "begin" "columns" <> brackets options
+ $$ contents
+ $$ inCmd "end" "columns"
else id
wrapColumn = if beamer && "column" `elem` classes
then \contents ->
- let w = maybe "0.48" fromPct (lookup "width" kvs)
- in inCmd "begin" "column" <>
+ let valign =
+ maybe ""
+ (brackets . text . T.unpack . mapAlignment)
+ (lookup "align" kvs)
+ w = maybe "0.48" fromPct (lookup "width" kvs)
+ in inCmd "begin" "column" <>
+ valign <>
braces (literal w <> "\\textwidth")
$$ contents
$$ inCmd "end" "column"
diff --git a/test/command/4805-beamer-columns-alignment.md b/test/command/4805-beamer-columns-alignment.md
new file mode 100644
index 000000000..bd1be0f20
--- /dev/null
+++ b/test/command/4805-beamer-columns-alignment.md
@@ -0,0 +1,40 @@
+```
+pandoc -t beamer
+:::: { .columns }
+::: { .column align=center }
+:::
+::: { .column align=bottom }
+:::
+::::
+
+:::: { .columns align=bottom .onlytextwidth }
+::: { .column align=top }
+:::
+::: { .column align=top-baseline }
+:::
+::::
+
+:::: { .columns totalwidth=7em }
+::::
+^D
+\begin{frame}
+\begin{columns}[T]
+\begin{column}[c]{0.48\textwidth}
+\end{column}
+
+\begin{column}[b]{0.48\textwidth}
+\end{column}
+\end{columns}
+
+\begin{columns}[b,onlytextwidth]
+\begin{column}[T]{0.48\textwidth}
+\end{column}
+
+\begin{column}[t]{0.48\textwidth}
+\end{column}
+\end{columns}
+
+\begin{columns}[T,totalwidth=7em]
+\end{columns}
+\end{frame}
+```