Categories
Research Tools

Getting Inkscape to play nicely with PSfrag

While browsing through some of the old TeXtip posts on Twitter, I was reminded of the possibility of using Inkscape to generate LaTeX-compatible illustrations. Given the vast amount of cruft that Illustrator includes in its EPS files, this sounded like it might be a good alternative.

However, Inkscape seems to be having some of the same problems as I was recently experiencing with Adobe Illustrator. Long story short, the only way I could find to make Inkscape play nicely with PSfrag was reverting to version 0.46. (The most recent Inkscape release is version 0.48.)

This problem is related to the use of the Cairo package from the GTK+ Project to export EPS files. Rather than store strings directly, references are made to a structure of characters actually used in the file. This is done to reduce file size, and improve performance. However, this is a real problem for those of us that use PSfrag. Specifically, string “abc” is no longer identified in the EPS file as (abc)Tj, but rather <01020304>Tj . This makes it impossible for PSfrag to find a matching string. There is some indication that a newer release of Cairo will fix this problem, but it hasn’t yet worked its way into the public release.

While some nice LaTeX-rending features are being introduced into the more recent releases of Inkscape, the benefit of PSfrag was nicely expressed by commenter emw on a Inkspace forum:

The reason for using psfrag is a kind of “coding style”, because I use a lot of complex symbols/equations defined by \newcommand statements in the latex document. For a consistent layout, I’d highly prefer to reuse these commands via psfrag in the figures.

I heartily concur.

Categories
Research Tools

Getting Illustrator to play nicely with PSfrag

When creating diagrams for inclusion in a Beamer presentation, I used to use the drawing package in Open Office. Then I could use PSfrag to replace drawing text with text rendered in in \LaTeX. This made all the symbols in the presentation match symbols on the diagram. Alas, I am no longer able to make Open Office work with PSfrag. (My old trick of modifying the EPS “textmode” value in the OO configuration file no longer works.)

No problem, I thought. I’ll use Adobe Illustrator instead. However, I could only get this arrangement to work if the drawing text consisted of single letters. Not a huge problem, I suppose, as there are 52 possible identifiers just using upper and lower case letters in the English alphabet. However, it is sometimes a bit difficult to remember if x_3 is being represented by “p,” or “q,” or some other letter.

So here’s a solution to the problem, that I found on Giovanni Lanzani’s blog. When saving the EPS file in Illustrator, select “Illustrator 3 EPS” in the “version” pulldown. Don’t use “Illustrator CS3 EPS.” The newer versions write out the text one letter at a time, thus preventing the PSfrag routine from finding a matching string. Apparently the older EPS export routine doesn’t mangle the drawing text in this manner.