0

I have a pdf which has 3 pages. I would like to insert the pdf into the document using the \includepdf command and the pagecommand option as below:

\includepdf[pages=-, scale=0.8, pagecommand=\subsubsection{Foo}]{./Attachments/foo.pdf}

However, this produces mulitple sections (Foo 1, Foo 2, Foo 3). How can this be avoided and only produce a header of "Foo" for each section?

  • 1
    Welcome! Please provide a complete minimal document we can compile to reproduce the problem. This isn't difficult to answer, but it is boring to set up. I'll see if I have something ready-made or just wait for you to finish the question, I guess. – cfr Jun 1 '16 at 1:15
  • I am not sure what you mean by minimal document. This is a sample of the issue I am having on a mulitpage document. How do you suggest I go about doing this? Thank you for your help – branch.lizard Jun 1 '16 at 1:26
  • Have a look at the guidance here. Basically, a minimal example (for LaTeX) should start \documentclass... and end \end{document} and reproduce the issue when compiled. – cfr Jun 1 '16 at 1:29
1

OK, I found something I probably did for somebody called victor and simplified it a bit. Basically, the page command gets redefined each time \includepdf is called and when page 1 of any such PDF is included. The first time, it is redefined to add the additional material. The second time, it is redefined not to. The upshot is that the material is used on only the first page of the included PDF.

\pdfminorversion=7
\begin{filecontents}{\jobname x.tex}% once written, you need to compile \jobname x.tex to produce \jobname x.pdf for inclusion below (the first run will produce an error but this is only for the example anyway)
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{scale=.75}
\begin{document}
  foo1\newpage foo2 \newpage foo3
\end{document}
\end{filecontents}
\documentclass[a4paper]{article}
\usepackage{geometry,pdfpages,etoolbox}
\geometry{scale=.85}
\makeatletter
\pretocmd{\includepdf}{%
  \def\victor@dynpage{\victor@firstpage\global\let\victor@dynpage\relax}%
}
\newcommand*\dynpage[1]{%
  \def\victor@firstpage{#1}%
  \victor@dynpage}
\makeatother
\begin{document}
\includepdf[pages={-}, pagecommand=\dynpage{\subsubsection{Subsubsection}}]{\jobname x}
\end{document}

dynamic page style

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.