automatic conversion of xfig to tikz

There is a utility just for this called fig2tikz. From the web page it seems that LaTeX overlays should be supported, and I'd be interested to know if it does.

Running fig2tikz on the code you supply in the question yields:

\begin{tikzpicture}[y=-1cm]

% objects at depth 50:
\draw[thick,arrows=-triangle 45,black] (17,7.5) .. controls (15.5,9.5) .. (17,12.5);

\end{tikzpicture}%

By placing this in a minimal document (note the arrows library)

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
%%% Code generated by fig2tikz
\begin{tikzpicture}[y=-1cm]

% objects at depth 50:
\draw[thick,arrows=-triangle 45,black] (17,7.5) .. controls (15.5,9.5) .. (17,12.5);

\end{tikzpicture}%
%%% End of code
\end{document}

the following is generated:

enter image description here


Releases 3.2.6 of xfig / fig2dev and newer can export to tikz. A standalone tex file is produced with fig2dev -L tikz -P f.fig f.tex. Omit -P to produce code for inclusion in a tex-file.


I have two alternative propositions to Mark's suggestion.

a. Since my understanding is that you have hundreds of old Xfig pictures you probably want to automatize that. I would use Transfig utility (should have come with your Xfig installation) in particular fig2dev to convert your files into eps files and then use eps2pgf utility to convert to PGF code (which is almost TikZ right)

cd my_pictures_dir
for i in *.fig
  do 
    fig2dev -L eps $i `basename $i .fig`.eps
    java -jar eps2pgf.jar `basename $i .fig`.eps `basename $i .fig`.pgf
  done

I have not tested the solution so YMMV.

b. The second option is that you pick some other intermediate format

$ fig2dev -help 
fig2dev Version 3.2 Patchlevel 5a
General Options (all drivers):
  -L language   choose output language (this must be first)
                Available languages are:
                  box cgm eepic eepicemu emf epic eps ge gif 
                  ibmgl dxf jpeg latex map mf mmp mp pcx 
                  pdf pdftex pdftex_t pic pictex png ppm ps pstex 
                  pstex_t ptk shape sld svg textyl tiff tk tpic 
                  xbm xpm 

which can be easer converted to TikZ or PGF. I do not use TikZ on the regular basis nor I am familiar enough with the library to make a correct selection.

Tags:

Xfig

Tikz Pgf