TeX - LaTeX Asked by James Grover on February 1, 2021
I am part of a team working collaboratively to prepare a large document containing tabular and multimedia content using LaTeX (publishing to PDF using lualatex), and we’ve hit a persistent problem with one page in our document having text content spill over the end of the page as follows:
We believe we’ve tracked down why, and the following is the MWE used to produce the above:
documentclass[a4paper]{report}
usepackage[margin=2.54cm]{geometry}
usepackage{lipsum}
%usepackage{showframe}
usepackage{longtable}
usepackage[draft]{graphicx}
%graphicspath{ {Resources/} }
begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
section{Section here}
subsection{Subsection here}
lipsum[1-2]
begin{figure}
caption{Caption 1}
includegraphics[height=9.24cm]{image1.png}
end{figure}
subsection{Subsection here}
lipsum[1]
begin{figure}
caption{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed consequat ex vitae}
includegraphics[height=9.60cm]{image2.png}
end{figure}
lipsum[1-3]
begin{longtable}{|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
cline{1-6}
& Text & Text & Text & Text & Text
cline{1-6}
end{longtable}
lipsum[1-6]
end{document}
The issue we’re hitting appears to be the bug documented at https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=tools/3512, caused by the longtable package incorrectly resetting the pagegoal erroneously when it follows a float.
There’s a suggested fix on the issue, and this has been discussed before at Pagebreak doesn't work with floats and longtabu, but in both cases the fix now predates the current version of Longtable, and we would ideally like to avoid trying to maintain a patched version of Longtable across our whole team.
Is anyone aware of a document-local fix to this that we could use as an alternative?
Sorry, I try to keep the bug report turnaround to under 20 years, but it's not always easy....
You can make the changes suggested in the report that you reference in-document rather than modifying the .sty
file.
documentclass[a4paper]{report}
usepackage[margin=2.54cm]{geometry}
usepackage{lipsum}
%usepackage{showframe}
usepackage{longtable}
makeatletter
defLT@start{%
letLT@startendgraf
endgrafpenaltyz@vskipLTpreendgraf
dimen@pagetotal
advancedimen@ htifvoidLT@firstheadLT@headelseLT@firstheadfi
advancedimen@ dpifvoidLT@firstheadLT@headelseLT@firstheadfi
advancedimen@ htLT@foot
dimen@iivfuzz
vfuzzmaxdimen
setboxtw@copyz@
setboxtw@vsplittw@ to ht@arstrutbox
setboxtw@vbox{unvboxtw@}%
vfuzzdimen@ii
advancedimen@ ht
ifdimht@arstrutbox>httw@@arstrutboxelsetw@fi
advancedimen@dp
ifdimdp@arstrutbox>dptw@@arstrutboxelsetw@fi
advancedimen@ -pagegoal
ifdim dimen@>z@vfilbreakfi
global@colroom@colht
ifvoidLT@footelse
% advancevsize-htLT@foot
globaladvancevsize-htLT@foot
globaladvance@colroom-htLT@foot
dimen@pagegoaladvancedimen@-htLT@footpagegoaldimen@
maxdepthz@
fi
ifvoidLT@firstheadcopyLT@headelseboxLT@firstheadfinobreak
output{LT@output}}
defendlongtable{%
crcr
noalign{%
letLT@entryLT@entry@chop
xdefLT@save@row{LT@save@row}}%
LT@echunk
LT@start
unvboxz@
LT@get@widths
if@filesw
{letLT@entryLT@entry@writeimmediatewrite@auxout{%
gdefexpandafternoexpand
csname LT@romannumeralc@LT@tablesendcsname
{LT@save@row}}}%
fi
ifxLT@save@rowLT@@save@row
else
LT@warn{Column @width s have changedMessageBreak
in table thetable}%
LT@final@warn
fi
endgrafpenalty -LT@end@pen
%
ifvoidLT@footelse
globaladvancevsizehtLT@foot
globaladvance@colroomhtLT@foot
dimen@pagegoaladvancedimen@htLT@footpagegoaldimen@
fi
%
endgroup
global@mparbottomz@
% pagegoalvsize
endgrafpenaltyz@addvspaceLTpost
ifvoidfootinselseinsertfootins{}fi}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
%
advancedimen@htLT@foot
%
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
%
globalvsize@colroom
%
setboxz@vbox{boxLT@head}%
fi
fi
% global@colroom@colht
% globalvsize@colht
% vbox
% {unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
unvboxz@ifvoidLT@lastfootcopyLT@footelseboxLT@lastfootfi
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
copyLT@headnobreak
fi}
makeatother
usepackage[draft]{graphicx}
%graphicspath{ {Resources/} }
begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
section{Section here}
subsection{Subsection here}
lipsum[1-2]
begin{figure}
caption{Caption 1}
includegraphics[height=9.24cm]{image1.png}
end{figure}
subsection{Subsection here}
lipsum[1]
begin{figure}
caption{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed consequat ex vitae}
includegraphics[height=9.60cm]{image2.png}
end{figure}
lipsum[1-3]
begin{longtable}{|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
cline{1-6}
& Text & Text & Text & Text & Text
cline{1-6}
end{longtable}
lipsum[1-6]
end{document}
Answered by David Carlisle on February 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP