|
Theory Computing Environment Graphics Software |
|
|
Hendrik van HeesThis is a personal report on how one can use the free drawing tool xfig to prepare simple graphics for preparing scientific papers using LaTeX rather than a usual software documentation. As usual in the Unix (and of course in the Linux) world there is a nice man-page which one should read if there arise questions. This report is meant to be an introduction for the practical use. There are two possible ways for using xfig: The first is to draw a picture with it and export it to eps (encapsulated postscript) which can be put into the LaTeX document using the graphicx or epsfig package which is documented within the teTeX-DOC directory or to combined PS/LaTeX format, which is my favourite feature. It is also possible to export your drawings to many other formats. The other application of xfig is to work on graphics coming from other programs (for instance from Mathematica, gnuplot, xmgr, scilab etc.). For this purpose you may export your graphics to eps and use pstoedit to export to the xfig-format, work on your graphics and export it back to your favourite format for including it into your paper. Some programs also produce directly xfig-format as gnuplot or scilab. Preparing graphics with xfigTo start the program simply write
On the upper line you find the main commands. Bringing the mouse cursor over it you can read off from the right hand box which role the three mouse buttons play for the symbol. On the bar of the left hand side you can chose the drawing mode (for instance to draw a circle or a polygon, to copy or move linked objects, to link objects together to a compound object or to break it again. Clicking on such a mode symbol the arises a short text explaining its function. Also the meaning of the mouse buttons can be read off from the upper right box. On the lower line arise symbols belonging to the chosen drawing mode which is also self explaining. We shall give an example how to work with all that soon. Before you type in some text into your graphics you should be sure how you like in which format you like to export it in order to include it into your LaTeX-document. My preferred method is to use the combined PS/LaTeX-format. In this case just type in your text as you would do in LaTeX. This format has the advantage that you may type in complicated formula or whatever you like and LaTeX will set it in its usual nice form! The disadvantage is that xfig is not longer wysiwyg. It is important to chose a LaTeX font for for this and to set the special flag from normal to special. Take into account that all text is resized when you resize the graphics when exporting it. Your exported file has to be in the original size to include it in your document. If you use the eps-format for exporting it just use a postscript font and you may resize it when importing it in your LaTeX document in the usual way using the graphicx-package from LaTeX. An exampleTo explain how a graphics is prepared it is most simple to use an example. Suppose you like to draw the following diagram to explain how to solve the operator equations of motion in quantum mechanics known from any elementary text book.
Now let's look how to draw this simple figure with help of xfig. First of all it is customary to chose zoom scale 2 which means that you prepare your drawing magnified with a factor 2 compared to what is coming out when exporting it. Then you might like to have a grid for orientation (which finally will not be exported to your graphics): Just click at grid mode and chose your preferred one from the window. Now we want to draw the axes. For this purpose chose POLYLINE as the drawing mode. The Point Posn button on the lower task line shows you which grid is possible for setting the position of the mouse cursor. For very precise work you should chose Any from the window popping up when clicking on the button. Now use the left mouse button to fix the beginning point of the y-axis and mark the end point with the middle mouse button which finishes your drawing of the line. In order to get the same length for the x-axis just copy the y-axis and rotate it with an angle of 90 ° which operations can be chosen from the Drawing modes. To draw the arrows at the ends of the axes just chose the arrow type and click to the end points of your lines. Now it should be clear how to draw the diagonal and the triangle with help of the POLYLINE-mode. To fill the triangle with a pattern just click at Fill style and chose from the menu whatever you like. Now click at Update and then to one of the points of the POLYLINE building the triangle. Now draw the projections of the points of the triangle to the axes by using the dashed line style. You can always use the update command to change the style of the object in question. More save can be the Edit Drawing mode which allows to chose the style of a graphics object from a menu and to check the result before fixing it finally. Now the only thing we have to do is to type all the text you see. I have chosen the combined PS/LaTeX format for this task and thus we have to click at Text Font and chose Use LaTeX Fonts and then Default. Also take care of the text flag special which as be set to special. This makes sure that LaTeX will be used for type setting. Take into account that the text begins where the first character is located (provided you use left justified text) also this character may not appear in the final output (which is the case for instance if this character is a \$-sign for the LaTeX math mode). At the end our drawing looks as follows within the xfig-window:
To obtain this result within your LaTeX document just export it as combined PS/LaTeX (in older versions of xfig you have to export both parts separately while in newer ones both parts are exported with one export command). Put
Using pstoedit to convert to xfigIf you have a file in ps- or eps-format and like to modify it using xfig just use the command
Now you can load the fig-file into xfig and just modify it as any other graphics prepared with xfig from scratch. Hint: If you like to do this with Feynman diagrams drawn with help of Thorsten Ohl's feynmf-package (Don't let Thorsten hear that you use this trick because this might upset him a little). you have to chose a broader line width than the default because otherwise pstoedit cannot handle these lines correctly. Known problemsOn some older beta-versions of the newer version 3.2 of xfig there is a bug in the combined PS/LaTeX-export. This bug is fixed in the newer version. Use the version 3.2 beta patch level 0-beta 4 (Protocol 3.2) on our tppc11 or tppc13 Linux machines or the older version 3.1 on the AIX-cluster. On the AIX-cluster of the theory group there is a problem with the fill patterns when exporting the figure to both PS/LaTeX-format or eps. Warning! Keep in mind that you may convert a figure from xfig version 3.1 to version 3.2 but that the opposite way is impossible! |
||||||||||||||||||||