7 PresentationsTop5 Snapping6 Stylesheets

6 Stylesheets

The symbolic attributes appearing in an Ipe document are translated to absolute values for rendering by a stylesheet that is attached to the document. Documents can have multiple "cascaded" stylesheets, the sheets form a stack, and symbols are looked up from top to bottom. At the bottom of any stylesheet cascade is always the minimal standard style sheet, which is built into Ipe.

When you create a new empty document, it automatically gets a copy of this standard style sheet (which does little more than define the "normal" attribute for each kind of attribute). In addition, Ipe inserts a predefined list of stylesheets. The list of these stylesheets can be customized using an ipelet, using Ipe's command line options, and an environment variable. By default, a new document gets the stylesheet basic that comes with Ipe.

The stylesheet dialog (in the Edit menu under Stylesheets) allows you to inspect the cascade of stylesheets associated with your document, to add and remove stylesheets, and to change their order. You can also save individual stylesheets.

The stylesheets of your document also determine the symbolic choices you have in the Ipe user interface. If you feel that Ipe does not offer you the right choice of colors, pen widths, etc., you are ready to make your own style sheet! Ipe's styles directory contains a few examples to look at. The colors.isy stylesheet defines all the colors of the X11 color database - you could make a selection of these for your own use.

When a stylesheet is "added" to an Ipe document, the contents of the stylesheet file is copied into the Ipe document. Subsequent modification of the stylesheet file has no effect on the Ipe document. The right way to modify your stylesheet is to either "add" it again, and then to delete the old copy from your stylesheet cascade (the one further down in the list), or to use the Update stylesheets function in the Edit menu. This function assumes that the stylesheet file is in the same directory as the document and that the filename coincides with the name of the stylesheet (plus the extension .isy).

Removing or replacing a stylesheet can cause some of the symbolic attributes in your document to become undefined. This is not a disaster—Ipe will simply use some default value for any undefined symbolic attribute. To allow you to diagnose the problem, Ipe will show a warning listing all undefined symbolic attributes.

The style sheet is also responsible for determining the paper and frame size. Ipe's default paper size is the ISO standard A4. If you wish to use letter size paper instead, include this style sheet:

   <ipestyle name="letterpaper">
     <layout paper="612 792" origin="0 0" frame="612 792"/>
   </ipestyle>

We discuss a few stylesheet topics below. Other stylesheet definitions that are (mostly) meant for PDF presentations are discussed in the next section.

Symbols.

Style sheets can also contain symbols, such as marks and arrows, background patterns, or logos. These are named Ipe objects that can be referenced by the document. If your document's stylesheets define a symbol named Background, it will be displayed automatically on all pages. You can create and use symbols using the Symbols ipelet. Here is a (silly) example of a style sheet that defines such a background:

<ipestyle name="background">
<symbol name="Background" xform="yes">
<text pos="10 10" stroke="black" size="LARGE">
Background text
</text>
</symbol>
</ipestyle>

Note the use of the xform attribute—it ensures that the background is embedded only once into PDF document. This can make a huge difference if your background is a complicated object.

Symbols can be parameterized with a stroke color, fill color, pen size, and symbol size. This means that the actual value of these attributes is only set when the symbol is used in the document (not in the symbol definition). The name of a parameterized symbol must end with a pair of parentheses containing some of the letters "s" (stroke), "f" (fill), "p" (pen), "x" (symbol size), in this order. The symbol definition can then use the special attribute values sym-stroke, sym-fill, and sym-pen. A resizable symbol is automatically magnified by the symbol size set in the symbol reference.

You can also use a stylesheet to define additional mark shapes, arrow shapes, or tiling patterns.

Latex preamble.

Stylesheets can also define a piece of LaTeX-preamble for your document. When your text objects are processed by LaTeX, the preamble used consists of the pieces on the style sheet cascade, from bottom to top, followed by the preamble set for the document itself.

Decorations.

A decoration is a symbol that can be used to decorate a group object. Its name must start with the string decoration/, and it should contain either a path object or a group of path objects.

Ipe resizes these path objects so that they fit nicely around the bounding box of the group object being decorated. For this to work correctly, the decoration object must be drawn such that it decorates the rectangle with corners at (100, 100) and (300, 200).

To make a decoration symbol, follow these steps:

For inspiration, have a look at the decoration symbols in the stylesheet decorations.isy that comes with Ipe.