Next / Previous / Contents / Shipman's homepage

13.3. Processing your math files for inclusion

Once you have written out your formula in LaTeX or TeX format, follow this procedure to prepare artwork for inclusion in DocBook. If you use a Makefile, you can automate this procedure; see Section 13.4, “Automating math display production with your Makefile.

  1. Translate the file to DVI format. For LaTeX, the command is:

    latex file.tex

    For TeX:

    tex file.tex

    For example, if your source file is eq14.tex, this will create a file named eq14.dvi.

  2. If there are any errors, fix them and recompile. Use xdvi or another DVI viewer to inspect the typeset output and fix any content or appearance problems.

  3. Convert the .dvi file to Encapsulated Postscript. To continue the example:

    dvips -E eq14.dvi -o eq14.eps

    The -E option forces dvips to produce EPS output, shrinking the bounding box to include only the marks on the page.

  4. Convert the EPS file to Encapsulated PDF. This command will build a file named eq14.pdf that can be included in DocBook PDF output:

    epstopdf eq14.eps

  5. Convert the Encapsulated PDF file to a grayscale image in PGM format. The pdftoppm utility does this conversion. Its -gray option uses anti-aliasing to produce an image that is considerably better-looking than a pure black and white image. The first argument is the input file. The second argument is the “base name”; each page of the input file is written to a file whose name is that base name with a suffix of the form -NNNNNN.pgm, where NNNNNN is the page number. In our case, there will be only one page.

    The pdftoppm program also accepts a resolution in dots per inch, but the default (-r 150) is reasonable.

    To continue the example, this would build file eq14-1.pgm:

    pdftoppm -gray eq14.pdf eq14

  6. Finally, convert the .pgm file to JPEG format using pnmtojpeg. In our example:

    pnmtojpeg eq14-1.pgm >eq14.jpg

  7. In your DocBook source file, encode the equation like this:

            <imageobject role='html'>
              <imagedata fileref='file.jpg'/>
            <imageobject role='fo'>
              <imagedata fileref='file.pdf'/>

    The informalequation element is preferable to the equation element, since it does not number the equation or give it a title.