How to import graphics into (La)TeX documents

Knuth, when designing the current version of TeX back in the early 1980s, could discern no "standard" way of expressing graphics in documents. He reasoned that this state could not persist for ever, but that it would be foolish for him to define TeX primitives that allowed the import of graphical image definitions. He therefore deferred the specification of the use of graphics to the writers of DVI drivers; TeX documents would control the drivers by means of \special commands.

There is therefore a straightforward way for anyone to import graphics into their document: read the specification of the \special commands your driver uses, and 'just' code them. This is the hair-shirt approach: it definitely works, but it's not for everyone.

Over the years, therefore, "graphics inclusion" packages have sprung up; most were designed for inclusion of Encapsulated PostScript graphics - which has become the lingua franca of graphics inclusion over the last decade or so.

Notable examples are the epsf package (distributed with dvips) and the psfig package. (Both of these packages were designed to work well with both Plain TeX and LaTeX 2.09; they are both still available.) All such packages were tied to a particular DVI driver (dvips, in the above two cases), but their code could be configured for others.

The obvious next step was to make the code configurable dynamically. The LaTeX standard graphics package and its derivatives made this step: it is strongly preferred for all current work. It can also be used (with the help of the miniltx "LaTeX emulator") in documents written in Plain TeX.

The graphics package takes a variety of "driver options" - package options that select code to generate the commands appropriate to the DVI driver in use. In most cases, your (La)TeX distribution will provide a graphics.cfg file that will select the correct driver for what you're doing (for example, a distribution that provides both LaTeX and PDFLaTeX will usually provide a configuration file that determins whether PDFLaTeX is running, and selects the definitions for it if so).

The graphics package provides a toolkit of commands (insert graphics, scale a box, rotate a box), which may be composed to provide most facilities you need; the basic command, \includegraphics, takes one optional argument, which specifies the bounding box of the graphics to be included.

The graphicx package uses the facilities of of graphics behind a rather more sophisticated command syntax to provide a very powerful version of the \includegraphics command. graphicx's version can combine scaling and rotation, viewporting and clipping, and many other things. While this is all a convenience (at some cost of syntax), it is also capable of producing noticeably more efficient PostScript, and some of its combinations are simply not possible with the graphics package version.

The epsfig package provides the same facilities as graphicx, but via a \psfig command, capable of emulating the behaviour (if not the bugs) the old psfig package. Epsfig also supplies homely support for users of the epsf package. There is no rational reason to stick with the old packages, which have never been entirely satisfactory in the LaTeX context.

A wide variety of detailed techniques and tricks have been developed over the years, and Keith Reckdahl's epslatex outlines them in compendious detail: this highly recommendable document is available from CTAN.

epsf.tex
macros/plain/contrib/epsf.tex
epsfig.sty
Part of the macros/latex/required/graphics.tar.gz bundle
epslatex.pdf
info/epslatex.pdf; the document is also available in PostScript format as info/epslatex.ps
graphics.sty
macros/latex/required/graphics.tar.gz
graphicx.sty
Part of the macros/latex/required/graphics.tar.gz bundle
miniltx.tex
macros/plain/graphics.tar.gz
psfig.sty
graphics/psfig.tar.gz