将标题或标题与图像对齐?

时间:2013-11-04 17:32:18

标签: xml image apache-fop docbook

我在Ubuntu 13.04上使用DockBook 4.5和Apache FOP 1.1。 Docbook翻译由Ubuntu提供,FOP直接从Apache下载。

第一个问题:有人请告诉我如何确保图像的标题或标题与图像对齐?例如:

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

我知道我可以将imagedata与以下内容对齐:

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

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

然而,align="center"产生的结果如下:

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

align="right"使情况变得更糟:

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

当我尝试将align标记添加到figuretitlemediaobjectimageobjectcaption时,我得到了类似于:

的错误
element figure: validity error : No declaration for attribute align of element figure

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

也许我又做错了。尝试在图像周围流动文本(Block Image Right and Flow Text Around It?)并将标题与图像对齐(这个问题)后,我想知道DocBook是否可以在现实生活中使用图像。

所以我的第二个问题:有没有人知道DocBook是否支持现实生活中的图像?

编辑:对于第二个问题的答案,问题在于Apache FOP而不是DocBook。

1 个答案:

答案 0 :(得分:4)

我认为“Docbook翻译”意味着docbook-xsl(我不认为确切的版本在这里很重要,但通常它很重要)。

您可以通过自定义formal.title.properties属性集来解决标题对齐问题。将其添加到您的自定义层:

<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>  

含义:如果align元素上有imagedata值,请将该值用于图标题,否则请使用“left”。

另见http://www.sagehill.net/docbookxsl/TitleFontSizes.html#FormalTitleProperties

相关问题