3

I want to include a single PDF page according to \includepdf[pages={1},scale=.80,pagecommand={}]{documents/CC_folgeseite-A4.pdf}. How can I make the PDF page to be centered as the text is, meaning shifted to the left or right depending if it is a odd or an even page as it is the case for normal text. Now on both pages the PDFs are centered to the page and not shifted. Is there an automatic option (not needing to find the right parameters for offset)?

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{mwe}
\usepackage{pdfpages}


\begin{document}
\includepdf[pages={1},frame=true,scale=.80,pagecommand={}]{example-image-a4.pdf}
\newpage
\includepdf[pages={1},frame=true,scale=.80,pagecommand={}]{example-image-a4.pdf}
\newpage
\lipsum[1-6]

\end{document}
Tanja
  • 559
  • What about \centering? – Werner Jan 25 '14 at 19:04
  • the PDF remains centered to the page and not to the "text" – Tanja Jan 25 '14 at 19:06
  • If you're only including a single page, I would suggest including it via \begin{center}\includegraphics[page=1,scale=.8,...]{<file>}\end{center}, which would then center it according to the text block like anything else. – Werner Jan 25 '14 at 19:23
  • with \begin{center}\includegraphics[page=1,scale=.8,...]{<file>}\end{center} the figure is in the right lower corner – Tanja Jan 25 '14 at 20:02

1 Answers1

2

For including only a single page of a multi-page document, you can also use \includegraphics directly:

enter image description here

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx

\begin{document}
\mbox{}\par\vfill
\noindent\makebox[\textwidth][c]{\raisebox{-.5\height}[0pt][0pt]{\includegraphics[page=1,scale=0.8]{example-image-a4}}}\par
\vfill\mbox{}
\newpage
\mbox{}\par\vfill
\noindent\makebox[\textwidth][c]{\raisebox{-.5\height}[0pt][0pt]{\includegraphics[page=1,scale=0.8]{example-image-a4}}}\par
\vfill\mbox{}
\newpage
\lipsum[1-6]

\end{document}

The \makebox centers the image on the page (see Center figure that is wider than \textwidth and/or How can I center a too wide table?), while \raisebox is used to remove any height/depth, and center the image vertically with respect to its placement. \mboxes and \vfills push the content to the center of the page, vertically.

Werner
  • 603,163
  • This does the job, thanks. What are the [0pt][0pt] for? – Tanja Jan 26 '14 at 12:56
  • @Tanja: See p 232 (part of section 57 LaTeX Box commands) of source2e.pdf: "\raisebox{<distance>}[<height>][<depth>]{<box>}: Raises <box> up by <distance> length (down if <distance> negative). Makes TeX think that the new box extends <height> above the line and <depth> below, for a total vertical length of <height>+<depth>. Default values of <height> & <depth> = actual height and depth of <box> in new position." So I just dropped the image (page) by 50% of its height and made sure it has no height/depth. – Werner Jan 26 '14 at 17:39