Centering an image vertically
\centerline
takes an argument so in
\centerline\noindent\makebox[\textwidth]{\includegraphics[width=\paperwidth]{MyImage.jpg}
the argument is just \noindent
so it is equivalent to
\centerline{\noindent}%
\makebox[\textwidth]{\includegraphics[width=\paperwidth]{MyImage.jpg}}
so you get one blank white line from the \centerline
then an overfull box with the image.
possibly you want
\vspace*{\fill}
\noindent
\hspace*{-\oddsidemargin}%
\makebox[0pt][l]{\includegraphics[width=\paperwidth]{MyImage.jpg}}
\vspace*{\fill}
I am assuming here you did intend your image to be as wide as the paper not just as wide as the text block, so covering both margins.
\documentclass[demo]{article}
\usepackage[a6paper,margin=2cm]{geometry}
\usepackage{graphicx}
\begin{document}
\null\vfill
\centering\includegraphics{xyz}
\vfill\null
\end{document}
How to prove?
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{foo.tex}
\documentclass[demo]{article}
\usepackage[a6paper,margin=2cm]{geometry}
\usepackage{graphicx}
\begin{document}
\null\vfill
\centering\includegraphics{xyz}
\vfill\null
\end{document}
\end{filecontents*}
\immediate\write18{pdflatex foo}
\immediate\write18{pdftops -f 1 -l 1 -eps foo.pdf}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{foo}}
\psset
{
xunit=0.1\wd\IBox,
yunit=0.1\ht\IBox,
}
\begin{document}
\begin{pspicture}[showgrid=top](10,10)
\rput[bl](0,0){\usebox\IBox}
\end{pspicture}
\end{document}
The image can easily be centered horizontally and vertically via package pdfpages
. It also enlarges the image as much as possible to fit into the paper area without distorting the image.
Example:
\documentclass[11pt,a4paper,BCOR=10mm,DIV=11]{scrbook}
\usepackage{pdfpages}
\begin{document}
\includepdf{MyImage.jpg}
\end{document}
Option BCOR
is not taken into account, when placing the image. Some white space can be added to the left or right of the image via option trim
:
\includepdf[trim=-5mm 0 -8mm 0]{MyImage.jpg}
Would add a white margin of 5mm to the left and 8mm to the right of the unscaled image.