Professional Documents
Culture Documents
Klaus Höppner
Nieder-Ramstädter Str. 47
64283 Darmstadt
Germany
klaus.hoeppner@gmx.de
Abstract
This talk presents strategies for including graphics into LATEX documents. It
shows the usage of the standard graphics packages of LATEX as well as an intro-
duction to different graphics formats. Some external tools for converting graphics
formats are discussed.
TUGboat, Volume 26 (2005), No. 1 — Proceedings of the Practical TEX 2005 Conference 59
Klaus Höppner
PNG is the portable network graphics format. It vides a convenient interface for specifying parame-
was introduced due to the problem that Unisys ters. In general, there is no reason not to always use
claimed a patent for the compression algorithm graphicx.sty.
used in GIF format. For this reason, it is of- So the first step is to load the graphicx style
ten used nowadays on web pages. PNG is a file after the \documentclass statement:
bitmap format that supports compression both \usepackage{graphicx}
with and without loss of image quality.
In fact, the TEX compiler doesn’t know any-
JPEG is a bitmap format with lossy compression thing about graphics, and including them is done
and is often used for photographs (e. g. most by the DVI driver. So the graphicx package has to
digital cameras produce JPEG files). do two things:
TIFF is a bitmap format sometimes used for high
1. find the bounding box of the image (this can
quality pictures — in part because it supports
be troublesome when you have e. g. an EPS file
the CMYK color space important especially for
created by an application that wrote a wrong
commercial printing.
BoundingBox comment — in this case, it can be
Now the question is: What format shall I use for helpful to put the \includegraphics command
what purpose? Though there is no one true answer into an \fbox to find out what graphicx thinks
to this question, my advice is as follows: about the bounding box);
1. For drawings (e. g. technical drawings or data 2. produce the appropriate \special for the out-
plots) use vector graphics. It gives you maxi- put driver; thus, the usage of the graphics bun-
mum freedom to manipulate the image when in- dle is driver dependent.
cluding it into a document where you often need Nowadays, there are two main workflows for
to scale the image to fit into your layout. Addi- producing documents: using latex to produce a
tionally, it is independent of the output device, DVI file and then dvips for converting it to Post-
and thus you can zoom into the image in your Script, and using pdflatex to produce a PDF file.
document viewer without seeing single pixels. Most modern TEX systems are configured to au-
Drawing tools offered by TEX distributions — tomatically check whether you are using latex or
notably PSTricks and METAPOST — can usu- pdflatex and producing dvips \specials in the
ally produce EPS output natively. Most vec- first case and the appropriate \pdfimage commands
tor drawing programs like xfig and Corel Draw in the second case. So if you are using one of the
also offer export functionality for producing EPS above workflows, you shouldn’t need to specify your
output (though sometimes buggy). output backend explicitly. If you are using another
2. If you are stuck with bitmaps, use PNG for im- backend you have to specify it as an option, e. g.
ages with sharp color transitions, such as black \usepackage[dvipsone]{graphicx}
and white boundaries.
(for the Y&Y dvipsone driver), but be aware that
3. For photographs, you can use JPEG in most
other backends often don’t support scaling or ro-
cases, since the quality loss by compression is
tating. For example, DVI previewers like xdvi or
normally imperceptible when printed. On most
windvi try to interpret the dvips specials, but rota-
devices, a resolution of 100 to 200 dpi will be
tions may not be displayed properly in DVI preview.
sufficient (remember that screen resolution is
After the package is loaded, to include an image
normally about 75 to 100 dpi, and color printers
simply use:
claim to have high resolutions but dither color
prints, so you will hardly notice the difference \includegraphics{sample}
compared to JPEGs with higher resolution).
The LATEX graphics package
Since the introduction of LATEX 2ε , the graphics
bundle is part of the standard package set accom-
panying the LATEX base distribution [1]. It consists Please notice that no extension for the file was
of two style files, graphics.sty and graphicx.sty. given. The explanation why will follow later. In
While graphics.sty requires the use of \scalebox the case of using \includegraphics without op-
and \rotatebox for scaling or rotating graphics, tions the image is included at its natural size, as
the extended style graphicx.sty supports scaling shown above. When using the graphicx style, you
and rotating using the keyval package, which pro- can scale your image by a factor:
60 TUGboat, Volume 26 (2005), No. 1 — Proceedings of the Practical TEX 2005 Conference
Strategies for including graphics in LATEX documents
TUGboat, Volume 26 (2005), No. 1 — Proceedings of the Practical TEX 2005 Conference 61
Klaus Höppner
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70
80 80
Windmühle
75 75
70 70
Haus für
65
Industriekultur ✗ 65
60 60
55
Mainzer Str.
55
50 50
45 45
25 25
Additional tools
20 20
There are many other helpful tools. I will mention
15 D 15
A Fr two I use quite often.
10 10
giftopnm sample.gif | pnmtopng - > sample.png potrace is a tool to convert a pure black and white
bitmap to vector graphics [6]. Fig. 4 shows a sample
Another nice tool is tif2eps by Boguslaw Jac- bitmap converted to a vector image.
kowski et al. [4] which uses Ghostscript to convert a
TIFF file to EPS, e. g. References
gs -- tif2eps.ps sample.tif sample.esp -rh [1] CTAN:macros/latex/required/graphics
[2] http://www.imagemagick.org
which produces a RLE compressed and hex encoded [3] http://netpbm.sourceforge.net
EPSfile. In my experience EPS files produced with
[4] CTAN:support/pstools/tif2eps
tif2eps are smaller than those produced by Im-
[5] CTAN:macros/latex/contrib/overpic
ageMagick. Additionally it supports CMYK TIFF
files smoothly. [6] http://potrace.sourceforge.net
62 TUGboat, Volume 26 (2005), No. 1 — Proceedings of the Practical TEX 2005 Conference