## Wednesday, August 11, 2010

### LaTeX formulas in XFig figures using PDFLaTeX

Hi,
this post is to explain how to insert mathematical formulas in figures created with XFig when using PDFLaTeX (and therefore when PSFrags is not an option). The procedure is actually so painless that I would recommend it even when PSFrags is available.
1. when inserting the text in XFig, make sure you set the "Special text" flag. This can be done even after inserting the text by opening the Edit dialog window. You can mix normal text and math with the usual $symbol. 2. instead of exporting to PDF, export as "Combined PDF/LaTeX (both parts)". This will create two files figure00.pdf and figure00.pdf_t (assuming the name of the XFig file is figure00.fig). 3. In your document, instead of using \includegraphics{figure00.pdf} include the _t file with \input{figure00.pdf_t}. If you want to resize the picture, you can use the command \resizebox as shown in the example below 4. run pdflatex as usual. Here are example files: test.tex:  \documentclass{article} \usepackage{graphicx} \usepackage{color} \begin{document} Some text before the figure. \begin{figure} \resizebox{.5\textwidth}{!}{ \input{figure00.pdf_t} } \end{figure} \end{document}  figure00.fig:  #FIG 3.2 Produced by xfig version 3.2.5b Landscape Center Metric A4 100.00 Single -2 1200 2 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 0 0 1.00 60.00 120.00 1800 5490 1800 1395 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 0 0 1.00 60.00 120.00 315 5310 5535 5310 3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 4 585 5220 1980 5130 3195 4320 4545 1440 0.000 1.000 1.000 0.000 4 0 0 50 -1 0 12 0.0000 6 210 735 5040 5625$\\alpha$\001 4 0 0 50 -1 0 12 0.0000 6 210 945 1935 1665$e^\\alpha\$\001 
Enjoy!