Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

Landscape
Center
Metric
A4
52.00
Single
-2
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... :(

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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

share|improve this answer
    
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. –  Stefan Waldmann Feb 28 '12 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 Feb 28 '12 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 Feb 28 '12 at 11:37
    
Dear Mark, I included some silly example. It seems that having won arrows is not supported... –  Stefan Waldmann Feb 28 '12 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 Oct 31 '13 at 20:38

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.

share|improve this answer
    
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 Feb 28 '12 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. –  Predrag Punosevac Feb 28 '12 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 Feb 28 '12 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.