Chapter 4. Tips and examples

Table of Contents
Program listings
Getting URLs and file names to line wrap
HTML stylesheets
The euro character
Please send me examples

This document is an example of a book, and a book generally contains chapters, which may contain sections. A paragraph of text can be put in a para tag. There are lots of examples of that in this book (see Appendix A).

When you want text to appear with its layout intact (spaces and newlines kept where they are), you can use the literallayout tag. Note that Tab characters are not expanded. If you also would like a different font for the listed text, you might want to use the programlisting tag.

The following sections are for example only, and may not actually mean anything.


This shows how to handle images for both print and web display; each format is included in one mediaobject so the stylesheet, when faced with a limited subset of formats for the current output media, can select the best fit.

There are some fairly subtle things going on to make this work properly with openjade. The problem is that we don't go straight from DocBook to PostScript, or from DocBook to PDF. Instead, we go from DocBook to TeX (actually JadeTeX), and then from TeX to either PostScript or PDF.

The complication comes from the fact that included images must be in encapsulated PostScript for PostScript output, and in PNG or PDF for PDF output. But openjade has no way of telling which output format we want! It just knows that we are converting to TeX, as an intermediate stage.

The way around this that I am using is to miss out the graphics file extension for EPS altogether, and to tweak the DSSSL stylesheet so that it passes that filename straight through, extension-less, to the TeX output.

So, for HTML output, the PNG format is preferred and simple.png is selected. For TeX output (either for PostScript or for PDF), the EPS format is preferred and so simple is used: note that it has no file extension. Then, for the second stage of processing, if I am converting to PostScript then the conversion tool will run tex, which will assume an extension of .eps. If, however, I am converting to PDF then the conversion tool will run pdfjadetex, which will assume an extension of .png.

I also have to make sure that the Makefile knows to have a file of the right format around in the current directory too, of course!