|
In computing, it is very common to require vector graphics within a LaTeX
report. UML diagrams, collaboration diagrams, etc, all demand vector drawings
annotated with text.
I introduce XFig, an interactive drawing tool which runs under X Window
System, fig2dev, a command line tool that translates Fig code to
various graphics languages and relate their use to inclusion of figures in
LaTeX reports.
XFig
With XFig you can create figures using
objects such as circles, boxes, lines, spline curves, text, etc. XFig saves
figures in its native Fig
format but can be coaxed into exporting to a variety of
formats. I use XFig in conjunction with fig2dev, but more on
that later.
Within XFig the user can select from the 35 available fonts. However, XFig
does have a special LaTeX font mode (which can be seen via the font
panel). If employed, when XFig figures are included in a LaTeX document
(via a format such as eepic (see later)) they adopt the
default/roman/bold/etc.. LaTeX font in operation at the point of inclusion. I use
LaTeX fonts in all of my XFig figures and so find it useful to invoke XFig in the
following way:
$ xfig -latexfonts
This command starts XFig using LaTeX fonts instead of the Postscript
default. Therefore, any text objects created thereafter will default to using
LaTeX fonts.
Similarly, XFig has the concept of "special text". In the context of a LaTeX
document, special text means that special characters in the string are not
specially processed but are passed directly to LaTeX. This allows me to
annotate a figure using the label "\code{make}", where \code{} is a LaTeX
command defined in the same document that includes the XFig figure (again via
the eepic format in my case). The figure's annotation is subject to LaTeX
processing as if it were text in the LaTeX document itself. Again, I use this
option for all my text and so I invoke XFig in the following way:
$ xfig -latexfonts -specialtext
In fact, I have added some more options to give:
$ xfig -exportL eepic -portrait -latexfonts -paper_size a4 \
-startfontsize 10pt -specialtext -startgridmode 1 \
-startposnmode 1 -startlinewidth 2
Each option is explained in the XFig man page.
fig2dev
The XFig Fig format cannot be directly included into a LaTeX document. The eepic
format can and so I use fig2dev to convert my Fig format diagrams
to eepic format.
$ fig2dev -L eepic diagram.fig
See the fig2dev
man page for a complete list of invocation options and supported export
languages.
Including your figures
In the course of writing a report, it is likely the including document and
the included figure will be altered many times. The two are edited
separately, one using a text editor and the other using XFig.
However, after each change to the Fig file, we are required to regenerate an
eepic file for inclusion in our LaTeX document. It represents the height of
inefficiency if a user is required to perform this task. Enter
makelatex.
makelatex includes rules for the
translation of Fig figures to eepic format. That is to say, the user never runs
fig2dev manually; he/she simply edits the files and then types
make to see the results. Let's see this by example:
I create a simple diagram, test.fig, using XFig. At the
appropriate point in my LaTeX document (test.tex), I place the
following code:
\begin{figure}[h]
\centering
\input{test.eepic}
\caption{A test figure}
\label{fig:ATestFigure}
\end{figure}
Notice that at this stage, we have not called fig2dev and so
test.eepic does not exist. We now call makelatex
on our document (see the makelatex pages for
more details):
$ makelatex test.tex
Listed in the Makefile generated by texdep (called by
makelatex) is a dependency between test.tex and
test.eepic. Notice that the latter file still does not exist.
However, the inclusion of a make rule, specifying how to create
.eepic files from .fig files, ensures that the
subsequent call to make succeeds. The behaviour of make then removes the need
for us to manually re-run fig2dev after each alteration to
test.fig.
We now proceed editing each file separately, finally calling make to merge
the results. The solution is neat and efficient and scales extremely well
to large reports including tens of figures.
References
-
1
-
Brian V. Smith
XFig User Manual
URL http://www.xfig.org/userman/
-
2
-
Micah Beck (maintained by Brian Smith)
XFig man page
URL http://www.cs.duke.edu/csl/docs/xfig-man.html
-
3
-
Micah Beck
Cornell University
Sept 28 1990
fig2dev man page
URL http://sun.uni-regensburg.de/xfig-3.2.2/share/man/man1/fig2dev.1.html
-
4
-
Paul Jolly
Jan 2004
makelatex
URL http://myitcv.org.uk/latex/makelatex.html
|