Eps Tiff Conversion
Eps Tiff Conversion
Eps Tiff Conversion
with pdflatex
by
H. Schulz and R. Koch
Introduction
Users who include eps and tiff figures in documents are sometimes surprised to find that they
have a problem when compiling those files using pdflatex. By default pdflatex can include jpg,
png and pdf files but not eps or tiff files. This document discusses methods of including eps and
tiff files in documents compiled with pdflatex. In the end these techniques use Ghostscript or
Apple’s distiller to convert eps files to pdf format, and Apple’s built-in sips program to convert tiff
files to png format.
Techniques to make the process very easy were first added to TeXLive-2011, and refined
in TeXLive-2012. These features remain unchanged in TeXLive-2015 and later. Only the list of
restricted mode commands in Appendix B may change from year to year; the list given here is for
the year 2022.
\includegraphics{foo.eps}
then the graphicx package will automatically convert foo.eps to foo-eps-converted-to.pdf and
load that pdf file. When the file is typeset again, foo.eps will be converted again only if it is newer
than foo-eps-converted-to.pdf, but in any case foo-eps-converted-to.pdf will be loaded.
Some users omit the extension and just write
\includegraphics{foo}
which will also work as above: the file foo.eps will be converted to foo-eps-converted-to.pdf and
so forth. But there is one tricky point. Suppose the source folder contains both foo.eps and a
completely unrelated file named foo.pdf. Then the graphics command will load foo.pdf first and
not even notice the eps file.
Incidentally, the system names the converted file foo-eps-converted-to.pdf rather than foo.pdf
precisely because a few users might have source files containing unrelated eps and pdf files with
1
the same name; these users wouldn’t appreciate an automatic conversion that destroyed their
original pdf file!
Users upgrading from earlier versions of TeX Live will be familiar with the command
\usepackage{epstopdf}
This command is not needed in TeX Live 2011 and later, although it does no harm, because the
graphicx package automatically loads it. Users may also be familiar with the TEX command-line
flag “--shell-escape”, which gives TEX the ability to call external programs during typesetting. This
flag is also not needed in TeX Live 2011 or later for eps to pdf conversion because the system
implements “restricted-shell-escape” which allows a small list of special system commands to be
executed even if shell escape is not set.
• Apple’s Preview program will convert tiff files to png format. Open the tiff file in Preview
and then Export the result as a png.
• It is often easier to use Terminal in /Applications/Utilities. Use Apple’s built-in sips program
to do the conversion:
• TEXShop 2.47 and later and TEXShop 3.12 and later have built-in tiff to png conversion. With
a document window active, select Convert TIFF in the File menu. A dialog appears listing all
of the tiff files in the folder containing the source file, and in sub-folders of this file. Select
the tiff files to be converted — multiple files can be selected — and push Convert.
• Herbert Schulz wrote a Drop Script which can convert all tiff files in a folder to png in a
single operation. Drag the individual tiff file or folder to the Drop Script. This is available as
‘Tif(f) to Png.zip’ at <https://herbs.github.io>.
• The first is to reconfigure TEX by adding the flag --shell-escape to its calling sequence. The
effect is to allow TEX to call any program, including for instance, a shell command to erase
2
all files in the home directory. How one adds the flag will depend upon which application
you are using to typeset your document but adding the flag is usually very easy. Adding
--shell-escape to TEXShop is discussed in more detail in Appendix A on page 4.
• The second method, available with TeX Live 2012 or later, is to add one or all of sips and/or
pstopdf to the list of trusted programs for restricted-shell-escape. This involves directly
manipulating the TeX Live configuration. This is discussed in more detail in Appendix B on
page 4
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.eps}{pdf}{.pdf}{%
pstopdf #1 -o \OutputFile}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.tif}{png}{.png}{%
sips -s format png #1 --out \OutputFile}
\epstopdfDeclareGraphicsRule{.tiff}{png}{.png}{%
sips -s format png #1 --out \OutputFile}
\PrependGraphicsExtensions{.tif, .tiff}
\epstopdfDeclareGraphicsRule{.tif}{png}{.png}{%
sips -s format png #1 --out \OutputFile}
\epstopdfDeclareGraphicsRule{.tiff}{png}{.png}{%
sips -s format png #1 --out \OutputFile}
\PrependGraphicsExtensions{.tif, .tiff}
3
and place it in your personal texmf tree at ~/Library/texmf/tex/latex/config/. But remem-
ber that others that see your source file may not have your epstopdf.cfg file and a compile will fail
for them. You may also place the epstopdf.cfg file in /usr/local/texlive/texmf-local/tex/
latex/config/ for use by all users of your system; make sure to run
sudo -H mktexlsr
$TSUserCompileOptions = ’’;
to
$TSUserCompileOptions = ’--shell-escape’;
i.e., from an empty string to one that includes the --shell-escape flag, and save the file. Remember
~/Library/ is the Library folder in your HOME folder. In Mac OS X 10.7 (Lion) and later you can
open the ~/Library/ folder by pressing the Opt key while clicking on the Finder’s Go Menu.
shell_escape_commands = \
bibtex,bibtex8,\
extractbb,\
gregorio,\
4
kpsewhich,\
makeindex,\
r-mpost,\
repstopdf,\
texosquery-jre8,\
sips,\
and name it texmf.cnf. Note: the file must end with at least one completely blank line! I
typically use two blank lines to make sure I don’t mess it up. The first part duplicates the default
list used for TeX Live 2016 since this command overrides the default rather than adding to the
default.
Using the “Go to Folder. . . ” command in Finder’s Go menu, open the
/usr/local/texlive/texmf-local/web2c
folder and copy the texmf.cnf file there. Finally run the command
sudo -H mktexlsr