I have to put some academic papers at the end of a document, but only include a subset of their pages (due to the page limitations in our project). Now, I would like to mark each included page with the original page number of the PDF paper I'm including.

Here is my MWE to illustrate the question.



\includepdf[pages={1-2,4},picturecommand={\put(30,30){\makebox{Lorem Ipsum p. XX}}}]{lorem.pdf}


I created a second PDF called lorem.pdf by just typesetting:



which creates a 4-page document lorem.pdf. Now, when I include only parts of the paper, namely pages 1, 2, and 4, I would like to fill in these numbers in the 'picturecommand' text instead of XX. Is there a way to reference that number there?

  • 3
    Just in general: I recommend to use article instead of the minimal class, even for minimal documents. minimal is more a code example than a real class and has no real benefit, but can cause some issues because not all normal things are set. – Martin Scharrer Apr 13 '12 at 18:29
  • Why not do pagecommand={\thispagestyle{plain}} and let the included pdf show its own page number? (instead of picturecommand) – Ariel Apr 13 '12 at 18:54

Assuming that your input document (lorem.pdf) has no pages numbers and that the page numbers specified by the key-value pages={1-2,4} are the actual page numbers in the source document, the macro \AM@page contains the value you're after:

\usepackage{pdfpages}% http://ctan.org/pkg/pdfpages
   picturecommand={\put(30,30){\makebox{Lorem Ipsum p.\ \AM@page}}}]

The above MWE prints

Lorem Ipsum p. 1
Lorem Ipsum p. 2
Lorem Ipsum p. 4

in the lower-left corner.

If the above conditions are not met, then it would be possible to temporarily modify \AM@page to be a certain shift from the given values.

  • hmph that's simpler than mine, I'll delete – David Carlisle Apr 13 '12 at 19:19
  • yes, the conditions were exactly as you stated. Thanks! – Linda Apr 13 '12 at 19:23

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.