Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a picture that I'd like to include in the center of the page. I don't want the picture to scale. So I tried this (among a lot of other variations):

\begin{figure}[htb]
\centering
\includegraphics{overview_pyramid.png}
\caption{Overview pyramid}\label{fg:overview_pyramid}
\end{figure}

Why isn't this working? I center the image and I don't set a specific size. Nevertheless the picture is scaled (but don't know the factor) and is on the left end of the page.

share|improve this question
2  
Please note that \label always come AFTER \caption (or other to-be-labeled elements like \section, etc.). The caption increments the figure or table number to which the label refers. Using \label before \caption labels the previous figure or table (correct: the last \caption in the same float type). –  Martin Scharrer Feb 6 '11 at 15:05
    
@Martin Scharrer Thanks I'll correct that –  RoflcoptrException Feb 6 '11 at 15:06
3  
No not use the center environment -- it adds unwanted margins. Simply use the \centering macro after \begin{figure}. –  Martin Scharrer Feb 6 '11 at 15:07
    
@Martin Scharrer Thanks again, that resolves the centering issue, but the image is still scaled. –  RoflcoptrException Feb 6 '11 at 15:09

2 Answers 2

up vote 10 down vote accepted

Your PNG probably doesn't have the correct resolution information set in its metadata. If you have ImageMagick on your system, you can run identify -verbose overview_pyramid.png to see the metadata of the image. If the output contains Units: Undefined and/or a Resolution: that is incorrect, you need to add the information.

You can do this using the command convert overview_pyramids.png -density 300 -units PixelsPerCentimeter overview_pyramids.png to set the resolution to 300 pixels per centimetre, for instance; or just convert overview_pyramids.png -units PixelsPerInch overview_pyramids.png if the value of the "Density" field is correct but the unit is missing.

share|improve this answer
    
I examined the picture: Dimensions: 376x152, Width 376 pixels, Height 152 oxels, Bit depth 32 –  RoflcoptrException Feb 6 '11 at 15:40
1  
@Roflcoptr: You need to use the -verbose switch to get the information on the resolution and the physical size (called Print size in ImageMagick) –  Jake Feb 6 '11 at 15:41
    
Thanks now it works, but the caption is still not centered but on the left. –  RoflcoptrException Feb 7 '11 at 20:20
2  
@Roflcoptr: I'm just guessing here: Your figure is probably wider than \textwidth, which would lead to the caption being correctly centered with regard to the text, but the figure being aligned with the left text margin and spilling into the right margin. To resolve this, you can follow what Stefan Kottwitz suggests in his blog: Enclose the figure with \makebox: \makebox[\textwidth]{\includegraphics{overview_pyramid.png}}. This also eliminates the need for the \centering command in your figure. –  Jake Feb 7 '11 at 20:33

Images are not scaled, if you don't set any scaling options.

Bitmap images like PNG and JPEG, have a "natural" pixel density. This is often 72DPI or 96DPI, but can be changed by softwares. On the other hand, PDF readers has its own video pixel density, it may be 96DPI, 110DPI or any other value you set. If the density of image and the PDF reader match, and in PDF reader you set the 100% scaling, you'll find the image looks unscaled.

share|improve this answer
    
I have found that setting the DPI of my images to 110 causes them to display nicely when viewed in Acrobat at 100% zoom (occasionally with 1 pixel extra in output). To me it seems that 110dpi is very close but not perfect. What is the logic/math behind this outcome? –  Lea Hayes Jul 31 '12 at 16:36
1  
@LeaHayes: It depends on the physical DPI of the screen. –  Leo Liu Aug 1 '12 at 1:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.