5

I am including a PDF file as part of my reports appendices.

The PDF file does not have page numbers, these are added using pagecommand=\thispagestyle{plain} which continues the LaTeX page numbering.

\usepackage{pdfpages}
\includepdf[pages=-, pagecommand=\thispagestyle{plain}]{file.pdf}

How would I make it possible to refer to each PDF page using \pageref{} in the rest of my report?

9

Here's a quick hack:

\documentclass{article}
\usepackage{pdfpages}

\newcounter{pdfpage}

\begin{document}

The second page of the included PDF file is on page~\pageref{file-2}.

\setcounter{pdfpage}{0}
\includepdf[pages=-,pagecommand={\thispagestyle{plain}\refstepcounter{pdfpage}\label{file-\thepdfpage}}]{file.pdf}

\end{document}

The custom counter pdfpage needs to be reset with every new includepdf.

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.