[Tex/LaTex] Appendix – Adding PDF

appendicespdf

In my appendix, I want to add several PDF documents (questionnaires) which I used in a study. I managed to implement an appendix and include the PDF files (not hard to do), but now I have two issues I cannot solve:

  1. I would like to see that the first page of my PDF is placed directly below the title of my appendix A. Yet, appendix A is standing solo on the beginning of the page, then a lot of unused space followes, followed by the next page with the content of the PDF.
  2. At the moment, the PDF pages are covering the header of the sections (A Appendix). I would like to see the headers followed by the PDF pages … Is this even possible?
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\newpage
\appendix
\section{Appendix A}

\includepdf[pages={1-2}]{Example.pdf}

\end{document}

Best Answer

Here is an adapted version of the code given in the answer I linked to. You will need to adjust this depending on the class and packages you are using and on how full the pages of your PDFs are. The code below is conservative and assumes the pages are quite full though the sample PDF I included doesn't meet this requirement so the pages look too empty. I'm guessing your PDFs are fuller but obviously that's just a guess.

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{pdfpages}
\usepackage{xparse}
\usepackage{kantlipsum}

\makeatletter
\NewDocumentCommand\headerspdf{ O {pages=-} m }{% [options for include pdf]{filename.pdf}
  \includepdf[%
    #1,
    pagecommand={\thispagestyle{fancy}},
    scale=.7,
    ]{#2}}
\NewDocumentCommand\secpdf{somO{1}m}{% [short title]{section title}[page specification]{filename.pdf} --- possibly starred
  \clearpage
  \thispagestyle{fancy}%
  \includepdf[%
    pages=#4,
    pagecommand={%
      \IfBooleanTF{#1}{%
        \section*{#3}}{%
        \IfNoValueTF{#2}{%
          \section{#3}}{%
          \section[#2]{#3}}}},
    scale=.65,
    ]%
    {#5}}
\makeatother

\pagestyle{fancy}

\begin{document}

\newpage
\appendix

\secpdf*{PDF on Starred Section Page}[3]{/usr/local/texlive/2013/texmf-dist/doc/latex/mwe/mwe.pdf}
  \kant[2]

\section{Include PDF after Section Page}
\kant[1]
\headerspdf[pages=1-2]{/usr/local/texlive/2013/texmf-dist/doc/latex/mwe/mwe.pdf}

\secpdf{PDF on Section Page}[4]{/usr/local/texlive/2013/texmf-dist/doc/latex/mwe/mwe.pdf}
\kant[2]

\secpdf[Short Title]{PDF on Section Page with Short Title}{/usr/local/texlive/2013/texmf-dist/doc/latex/mwe/mwe.pdf}
\kant[3]
\headerspdf[pages=2-3]{/usr/local/texlive/2013/texmf-dist/doc/latex/mwe/mwe.pdf}

\end{document}

Sample output:

PDF following section heading with headings

Related Question