Landscape images

Sometimes an image is too wide to fit into a regular portrait page width. Rotating a figure 90 degrees and presenting it in landscape mode is one way to handle such figures. DocBook's schema does not have an attribute for figure or mediaobject to indicate rotation the way orient="land" is available for tables.

One solution is to create a processing instruction for use inside a figure element. The DocBook stylesheet does not define one, so you have to make up your own processing instruction and write a matching template to process it. For example:

<figure>
  <?landscapeFigure?><title>My figure title</title>
  ...
</figure>

Here is a customization that will rotate a figure that has such a processing instruction.

<xsl:template match="figure[processing-instruction('landscapeFigure')]">
  <fo:block-container reference-orientation="90">
    <xsl:apply-imports/>
  </fo:block-container>
</xsl:template>

This customization matches only figure elements that contain the processing instruction. It just wraps a fo:block-container element around the normal processing of figure that is achieved with the xsl:apply-imports statement. The block container has reference-orientation="90", which means the content of the container will be rotated 90 degrees counterclockwise. Depending on the behavior of your XSL-FO processor with block containers, you may need to add other properties to achieve proper formatting of the rotated figure.

This customization will also rotate the figure title along with the figure. That is because it uses xsl:apply-imports, which calls the original figure template that handles both the title and the image.