2

I want to glue together different parts of a book using \includepdf. How do I preserve the source pdf's page labels? I guess that's what they're called. I don't mean the page numbers on the actual pages to be printed, but shown to me in the pdf viewer. In a very simplified parallel scenario I would have 1.tex

\documentclass{memoir}
\usepackage{hyperref}
\begin{document}
\frontmatter
Some text.
\mainmatter
Something more.
\end{document}

producing a 3 page document, with the pages labeled i,ii and 1. When I now include the generated pdf in a new document,

\documentclass{article}
\usepackage{hyperref}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{1.pdf}
\end{document}

my pdf viewer does not show any page labels anymore, just numbered pages, 1, 2, 3, although the actual page number stay correct. Is there a way to preserve the labels automatically, or would I need a new call to \includepdf for the switch of roman page numbering to arabic? Or would an altogether different approach be advised?

  • 1
    One can use \includeonly instead. It avoids redong every file every time, but will automatically keep the page numbers straight (if you do the files in order, front to back). – John Kormylo Apr 22 '18 at 22:20
  • @JohnKormylo Would that approach work if the pdfs are produced separately? In this case I have one part of the book created by plain tex, a critical edition of a Sanskrit text, and the English part of the book is set with LaTeX. – muk.li Apr 23 '18 at 7:43
  • 1
    not automatically but works: \documentclass{book} \usepackage{hyperref} \usepackage{pdfpages} \begin{document} \frontmatter \includepdf[pages=1-2]{1.pdf} \mainmatter \includepdf[pages=3-]{1.pdf} \end{document} – touhami Apr 23 '18 at 7:51
  • You can incorporate plain TeX into LaTeX using the plain package. – John Kormylo Apr 23 '18 at 13:40
  • @touhami I fear that this does not answer the OP question "How to keep the labels (meaning the hyperlinks)" To the best of my knowledge, you can't keep them at all because internally\includepdf uses \includegraphics. The only way would be to make a single document, a hinted by John Kormylo, or to create them after merging either by hand or with a tool like pdftk. – Jhor Apr 23 '18 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.