1

I would like to merge different PDF files and have two different page numberings. The header should have #current PDF# - #current page# (1-1, 1-2, ...), next PDF will have (2-1, 2-2,...) The footer should have Page # of (total pages after merging)

I've been trying using \includepdf with different options but nothing

I know I can reset the page countr (\setcounter{page}{1}) but in a way I will need 2 different page counters for this

1
  • Welcome! Can you provide a minimal example setting the problem up for people to play with? See tex.meta.stackexchange.com/q/228 for help with this. pageslts used to provide support for local page numbering etc. It isn't compatible with current LaTeX, although it still works for some purposes. There is also some new functionality in LaTeX which might be usable for this. So it depends a bit on how old/recent your TeX installation is. Commented May 20, 2024 at 14:45

1 Answer 1

1

You can use option picturecommand of \includepdf to write arbitrary text onto each page. And of course the text could include a counter that you increment (\stepcounter) each time the text is typeset onto each page. I guess this is the most flexible way to do it:

\documentclass[a4paper]{article} \usepackage{lastpage} \usepackage{mwe} \usepackage{pdfpages} \newcounter{pdf-page} \newcommand\labeling[1]{% \put(450,800){#1-\arabic{pdf-page}}% \put(450,100){Page \arabic{page} of \pageref{LastPage}} \stepcounter{pdf-page}} \begin{document} \setcounter{pdf-page}{1} \includepdf[ pages=1-3, picturecommand={\labeling{1}}, ]{example-image-a4-numbered.pdf} \setcounter{pdf-page}{1} \includepdf[ pages=1-3, picturecommand={\labeling{PDF 2}}, ]{example-image-a4-numbered.pdf} \end{document} 

Another possibility is adjusting LaTeXs header and footer with a package like fancyhdr.

\documentclass[a4paper]{article} \usepackage{lastpage} \usepackage{mwe} \usepackage{pdfpages} \usepackage{fancyhdr} \newcounter{pdfPage} \fancypagestyle{fancy}{% \fancyhf{}% \fancyhead[R]{\pdfName-\arabic{pdfPage}\stepcounter{pdfPage}}% \fancyfoot[C]{Page \arabic{page} of \pageref{LastPage}}% \renewcommand\headrulewidth{0pt}% } \pagestyle{fancy} \newcommand\pdfName{} \newcommand\pdfDocument[1]{% \renewcommand\pdfName{#1}% \setcounter{pdfPage}{1}% } \begin{document} %\newpage \pdfDocument{1} \includepdf[ pages=1-3, pagecommand={}, ]{example-image-a4-numbered.pdf} %\newpage \pdfDocument{2} \includepdf[ pages=1-3, pagecommand={}, ]{example-image-a4-numbered.pdf} \end{document} 

In this example \newpage is not necessary. But as soon as you extend this example you want to take care that \pdfDocument and \includepdf are evaluated on the same page.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.