17

I would like to append the several-pages .pdf directly after the section-heading.

\subsection{Kopie des Projektantrages}
\includepdf[pages=-, fitpaper=true]{\antrag} // my PDF file-command

... but it's inserting the pdf on a new page...

Do you know what i try to achive? Hope someone can help me.

Second Try:

    \includepdf[pages=1,pagecommand=\subsection{Kopie des Projektantrages}, fitpaper=true]{\antrag}
\includepdf[pages=2-,pagecommand={}, fitpaper=true]{\antrag}

Now the Headlines of the latex document and the pdf are colliding...

2
  • 1
    Hi. Is this a page or several pages? If it is only a page you can include it with \includegraphics[]{Something.pdf}
    – Dolphin
    Commented Jan 28, 2015 at 14:30
  • serval pages... tried it with pagecommand to add subsection but then the headline of the latex-document is colliding with the pdfs headline...
    – regetskcob
    Commented Jan 28, 2015 at 14:33

5 Answers 5

15

This solves the problem :-)

\includepdf[pages=1,pagecommand={\subsection{Kopie des Projektantrages} \thispagestyle{empty}}, fitpaper=true]{\antrag}
\includepdf[pages=2-,pagecommand={\thispagestyle{empty}}, fitpaper=true]{\antrag}
11

\inlcludepdf always inserts the content on separate pages, because it inserts the pdf-document into your document. If you want the pdf to appear on a page within your document you have to use \includegraphics, which works perfectly fine with pdf files as images in pdflatex.

\usepackage{graphicx}
\subsection{Kopie des Projektantrages}
\includegraphics{antrag.pdf}

Edit: In regard to Dolphins comment: Yes, I think that only works when the pdf file has only one page.

3
  • this don't help with several pages.
    – regetskcob
    Commented Jan 28, 2015 at 14:34
  • @DanielBocksteger I see, but I think what you want to achieve is not so easy then. As I understand it you want to include a pdf of your application in another document. Have you considered not to insert a header in the document but only in your document toc (and maybe pdf-toc) by manually setting an anchor to the first page of the pdf? Commented Jan 28, 2015 at 14:39
  • Solved this :-) Look @ my answer :)
    – regetskcob
    Commented Jan 28, 2015 at 14:47
1

I had the same issue and tried various suggestions out there include this: https://tex.stackexchange.com/a/176188/104699. It is either that they do not work as they claim or are too complicated to follow (e.g. the link above). If you are a beginner or use Lyx because you love the GUI, you know how frustrating it is to spend time hacking with tex code. Here is a very simple solution that I found:

  1. Include the first page as a graphic using INSERT>GRAPHICS
  2. include the rest of the pages as pdf via INSERT>FILE>EXTERNALMATERIAL

    \section{NAME OF SECTION}
    \includegraphics[height=0.8\textheight]{\string"FILENAME".pdf}
    \includepdf[pagecommand={\thispagestyle{plain}}, pages={2-last},scale=0.8]{LINKTOFILE}
    

That simple.

0

Yes I agree, This is a working code

\documentclass{article}
\begin{document}
\begin{table}[h!]
    \centering
    \begin{tabular}{p{1\linewidth}}
        \includegraphics[width=1\linewidth]{1.pdf}
        \includegraphics[width=1\linewidth]{2.pdf}
    \end{tabular}
\end{table}
\end{document}
2
  • 1
    Please -- as usual here -- make your code snippet compilable for a fast proof.
    – Mensch
    Commented Nov 25, 2021 at 21:20
  • Thanks, The above code is working Commented Nov 25, 2021 at 22:20
0

I wrapped the code idea above as a function that allows for its direct use with \includepdf.

\usepackage[final]{pdfpages}% added for \includepdf

% function for creating a section and attaching a PDF on the same page
\newcommand{\pdfsection}[2]{\includepdf[pages=1,pagecommand={\section{#1} }, width=0.75\textheight]{#2}
\includepdf[pages=2-,pagecommand={}, width=0.75\textheight]{#2}}

\begin{document}

\pdfsection{Your section header}{Your file path}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .