What finally worked for me was to draw nice diagrams in Dia, write the labels as TeX source, export it as a .fig file and then convert it to PDF. For the last step you need Linux or maybe Cygwin for Windows. When you have a PDF you can embed it into your LaTeX document whether you're using pdflatex or latex.
The short version:
- $> sudo apt-get install fig2ps
- Write TeX - math code in your diagram, surrounded by $-signs
- Don't use special characters like underscores in non-math labels (or escape them)
- Export diagram from Dia to .fig (Xfig format)
- $> fig2pdf yourDia.fig
- \includegraphics{yourDia.pdf}
Step 1 - Create diagram
As you would write formulas in TeX you have to set Dollar signs around your code. So to write the fraction 4/5 the label in Dia would be $\frac{4}{5}$
Finally your diagram will look something like this. Hopefully not as ugly if "snap to grid" worked better for you ;) You can see it won't be easy to set the label to the correct position as the rendered math text will (usually) be more compact.
Now export the diagram to a .fig file (Xfig format). The conversion is then done painlessly by the perl script fig2pdf (or fig2ps) which is a part of TeXmacs. I guess you can find this in the standard repositories of most Linux distros. For Windows Cygwin should probably work too, any feedback is welcome. In Ubuntu just apt-get the package fig2ps. There is another script which I didn't test with the same name for the same purpose from here.
The compilation, rendering, composition,.. (dont really care) is simply done by:
fig2pdf yourDia.fig

Be careful not to use special characters like underscores in your non-math labels or TeX is gonna mess things up. The fig2pdf script will hang during compilation. I guess you could for example escape underscores and backslashes as \_ and \\ but I didn't try that.
0 Kommentare:
Kommentar veröffentlichen