Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

To insert only a few pages of a PDF document to my latex document, I use this macro. The numbering of the pages in my document is not interrupted even if I customize the header-footer with fancyheader.

\documentclass{article}
%%%% www.madit.be
\usepackage[a4paper]{geometry}
    \geometry{top=25mm,bottom=25mm,inner=25mm,outer=20mm,,marginparwidth=1cm,marginparsep=10pt}
\usepackage[ansinew]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage{pdfpages}
\usepackage{lipsum}

%%%%%%%%%%%%%%%%%% macro
\newcounter{myCurrentPage}
\newcounter{myLastPage}
\newcommand{\myMultipdf}[3]{%args: {uri of pdf}{startpage}{endpage}
    \setcounter{myCurrentPage}{\number#2}%page start
    \setcounter{myLastPage}{(\number#3)+1}%last page    
    \whiledo{\themyCurrentPage<\themyLastPage}{%
        \includegraphics[width=\linewidth,page=\value{myCurrentPage}]{#1}
        \newpage
        \setcounter{myCurrentPage}{\value{myCurrentPage}+1}
    }%
}
\begin{document}

\section{Some Text}

\lipsum[1]

\section{Some insert of pdf pages}

\myMultipdf{foo.pdf}{3}{4}

\section{Some Text}

\lipsum[2]

\end{document}
share|improve this question

closed as not a real question by Lev Bishop, qubyte, Marco Daniel, diabonas, Stefan Kottwitz Oct 3 '12 at 16:36

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Of course to use this example correctly, you must replace the foo.pdf by (1) a correct URI and (2) with the actual name of your document. –  madit Oct 3 '12 at 11:23
    
However i have 1 BadBox at compile : Overfull \hbox(15.0pt too wide). Who has an idea to avoid this? –  madit Oct 3 '12 at 11:31
    
I'm having trouble finding the question in your question. If your question is how to avoid the BadBox I believe you should update the question with that. –  Silex Oct 3 '12 at 12:08
    
@ Silex. No my first objective was'nt to ask something. Simply add small piece of code to the community. Early as newbies, I lost a lot of time to find an easy way to insert often PDF pages in a large syllabus. It is only sharing. But it is true that the most talented of you will find it a bit "light" ;-) –  madit Oct 3 '12 at 12:14
1  
In that case you should formulate a question and add your solution as an answer. –  Stephan Lehmke Oct 3 '12 at 13:51

1 Answer 1

The overfull \hbox is caused by \parindent. The graphics starts a new paragraph and the width is the line width. \noindent suppresses the paragraph indent:

\noindent
\includegraphics...

For completeness. Also

\includepdf[pages=3-4,pagecommand={}]{foo.pdf}

keeps the head and foot lines of the original document. But the original document might contribute it own head and foot lines. The margins can be influenced to some degree by options trim, clip.

share|improve this answer
    
Indeed, the command \noindent suppresses bad box. Thanks for this tip. But I do not like the command "includepdf" because it causes a page break before insertion. With the following command, it is possible to insert a section on the same page, but unfortunately it is repeated on every page :-(. \includepdf [pages = 3-4, scale = 0.9, pagecommand = {\section {With includepdf}} ] {} foo.pdf And as includepdf documentation is very basic, so I ended up using this macro. –  madit Oct 3 '12 at 15:54
    
Thank you for having responding to my non-question... –  madit Oct 3 '12 at 18:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.