I am using pdflatex with PDF images for figures. When I do not scale the image, the figure goes off the page. When I do scale the image, it is very poorly placed. A little too far to the right of the page. I know something is not correct, because not only does the placement look terrible, but when I put a frame around the float, the frame crosses the image.

Here is a minimal working example. I'm not sure how to include the PDF image here. The image is a horizontally long image, not a standard size. I guess this might be the problem? How does one deal with this issue?

\section{Section Title}
  \caption{Blah blah}
  • 2
    You should post an image of the exact display produced from your minimal working example. Since a "frame crosses the image", this may be an issue with the image bounding box. You should either correct for this using the bb=lx ly ux uy option of \includegraphics, or recreate the image with a correctly cropped bounding box. What package did you use to create the image?
    – Werner
    Commented Dec 1, 2011 at 6:56

3 Answers 3


Using scale, leads to a lot of problems, especially if you have images with different aspect ratios, rather limit the size of the image by using width and height as follows:

\includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{Graph.pdf}

The image will either be scaled so as not to exceed any of the two limits and will keep the aspect ratio correct.

You can also use actual dimensions, instead of of \textwidth or \textheight and also values such as 0.7\textwidth.

Just a short explanation also why it is always good to include both a textwidth as well as a textheight. The number of floats and the amount of vertical space they can occupy on a page is controlled by a number of parameters. For example topfraction controls the top fraction of the page that can be occupied by a top float. In my opinion default settings are set too low ending up with relatively small images occupying full pages.

Try the minimal below. Then change \topfraction to 0.6 and try again. From two nicely looking pages, you will end with a lot of emptiness and three pages.

 \renewcommand{\topfraction}{0.9}   % max fraction of floats at top change to 0.6
 \renewcommand{\bottomfraction}{0.9}% max fraction of floats at bottom
    %   Parameters for TEXT pages (not float pages):
\setcounter{totalnumber}{4}     % 2 may work better
\setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\dbltopfraction}{0.7} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07}  % allow minimal text w. figs
 %   Parameters for FLOAT pages 
% floatpagefraction must be less than topfraction !!
First page image will go to next page, if topfraction is less than 0.71

\captionof{figure}{First Figure}


\captionof{figure}{Second Figure}

The second reason which is more obvious for including a height in the specs, is not to cause overflow at the bottom, as with the image below that I set width=\textwidth. This case is very obvious, but if you have figures that are more or less squarish this can trip you.

The best strategy for a book with a lot of figures, is to standardize on a number of image sizes and carefully set all parameters.

enter image description here

  • 1
    The scale does preserve aspect ratio: I wonder what you mean here.
    – Joseph Wright
    Commented Dec 1, 2011 at 6:58
  • @Joseph Yes it does. If you though scale to 0.5 an image which is 3 times the width of \textwidth it will overflow, hence I am recommending not to use scale but rather natural page limits. Same scale also would give problems with thin tall figures etc...
    – yannisl
    Commented Dec 1, 2011 at 7:08
  • Well yes, if you don't do a first 'survey' typesetting without the scale! I'm also not sure why you use both the width and height keys: if you use only one, the aspect ratio is preserved automatically.
    – Joseph Wright
    Commented Dec 1, 2011 at 8:15
  • 3
    @JosephWright I will post some more details and an example in the evening, but imagine that you have an image which is equal to textwidth + 3 mm, but has a natural image height of textheight+5cm. If you only specify that width=textwidth, it will still overflow at the bottom; hence my preference for always if possible to specify both. Where the images are in floats a height limit is advisable as well to ensure that the limits on the fraction of a page that can be occupied by floats is not exceeded for a few mm and the image disappears to another page or even to the end of the document.
    – yannisl
    Commented Dec 1, 2011 at 9:18
  • I was using Mathematica to produce the images. My solution was on the Mathematica side, I just reduced the size of the images to be put into the document and it fixed the problem. Thank you for your explanation. There is a lot of information here, so I will have to come back to the post when I am finished with the report I'm working on since I was able to get it working for now. Thank you again for the explanation.
    – Bre
    Commented Dec 2, 2011 at 21:02

Have you tried using \centering

 \caption{Blah blah}

The following code let's you scale the image to the full width of the textblock (which is the most you can get without having the image stick out on the left or right, or on both sides):

\caption{Blah blah} \label{fig:blahblah}

If the width of the textblock is insufficient to do justice to the image, you could try rotating the entire figure float by 90 degrees ("portrait mode" on the piece of paper). To do so, you could use the sidewaysfigure environment, which is provided by the rotating package. You'd type \usepackage{rotating} in the preamble and later

\caption{Blah blah} \label{fig:blahblah}

Sideways-figures are placed automatically on separate pages, hence there's no need to add a [h] or [ht] location specifier.

You must log in to answer this question.

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