4.6. Inserting Pictures

It is necessary to insert pictures for all media the document will be published for.

If you use the TeX format you'll need the images as a PostScript file. For online publishing you can use any kind of common image file, such as JPG, GIF or PNG.

The easiest way to insert pictures is to use the fileref attribute. Usually pictures are generated in JPG and in PostScript (PS or EPS).

Example 4-5. Inserting a picture


<figure>
   <title>Picture's Title</title>
   <graphic fileref="images/file"></graphic>
</figure>

Replacing <figure> by <informalfigure> eliminates the need to insert a title for the picture.

There's still the float attribute on which the value 0 indicates that the picture should be placed exactly where the tag appears. The value 1 allows the picture to be moved to a more convenient location (this location can be described on the style sheet used or even can be controlled by the application being used).

4.6.1. Alternative Methods

The first alternative to Example 4-5 is to eliminate the <figure> or <informalfigure> elements.

Another interesting alternative when you have decided to publish the text on media where pictures are not accepted, is the use of a wrapper, <imageobject>.

Example 4-6. Using <imageobject>


<figure>
   <title>Title</title>
   <mediaobject>
      <imageobject>
         <imagedata fileref="images/file.eps" format="eps">
      </imageobject>
      <imageobject>
         <imagedata fileref="images/file.jpg" format="jpg">
      </imageobject>
      <textobject>
         <phrase>Here there's an image of this example</phrase>
      </textobject>
      <caption><para>Image Description. Optional. </para></caption>
   </mediaobject>
</figure>

Files using the following formats are available BMP, CGM-BINARY, CGM-CHAR, CGM-CLEAR, DITROFF, DVI, EPS, EQN, FAX, GIF, GIF87A, GIF89A, IGES, JPEG, JPG, LINESPECIFIC, PCX, PIC, PS, SGML, TBL, TEX, TIFF, WMF, WPG.

This method presents an advantage: a better control of the application. The elements <imageobject> are consecutively tested until one of them is accepted. If the output format does not support images the <textobject> element will be used. However, the biggest advantage in usage of the format Example 4-6 is that in DocBook 5.0, the <graphic> element will cease to exist.

As a disadvantage, there is the need for more than one representation code of the same information. It is up to the author to decide which method to implement illustrations and pictures on the document, but for compatibility with future versions I recommend the use of this method for pictures and graphics.