TeX - LaTeX Asked by yuyichao on May 3, 2021
I am trying to get the footnote to appear on the same page (1st) as the reference of it in the main text but it appears on the next page (2nd) instead.
The closest to my problem I can find is Footnote appears on next page. Why? but my problem does not seem to be too little space on the page. In fact, when I add something to the paragraph to make it longer and reduce the space at the bottom of the page, the footnote can then appear on the 1st page with pretty much nothing else changed about the layout.
The reduced source code is the following,
documentclass[letter]{article}
usepackage{setspace}
begin{document}
small rm
setstretch{2.0}
a aj jfskdj pojsdf jasdfj jjiaosdjf jaisdojf ajsidfj oaijds fsojijf sd,
vspace{11cm}
a aj jfskdj pojsdf jasdfj jjiaosdjf jaisdojf ajsidfootnote{fasu tuthwery ;xncdnbcd},
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
% Uncomment the following to fix the problem...
% jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadjjpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
% fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
subsubsection{jpai sdjp foiadsj fpajdsp fia jsdpoij fapods fjpoiadj}
begin{figure}
centering
caption{
JHLHL Jlkjaklsdf jalksjdf kja;d fa;skldjf ;aksdjf japisodf
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
pdo fpaisodf aosdjf ia psfj aspoidjaposifjpaiod fpiaos fpais pfoa sdpoif sdf}
end{figure}
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
end{document}
and I can reproduce this issue using either pdflatex
or xelatex
.
This comes out of a 200+ pages document so I would really like a robust and automatic solution so that I don’t need to manually review the document everytime there’s a change…
I would also like to understand why this is happening. It really seems that the footnote can fit on the first page without any problems. Any notes about the internal or how to debug something like this will also be appreciated.
Note: This issue is sensitive to the space available at the bottom of the first page so it’s fairly sensitive to how much space the content on the first page takes. I’m not really looking for advance on how to change that to avoid hitting this issue. If you made any change to the document that causes the issue to go away, try changing the vspace value a little to see if it merely stops triggering the issue due to the chang in the vertical position. The text before the section header should be on the first page with just enough room at the bottom of the page whereas the figure and the section should be on the second page. I’d like the footnote to be on the first page but it appears on the second one even when there’s clearly enough space on the first one.
I’m using TeX Live 2020.57066 on Arch Linux. Also reproduced on overleaf using pdfLatex and texlive version 2020 (currently the default).
This is an issue with how the TeX output routine works in the presence of floats. The exact same issue has been reported to the LaTeX team here as part of a larger issue that involves also other parts of TeX. I'll let Frank Mittelbach explain what is happening:
Whenever LaTeX encounters a float it calls on the output routine [N.B. this is "OR" below] to settle its placement. After that the OR returns the page material back to the main vertical list but there will be one difference:
- before the call to the OR the footnotes are individually located next to the place they are encountered
- after the OR has been called they are all bunched together in the insertion box. so LaTeX has to make a decision where to place them, eg first or last. currently it is last
- So in your example they are reinserted after the section [N.B. subsubsection in your case], but then LaTeX determines to break before the section [N.B. subsubsection], hence the result.
Doing it first has the opposite problem (and one that would happen more requently I guess) that you might pick up a footnote text where the mark then ends up on the following page.
For this problem the correct approach is to use holdinginserts when calling the OR but this is not easy to integrate into the algorithm as it is a major change.
For the specific case that you are running into, a possible workaround was also given; though if your document is more complicated it may break some other things. The fix given involves loading etoolbox
and patching how floats are handled, so you can try adding
usepackage{etoolbox}
makeatletter
patchcmdend@float{@cons@currlist@currbox}
{@cons@currlist@currbox
globalholdinginserts@ne}
{}{}
apptocmd@specialoutput{globalholdinginsertsz@}
makeatother
to your preamble. On your MWE I tested it and it works.
Correct answer by Willie Wong on May 3, 2021
UPDATED
I added float
and begin{figure}[H]
to make the figure appear after the subsubsection
The footnote will stay until the end in the first page. (vspace{17.5cm}
)
% !TeX TS-program = pdflatex
documentclass[letter]{article}
usepackage{setspace}
usepackage{float}
begin{document}
small rm
%setstretch{2.0}
doublespacing
a aj jfskdj pojsdf jasdfj jjiaosdjf jaisdojf ajsidfj oaijds fsojijf sd,
vspace{17.5cm}
a aj jfskdj pojsdf jasdfj jjiaosdjf jaisdojf ajsidfootnote{fasu tuthwery ;xncdnbcd},
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
% Uncomment the following to fix the problem...
% jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadjjpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
% fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
subsubsection{jpai sdjp foiadsj fpajdsp fia jsdpoij fapods fjpoiadj}
begin{figure}[H]
centering
caption{
JHLHL Jlkjaklsdf jalksjdf kja;d fa;skldjf ;aksdjf japisodf
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
pdo fpaisodf aosdjf ia psfj aspoidjaposifjpaiod fpiaos fpais pfoa sdpoif sdf}
end{figure}
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
jpaisdjpfoiadsj fpajdspfiajsdpoijfapodsfjpoiadj
fpoiajsdfpoiajdskajsdpof fiosd f asd faijdf a df a jfpo oiaf pa pfoija
end{document}
Answered by Simon Dispa on May 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP