I'm trying to create a somewhat specially formatted document, with some text on the recto (right side) and a graphic on the verso (left side). This is for a brochure of sorts. See below:

---------    ---------
|       |    |       |
| text  |    |  fig  |  
|       |    |       |
|   n   |    |  n+1  |
--------     ---------

My idea is to compile two separate documents -- one will have the text, and the other the graphics, and these are easy to create. With some pdftk wizardry, I can easily mix the pages together in the order they should appear, together with some additional front and back matter.

Now, I want to have page numbers on each page, and for this, they need to be incremented by two for each document. I guess I could try to do this manually, but I was kinda hoping there could be a better way to do it.

All kinds of ideas welcome. I'm using LaTeX, but ConTeXt solutions will be interesting to see as well. If you think of another way to do the whole thing, feel free to give it a go.

Bonus points for specifying arbitrary page increment.


This idea popped into my mind: Using \afterpage to simply increase the page counter after every page. Note the recursive call. This allows for arbitrary, but fixed page increments. Variable page increments would need some form of \increasethispagenumber{<n>} macro in the text which sets the increment. I think you get the idea.







Works fine in my simple test.

|improve this answer|||||
  • I'm not very well versed in TeX, but why the \afterpage argument doesn't expand forever, given that is makes a recursive call? (The solution works beautifully, BTW). – Martin Tapankov Feb 18 '11 at 10:09
  • @MartinTapankov: Because the \afterpage content is not expanded directly but only after the page. The then resulting new \afterpage counts for the next page, not the current one. – Martin Scharrer Feb 18 '11 at 10:15
  • @MartinScharrer: Ahh, I see. Thanks for the explanation. – Martin Tapankov Feb 18 '11 at 10:19
  • 1
    @Martin: the behaviour of \afterpage is very interesting! Thanks. – Bruno Le Floch Feb 19 '11 at 21:41
  • @Bruno: It's often used to flush floats: \afterpage{\clearpage}, but comes in handy for other things to – Martin Scharrer Feb 19 '11 at 21:44

Beside changing the page counter you can also simply change the output and leave the counter as is:

\renewcommand\thepage{\number\numexpr 2*\the\value{page}\relax}

a\newpage b\newpage c\newpage d\newpage
|improve this answer|||||
  • That works too; one needs to only fiddle with the formula instead of using \setcounter{page}{n} or similar for the starting offset. This is quite flexible as well. Thanks! – Martin Tapankov Feb 18 '11 at 10:40

A slightly less obvious way of doing this (and probably less robust than Martin's) is to use etoolbox to patch the macro that actually outputs the page number.


Here, the single \stepcounter{page} is replaced by two of them.

|improve this answer|||||
  • Hmm, the etoolbox manual says \patchcmd is robust; where do you think there might be issues with this particular use? (or do you mean "robust" as in "reliable", not in the TeX sense). – Martin Tapankov Feb 18 '11 at 12:48
  • @Martin: I meant reliable. If the output routine is replaced before the \patchcmd, then this might fail silently (although that is easy to check by adding an error message to the last argument). If it is replaced after the \patchcmd, then it will have had no effect. – TH. Feb 18 '11 at 13:12

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.