12

Internally, what causes latex.exe to be unable to import *.jpg, *.png, *.pdf directly?

1

4 Answers 4

6

Knuth TeX (the original TeX engine) does not support any image directly. The only thing we can do is to use \special commands to tell dvi drivers to deal with image files. When .dvi files converted to PostScript through Dvips driver, PostScript images can be supported; and dvipdfm(x) support pdf/png/jpg format.

TeX needs to know the bounding box of imported images. Eps files is typically ASCII texts, and has a meta comment like

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 276 362 335 429

Then size of eps images can be rendered by TeX well. However, TeX cannot determine the size of binary image files (JPEG, PNG, etc.) itself, tools such as extractbb(mainly for dvipdfm) or bmpsize.sty(using pdfTeX) is needed.

If dvi is not the output format, modern TeX engines (pdfTeX, XeTeX and LuaTeX) can import binary images well.

12

Age! None of these standards were around when TeX was developed. As a matter of fact there were only dot matrix printers! As Knuth - wisely - in my opinion - decided to freeze the development of TeX and concentrate in making it better and bug free, these were added much later via the special command by packages such as graphicx.

3
  • by the way, you won't find a \special in the package graphicx ... ;-)
    – user2478
    Dec 30, 2010 at 21:12
  • @Herbert aren't the \special's hidden in the drivers.dtx? My point though - and I didn't made it very clear was that Knuth, had the foresight to provide hooks at a time when everyone else only used hooks for fishing! (I think he must have been the person that defined it as such!)
    – yannisl
    Dec 31, 2010 at 10:04
  • as I already pointed out, the inclusion of the images is done by the driver files, not by graphics or graphicx, these are only packages to pass the needed information (bounding box) to TeX.
    – user2478
    Dec 31, 2010 at 10:13
8

TeX is not interested in graphics it needs only a bounding box, the rest is done by an import filter driver and there is none for LaTeX that supports other formats than ps, eps, mp and some bitmap formats ...

2
  • \includegraphics{} can work with .bmp using latex? Dec 29, 2010 at 20:15
  • 2
    with package bmpsize
    – user2478
    Dec 29, 2010 at 20:23
8

In the LaTeX-step (from tex to dvi) LaTeX needs to know only the size of the image. As an eps is a simple text file, LaTeX can read the file and find the bounding box informations. With binary image formats this is not possible. But if you give the bounding box informations to LaTeX - either with the bb-key or with a .bb-file - LaTeX will happily process every image:

\documentclass[12pt]{article}

\usepackage{graphicx}
\begin{document}
\includegraphics[bb = 0 0 100 100]{dontexit.exotic}
\end{document}

In the second step (dvi to ps or pdf or ...) the real images are inserted and which formats can be handled in this step depends on the driver (dvips, dvipdfmx, ....). Some of them (dvips) can handle eps natively, some can handle png, some of them can call converters in the background (e.g. dvipdfmx can call ghostscript to handle eps).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .