2

Never happened to me before: I'm trying to insert a pdf file using pdfpages and also create a TOC entry as a chapter. But the first page of the inserted file then overlaps with the second page. No such problem if I don't use tableofcontents or if the inclusion in TOC is at the level of sections. MWE:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{pdfpages}
\begin{document}
\tableofcontents
\includepdf[noautoscale=false,nup=1x2,pages={1-},landscape=true,addtotoc={1,chapter,1,{PDF file included},pdffile}]{PDFfile}
\end{document}

If I replace "chapter" with "secton", the problem disappears (but the TOC line is unsatisfactory). If the first number in addtotoc is 3 or above, the problem disappears (but the result is unsatisfactory).

Any ideas? Unfortunately, I don't have a second machine here to test if this is something specific to my installation.

4
  • I have managed to isolate the problem with pdfpages. The issue doesn't exist, and everything compiles as expected with the version as late as v0.5f (from 2016). Not sure how to deal with it other than by using this older version.
    – Jabot
    Jan 26 at 8:35
  • @egreg I get a problem. When I use example-image-a4-numbered as pdf page 1 and 2 are gone. Jan 26 at 10:01
  • @UlrikeFischer Oh! I didn't check the number of pages. I'll retract my comment.
    – egreg
    Jan 26 at 10:12
  • Just a note: Andreas Matthias, the author and current maintainer of pdfpages has fixed this in pdfpages 0.5u (2022-01-29). Check the CTAN Announcement. Jan 30 at 18:48

1 Answer 1

1

No idea why it happens. Anyway, a workaround seems to be adding something invisible between the TOC and the included file.

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{pdfpages}

\begin{document}

\tableofcontents

\mbox{}

\includepdf[
  noautoscale=false,
  nup=1x2,
  pages=-,
  landscape=true,
  addtotoc={1,chapter,0,{PDF file included},pdffile}
]{\jobname fake}

\end{document}

enter image description here

The “fake” file has eight pages.

2
  • 1
    it happens as pdfpages issues \@chapter in the middle of the code, and then the {\setbox\z@\lastbox} from \@afterheading eats the last box away. It works if one e.g. use \usepackage{indentfirst}. Looks like a bug that should be reported to pdfpages. Jan 26 at 10:42
  • @UlrikeFischer Thank you for identifying this issue. Jan 28 at 20: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.