git.iko.soy/typeable/pandoc
on master help sign in
LaTeX Writer: Add support for customizable alignment of columns in beamer (#6331)
97fe2eaandrebauer
MANUAL.txt+35
@@ -5379,6 +5379,41 @@ containers with class `column` and a `width` attribute:
5379 :::
5379 :::
5380 ::::::::::::::
5380 ::::::::::::::
5381
5381
5382+### Additional columns attributes in beamer
5383+
5384+The div containers with classes `columns` and `column` can optionally have
5385+an `align` attribute.
5386+The class `columns` can optionally have a `totalwidth` attribute or an
5387+`onlytextwidth` class.
5388+
5389+ :::::::::::::: {.columns align=center totalwidth=8em}
5390+ ::: {.column width="40%"}
5391+ contents...
5392+ :::
5393+ ::: {.column width="60%" align=bottom}
5394+ contents...
5395+ :::
5396+ ::::::::::::::
5397+
5398+The `align` attributes on `columns` and `column` can be used with the
5399+values `top`, `top-baseline`, `center` and `bottom` to vertically align
5400+the columns. It defaults to `top` in `columns`.
5401+
5402+The `totalwidth` attribute limits the width of the columns to the given value.
5403+
5404+ :::::::::::::: {.columns align=top .onlytextwidth}
5405+ ::: {.column width="40%" align=center}
5406+ contents...
5407+ :::
5408+ ::: {.column width="60%"}
5409+ contents...
5410+ :::
5411+ ::::::::::::::
5412+
5413+The class `onlytextwidth` sets the `totalwidth` to `\textwidth`.
5414+
5415+See Section 12.7 of the [Beamer User's Guide] for more details.
5416+
5382## Frame attributes in beamer
5417## Frame attributes in beamer
5383
5418
5384Sometimes it is necessary to add the LaTeX `[fragile]` option to
5419Sometimes it is necessary to add the LaTeX `[fragile]` option to
src/Text/Pandoc/Writers/LaTeX.hs+24−5
@@ -1031,6 +1031,14 @@ sectionHeader classes ident level lst = do
1031 braces txtNoNotes
1031 braces txtNoNotes
1032 else empty
1032 else empty
1033
1033
1034+mapAlignment :: Text -> Text
1035+mapAlignment a = case a of
1036+ "top" -> "T"
1037+ "top-baseline" -> "t"
1038+ "bottom" -> "b"
1039+ "center" -> "c"
1040+ _ -> a
1041+
1034wrapDiv :: PandocMonad m => Attr -> Doc Text -> LW m (Doc Text)
1042wrapDiv :: PandocMonad m => Attr -> Doc Text -> LW m (Doc Text)
1035wrapDiv (_,classes,kvs) t = do
1043wrapDiv (_,classes,kvs) t = do
1036 beamer <- gets stBeamer
1044 beamer <- gets stBeamer
@@ -1038,14 +1046,25 @@ wrapDiv (_,classes,kvs) t = do
1038 lang <- toLang $ lookup "lang" kvs
1046 lang <- toLang $ lookup "lang" kvs
1039 let wrapColumns = if beamer && "columns" `elem` classes
1047 let wrapColumns = if beamer && "columns" `elem` classes
1040 then \contents ->
1048 then \contents ->
1049+ let valign = maybe "T" mapAlignment (lookup "align" kvs)
1050+ totalwidth = maybe [] (\x -> ["totalwidth=" <> x])
1051+ (lookup "totalwidth" kvs)
1052+ onlytextwidth = filter ((==) "onlytextwidth") classes
1053+ options = text $ T.unpack $ T.intercalate "," $
1054+ valign : totalwidth ++ onlytextwidth
1041− inCmd "begin" "columns" <> brackets "T"
1055+ in inCmd "begin" "columns" <> brackets options
1042− $$ contents
1056+ $$ contents
1043− $$ inCmd "end" "columns"
1057+ $$ inCmd "end" "columns"
1044 else id
1058 else id
1045 wrapColumn = if beamer && "column" `elem` classes
1059 wrapColumn = if beamer && "column" `elem` classes
1046 then \contents ->
1060 then \contents ->
1061+ let valign =
1062+ maybe ""
1063+ (brackets . text . T.unpack . mapAlignment)
1064+ (lookup "align" kvs)
1047− let w = maybe "0.48" fromPct (lookup "width" kvs)
1065+ w = maybe "0.48" fromPct (lookup "width" kvs)
1048− in inCmd "begin" "column" <>
1066+ in inCmd "begin" "column" <>
1067+ valign <>
1049 braces (literal w <> "\\textwidth")
1068 braces (literal w <> "\\textwidth")
1050 $$ contents
1069 $$ contents
1051 $$ inCmd "end" "column"
1070 $$ inCmd "end" "column"
test/command/4805-beamer-columns-alignment.mdnew file+40
@@ -0,0 +1,40 @@
1+```
2+pandoc -t beamer
3+:::: { .columns }
4+::: { .column align=center }
5+:::
6+::: { .column align=bottom }
7+:::
8+::::
9+
10+:::: { .columns align=bottom .onlytextwidth }
11+::: { .column align=top }
12+:::
13+::: { .column align=top-baseline }
14+:::
15+::::
16+
17+:::: { .columns totalwidth=7em }
18+::::
19+^D
20+\begin{frame}
21+\begin{columns}[T]
22+\begin{column}[c]{0.48\textwidth}
23+\end{column}
24+
25+\begin{column}[b]{0.48\textwidth}
26+\end{column}
27+\end{columns}
28+
29+\begin{columns}[b,onlytextwidth]
30+\begin{column}[T]{0.48\textwidth}
31+\end{column}
32+
33+\begin{column}[t]{0.48\textwidth}
34+\end{column}
35+\end{columns}
36+
37+\begin{columns}[T,totalwidth=7em]
38+\end{columns}
39+\end{frame}
40+```