Cannot determine size of graphic
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>
A non-Latex solution
A very fast solution is to convert the png
file into eps
format. It can be done easily using graphic software, for instance Inkscape
.
So, you only need to open the file in Inkscape
and then SaveAs
and select eps
format.
Now change the extension in the tex
file from
\includegraphics[width=0.8\textwidth]{tiger.png}
to
\includegraphics[width=0.8\textwidth]{tiger.eps}
Fix the file name
I got this error with a pdf file which contained dots in the filename. Removing the dots (except the .pdf, of course) fixed the issue.
Fix file type detection
The LaTeX graphics/graphicx package uses the first dot to find the extension. Simply adding \usepackage{graphicx} \usepackage{grffile} fixed the issue without changing file names. Package grffile
changes the algorithm to check for known extensions (option multidot
, enabled by default).