Xfig and special text for LaTeX

(Updated 06-07-10)

I create or modify all my figures for presentations and publications in xfig. I won't claim it is the best tool for this, but it is free, not resource intensive, and performs the task well.

Xfig can export an eps or pdf file so the figure is easily used in other documents. Or from the command line:

    fig2dev -L eps figure.fig > figure.eps

Xfig allows latex commands, e.g. math, to be included. This creates a multistep process to include the figure in a LaTeX document, including exporting the parts, and adding an input statement to the .tex file. This is no wholly satisfactory because a separate eps file is required for journal submission or share figures with others. It is much better to have a similar system to create eps files simply from fig files with special text.

First, a short script for converting the exported .pstex and .pstex_t files into eps. My script is called pstexfig. It creates a temporary LaTeX file with just the figure and creates an eps file from it.

There is a problem with bounding boxes and rotated special text, e.g. labels on vertical axes. The bounding box based on the text as if it were horizontal. Two possible solutions are (1) run epscrop on the eps file to fix the bb, or (2) use left or right justification on the labels so that they extend toward the figure interior.

For use with make, I use an extension of .figs for xfig files with special text. That way, I can define a different rule to handle them automatically. Here is an implicit makefile rule:

%.epss : %.figs
	fig2dev -L pstex_t -p $(notdir $(basename $< )).pstex $< > $(dir $< )$(notdir $(basename $< )).pstex_t
	fig2dev -L pstex $< > $(dir $< )$(notdir $(basename $< )).pstex
	pstexfig $(dir $< )$(notdir $(basename $< ))
	mv $(dir $< )$(notdir $(basename $< )).eps $(dir $< )$(notdir $(basename $< )).epss
Extensions of this that would be useful:
  1. Some way of marking files needing epscrop and working it into makefile rules
  2. Let pstex handle the .fig file directione