149

I have a problem when I insert a PDF file in LaTeX:

\usepackage[final]{pdfpages}

\includepdf[pages=-]{file.pdf}

The problem is that the PDF page is not centered:

result

I've tried to place tags center, but nothing works.


Thank you for your response.

I still have the same problem.

For a good layout, I have to do this:

\includepdf[pages=1,pagecommand={},offset=-2.5cm -3cm]{file.pdf}
\includepdf[pages=2,pagecommand={},offset=2.5cm -3cm]{file.pdf}
\includepdf[pages=3,pagecommand={},offset=-2.5cm -3cm]{file.pdf}
\includepdf[pages=4,pagecommand={},offset=2.5cm -3cm]{file.pdf}
\includepdf[pages=5,pagecommand={},offset=-2.5cm -3cm]{file.pdf}

This is very annoying. I want to insert a PDF of 50 pages, I can not insert page by page ...

I tried

\begin{figure}
 \centering 
 \includepdf[pages=-]{file.pdf}
\end{figure}

But all pages of the PDF are superimposed on one page!

And with \usepackage[pdftex]{graphicx} I have an error :

! LaTeX Error: Option clash for package graphicx

Please help me!

P.S. I use a model given by my university. In this model, we find this:

%----- Dimensions -----
\setlength{\evensidemargin}{2cm}
\setlength{\oddsidemargin}{2cm}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-5.7cm} % 24cm
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-4cm} % 17cm
\setlength{\topmargin}{0.5cm}
\setlength{\headheight}{2cm}
\setlength{\headsep}{0.5cm}
\setlength{\voffset}{-2.54cm}
\setlength{\hoffset}{-2.54cm}
\setlength{\footskip}{1.5cm}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

If I remove this:

\setlength{\voffset}{-2.54cm}
\setlength{\hoffset}{-2.54cm} 

the layout of the PDF is OK, but the rest is bad!

2
  • 3
    Can you provide a minimal working example of your code?
    – Juri Robl
    Mar 27, 2013 at 18:15
  • 1
    By default pages are centered and it works fine for me. So it looks as if either your pdf has curious margins or your pdfpages version has a bug. Beside this: pdfpages has a documentation which also contains a section which describes how to move the pdf around. Mar 28, 2013 at 7:37

5 Answers 5

129

I did it this way with package pdfpages:

\includepdf[pages=-,pagecommand={},width=\textwidth]{file.pdf}
4
  • 2
    It scaled the pages down to the available text width. If inserting A4 in A4, this will not work properly. The above option with @twoside is the best I could get so far.
    – Alberto
    Jun 8, 2018 at 13:09
  • I would like to keep the original page numbering, but also the new one. I mean my thesis already has a numbering, on top, and I need to embed an article in the appendix. How can I keep both? One inside the other?
    – skan
    Sep 17, 2019 at 12:08
  • 14
    Though it's stated in words and in the question, it's better to be explicit: include a line in the preamble \usepackage{pdfpages}
    – Liam
    Sep 25, 2019 at 23:17
  • this one worked for me thanks @Angelo!!! Dec 4, 2020 at 6:35
61

I found the solution :

\setboolean{@twoside}{false}

And

\includepdf[pages=-, offset=75 -75]{file.pdf}

And it works !

2
  • While it works, I preferred the solution bellow, that changes voffset and hoffset.
    – Alberto
    Jun 8, 2018 at 13:16
  • Works fine! Just need to change the offset a bit. More info on tweaking the offset is welcome.
    – varsh
    Jan 31, 2019 at 14:59
30

Try this:

\setlength{\voffset}{0cm}
\setlength{\hoffset}{0cm}

\includepdf[pages=-]{file.pdf}

\setlength{\voffset}{-2.54cm}
\setlength{\hoffset}{-2.54cm}

Then the pdf will be put in the page without the offsets of the rest of the document.

In case you are with a similar problem but do not know which are he actual offsets, you can create two new lengths, store the original values, and restore them again:

 \newlength{\originalVOffset}
 \newlength{\originalHOffset}
 \setlength{\originalVOffset}{\voffset}   
 \setlength{\originalHOffset}{\hoffset}

 \setlength{\voffset}{0cm}
 \setlength{\hoffset}{0cm}
 \includepdf[pages=-]{file}
 \setlength{\voffset}{\originalVOffset}
 \setlength{\hoffset}{\originalHOffset}
23

I would say: put the page inside a figure environment and use the \centering command. It's action should be restricted to the figure.

\begin{figure}
 \centering 
 \includepdf[pages=-]{file.pdf}
\end{figure}

Note that a simple \includegraphics{file.pdf} should to the trick, no need for extra packages. i.e. this a working code for me:

\usepackage[pdftex]{graphicx}
\begin{document}

\begin{figure}
 \centering 
 \includegraphics{file.pdf}
\end{figure}

\end{document}

Moreover, this allows the use of additional scaling options such as \includegraphics[scale=0.50]{file.pdf}, etc.

4
  • 3
    Have you tried this? Moreover graphicx's \includegraphics doesn't really need the driver pdftex explicitly specified, since it's picked up by the method of compilation.
    – Werner
    Mar 27, 2013 at 19:08
  • Oops! Typo, I'll edit my post to reflect that. Otherwise, I never used pdfpage, but I used the includegraphics variant countless times :)
    – jgyou
    Mar 27, 2013 at 19:34
  • 9
    This actually only work if your PDF contains only one page. It won't create new pages for each of your PDF pages. Nov 22, 2015 at 2:57
  • 1
    Indeed it won't.
    – jgyou
    Nov 22, 2015 at 20:06
19

Try this. Compile it with pdflatex.

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{status-lua}
\end{document}

I tested with TeX Live 2012 (just updated several days ago) and it works fine.

Note: status-lua is one (of limited number of others) accessible PDF file (in the installed TeX distribution) that I can use for a demonstration purpose.

1
  • 1
    Best working option in particular regarding page geometry.
    – Vesnog
    Sep 20, 2017 at 11:55

You must log in to answer this question.

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