TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to use \pageref{foo} as a number?

i'd like to store the current page number into a variable and reuse it later:

% Roman numbers list of contents list of figures

variable lastpagenumber = this.page.currentnumber

% Arabic numbers contents

% Literature & Appendix pagenumbering: Roman

start with page (lastpagenumber)

if you could show me the defining, setting and reusing of the variable that'd be great.

share|improve this question

marked as duplicate by Werner, Kurt, Qrrbrbirlbel, Thorsten, Martin Schröder Dec 13 '12 at 7:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Does How to use \pageref{foo} as a number? solve your question? It uses refcount to store the page reference in a counter (variable). Give some feedback. – Werner Dec 12 '12 at 23:45
First of all: Welcome to TeX.sx! It doesn't get quite clear to me what you aim at with your question, ans as I look at the comments to the answer below, others seem to have the same problem. Maybe you explain a bit more, what you want to reach. Maybe also have a look at the How to Ask-page. – Benedikt Bauer Dec 13 '12 at 7:11
Following up on on @BenediktBauer's comment, you need to tell us how you want to use this infomation later in the document. – Andrew Swann Dec 13 '12 at 7:48

You could use \label on the page in question and \pageref where you want to later reference it.




\label{I want to remember this first page}


I've remembered the page \pageref{I want to remember this first page}


Do note that you must compile your document twice to get the page references correct.

Here's an example which let's you put material in the header and footer:



\label{I want to remember this first page}


I've remembered the question \pageref{I want to remember this first page}

Check out the bottom of the page:
\cfoot{My reference to the first page\pageref{I want to remember this first page}}


I've called the package fancyhdr to accomplish this, but make sure you don't call \pagestyle{empty} as I did in the first example or you won't see anything.

share|improve this answer
ooh you beat me by less than a second, I'll delete my answer which was the same, so +1:-) – David Carlisle Dec 12 '12 at 23:25
doesn't work. just prints the page number into the text area instead of the footer area. any method to convert the string to int? – ndrizza Dec 12 '12 at 23:35
Give a MWE so we can better see what you're trying to do and better understand the issue you're facing – A.Ellett Dec 12 '12 at 23:40
Make sure you get rid of the\pagestyle{empty}. That might be your problem if you too literally copied my example. Sorry (my bad) I should have removed that line from my MWE – A.Ellett Dec 12 '12 at 23:43
that does not support automatic incrementing of numbers. isn't there any way to convert the string (returned by pageref) to an integer? – ndrizza Dec 13 '12 at 1:03

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