|  |  | 7 Style sheets

# 7 Style sheets

The symbolic attributes appearing in an Ipe document are translated to absolute values for rendering by a style sheet that is attached to the document. Documents can have multiple "cascaded" style sheets, the sheets form a stack, and symbols are looked up from top to bottom. At the bottom of any style sheet cascade is always the 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.

The style sheet dialog (in the Edit menu under Style sheets) allows you to inspect the cascade of style sheets associated with your document, to add and remove style sheets, and to change their order. You can also save individual style sheets. You can, for instance, save the standard style sheet and use this as a basis for making your own style sheets.

The style sheets of your document also determine the choices you have in the Ipe user interface in "symbolic" mode. If you feel that Ipe does not offer you enough choice of colors, line widths, etc., you are ready to make your own style sheet! As an example for defining a style sheet with new colors, here is a style sheet that defines all the colors of the X11 color database (you should probably make a selection of these for your own use, as this style sheet is rather unwieldy).

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

Ipe will complain if you try to delete a style sheet that will cause symbolic attributes to become undefined. The trick is to first add a style sheet that also defines (and overrides) these same attributes, and then to remove the old style sheet from the document.

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 with to use U.S. letter size paper instead, include this style sheet:

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

Style sheets can also contain templates, such as background patterns, or logos to be displayed on each page. These are named Ipe objects that can be reused in documents. If your document's style sheets define a template named Background, it will be displayed automatically on all pages. You can create and use templates using the template ipelet. Here is a (silly) example of a style sheet that defines a background template. This template is automatically added to all new pages:

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

Style sheets 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.

Here is a style sheet presentation.xml that can be used for presentations. It enlarges all standard sizes by a factor 3:

    <ipestyle name="presentation">
    <linewidth name="normal" value="1.2"/>
    <linewidth name="heavier" value="2.4"/>
    <linewidth name="fat" value="3.6"/>
    <linewidth name="ultrafat" value="6"/>
    <marksize name="normal" value="9"/>
    <marksize name="large" value="15"/>
    <marksize name="small" value="6"/>
    <marksize name="tiny" value="3.3"/>
    <arrowsize name="normal" value="21"/>
    <arrowsize name="large" value="30"/>
    <arrowsize name="small" value="15"/>
    <arrowsize name="tiny" value="9"/>
    <textstretch name="normal" value="3 3"/>
    <textstretch name="large" value="3 3"/>
    <textstretch name="Large" value="3 3"/>
    <textstretch name="LARGE" value="3 3"/>
    <textstretch name="huge" value="3 3"/>
    <textstretch name="Huge" value="3 3"/>
    <textstretch name="small" value="3 3"/>
    <textstretch name="footnote" value="3 3"/>
    <textstretch name="tiny" value="3 3"/>
    <preamble>
    \renewcommand\rmdefault{cmss}
    \newenvironment{ITEM}{\begin{itemize}\item}{\end{itemize}}
    </preamble>
    <margins tl="72 72" br="72 72"/>
    <shading type="axial" colora="1 0.9 0.5" colorb="1 0.8 0.75"
             coords="0 0 0 200" extend="0 1"/>
    </ipestyle>

Note the use of the `<textstretch>` element to magnify text. The text size you choose from the Ipe user interface ("large", for instance) is in fact used for two symbolic attributes, namely `textsize` (where large maps to `\large`) and `textstretch` (where it maps to no stretch in the standard style sheet). By setting the text stretch, you can magnify fonts.

Also note the `<margins>` element--it determines the boundaries of the "standard" text area. The Insert text box function (in the Edit menu) uses these margins.

The LaTeX-preamble defined in the `<preamble>` element redefines the standard font shape to `cmss` (Computer Modern Sans Serif). Many people find sans-serif fonts easier to read on a screen.

Finally, note the `<shading>` element. You can use this to define a shading that will be applied to every page in your PDF/Postscript output, before anything else is drawn on the page. The shading is invisible in the Ipe user interface, so use this it with care.

|  |  | 7 Style sheets