# Graphics not centering properly

I am inserting an image into my document using

\begin{figure}[!htbp]
\centering
\includegraphics[width=0.7\textwidth,natwidth=338,natheight=176]{images/cloud_stack.png}
\caption{Service model stack}
\label{fig:cloud_stack}
\end{figure}


The image ends up being slightly off-center to the left (the caption is centered correctly).

This is happening for all of the images in the document. Tables are centered correctly. I'm using TeXstudio's DVI->PDF chain with MiKTeX 2.9 on Windows.

Edit: Using \fbox{\includegraphics{..}} shows extra whitespace inside the box:

• for testing use \fbox{\includegraphics{..}} if the white space is inside the box, then the white space is part of the image (or tex thinks it is) – David Carlisle Oct 4 '14 at 12:59
• why are you specifying natwidth=338,natheight=176 if you don't do that pdflatex will use the exact image measurement, if you override that you need to make sure you are exactly correct oh I see you are using dvi OK but make sure the dimension is correct:-) – David Carlisle Oct 4 '14 at 13:02
• @DavidCarlisle not adding it makes the compiler fail with the error 'Cannot determine size of graphics (no BoundingBox)'. The sizes are correct – AesSedai101 Oct 4 '14 at 13:04
• yes I saw you are using dvi output so you do need to tell it the size, are you sure the size is correct (in bp units) not being correct would explain the output you get:-) – David Carlisle Oct 4 '14 at 13:05
• as I suspected Tex is centering something based on the size you said the image is, but it's much smaller – David Carlisle Oct 4 '14 at 13:07

The default units for natheight and natwidth keys are bp (so that it matches the units of an EPS BoundingBox comment). Using \fbox you can see the actual size of the image is much smaller but classic TeX can not see that and uses whatever size you give.
If instead you used pdflatex then you could omit the natheight and natwidth keys and let the system measure the image exactly as it includes it.