1

I would like to make a page reference to my bibliography, but it refers to the last page of the bibliography (page 2 e.g.). I assume it's because the label in the master document is after the bibliography input. Is it possible to refer to a previous page using \pageref{}, (page 1 e.g.)??

I assume a code isn't necessary.

Thanks!

  • The values delivered by pageref are nothing that can be counted etc. with. You need \getpagerefnumber from refcount package to handle this or provide a better label position. Without any seeing compilable code, this is hard to solve, so your assumption that the code is not necessary is wrong ;-) – user31729 May 26 '16 at 9:00
  • Ok, thanks! Just to be sure, I can't use e.g. \pageref{(my label)} and the substract one page? – Rasmus May 26 '16 at 9:21
  • Yes, \pageref is not expandable, i.e. you can't use its output and process it again other than just typeset it. You need something like \the\numexpr\getpagerefnumber{yourlabel}-1, where yourlabel is the relevant label you provided for the bibliography page – user31729 May 26 '16 at 9:23
1

Here's a way to achieve this 'manipulation', but this would give wrong links if hyperref is used (although \getpagerefnumber does not provide links at all, so this is no real issue)

Since I don't have the real document at hand, I 'invented' a use case and modify the number that would be reported by \pageref.

However, \pageref is an unexpandable command, so the values reported by it can't be used again other than typesetting them. The package refcount provides the \getpagerefnumber command which gives the direct entry of the page-entry in the \newlabel found in the .aux file.

The rest consists of a \the\numexpr\getpagerefnumber{somelabelname}-1 to subtract a value of 1 and displaying this as 'page' reference.

\documentclass{article}

\usepackage{blindtext}

\usepackage{refcount}

\begin{document}

So, now the real page number is \pageref{section::foobar} but we manipulate it to print \the\numexpr\getpagerefnumber{section::foobar}-1, which is weird, of course ;-)

\section{Foo section}
\blindtext[10]
\section{Foo bar section}\label{section::foobar}
\blindtext[10]
\end{document}
  • In general, I would rather fix the label position however than to modify the page reference – user31729 May 26 '16 at 9:47
  • Thanks, this was just the solution I was looking fore! At this particular problem I would prefere not to change the label position :-) – Rasmus May 26 '16 at 9:49
  • @Rasmus: I see -- happy TeXing! – user31729 May 26 '16 at 10:49

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.