# Prevent page break of full-text-area graphic inclusion

I want to include a picture with width=\textwidth and height=\textheight. In the following MWE, the picture is not placed in the desired page. It produce one blank page first and then the picture. If I do not want the blank page what should I do?

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=\textwidth,height=\textheight]{picture.jpg}
\end{document}
• you might try "reducing" the height of the graphic by preceding it (after a page break) by some negative \vspace. start with \vspace*{-1\baselineskip) and increase the value gradually until the graphic stays on that page. then you could "compensate" by splitting the negative space between the top and bottom of the page. – barbara beeton Aug 17 '15 at 16:31
• Just do \includegraphics[height=\textheight]{picture.jpg} as you can not set both sizes. If the aspect ratio is different to \textwidth/\textheight, your image will become too big for the page. – LaRiFaRi Aug 17 '15 at 16:32
• you need \noindent as currently you are starting a paragraph with the image so it is indented by \parindent so you do not have \textwidth space – David Carlisle Aug 17 '15 at 17:00
• @SayOL you need noindent for horizontal, then for vertical you need as barbara said in initial comment \vspace*{-something} tex is trying to put the baseline of the image \topskip below the top of the page – David Carlisle Aug 17 '15 at 17:10
• as posted above both width and height of the text area are exceeded. – David Carlisle Aug 17 '15 at 17:29

Here is an example which creates a 1 page document in which the text area is filled by a suitably scaled A4 image.

I use width=\textwidth, height=\textheight, keepaspectratio. This means that the image will be as large as it can be subject to three constraints:

1. width not to exceed \textwidth,
2. height not to exceed \textheight
3. image not be be distorted i.e. the width and height will be scaled by the same factor if they require scaling.

\documentclass[a4paper]{article}
\usepackage{graphicx,geometry}
\begin{document}
\noindent\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{example-image-a4}
\end{document}

If you really want to use the entire page, rather than just the area reserved for the text block, you need a different approach:

\documentclass[a4paper]{article}
\usepackage{graphicx,geometry,kantlipsum}
\begin{document}
\newgeometry{scale=1}%
\noindent\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{enfys}\thispagestyle{empty}
\restoregeometry
\kant[1-3]
\end{document}

This produces the following two pages of output shown as a double-page spread (but with the odd page on the left):

• My picture dimensions is not proportional to the dimensions of the paper. So when I add option keepaspectratio it is not stretched to fit the whole text area. – Say OL Aug 18 '15 at 2:44
• @SayOL OK. Sorry... I don't see the problem. Either use keepaspectratio to prevent distortion or don't use it and the area will be filled but, of course, the disproportionate scaling will distort the image somewhat. I mean, there's no rule that you can't distort it. Just people don't usually want the distortion. If you don't mind, just omit the option. (I doubt it would matter with my rainbow, for example. If I were using that, distortion wouldn't really be an issue.) – cfr Aug 18 '15 at 2:48