LaTeX writer: Add \strut to fix multiline tables

See: http://tex.stackexchange.com/questions/34971
This commit is contained in:
Jose Luis Duran 2014-08-29 13:54:08 +00:00
parent f1d330b7b5
commit 4c684561ee
2 changed files with 47 additions and 46 deletions

View file

@ -556,7 +556,8 @@ tableCellToLaTeX header (width, align, blocks) = do
AlignDefault -> "\\raggedright" AlignDefault -> "\\raggedright"
return $ ("\\begin{minipage}" <> valign <> return $ ("\\begin{minipage}" <> valign <>
braces (text (printf "%.2f\\columnwidth" width)) <> braces (text (printf "%.2f\\columnwidth" width)) <>
(halign <> cr <> cellContents <> cr) <> "\\end{minipage}") (halign <> "\\strut" <> cr <> cellContents <> cr) <>
"\\strut\\end{minipage}")
$$ case notes of $$ case notes of
[] -> empty [] -> empty
ns -> (case length ns of ns -> (case length ns of

View file

@ -52,47 +52,47 @@ Multiline table with caption:
\begin{longtable}[c]{@{}clrl@{}} \begin{longtable}[c]{@{}clrl@{}}
\caption{Here's the caption. It may span multiple lines.}\tabularnewline \caption{Here's the caption. It may span multiple lines.}\tabularnewline
\toprule \toprule
\begin{minipage}[b]{0.13\columnwidth}\centering \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Centered Header Centered Header
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
Left Aligned Left Aligned
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
Right Aligned Right Aligned
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
Default aligned Default aligned
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\midrule \midrule
\endfirsthead \endfirsthead
\toprule \toprule
\begin{minipage}[b]{0.13\columnwidth}\centering \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Centered Header Centered Header
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
Left Aligned Left Aligned
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
Right Aligned Right Aligned
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
Default aligned Default aligned
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\midrule \midrule
\endhead \endhead
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
First First
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
12.0 12.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Example of a row that spans multiple lines. Example of a row that spans multiple lines.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
Second Second
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
5.0 5.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Here's another one. Note the blank line between rows. Here's another one. Note the blank line between rows.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\bottomrule \bottomrule
\end{longtable} \end{longtable}
@ -100,35 +100,35 @@ Multiline table without caption:
\begin{longtable}[c]{@{}clrl@{}} \begin{longtable}[c]{@{}clrl@{}}
\toprule \toprule
\begin{minipage}[b]{0.13\columnwidth}\centering \begin{minipage}[b]{0.13\columnwidth}\centering\strut
Centered Header Centered Header
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
Left Aligned Left Aligned
\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
Right Aligned Right Aligned
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
Default aligned Default aligned
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\midrule \midrule
\endhead \endhead
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
First First
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
12.0 12.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Example of a row that spans multiple lines. Example of a row that spans multiple lines.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
Second Second
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
5.0 5.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Here's another one. Note the blank line between rows. Here's another one. Note the blank line between rows.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\bottomrule \bottomrule
\end{longtable} \end{longtable}
@ -146,23 +146,23 @@ Multiline table without column headers:
\begin{longtable}[c]{@{}clrl@{}} \begin{longtable}[c]{@{}clrl@{}}
\toprule \toprule
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
First First
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
12.0 12.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Example of a row that spans multiple lines. Example of a row that spans multiple lines.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\begin{minipage}[t]{0.13\columnwidth}\centering \begin{minipage}[t]{0.13\columnwidth}\centering\strut
Second Second
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
row row
\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft \strut\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
5.0 5.0
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright \strut\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
Here's another one. Note the blank line between rows. Here's another one. Note the blank line between rows.
\end{minipage}\tabularnewline \strut\end{minipage}\tabularnewline
\bottomrule \bottomrule
\end{longtable} \end{longtable}