# Base document page numbers with pdfpages and nup

It's possible to have pdfpages number the pages of the document it including using the following command:

\includepdfset{pagecommand=\thispagestyle{plain}}


Unfortunately, this doesn't play nicely with nup (which puts multiple source pages on one target page); the numbering is applied to the output pages rather than the input pages:

\documentclass{article}
\usepackage{pdfpages}
\includepdfset{pagecommand=\thispagestyle{plain}}

\begin{document}
\includepdf[nup=2x3,pages={1-6},frame=true]{<use any PDF file>}
\end{document}


Cf. the '1' at the bottom of this, where I would want 1-6 on the pages:

Is there any way around this?

• This is the expected output, so you'll have to change the way \thepage is printed in order to achieve the desired output. It will also have to be done somewhat manually, since the page numbers of the input document could be anything. That's just my opinion. – Werner Dec 7 '12 at 20:54
• @Werner: numbering 1-6 (regardless of the source numbering) would be fine. – Mohan Dec 7 '12 at 21:00
• Are you interested in referencing these page numbers 1-6? Not the included "nup"-ed pages, but the target page numbers? – Werner Dec 7 '12 at 21:11
• @Werner: I want to label the small 'nup'-ed pages 1-6. The context is that in the image in meta.tex.stackexchange.com/questions/2937/… , I realised one couldn't tell whether the "small" pages 1,2,3,4 went across or down -- having pdfpages number them would fix that. – Mohan Dec 7 '12 at 21:18

You could use two stages. The first stage just adds the page number, e.g.:

%%% test-stage1.tex %%%
\documentclass{article}
\usepackage{pdfpages}
\includepdfset{pagecommand=\thispagestyle{plain}}

\begin{document}
\includepdf[fitpaper,pages={1-6}]{test-org.pdf}
\end{document}
%%% test-stage1.tex %%%


The next stage uses nup:

\documentclass{article}% set the correct paper size, default is letterpaper
\usepackage{pdfpages}

\begin{document}
\includepdf[nup=2x3,pages={1-6},frame=true]{test-state1.pdf}
\end{document}