Home Contact Research Tools LaTeX

Using Xfig

Picture created with fig2eps and eps2png

Xfig special text

Xfig is an ideal drawing tool for LaTeX users, since it allows you to combine vector graphics with TeX output. The FIG Tools automate the process of converting Xfig pictures to EPS and PDF with the TeX output embedded. Text objects that have the "special" flag on will be typeset by TeX.

The FIG Tools allow you to choose the document class with the -c option and to include LaTeX packages with the -p option. If you make frequent use of LaTeX commands that you normally insert in the preamble of your documents, you should bunch them together in a file foo.sty, and then call fig2eps or fig2pdf with the option -p foo to use them. Preamble commands that you need only occasionally can also be inserted by using the -i "tex code" option of fig2eps and fig2pdf.


The picture on this page was created from the file Example.fig. It uses the LaTeX commands \avec and \bvec defined in the Example.sty file. This picture was converted to Example.eps and Example.pdf by the commands

fig2eps -c[17pt]slides -pExample Example.fig
fig2pdf -c[17pt]slides -pExample Example.fig

The transparent PNG version on this web page was created with the EPS Tools:

eps2png -t -w400px -m256 Example

The Example.sty file also defines a "boldvecs" option, which will cause vectors to be typeset with bold letters. To use this option you would say, for instance,

fig2pdf -c[17pt]slides -p[boldvecs]Example Example.fig

Some advice

It is best to create Xfig pictures directly at the desired size. To help you do this, choose a comfortable Zoom factor in Xfig, use the LaTeX fonts at the correct size and make use of the rulers. You can set your Xfig preferences in the .Xdefaults and .Xresources files in your home directory. Mine contain the lines

Fig.latexfonts: on
Fig.specialtext: on
Fig.startfontsize: 10
Fig.startgridmode: 1
Fig.zoom: 2.0

To include graphics in a LaTeX document, use the graphicx package and do not specify the file extension in the \includegraphics command: latex will automatically search for an EPS file while pdflatex will search for a PNG, JPEG or PDF file. For example,


causes the file Example.eps to be included when you run latex, but the file Example.pdf (or Example.png or Example.jpg if they exist) when you run pdflatex.