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 rendering the following code with xelatex:

\documentclass{article}
\usepackage[debugshow]{graphicx}
\begin{document}
%% This gives ! LaTeX Error: Cannot determine size of graphic in lowres (no size specifed).
\includegraphics[type=png]{lowres}
%% This works fine without specified size.
\includegraphics{highres.png}
\end{document}

I've got the files 'lowres' and 'highres.png' in my current directory:

$ file lowres 
lowres: PNG image data, 348 x 350, 8-bit colormap, non-interlaced
$ file highres.png 
highres.png: PNG image data, 348 x 350, 8-bit colormap, non-interlaced

The obvious difference between these files is the lack of extension for 'lowres', so that's why I specify the type in the 'includegraphics'.

The problem is, it looks like it is mandatory to specify the size when the file hasn't got any extension (although we give the type as a parameter).

This behaviour doesn't make sense to me, is there a way to get around it?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you don't specify an extension as part of the filename with \includegraphics a predefined set of extension is used to search for a suitable file. If you use only lowres then it looks for the files lowres.png, lowres.jpg and lowres.pdf (not necessary in this order) and uses the first one which is found. It does not look for a lowres file without any extension. The type option is rather deprecated, IIRC, and might not do what you expect from it.

The best thing would be to simply rename the file in question to have the correct file extension. You could also define an empty extension as part of the default extension list and remove the type option.

The following works for me. Apparently XeTeX is smart enough to figure out the real type without an extension, which actually isn't very difficult.

\documentclass{article}
\usepackage[debugshow]{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg,}% Note the trailing ',' which defines an empty extension
\begin{document}
\includegraphics{lowres}
\includegraphics{highres.png}
\end{document}
share|improve this answer
    
Brilliant, thanks! –  jeje Jan 23 '12 at 12:05

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.