Department of Engineering

IT Services

Xfig: some hints

First Time Users

xfig is a drawing package that's ideal for producing diagrams that can be imported into LATEX and many other word processing packages. On CUED's Teaching System you'll find it in the Graphics section of the Applications menu. Or you can start it by typing its name.

First familiarise yourself with the layout. This document describes version 3.2.5, but other versions are similar. Down the left is a panel of command buttons. Put the pointer on the icons to see what they do. The boxes along the bottom change according to the command you're using. Along the top is a menubar. The File option is concerned with loading and saving. The Help menu leads to full documentation.


Top left, under the menu bar, is a description of the current mode. Initially it says READY. Select a mode or load a file. Top right in the Mouse Buttons box, is a description of what the 3 mouse buttons currently do.

Unlike some graphics editors, xfig makes you select the function, then choose the object. Try drawing some objects. Keep an eye on the top corners of the window to get feedback. You'll notice that the objects sometimes have little boxes (handles) at their extremities. These are what you need to click on when you need to choose an object or vertex. Try moving and rotating some objects.

If you want to change the color of an object, fill it in, add arrows to lines, etc, click the edit button then select the object. A dialog box will appear that lets you change many features. If you want to change the same feature(s) of many objects, use the Update command.

Short cuts

Many of the buttons along the top and the bottom of the windows produce dialog boxes when clicked on with the left mouse button. Often however, you don't need to use these dialog boxes because short cuts have been set up. To cycle through a range of possibilities (text size, for instance) one can often use the middle button on the bottom row of buttons. The menu items have keyboard shortcuts too, listed on the menus.


The xfig picture can consist of many see-through layers. Each object has a depth that shows which layer the object is in. This depth can be set before the object is created or, by using the edit facility, changed later. If objects at the same depth overlap, then which appears on top is undefined, and the screen version may not match the hardcopy. Depth 0 is nearest you. Default is depth 50. On the top right of the window are the controls that let you control which layers to hide or display.

Grouping and Alignment

It's often useful to group objects so that they can be scaled, moved or copied like a single object. Click on the GLUE button (just under the Editing modes title). Using the middle button, draw a box around the objects that you want to group, then click on the right mouse button to group them. You'll see a handle at each corner of the new group. Note that you can't edit the objects within this group individually unless you ungroup the objects first.

To align objects, it's best to group them first. Then click on the Align option. A dialog box will appear so that you can choose whether the tops of the objects should be aligned or whatever. Then just click on a handle of the group.


  • Smart Links - If you're drawing a block diagram and decide to move a box, xfig can move the links attached to the box too. This facility, called smart links, is controlled by a box that appears when move or copy is chosen. It works with polylines (not splines).
  • Measuring - the last 3 icons in the Editing panel let you measure Angles, Lengths, and Areas. dimensionline
  • Add TangentNormal -Adds a tangent or normal to a curve.
  • Dimension lines - if you hold down the shift key while drawing a line, the length of the line will also be drawn. dimensionline

Importing, exporting, screendumps and LATEX

  • Importing - Various types of files (in particular postscript) can be imported using the Picture Object button. Note that you cannot edit the imported picture. You can however draw over it if you put the picture in a lower layer. If you want to edit a postscript picture you can try converting it to the FIG format using the pstoedit program.
  • Exporting - In the File menu the Export item lets you produce output in many formats. You'll probably only ever use a few. Encapsulated postscript (eps) is needed if you want to put the diagram into a LATEX document. See the LaTeX Maths and Graphics document for details.
    Note that if you export as EPS and try to print out the file, you're likely to get an empty page. Postscript (ps) files will print out, but you may as well use the Print shortcut instead and not produce a file at all.
    PNG files are useful for WWW documents.
  • Cut and Paste - You can copy objects from one drawing into another. If in one xfig you copy an object using the right button, then in another xfig you can paste the object in using the Paste button along the top. To paste text from another application, use the Edit menu's Paste Text option.
  • Screendumps - The Picture Object dialog box has a Screen Capture option that lets you capture a window or an arbitrary rectangle.
  • Clip art - Many engineering-related pictures are available in xfig's library - click on the bookshelf icon.
  • LATEX - To add LATEX maths to a FIG drawing, use the psfrag package.