Features to format graphics (figures, equations)

Display graphics for graphics

The stylesheet p12-graphics.xsl has all features and instructions to set up text and graphics styles for formal objects and informal objects in PDF. Formal objects have a title that appears in a table of contents and include <figure>, <example> and <equation> elements. Tables are also formal objects and are outlined in the section titled Tables. Informal objects do not have a title. The features for formal and informal objects that can be set in the stylesheet are:
The <mediaobject> element contains all markup for images in XML files. It has several elements nested inside it to represent:

The following diagram shows how elements are nested inside the <mediaobject> element.

Diagram of boxes that show how XML markup is nested for graphics. From the outermost element, the nested markup is mediaobject, textobject with phrase nested inside it for alternate text, imageobject, imagedata.
Note: You do not need to create three different versions for each image—you can create one image for all three ebook formats if that is suitable for output. In that case, do not add a role attribute to <imageobject>. The diagram only shows how to structure the XML markup if you needed different image formats and sizes for each ebook format.

XML markup to edit

Background colours with processing instructions. To add a background colour to specific formal objects (<figure>, <example>, <equation>), add processing instructions within XML markup. Put the processing instruction immediately after the opening tag of the formal object. There are options for different ebook formats:
  • for PDF—follow the example <?dbfo background-color="#e0e0e0"?> (change the colour value)
  • for EPUB and web pages—follow the example <?dbhtml background-color="#e0e0e0"?> (change the colour value).
Change the abbreviation for the ebook format. The stylesheet feature at p12-5 is an abbreviation or name that selects a specific image in each <imageobject> element only for output to PDF. You specify the name in a role attribute. For example:
<imageobject role="pdf">
The image that is contained inside this particular <imageobject> element (which is marked up using <imagedata>) will appear only in PDF output. The name that you specify in the stylesheet must match the abbreviation you use in XML files. You can change the name to any text, such as "print", but you need to use the same name in both the stylesheet and XML files.

Stylesheet settings to edit

The relevant Stylesheet Guide page to set up text formats for PDF is PDF-graphics.svg.