From 97fe2ea16cca643e4f9d3a77e39ad8c3a3ff01d5 Mon Sep 17 00:00:00 2001
From: andrebauer <bauerand@informatik.uni-marburg.de>
Date: Sun, 3 May 2020 02:08:16 +0200
Subject: 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.
---
 src/Text/Pandoc/Writers/LaTeX.hs | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

(limited to 'src/Text/Pandoc/Writers')

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"
-- 
cgit v1.2.3