سؤال

Is there in Docbook something similar to Subfig from LaTeX?

I want to put two images in a figure, side by side - how is this done in Docbook?

هل كانت مفيدة؟

المحلول

You can have two (or more) images inside single figure.

<figure><title>The Pythagorean Theorem Illustrated</title>
<mediaobject>
  <imageobject>
    <imagedata fileref="figures/pythag.png"/>
  </imageobject>
  <textobject><phrase>An illustration of the Pythagorean Theorem</phrase></textobject>
</mediaobject>
<mediaobject>
  <imageobject>
    <imagedata fileref="figures/pythag2.png"/>
  </imageobject>
  <textobject><phrase>the second</phrase></textobject>
</mediaobject>
</figure>

But according to http://docbook.org/tdg/en/html/figure.html DocBook standard does not specify how these elements are to be presented with respect to one another. In other words, you have to develop your representation on your own.

If you'd have XSLT for converting DocBook to HTML (like I do), you could add a CSS rule for images inside figure block to float.

نصائح أخرى

You might be able to get around your limitation by using two inline mediaobjects sized appropriately.

<inlinemediaobject>
  <imageobject><imagedata fileref='image1' /></imageobject>
</inlinemediaobject>
<inlinemediaobject>
  <imageobject><imagedata fileref='image2' /></imageobject>
</inlinemediaobject>

This works marginally well with many stylesheets, thought the end result will depend on your publisher. I never thought this was very "good" xml though...

Here is the way I did (after a lot of tries....) - I am using this to generate a pdf (using publican to generate the pdf). I will need to check if will work with html....

<figure id="fig09">
    <title>.....</title>
    <inlinemediaobject>
        <imageobject>
            <imagedata align="left" fileref="images/waveformSingle.png" scale="30"/>
        </imageobject>
    </inlinemediaobject>
    <inlinemediaobject>
        <imageobject>
            <imagedata align="right" fileref="images/waveformAll.png" scale="30"/>
        </imageobject>
        <textobject>
            <phrase>.....</phrase>
        </textobject>
    </inlinemediaobject>
</figure>

DocBook 5.2 is bringing the subfigure feature from LaTeX using formalgroup (available from b05). akond's example would look like this (and work as expected, when the tooling is updated):

<formalgroup>
  <title>The Pythagorean Theorem Illustrated</title>
  <figure>
    <title>An illustration of the Pythagorean Theorem</title>
    <mediaobject>
      <imageobject>
        <imagedata fileref="figures/pythag.png"/>
      </imageobject>
    </mediaobject>
  </figure>
  <figure>
    <title>The second illustration of the Pythagorean Theorem</title>
    <mediaobject>
      <imageobject>
        <imagedata fileref="figures/pythag2.png"/>
      </imageobject>
    </mediaobject>
  </figure>
</formalgroup>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top