Adding LaTeX figures in xfig

It is possible to add LaTeX commands directly to figures in xfig, however xfig needs to be started with special settings to work well with Latex in figures.

EITHER start xfig using

xfig -specialtext -latexfonts -startlatexFont default

(note - there is a single capital F on the above line)

OR add the following lines to your .Xdefaults file, logout and login again, and start xfig as normal:

Fig.latexfonts: true
Fig.specialtext: true

Now as a simple test to ensure things are working, draw a quick figure, add a single equation (by text such as e.g. $\alpha = \beta$) and save this as myfigure.fig. Now go to File-->Export from within xfig and export as a "combined ps/latex", choosing myfigure.pstex as the output file name.

(note - you can't have an equation on it's own .. there has to be a figure component)

The export will create 2 things:

myfigure.pstex (postscript of your figure)
myfigure.pstex_t (latex commands to draw your equation 
                  and position it exactly over the figure 
                  as in myfigure.fig)

In your LaTeX document you simply add a \input{myfigure.pstex_t} in order to include the figure. As long as you have \usepackage{psfig} and \usepackage{graphicx} it will show up.

Here is an example latex document:

\documentclass{article}
\usepackage{graphicx}
\usepackage{epsfig,color}
\begin{document}
\pagestyle{empty}
\input{myfigure.pstex_t}
\end{document}