diff options
author | andrebauer <bauerand@informatik.uni-marburg.de> | 2020-05-03 02:08:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 17:08:16 -0700 |
commit | 97fe2ea16cca643e4f9d3a77e39ad8c3a3ff01d5 (patch) | |
tree | 5cd764a2f6a6810c05147f60efff2aacb9de7e16 /src | |
parent | 0fafe9dd32d5a0266d74ac78b1818050bc69a4bd (diff) | |
download | pandoc-97fe2ea16cca643e4f9d3a77e39ad8c3a3ff01d5.tar.gz |
LaTeX Writer: Add support for customizable alignment of columns in beamer (#6331)
Add support for customizable alignment of columns in beamer.
Closes #4805, closes #4150.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 29 |
1 files changed, 24 insertions, 5 deletions
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" |