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.

\documentclass[a5paper]{article}
\usepackage{lipsum}

\makeatletter
\newcommand*{\abpage}[1]{%
  \expandafter\@abpage\csname c@#1\endcsname
}
\newcommand*{\@abpage}[1]{%
  \ifodd\numexpr(#1)\relax
    \the\numexpr(1+#1)/2\relax
    a%
  \else
    \the\numexpr(#1)/2\relax
    b%
  \fi
}
\makeatother

\renewcommand*{\thepage}{\abpage{page}}

\begin{document}
\lipsum[1-30]
\end{document}

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.

\documentclass{article}
\def\transitionpagenumbers{
  \clearpage
  \edef\ptran{\thepage}
  \def\pcycle{a}
  \newcounter{falsepage}
  \def\thepage{%
    \setcounter{falsepage}{\numexpr\value{page}-\ptran\relax}%
    \divide\value{falsepage} by 2\relax%
    \addtocounter{falsepage}{\ptran}%
    \arabic{falsepage}\pcycle%
    \if a\pcycle\gdef\pcycle{b}\else\gdef\pcycle{a}\fi%
  }
}
\usepackage{lipsum}
\begin{document}
\lipsum[1-23]
\transitionpagenumbers
\lipsum[1-36]
\end{document}

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:

\documentclass{article}
\usepackage{geometry,lipsum,atbegshi,fancyhdr}
\geometry{
  twoside,
  landscape,
  paper=a5paper,
  margin=15mm
}
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\fancyfoot[C]{\theslowpage\ifodd\value{page}a\else b\fi}
\pagestyle{fancy}
\newcounter{slowpage}\setcounter{slowpage}{1}% Set first slow page
\AtBeginShipout{\ifodd\value{page}\else\stepcounter{slowpage}\fi}
\begin{document}

\lipsum[1-50]

\end{document}

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.