paper on using Latex to annotate Xfig figures
While getting familiar with the new version of Lyx, I decided to go ahead and write up several of the ways to annotate included figures with Latex fonts (including math mode fonts). The instructions mostly deal with figures made using the Xfig program. Here is the compressed Postscript of the paper, http://www.datafilter.com/software/figuresInXfig.ps.gz and here is the tarred, gzipped source directory containing the Lyx file and the example Xfig files. http://www.datafilter.com/software/howToUseLatexMathWithXfig.tar.gz (The table of contents is not currently printing on my system; I'll put up a fixed compressed Postscript file if I get it working.) I hope someone will find this useful. Comments are welcome, but please CC me if you reply to the list since I read the list from the archives. Allen Barker
xfig converter rotates image
I recently updated to lyx-1.5.5 from lyx-1.5.3 at the same time time that I updated my Fedora from core 5 to fc8. I am including xfig images as graphics. Before, the converter would automatically take care of the conversion to EPS, so that psfrag worked on the resulting image (which I use to put equations in the figures). Now, however, there are two problems. First, the automatic conversion of the xfig graphic is rotated by 90 degrees from its usual orientation. Second, the conversion is not recognized by psfrag and so the text strings are not replaced properly. If I export directly to EPS in xfig and include that graphic then everything works correctly again. I would prefer not to have to do that for all of the images, though. Any ideas what is going wrong here? BTW, I think LyX is a wonderful program.
Re: xfig converter rotates image
Allen L. Barker wrote: I recently updated to lyx-1.5.5 from lyx-1.5.3 at the same time time that I updated my Fedora from core 5 to fc8. I am including xfig images as graphics. Before, the converter would automatically take care of the conversion to EPS, so that psfrag worked on the resulting image (which I use to put equations in the figures). Now, however, there are two problems. First, the automatic conversion of the xfig graphic is rotated by 90 degrees from its usual orientation. Second, the conversion is not recognized by psfrag and so the text strings are not replaced properly. If I export directly to EPS in xfig and include that graphic then everything works correctly again. I would prefer not to have to do that for all of the images, though. Any ideas what is going wrong here? BTW, I think LyX is a wonderful program. I have apparently solved the problem by updating all the fc8 software to the latest versions and then deleting my .lyx directory and letting lyx re-create it (for both 1.5.3 and 1.5.5). I still can't determine exactly where the problem was arising from, but it apparently involved the .lyx directory as well as some other factors. FYI, just in case someone else comes across a similar thing.
Re: Xfig and LyX
> I have often used fig2ps (from sourceforge) to transform .fig files > to .eps and then include the resulting eps file in LyX. (I don't > remember what started me doing this; there was a problem of > complexity in my figure a few years ago and this provided the > solution.) > > It is possible to force specialtext from hte fig2ps command line. I checked out fig2ps and it is a neat program. I have been playing around with the converters in LyX, but I still am not completely clear on all the details of how they are operating. It seems like you could define a converter to use the fig2ps program automatically, without having to do it by hand. Even more interesting, it seems like you could use a fig2ps type of program as a converter to get a preview with the actual math symbols, rather than something with the usual $x_2$ types of strings... This type of thing, if it works, should work both with a graphics include as well as with an external file include... Any suggestions, critiques, or comments? It would be very nice to have a preview which included the actual math, if that could be done easily. But maybe such a thing can already be done in a way I am not familiar with?
Xfig and LyX
> Could somebody kindly point me to an understandable explanation > of how to use xfig produced figures in LyX? > Help file Userguide tells me to check for detailed explanation > under ImbeddedObjects but there I canĀ“t find any detailed > explanation. Just FYI, here is my current preferred method, for the types of equation-heavy figures I tend to have. First, include the following in the preamble: \usepackage{color} \usepackage{graphics} \usepackage[scanall]{psfrag} Now in your actual .fig images you use special text replacement-tags (without setting the "special" flag on the xfig text). These tags are just placeholders which will then be replaced by the final text, defined from within LyX. The replacements are specified by strings like \psfrag{FOURIERTRANSFORM}{} The text FOURIERTRANSFORM is what you would include in your actual image. By skillfully choosing these labels the images can be reasonably comprehensible even without the conversions. Within LyX, the whole "\psfrag{FOURIERTRANSFORM}{" is a red TeX box, as is the final "}". But the part between them can be arbitrary, normal LyX text (within reason). In particular, it can include LyX math-boxes for equation-editing. This is extremely convenient when you have complicated formulas (and when you are no longer used to entering the LaTeX strings for everything). I wrote a simple tutorial on this stuff in 2001, but it no longer seems to be out on the web. It does need some updating, but many things are the same. BTW, the "psfrag" way to include arbitrary text like $x_2$ in images is to have the string \tex{$x_2$} in the original image. Anyway, the advantages of the general psfrag substitution method in LyX are that you can scale the text-size of any substitution from within LyX, and you can use the math-editor boxes rather than having to use the LaTeX math strings. Ideally, of course, we all want the best of all the worlds as things progress. It would be nice if all the methods were compatible. I'm still looking into and considering how the psfrag stuff could be compatible with the external-file pstex stuff. The external-file mechanism in LyX is actually rather general and customizable. In the future (however distant) it would be nice if we could use a LyX math-box to edit the equations in a previewed figure, and to have the results displayed in the final equation form
Re: Xfig and LyX
> Yes xifg previewing can already been done thanks to fig2dev which > is part of the xfig program. Just use the external material inset > (Inset->File->External Material) and choose XFig in the combo. In > the display tab, select 'preview'. I think you are missing my point. Yes, I agree with you that LyX can already preview the xfig images. But, can it preview the math text like $x_2$ in its final form? I have not found any way for doing that, and I was suggesting a possibility... I have tried the External Material type of inset, but it still displays $x_2$ as $x_2$.
Re: Xfig and LyX
> Yes, if you mark the text field as LateX in xfig the equation > will be latex compiled and previewed on LyX screen. At least > it works in 1.6, maybe there's a bug in 1.5... > > You need the instant-preview package and dvipng installed for > this to work. Are these packages installed by default in the normal LyX setups (such as on a recent Fedora Linux)? If not, how should one install the packages? Are there any other side-effects to the packages? From within xfig, do you need to both select the text field as special and select it to use the latex-font?