1

I would like to write a counter to the aux file and then read it back when compiling the tex file for the second time. Basically, I am trying to write a command that has the same logic as the LastPage package. I want to save a certain pagenumber, and then refer to it on the pages before it.

2
  • Use \label{mypageref} and \pageref{mypageref}. Commented May 14, 2022 at 13:46
  • Actually, you need \refstepcounter{mycounter} before \label. It sets \@currentlabel (and possibly \@currentlabelname and \@currentHref) locally. Commented May 14, 2022 at 13:55

1 Answer 1

2

The mechanism for this is already in place.

When you do \label{whatever} next to a word that you know will fall in the page you want to refer to, you just say

\pageref{whatever}

to print the page number wherever you desire.

The purpose of lastpage is to place a suitable \label without user intervention, but of course it can only work for referring to the last page.

You must log in to answer this question.

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