Question

I'm working with DockBook 4.5 and Apache FOP 1.1 on Ubuntu 13.04. The Docbook translation are provided by Ubuntu and FOP was downloaded directly from Apache.

First question: would someone please tell me how to ensure the title or caption of a image is aligned with the image? For example:

 Figure X: YYYYYY
 +---------------+
 |               |
 |     Image     |
 |               |
 +---------------+

I know I can align the imagedata with the following:

<figure id="figure-xxx">
<title>YYYYY</title>

  <mediaobject>
    <imageobject>
      <imagedata align="center" fileref="xxx.png" scale="75"/>
    </imageobject>
    <caption>XXX/caption>
  </mediaobject>
</figure>

However, align="center" produces something like:

 Figure X: YYYYYY
           +---------------+
           |               |
           |     Image     |
           |               |
           +---------------+

And align="right" makes it worse:

 Figure X: YYYYYY
                     +---------------+
                     |               |
                     |     Image     |
                     |               |
                     +---------------+

When I attempt to add the align tag to the figure, title, mediaobject, imageobject, or caption, I get an errors similar to:

element figure: validity error : No declaration for attribute align of element figure

and:

element mediaobject: validity error : No declaration for attribute align of element mediaobject

Perhaps I'm doing something wrong again. After trying to flow text around an image (Block Image Right and Flow Text Around It?) and align the caption to the image (this question), I'm left wondering if DocBook can work with images in real life.

So my second question: does anyone know if DocBook supports images in real life?

EDIT: for the answer to the second question, the problem is with Apache FOP and not DocBook.

Was it helpful?

Solution

I assume that "Docbook translation" means docbook-xsl (I don't think the exact version matters much here, but often it can be important).

You can work around the title alignment problem by customizing the formal.title.properties attribute-set. Add this to your customization layer:

<xsl:attribute-set name="formal.title.properties">
 <xsl:attribute name="text-align">
  <xsl:variable name ="align">
    <xsl:value-of select=".//imagedata/@align"/>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="self::figure and $align !=''">
     <xsl:value-of select="$align"/>
    </xsl:when>
   <xsl:otherwise>left</xsl:otherwise>
  </xsl:choose>
 </xsl:attribute>
</xsl:attribute-set>  

Meaning: if there is an align value on the imagedata element, use that value for the figure title, otherwise use "left".

See also http://www.sagehill.net/docbookxsl/TitleFontSizes.html#FormalTitleProperties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top