Friday, August 03, 2007

Xfig (with Latex commands) to EPS



This tutorial will help in creating .eps files from .fig files that have Latex commands in them. This is especially usefull for creating figures containing mathematical formulas, for Latex documents. The procedure is outlined below.
  1. The first step is to obviously create the figure using Xfig. However, special care needs to be taken while adding mathemateical formulas and Latex specific text in the figure. Say you want to add "log216" to your figure. Write it in Xfig just as you would in a Latex document i.e.

$log_{2}16$
  1. We will now need to edit the properties of this text by bringing up the "Edit Panel". For the property _Special Flag_, select _Special_ from the drop down box.
  1. Save the figure as a .fig file, say example.fig. Export the figure in "Combined PS/LaTeX (both parts)" format. This will create example.pstex and example.pstex_t files in your working directory.
  1. One has 2 options now - either include the example.pstex_t file directly in the Latex document or create a example.eps file that will be included in the Latex document. For the first case, include the following code in your Latex doc
    ument:

\begin{figure}[htbp]
\begin{center}
\input{example.pstex_t}
\caption{Figure with Latex formula in it.}
\end{center}
\end{figure}

  1. For the second case, create a .tex file, say figure.tex, with the following commands in it:



\documentclass{article}
\usepackage{epsfig}
\usepackage{color}
\setlength{\textwidth}{100cm}
\setlength{\textheight}{100cm}


\begin{document}
\pagestyle{empty}
\begin{center}
\input{example.pstex_t}
\end{center}
\end{document}


Compile this file using the command:


latex figure.tex


Now create the .eps file using the command:

dvips figure.dvi -E -o example.eps

You can now include the .eps file into your Latex document.