1

Consider the code

\documentclass{book}
\usepackage{lipsum,pgfpages}
\pgfpagesuselayout{2 on 1}

\begin{document}
\Large
\lipsum[1-5]\footnote{This is the footnote I was to make reference to, shortly.}
\lipsum[4-7]
\textbf{See footnote on page [Latex to insert page \#]}
\end{document}

which produces

enter image description here

enter image description here

The footnote, which appears on pg. 3, is referenced on pg. 4.---

See footnote on page [pg. #]

I would like to have LaTeX automatically reference (in this case), "pg. 3".

QUESTION: How may I modify the above code so that I may accomplish this? Moreover, I would like to be able to do this on a larger scale as well, so that it I had a document with say, one hundred footnotes, three say, are to be referenced similarly, I would be able to do this. I imagine that this must involve placing a unique distinguishing mark on each of the (three) footnotes and then, later in the document, reference those three marks to print out the page number on which each of those footnotes appear---but I don't know how I would code this.

Thank you.

2
  • 1
    Normally you'd use \label{myfn} in the footnote and \pageref{myfn} to get its page number later, but the pgfpages package messes this up. If it were me, I wouldn't use that package and if you want a 2x1 layout, do it with something like pdfjam after creating the single paged version.
    – frabjous
    Oct 17, 2022 at 22:34
  • @frabjous Thank you very much!! This works very nicely. Perhaps you would post this as an answer. Also, thanks for the warning about the pgfpages package.
    – DDS
    Oct 18, 2022 at 0:41

1 Answer 1

1

Normally, when you give something with a reference counter (like a footnote, list item, section, etc.) a label using the \label{key} command, you can refer back to its counter number with \ref{key} and its page number with \pageref{key}.

So to get the page on which a certain footnote appears you can label it with \label{myfootnote} (use whatever key will help you remember in place of myfootnote) and then refer back to its page number later on with \pageref{myfootnote}, like so:

\documentclass{book}
\usepackage{lipsum}{

\begin{document}
\Large
\lipsum[1-5]\footnote{\label{myfootnote}This is the footnote I want to make reference to, shortly.}
\lipsum[4-7]
\textbf{See footnote on page \pageref{myfootnote}.}
\end{document}

page reference

This works by writing the page numbers to the .aux file, and so requires multiple compilations.

However, the \pgfpagesuselayout command from the \pgfpages package makes this not work properly without intervention. As is explained on page 1014 of the pgf manual:

Another word of caution: using pgfpages will produce wrong page numbers in the .aux file. The reason is that TeX instantiates the page numbers when writing an .aux file only when the physical page is shipped out. Fortunately, this problem is easy to fix: First, typeset our file normally without using the \pgfpagesuselayout command (just put the comment marker % before it) Then, rerun TeX with the \pgfpagesuselayout command included and add the command \nofiles. This command ensures that the .aux file is not modified, which is exactly what you want.

So you can first typeset:

\documentclass{book}
\usepackage{lipsum}{
\usepackage{pgfpages}
%\pgfpagesuselayout{2 on 1}
%\nofiles

\begin{document}
\Large
\lipsum[1-5]\footnote{\label{myfootnote}This is the footnote I want to make reference to, shortly.}
\lipsum[4-7]
\textbf{See footnote on page \pageref{myfootnote}.}
\end{document}

And then

\documentclass{book}
\usepackage{lipsum}{
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}
\nofiles

\begin{document}
\Large
\lipsum[1-5]\footnote{\label{myfootnote}This is the footnote I want to make reference to, shortly.}
\lipsum[4-7]
\textbf{See footnote on page \pageref{myfootnote}.}
\end{document}

And you will get the proper result.

However, I personally would find it to be a pain to have to constantly swap back and forth between the two versions. If you mainly want an end document with side by side pages, you can just typeset a normal document with one side per page, and then create a 2 on 1 version of the pdf using a tool like pdfjam (which comes with most TeX distributions) with the --nup option:

pdfjam --landscape --nup 2x1 filename.pdf '{},1-' -o filename-2x1.pdf

The output looks like this:

pdfjam nup

Notice that I used the page range {},1-. The reason for the {} is to insert a blank "page" on the left side of the first page so that odd numbered pages are on the right (recto), and even numbered pages are on the left (verso), as it would be in a real book.

Word of warning: pdfjam ruins hyperlinks, but then again, so does pgfpages.

1
  • Many thanks for posting this answer.
    – DDS
    Oct 18, 2022 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .