I have a large collection (hundreds) of partially quite old xfig pictures. Though I really like the xfig program I would like to move to some more up-to-date picture format like TikZ. So I would like to ask if someone has a good idea for an automatic conversion tool. Ideally, some shell srcipt or so... Then problem (?) is that many of the xfig pictures have LaTeX overlays.

EDIT: this might be too long for a comment on Mark's answer, so I post it here as an edit:

Here is a sample of a xfig which simply produces an error

FIG 3.2 Produced by xfig version 3.2.5b

1200 2
3 0 0 3 0 7 50 -1 -1 0.000 0 1 0 3
1 1 4.00 60.00 150.00
7650 3375 6975 4275 7650 5625
0.000 1.000 0.000

the script gives some tikz command requesting an error

Package pgf Error: Arrow end type ``triangle 45'' unknown.

So, of course, I can edit now by hand several arrows and so, but I would like to have it more automatic... :(

4 Answers 4


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:


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


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


%%% Code generated by fig2tikz

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

%%% End of code

the following is generated:

enter image description here

  • Dear Mark: thank for the hint. Unfortunately, the script is not that perfect. It needs a lot of editing afterwards. But it is a start. Commented Feb 28, 2012 at 11:09
  • xfig can also save to SVG I think, in which case you can try opening the resultant SVG in Inkscape, which in turn can export to TikZ with the appropriate plugin. I have no idea if the output will be better or worse than fig2tikz, but it can still all be scripted.
    – qubyte
    Commented Feb 28, 2012 at 11:33
  • What kind of things need editing? It may be that there's just no natural mapping for certain things in .fig files. It may be a good idea to link to an xfig file that doesn't convert well.
    – qubyte
    Commented Feb 28, 2012 at 11:37
  • Dear Mark, I included some silly example. It seems that having won arrows is not supported... Commented Feb 28, 2012 at 12:58
  • 1
    I know that SX discourages "me too" comments, but I have to say that this deserves to be more widely known!
    – kcrisman
    Commented Oct 31, 2013 at 20:38

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
    fig2dev -L eps $i `basename $i .fig`.eps
    java -jar eps2pgf.jar `basename $i .fig`.eps `basename $i .fig`.pgf

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.

  • Are the LaTeX overlays preserved with these methods? If lucky they would be preserved in the EPS route but I'm not sure if they get mangled.
    – qubyte
    Commented Feb 28, 2012 at 15:49
  • @Mark S. Everitt I have no idea. I was under impression that the OP was asking only about separate Xfig pictures not overlays. Commented Feb 28, 2012 at 16:06
  • Overlays are a stressed point in the question. This is trawling back some years to when I used xfig as a student. I remember LaTeX making it in as simple text, and I guess that would be placed without changes into an EPS file upon conversion. If that is the case then the LaTeX snippets would survive and your suggestion could work perfectly. I just don't happen to have xfig installed or any old fig files to test it on!
    – qubyte
    Commented Feb 28, 2012 at 16:11

To avoid that pgf error, simply add the tikz arrows library:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .