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'm trying to include graphics in my Latex-file, which I compiled with latex+dvipdf on OS X. Latex however returns this error: "Cannot determine size of graphic"

My graphic is exported from PowerPoint, so I have tried both .pdf and .png. I get the same errors for both.

Sample code that doesn't work:

\begin{figure}[htb]
\begin{center}
\leavevmode
\includegraphics[width=0.8\textwidth]{graph.png}
\end{center}
\end{figure}

If I have to manually set some measurements of the image, please tell me how I can find out those measurements. I need the image to take up about 80% of text width and be centered. Thanks.

share|improve this question
    
possible duplicate of: tex.stackexchange.com/questions/11193/… (untagged) –  Ciro Santilli Aug 15 at 20:20

1 Answer 1

up vote 57 down vote accepted

The DVI producing latex doesn't support reading the size of PNG, JPG or PDF images. You need to use pdflatex for this. Actually latex is pdflatex in DVI mode in modern distributions, but it can read the sizes only in PDF mode for some reason. You are however able to state the natural size of the images using natwidth and natheight which will make latex compile without error. The produced DVI file will only link to the PDF and the DVI-to-PDF converter will need to include it in the final PDF. AFAIK dvpdf doesn't support this but dvipdfm does.

\documentclass{article}

\usepackage{graphicx}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[width=0.8\textwidth,natwidth=610,natheight=642]{tiger.pdf}
\end{figure}
\end{document}

Compile with either

pdflatex <file base>

or

latex <file base>
dvipdfm <file base>
share|improve this answer
3  
For dvipdfm(x), one should use dvipdfm or dvipdfmx option of graphicx pacakge, and use extractbb (ebb, xbb) program to produce .bb or .xbb file. bmpsize package can also used to replace extractbb. –  Leo Liu May 8 '11 at 15:15
    
Thank you for the solution provided. I simply added \usepackage[dvipdfm]{graphicx} \usepackage{bmpsize} to my file, and it worked perfectly ! No need to spend time to manually set the bounding box with the time-consuming trial-and-errors method (what I did until this day). –  user41288 Nov 19 '13 at 15:17
    
I used this solution for a png-figure with latex, dvipdfmx and graphicx-package, which worked for me without doing anything additional (2013 TeX Live) –  Bernhard Jul 3 at 12:09

protected by Community Dec 2 at 13:59

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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