6.2 Stylesheet theory6 Stylesheets6.1 Make your own stylesheet!

6.1 Make your own stylesheet!

So you are ready to roll your own stylesheet, to have the colors and pen widths you've always wanted? Here you go:

First, decide on a name for your stylesheet. In this section, let's pick the name "personal".

Open an Ipe document (or make a new one and save it in a file), then start up your favorite text editor and create the file personal.isy. The file must be in the the same folder as your Ipe document!

Enter the following contents into the file, and save it:

<ipestyle name="personal">
<color name="yellowgreen" value="0.604 0.804 0.196"/>
(The name attribute in the first line must match the filename, without the extension .isy.)

In Ipe, use Style sheets from the Edit menu to bring up the stylesheet dialog. Press the Add button, and select your file personal.isy. You'll see personal appear at the top of the list of stylesheets. Click Ok to confirm adding the stylesheet.

You will notice that a new color named "yellowgreen" is now available in the dropdown for stroke and fill color. Congratulations—you made your first stylesheet!

You can now add colors, pen widths, and sizes for symbols (markers), arrows, and the grids, by imitating the following examples:

<pen name="light" value="0.7"/>
<symbolsize name="giant" value="20"/>
<arrowsize name="small" value="6"/>
<gridsize name="10 pts" value="10"/>
<anglesize name="20 deg" value="20"/>
Each line contains the symbolic name, and an absolute numeric value in value. The name must start with a letter (grid size and angle size are exceptions).

To add a definition, update the file personal.isy in your text editor, then use Update style sheets from the Edit menu. This will cause Ipe to read the file again, and to replace the copy of the stylesheet inside your document with this newest version.

This way, you can quickly test out new definitions by editing the stylesheet in your text editor, and pressing Ctrl+Shift+U in Ipe to try out the new definitions.

You may wonder how to get your favorite colors right, so here is a little trick: draw a small box in Ipe, then press the absolute stroke color button (the top-left button in the Properties panel). It will allow you to select a color using a graphical user interface. Once you have found the right color, apply it to the box (by selecting <absolute> in the stroke color selector), then right-click on the box and select Edit as XML. A dialog will appear showing the current definition of the box in Ipe's internal XML format, like this:

<path stroke="0.561 0.349 0.008" pen="ultrafat">
64 816 m
64 800 l
80 800 l
80 816 l
You can now copy the color definition (in this case "0.561 0.349 0.008", a nice shade of brown) to your stylesheet.

You can find inspiration for more colors in the colors.isy stylesheet in Ipe's styles folder. It defines all the colors of the X11 color database—you could make a selection of these for your own use.

There is much more you can do with stylesheets. Have a look in the stylesheets that come with Ipe for some inspiration, or keep reading this chapter and the next. The ultimate reference is, of course, the description of the stylesheet file format.