# LaTeX: First page blank

I just installed LaTeX with TeXworks today. I need to create a simple PDF out of a couple large images, I realize this is likely very crude and roundabout but I somehow managed to get the thing done. However, LaTeX inserts a blank page before the stuff I want, and I can't find a way to get rid of it. I thought it may simply be the title page and tried adding notitlepage in documentclass, but that's not it. Here's the whole thing:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\setlength{\oddsidemargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\marginparsep}{0pt}
\setlength{\marginparwidth}{0pt}
\setlength{\textheight}{25.8cm}
\graphicspath{{A:/Desktop/pdf/1/}}
\DeclareGraphicsExtensions{.png}
\pagenumbering{gobble}
\begin{document}
\centering
\includegraphics[width=17.7cm]{pg1}
\newpage
\includegraphics[width=17.7cm]{pg2}
\newpage
\includegraphics[width=17.7cm]{pg3}
\newpage
\includegraphics[width=17.7cm]{pg4}
\newpage
\includegraphics[width=17.7cm]{pg5}
\end{document}


-
I used the demo option for graphicx, and I do not get a blank page in the start of my document using your code. –  J M Aug 2 '12 at 16:18
Use \usepackage{geometry} to set the margin and type block. –  Sveinung Aug 2 '12 at 16:19
At a guess, I'd say your pictures are bigger than the page size that you've defined. Try using the geometry package to get better control over the page size and make it big enough that your pictures fit on the page. –  Andrew Stacey Aug 2 '12 at 16:19
@AndrewStacey: this was also my suspicion; @ozu: you can test this very easily if you replace the first \includegraphics{...} with \rule{17.7cm}{35cm}. When you change the height to a smaller value, e.g. 25 cm, no blank page is generated. –  hakaze Aug 2 '12 at 16:23
My pictures are exactly the same height as the page height I defined, and it turns out I simply had to set it a little higher, changing it from \setlength{\textheight}{25.8cm} to \setlength{\textheight}{25.9cm} did the trick. Thanks a lot! However, I'd like to know why does it work this way. Do the images get some minimal border/margin by default? –  ozu Aug 2 '12 at 16:46

## migrated from stackoverflow.comAug 2 '12 at 16:14

This question came from our site for professional and enthusiast programmers.

Even a tiny difference in the computed dimensions may produce an overfull box. So I suggest another approach: zero margin and vertical centering.

\documentclass{article}
\usepackage[a4paper,margin=0pt]{geometry}
\usepackage{graphicx}

\newcommand{\vcenterincludegraphics}[2][]{%
\newpage
\vspace*{\fill}
\includegraphics[#1]{#2}\par
\vspace{\fill}
\newpage
}
\pagestyle{empty}

\begin{document}

\centering

\vcenterincludegraphics[width=17.7cm]{pg1}

\vcenterincludegraphics[width=17.7cm]{pg2}

\vcenterincludegraphics[width=17.7cm]{pg3}

\vcenterincludegraphics[width=17.7cm]{pg4}

\vcenterincludegraphics[width=17.7cm]{pg5}

\end{document}

-
I already solved the problem somehow, but this is clearly a far more elegant solution, I didn't know you could use geometry to set all margins to 0 at once. I guess I should actually sit down and make some effort to learn LaTeX properly instead of trying to stitch a pdf in 15 minutes with no prior experience. Thanks again –  ozu Aug 2 '12 at 17:27
@ozu I think most of us started out my trying to stitch a pdf in 15 minutes with no prior experience ... so you're currently following the tried-and-tested route for learning LaTeX! –  Andrew Stacey Aug 2 '12 at 19:37