diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-06-05 14:13:58 -0600 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-06-05 14:13:58 -0600 |
commit | 21cc52abe33997ea2f2c539f10d26684b7633bc0 (patch) | |
tree | 0696a72ee641bfdf51289ede94c7a5c0603c7886 /src | |
parent | c550bf8482310dfbcb20694e7bc969d19acc5f7d (diff) | |
download | pandoc-21cc52abe33997ea2f2c539f10d26684b7633bc0.tar.gz |
LaTeX writer: Fix regression in table header position.
In recent versions the table headers were no longer bottom-aligned
(if more than one line). This patch fixes that by using minipages
for table headers in non-simple tables.
Closes #7347.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX/Table.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs index 16f63314b..8dc7d1162 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs @@ -16,6 +16,7 @@ module Text.Pandoc.Writers.LaTeX.Table ) where import Control.Monad.State.Strict import Data.List (intersperse) +import qualified Data.List.NonEmpty as NonEmpty import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Text (Text) import qualified Data.Text as T @@ -243,8 +244,13 @@ cellToLaTeX :: PandocMonad m -> Ann.Cell -> LW m (Doc Text) cellToLaTeX blockListToLaTeX celltype annotatedCell = do - let (Ann.Cell _specs _colnum cell) = annotatedCell - let (Cell _attr align rowspan colspan blocks) = cell + let (Ann.Cell specs _colnum cell) = annotatedCell + let hasWidths = snd (NonEmpty.head specs) /= ColWidthDefault + let specAlign = fst (NonEmpty.head specs) + let (Cell _attr align' rowspan colspan blocks) = cell + let align = case align' of + AlignDefault -> specAlign + _ -> align' beamer <- gets stBeamer externalNotes <- gets stExternalNotes inMinipage <- gets stInMinipage @@ -256,7 +262,7 @@ cellToLaTeX blockListToLaTeX celltype annotatedCell = do Plain{} -> True _ -> False result <- - if all isPlainOrPara blocks + if not hasWidths || (celltype /= HeaderCell && all isPlainOrPara blocks) then blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks else do @@ -290,3 +296,4 @@ cellToLaTeX blockListToLaTeX celltype annotatedCell = do data CellType = HeaderCell | BodyCell + deriving Eq |