@@ -490,24 +490,28 @@ tableRowToLaTeX :: Bool
490 -> [[Block]]
490 -> [[Block]]
491 -> State WriterState Doc
491 -> State WriterState Doc
492tableRowToLaTeX header aligns widths cols = do
492tableRowToLaTeX header aligns widths cols = do
493− renderedCells <- mapM blockListToLaTeX cols
494− let valign = text $ if header then "[b]" else "[t]"
495− let halign x = case x of
496− AlignLeft -> "\\raggedright"
497− AlignRight -> "\\raggedleft"
498− AlignCenter -> "\\centering"
499− AlignDefault -> "\\raggedright"
500 -- scale factor compensates for extra space between columns
493 -- scale factor compensates for extra space between columns
501 -- so the whole table isn't larger than columnwidth
494 -- so the whole table isn't larger than columnwidth
502 let scaleFactor = 0.97 ** fromIntegral (length aligns)
495 let scaleFactor = 0.97 ** fromIntegral (length aligns)
503− let toCell 0 _ c = c
504− toCell w a c = "\\begin{minipage}" <> valign <>
505− braces (text (printf "%.2f\\columnwidth"
506− (w * scaleFactor))) <>
496+ let widths' = map (scaleFactor *) widths
507− (halign a <> cr <> c <> cr) <> "\\end{minipage}"
497+ cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
508− let cells = zipWith3 toCell widths aligns renderedCells
509 return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
498 return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
500+tableCellToLaTeX :: Bool -> (Double, Alignment, [Block])
501+ -> State WriterState Doc
502+tableCellToLaTeX _ (0, _, blocks) = blockListToLaTeX blocks
503+tableCellToLaTeX header (width, align, blocks) = do
504+ cellContents <- blockListToLaTeX blocks
505+ let valign = text $ if header then "[b]" else "[t]"
506+ let halign = case align of
507+ AlignLeft -> "\\raggedright"
508+ AlignRight -> "\\raggedleft"
509+ AlignCenter -> "\\centering"
510+ AlignDefault -> "\\raggedright"
511+ return $ "\\begin{minipage}" <> valign <>
512+ braces (text (printf "%.2f\\columnwidth" width)) <>
513+ (halign <> cr <> cellContents <> cr) <> "\\end{minipage}"
511listItemToLaTeX :: [Block] -> State WriterState Doc
515listItemToLaTeX :: [Block] -> State WriterState Doc
512listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
516listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .