Custom page numbers

I’m writing an article in LaTeX which I will print so that there are two pages per side. I want to number the pages as 1a, 1b, 2a, 2b, 3a, 3b, … so that the two pages appearing on page 1 will be 1a and 1b, and so on.

Is it possible to do this, for example, using the fancyhdr package?

Solutions Collecting From Web of "Custom page numbers"

The following example defines a counter format command \abpage in a similar way as \arabic, \alph, \roman. The command is expandable, thus \thepage can be used with hyperref, in page references, … as usual.


  \expandafter\@abpage\csname c@#1\endcsname



The example performs the expandable calculations with e-TeX’s \numexpr. In the quite rare cases, where e-TeX is not available (e.g., ancient TeX systems), package intcalc can be used for the expandable integer calculations.

The OP clarified thus:

“So the ordinary document will have page numbers 1, 2, …, (N-1) and then the “slides”, which appear two per page, will be Na, Nb, (N+1)a, (N+1)b, …”

The following MWE would seem to achieve that result, through a redefinition of \thepage, brought about by invocation of \transitionpagenumbers which clears the current page under the old numbering system and begins the new numbering system after the \clearpage.

    \divide\value{falsepage} by 2\relax%
    \if a\pcycle\gdef\pcycle{b}\else\gdef\pcycle{a}\fi%

This produces a document with pages 1-5, then 6a, 6b, 7a, 7b, 8a, 8b, and 9a.

The one document with “ordinary page numbers” should be no problem to create, and is therefore excluded from this answer. Also, I assume that stacking landscape pages into a portrait one implies you’re using something like an A5 page size for the slides so they’ll fit vertically on an A4.

Here’s how one could create the slides:

\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\fancyfoot[C]{\theslowpage\ifodd\value{page}a\else b\fi}
\newcounter{slowpage}\setcounter{slowpage}{1}% Set first slow page



Based on the last page of the previous document, set the value for slowpage accordingly. The slowpage counter is actually a slave-like counter, only incremented every other page, while the appendix a or b is conditioned upon the oddness of the regular page counter.

The above approach does not mess around with the regular page counter, and should therefore not give any troubles with hyperref or other cross-referencing.