Monday, January 25, 2010

LaTeX in your figures with XFig (shudders)

So in a recent paper I've put together I put beautiful axis labels and misc. LaTeX stuff on my EPS figs. by using the \put commmand. in the "picture" environment. It goes something like this:
\begin{figure}[tbp]
\begin{center}
\setlength{\unitlength}{1cm}
\begin{picture}(8,7)
\put(-0.8,0.5){\includegraphics[width=8.4\unitlength]{figure1.eps}}
\put(0,0){$\ket{1}$}   % this makes a |1> and puts it at (0,0) ie. bottom left
\end{picture}
\end{center}
\end{figure}
It is very handy and super cool. Much to my dismay however the journal did not agree with me:

"PLEASE NOTE,..., we ask that you adhere to the following guidelines with regard to your figure files:
     One or more of the figure files you have provided are not complete,... . Please be advised that each figure file should contain the entire contents of the figure. Use of commands in your manuscript source file to include axis labeling or other such content to your figures is problematic for us.  These commands should be removed from your manuscript TeX file and complete files for each of the figures should be submitted." 

Fantastic. So here then is how you put the LaTeX in your figures and keep PRA happy:
First we need an archaic program Xfig. It is a "new" version, but it is an X program (runs under X windows), and feels old and weird. Under linux install the transfig package as well. Under other OSes follow the instructions. WARNING, under Mac OSX 10.4.11 I couldn't save my Xfig figures. Not cool. I ended up doing in Linux.
Using: xfig -specialtext -latexfonts -startlatexFont default 
at the command line will open Xfig ready to go for using LaTeX commands. Otherwise make sure that for the text boxes the "text flags" are set to "special". This is done on the bottom of the screen. $...$ puts you in mathmode.

Once you have all your LaTeX goodies put in, export the figure as combined ps/latex. This gives you 2 files, a figure1.pstex, and a figure1.pstex_t. Now create a LaTeX driver file. It is going to compile the LaTeX part and the picture part into one thing:
\documentclass{article}
\usepackage{epsfig}
\usepackage{color} 
\setlength{\textwidth}{100cm}
\setlength{\textheight}{100cm}
\begin{document}
\pagestyle{empty}
\input{figure1.pstex_t}
\end{document}
Compile it (not using pdflatex) ie make a .dvi file. Lets say you called your LaTeX document converter.tex. Then from the terminal run:
dvips -E converter.dvi -o figure1.eps
Now you have a nice .eps figure with all your LaTeX goodies.

NB!! You have to make the figure in Xfig the size you want it in your document. If you scale your funky new .eps in your LaTeX  document your labels are going to scale as well. So make the picture the size you want, and use the font size you would like to have in your document.   <--This is why I would just stick with /put for labels when doing a thesis, or whenever you can get away with it.


 Further info:
http://epb.lbl.gov/xfig/latex_and_xfig.html
http://graphics.stanford.edu/infrastructure/howto/xfig_latex.html
Usermanual
I hope this helps.

No comments:

Post a Comment