0

I'm looking for a solution to the following problem.

In a book that I'm latexing at the moment there are many references to other pages - i.e. 'gentle reader, take a look at a discussion of this issue on p. 555'.

Now the problem is that in the latex/pdf output chances are that said discussion will live on a different page from the paper original.

Of course I could compile the latex source… take a look at what page the 'discussion' ends up in the pdf output and modify the latex source accordingly.

Now apart from the fact that this is a rather tedious process with hundreds of page cross-references (and error-prone to boot) there remains the problem that with my eyesight failing over the years I might at some point change the font size from, say 10pt to 12pt… or decide that I need a small-screen version and change the paper size from A7 to A5… or anything that you can imagine that will cause the 'discussion' on the original paper book to end up on page 666 or page 777, or page 1234… etc.

I was wondering if there is anything in LaTeX that might help handle this in a clever… shall we say… way… i.e. make the page number some kind of variable object that gets resolved after the 7th compilation pass ;-)

Obviously in my pdf version of the paper book behind the page number lives a hyperref link that allows the reader to be immediately ported to the 'discussion of the issue' on p. 555 in the original if he cares to click or long-press the page number.

So that the less clever way to handle this is quite naturally to just omit the page number that's causing the trouble and move the link behind the 'discussion of the issue' text. After all these 'go to p.555' in paper books can be regarded as a legacy version of the html style links in days of yore. And that's probably what I'll end up doing — except that the nice thing about the page number is that once the reader is aware of it he'll quickly gets into the habit of clicking it without having to remmind him by making the link a different colour… underlining it… etc. something that where I'm concerned ruins the look of the text.

On the other hand I could just ignore the discrepancy (possibly with a short introductory note explaining that under the circumsances the page numbers refer to the original printed book page numbers) to avoid the reader clicking on p. 555… and first thing he sees is that he is transported to p. 987… giving him a feeling that he is on shaky ground indeed with page numbers that don't make any sense.

Any suggestions?

Thanks,

RSF

2
  • 1
    If the \label{key} -- \pageref{key} method is not enough for you, see ctan.org/topic/label-ref
    – Fran
    Oct 31 '19 at 18:27
  • Lovely… I changed my 'take look at the discussion… \hyperlink{p0324}{p. 324}.' to '\hyperlink{p0324}{\pageref{pg0324}}. and added a '\label{pg0324}' right after the corresponding '\hypertarget{p0324}{}' Oct 31 '19 at 20:27
1

You are making the easy difficult! Just use \pageref.

mwe

\documentclass[a6paper]{article}
\usepackage[margin=1em,
paperheight=4cm,bmargin=2cm]{geometry}
\usepackage{lipsum}
\usepackage[colorlinks]{hyperref}
\begin{document}
\section{Intro}
Gentle reader, take a look at a discussion 
of this issue on page \pageref{dis}
\newpage
(many, many  pages more ...) 
\setcounter{page}{554}
\newpage
\section{Discussion}\label{dis}
This in the discussion.
\end{document}

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.