## 4. Formatting SGML Documents

Let's say you have the SGML document `foo.sgml`, which you want to format. Here is a general overview of formatting the document for different output. For a complete list of options, consult the man pages.

## 4.1 Checking SGML Syntax

If you just want to capture your errors from the SGML conversion, use the `sgmlcheck` script. For example.

> `

>     % sgmlcheck foo.sgml

> `

If you see no output from an sgmlcheck run other than the ``Processing...'' message, that's good. It means there were no errors.

## 4.2 Creating Plain Text Output

If you want to produce plain text, use the command:

> `

>     % sgml2txt foo.sgml

> `

You can also create groff source for man pages, which can be formatted with `groff -man`. To do this, do the following:

> `

>     % sgml2txt --man foo.sgml

> `

## 4.3 Creating LaTeX, DVI or PostScript Output

To create a LaTeX documents from the SGML source file, simply run:

> `

>     % sgml2latex foo.sgml

> `

If you want to produce PostScript output (via `dvips`), use the `-p` option:

> `

>     % sgml2latex --output=ps foo.sgml

> `

Or you can produce a DVI file:

> `

>     % sgml2latex --output=dvi foo.sgml

> `

## 4.4 Creating HTML Output

If you want to produce HTML output, do this:

> `

>     % sgml2html --imagebuttons foo.sgml

> `

This will produce `foo.html`, as well as `foo-1.html`, `foo-2.html`, and so on -- one file for each section of the document. Run your WWW browser on `foo.html`, which is the top level file. You must make sure that all of the HTML files generated from your document are all installed in the directory, as they reference each other with local URLs.

The --imagebuttons option tells sgml2html to use graphic arrows as navigation buttons. The names of these icons are "next.gif", "prev.gif", and "toc.gif", and the SGML-tools system supplies appropriate GIFs in its library directory.

If you use `sgml2html` without the `-img` flag, HTML documents will by default have the English labels ``Previous'', ``Next'', and ``Table of Contents'' for navigation. If you specify one of the accepted language codes in a --language option, however, the labels will be given in that language.

## 4.5 Creating GNU Info Output

If you want to format your file for the GNU info browser, just run the following command:

> `

>     % sgml2info foo.sgml

> `

## 4.6 Creating LyX Output

For LyX output, use the the command:

> `

>     % sgml2lyx foo.sgml

> `

## 4.7 Creating RTF Output

If you want to produce RTF output, run the command:

> `

>     % sgml2rtf foo.sgml

> `

This will produce `foo.rtf`, as well as `foo-1.rtf`, `foo-2.rtf`, and so on---one file for each section of the document.