I'd like to have a footnote that refers to text later in the document, and say "... above ..." or "... below ..." depending on whether the text is on the same page (and thus above) the footnote, or on a later page (and thus below) the footnote. How do I do this? Is there a way to do this without manually writing to the aux file?

(Is it bad practice to refer to future text in a footnote?)

I have it (almost) working with the following code:

Right before the footnote:


In the footnote, \IfDoAbove{above}{below}

By the text that I care about


But it fails if the text that I care about is in an \item which is the first thing on a new page; \thepage is the same as the old page, not the new page. Why is this?

  • Hmm. I suppose this ought to at least be possible in principle, given the fact that the footnotes are supposed to be at the bottom of the page -- assuming, of course, that such footnotes don't ever end up spanning pages, which might be able to result in the puzzling situation that the word "above" or "below", in TeX's opinion, ought to be split between pages such that "below" would be appropriate on the first page and "above" would be appropriate on the second. – SamB Nov 30 '10 at 3:03
  • 1
    The actual placement of the footnote isn't important: what's important is the place in the main text that it refers to... So this misses the point. – Seamus Dec 3 '10 at 15:55

With the suggestion of Will Robertson, I've made the following code mostly work (it assumes the footnotetext is on the same page as the footnotemark):

\newcommand{\numeric@pageref}[1]{% since hyperref makes \pageref into a hyperlink, and \pageref, even without hyperref, gives me an extra {} at the end
  \expandafter\ifx\csname r@#1\endcsname\relax
  {-1}{\expandafter\@secondofmany\expandafter{\romannumeral-`\q\csname r@#1\endcsname}}%
  \label{current page \arabic{iflabelabove@counter}}%
  \savebox{\@tempboxa}{\pageref{current page \arabic{iflabelabove@counter}}\pageref{#1}}%
  \ifnum\numeric@pageref{#1}<\numeric@pageref{current page \arabic{iflabelabove@counter}}\relax%
    \ifnum\numeric@pageref{#1}=\numeric@pageref{current page \arabic{iflabelabove@counter}}\relax%

As far as I know, this is not possible, because TeX completely formats footnotes when you define them. They are stored in a "waiting list", as a sequence of completely formatted lines, and when TeX breaks a page, he tries to put some of those lines at the bottom of the current page. So at the moment you could possibly know on which page a footnote will be, it is too late to change it.

And since it is actually not even possible to reliably determine on which page a footnote is, multi-pass algorithms will not be of any help...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.