LaTeX toolchains and images

Different LaTeX toolchains and images

In a previous article I mentioned the different versions of LaTeX in common use (XeLaTeX, pdfLaTeX, LaTeX, luaLaTeX). In this article I will explain the differences as they relate to typesetting images, and which chain to choose in each case.

Long form

Image types

There are two fundamental classifications of image file formats - vectored and bitmap formats.

Vector files (e.g. svg, pdf, eps) are geometrical in nature, they are a list of instructions of what shape to draw and where to draw it. As such they remain smooth however far you zoom in. These are very popular for graphs, charts and diagrams as they efficiently represent the image and there is no loss of quality when it is zoomed.

Bitmap images (e.g. png, jpg, bmp, tiff, gif) are grids of pixels with a colour assigned to each pixel. The number of pixels in the image sets a hard limit on how far you can zoom without loss of quality. As soon as the image pixel takes more space than a pixel on your display it will look blurry. Photographs are always stored in a Bitmap format.

Which images work with which toolchains and why

LaTeX (and XeLaTeX)

The oldest toolchain is the LaTeX toolchain. This typesets to a DVI file, which has long since fallen into obsolescence, therefore the DVI file must be converted to a PostScript file, and from there distilled into a PDF file, before it can be viewed. This rather tortuous route is highly inefficent, bug ridden and it can hardly be recommended.

Nevertheless, this toolchain does have the advantage of an intermediate PostScript stage, which is necessary for certain LaTeX packages. DVI is incapable of representing anything other than black text and boxes on a white background, so all images, colour commands and diagrams must be encoded inside the DVI file to be expanded at the PostScript stage. Therefore this toolchain only really supports EPS files, which are fragments of PostScript. Nevertheless EPS is a highly flexible format and there are tools to convert all known file formats, vector or bitmap, into EPS.

EPS and PostScript still have an important role to play as a interchange format for printers, but they have long since been replaced by PDF files for exchanging documents. We strongly recommend that you typeset with a native PDF toolchain such as pdfLaTeX or luaLaTeX. Some will find it a little tough to switch at first either because they are used to a package such as PSTricks or they are used to using EPS files, however in both cases there are better, more modern alternatives (Tikz instead of PSTricks and PDF files instead of EPS files).

For those unwilling to change, XeLaTeX is a more modern development of LaTeX that handles the file format conversions for you, and we strongly recommend switching to it.

pdfLaTeX and luaLaTeX

pdfLaTeX and luaLaTeX generate PDF directly and as such need they require no intermediate PostScript stage. This makes for a more efficient and capable toolchain.

The main problem for many people when switching to pdfLaTeX is that it does not support EPS. The best advice here is to export images from your graphics package in PDF rather than EPS format, as the EPS filetype has many fundamental problems, and PDF is in all ways an improvement upon it.

If you are unable to switch your graphics to PDF, then simply adding the line \usepackage{epstopdf} will automatically convert any figures during the typeset process. (NB you must turn on the --shell-escape option to be able to do this. Texifier users can do this from the typesetting pane of Texifier macOS’s Preferences window).