The Structure of the Document
Author: Luc Maranget

## B.2 The Structure of the Document

Document structure is a bit simplified with respect to LATEX, since documents consist of only two parts. The preamble starts as soon as HEVEA starts to operate and ends with the `\begin{document}` construct. Then, any input occurring before `\end{document}` is translated to html. However, the preamble is processed and the preamble comprises the content of the files given as command-line arguments to HEVEA, see section C.1.1.1). As a consequence, command and environment definitions that occur before `\begin{document}` are performed. and they remain valid during all the processing.

In particular one can define a header and a footer, by using the `\htmlhead` and `\htmlfoot` commands in the preamble. Those commands register their argument as the header and the footer of the final html document. The header appears first while the footer appears last in (visible) html output. This is mostly useful when HEVEA output is later cut into pieces by HACHA, since both header and footer are replicated at the start and end of any file generated by HACHA. For instance, to append a copyright notice at the end of all the html pages, it suffices to invoke the `\htmlfoot` command as follows in the document preamble:

    \htmlfoot{\copyright to me}

The `\htmlhead` command cannot be used for changing anything outside of the html document body, there are specific commands for doing this. Those command must be used in the document preamble. One can change HEVEA default (empty) attribute of the opening `<body ...>` tag by redefining `\@bodyargs`. For instance, you get black text on a white background, when the following declaration occurs before `\begin{document}`:

    \renewcommand{\@bodyargs}{style="color:black;background:white"}

Since version 1.08, a recommended alternative is to use style sheets:

    \newstyle{body}{color:black; background:white;}

One can also change the default (empty) attribute of the opening `<html ...>` tag by redefining `\@htmlargs`. For instance you can set the language attribute of the whole document by issuing the following redefinition in the document preamble:

    \renewcommand{\@htmlargs}{lang=en}

Similarly, some elements can be inserted into the output file `head` element by redefining the `\@meta` command (Such elements typically are `meta`, `link`, etc.). As such text is pure html, it should be included in a `rawhtml` environment. For instance, you can specify author information as follows:

    \let\oldmeta=\@meta
    \renewcommand{\@meta}{%
    \oldmeta
    \begin{rawhtml}
    <meta name="Author" content="Luc Maranget">
    \end{rawhtml}}

Note how `\@meta` is first bound to `\oldmeta` before being redefined and how `\oldmeta` is invoked in the new definition of `\@meta`. Namely, simply overriding the old definition of `\@meta` would imply not outputting default meta-information.

The `\@charset` command holds the value of the (html) document character set. By default, this value is US-ASCII. In previous versions of HEVEA, one could change the value of the document character set by simply redefining `\@charset`. Then, it was users responsability to provide a (LATEX) document in the correspounding encoding. This is no longer so, and users should not redefine `\@charset` directly. Please, see Section 8.6 for details.