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?
\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\section{Section Title}
\begin{figure}[h]
\caption{Blah blah}
\includegraphics[scale=.4]{Graph.pdf}
\end{figure}
\end{document}
Best Answer
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 usingwidth
andheight
as follows: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 as0.7\textwidth
.Just a short explanation also why it is always good to include both a
textwidth
as well as atextheight
. The number of floats and the amount of vertical space they can occupy on a page is controlled by a number of parameters. For exampletopfraction
controls the top fraction of the page that can be occupied by atop 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.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.