Creating Stylesheets

Stylesheets determine the fonts and sizes that are used when objects are displayed. They are designed somewhat like cascading style sheets. Creating a new stylesheet just involves creating a new object definition for the new stylesheet.

If you wanted to create a new stylesheet that just adds a class to the standard style sheet, the steps to do that would be (refer to the documentation on Creating an Object Module, Creating an Object Definition, and Adding Clauses to an Object Definition if you need more details):

  1. Create a new Object Module in either the current document or in a library.
  2. In that module, create the StyleSheets namespace and create an object for the stylesheet. In this example, we will use MyStylesheet.
  3. Make the type definition ClassNameStyle. At this point the new Object Module should contain:

  4. Create an object for the new class name. For this example, we will use MyClass. The definition can be in the same Object Module or in a different Object Module. The MyClass object should be typed as ClassName.
  5. Add a property (or properties) to MyClass if you want to have it appear in the list of styles at the top of a module in the document or in the list of styles that appear in the Rendering Editor. The property required is the StyleGroup property with either DocumentGroup or RenderingEditorGroup in the parameter. To add a property to an object definition, right-click the object definition and select Add Property from the context menu. After creating MyClass, build (press F6) the document. After the build, the MyClass object will show up in the autocomplete if you start typing "myclass".
  6. Add a clause for the new class. Notes: The parameter of the FontFamily object is just text. To put text in it, switch to Text mode (press Escape with the empty box highlighted) and type the name of a font. The name must be an exact match to one of the fonts. Note also that it may be easiest to start by copying and pasting a clause from an existing stylesheet.
  7. Add a clause that refers to the Standard stylesheet to handle other class names. A stylesheet can handle a just a few class names and refer to another stylesheet to handle all the other classes. This is done by putting a clause like:

    { c } => StandardStylesheet[c]

    as the last clause in the new style sheet function. At the end of this step the new Object Module should look something like:

You can now use this stylesheet in an existing notation or in a new notation. See the documentation on Creating a New Notation for details.

You can also add a style to an existing stylesheet