LaTeX writer: add strut at end of minipage if it contains...

line breaks.  Without them, the last line is shorter
than it should be, at least in some cases.
This commit is contained in:
John MacFarlane 2021-06-21 23:31:27 -07:00
parent 9867231779
commit 8eed5b90d0
3 changed files with 10 additions and 7 deletions

View file

@ -264,10 +264,11 @@ cellToLaTeX blockListToLaTeX celltype annotatedCell = do
_ -> False
let hasLineBreak LineBreak = Any True
hasLineBreak _ = Any False
let hasLineBreaks = getAny $ query hasLineBreak blocks
result <-
if not hasWidths || (celltype /= HeaderCell
&& all isPlainOrPara blocks
&& not (getAny (query hasLineBreak blocks)))
&& not hasLineBreaks)
then
blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
else do
@ -280,7 +281,9 @@ cellToLaTeX blockListToLaTeX celltype annotatedCell = do
let halign = literal $ alignCommand align
return $ "\\begin{minipage}" <> valign <>
braces "\\linewidth" <> halign <> cr <>
cellContents <> cr <>
cellContents <>
(if hasLineBreaks then "\\strut" else mempty)
<> cr <>
"\\end{minipage}"
modify $ \st -> st{ stExternalNotes = externalNotes }
when (rowspan /= RowSpan 1) $

View file

@ -20,7 +20,7 @@
\endhead
\begin{minipage}[t]{\linewidth}\raggedright
{ text\\
text2 }
text2 }\strut
\end{minipage} \\
\bottomrule
\end{longtable}

View file

@ -11,10 +11,10 @@ Name
Capital
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Population\\
(in 2018)
(in 2018)\strut
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Area\\
(in km\textsuperscript{2})
(in km\textsuperscript{2})\strut
\end{minipage} \\
\midrule
\endfirsthead
@ -25,10 +25,10 @@ Name
Capital
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Population\\
(in 2018)
(in 2018)\strut
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Area\\
(in km\textsuperscript{2})
(in km\textsuperscript{2})\strut
\end{minipage} \\
\midrule
\endhead