[up]

Features of TeX4ht

* From LaTeX to HTML   * Low-Level Features   * Sectioning and Tables of Contents   * Tables   * Lists and Environments   * Pictures   * Mathematical Formulas   * Paragraphs   * Configuration Files   * Cascade Style Sheets (CSS)   * Xml   * HTML Voyager, Unicode, and MathML   * Fonts   * Configurable Hooks   * Literate Programs (with ProTeX) and Scripts   * TeX  

From LaTeX to HTML

The simplest way to translate a LaTeX file into HTML is by loading the base style file of TeX4ht into the source file, with a command of the form `\usepackage{tex4ht}', and activating the translation with a command of the form `ht latex filename'.
       \documentclass{article}
          \usepackage{tex4ht}
       \begin{document}
          ..................
       \end{document}

Variations to the default outcome may be requested through parameters of the \usepackage command. The package parameters invoke built-in options of TeX4ht.

       \documentclass{article}
          \usepackage[html,3.2]{tex4ht}
       \begin{document}
          ..................
       \end{document}

The `html' parameter requests HTML output; the `3.2' parameter asks for HTML version 3.2, instead of the default setting of the HTML transitional 4.0 version.

The first package parameter is distinguished in that it may refer either to `html' or to a user-provided configuration file; other values are ignored. An extension `cfg' is assumed, if the file name is provided without an extension.

       \documentclass{article}
          \usepackage[myconfig,html,3.2]{tex4ht}
       \begin{document}
          ..................
       \end{document}

The default environment loaded by the command `\usepackage{tex4ht}' implicitly assumes an empty configuration file, and a `html' parameter. The parameter `htm' may be used as an alternative to `html', for cases where the file names should satisfy the requirements of the DOS operating system.

Most applications might require the knowledge of just a few additional simple features of TeX4ht, if any. Before making any changes to the default configuration, you are strongly advised to check the output obtained just from the inclusion of the `\usepackage{tex4ht}' command in your source file.

The remainder of this document provides much more than that, with an eye directed toward users that want to customize their outcome. Therefore, the reader is encouraged to skim the information provided below for acquiring a general understanding of the system, leaving the tedious learning of the details to when the need arises.

To keep with the spirit of LaTeX and hypertext, in which style is assumed to be separated from content, the users are encouraged to avoid inserting TeX4ht code into their source files. Instead, they should place their modifications, to the default settings, within configuration files to be loaded by the \usepackage command.

STOP! THIS IS A WARNING! Please don't continue without reading the three preceding paragraphs.

Low-Level Features

The following are some of the more useful underlying commands of TeX4ht.

1\HCode{...}
2\HPage{anchor}content\EndHPage{}
3\Link[target-file arguments]{target-loc}{cur-loc}anchor\EndLink
4\ifHtml... \else... \fi

Sectioning and Tables of Contents

A non-leading package parameter `1', `2', `3', or `4', in \usepackage, asks for a tree-structured set of files, reflecting on the sectioning of the document to the specified depth. Sequential prev-next links within the hierarchy, instead of the default hierarchical ones, can be requested with the `next' parameter. The parameter `sections+' creates titles for the sectioning commands that link to the tables of contents.

Finer control is possible with the following commands.

1\CutAt{at-unit,until-unit-1,until-unit-2,...}
2\tableofcontents[unit-1,unit-2,...]
3\TocAt{at-unit,unit-1,unit-2,...,/until-unit-1,/until-unit-2,...}
4\ConfigureToc{unit} {before-mark} {before-title} {before-page-number} {at-end}
5\Configure{tableofcontents} {before-toc} {end-of-toc} {after-toc} {before-nonindented-par} {before-indented-par}
6\Configure{TocAt} {before-toc} {after-toc}
7\Configure{TocAt*} {before-toc} {after-toc}
8\Configure{unit} {top} {bottom} {before-title} {after-title}
9\Configure{CutAt} {unit} {before-button} {after-button}
10\Configure{+CutAt} {unit} {before-button} {after-button}
11\NewSection\unit {mark-for-toc}
12\Configure{crosslinks} {left-delimiter} {right-delimiter} {next} {prev} {prev-tail} {front} {tail} {up}

Tables

HTML 4.0 offers new opportunities for tables. The following "large example, illustrating most of the features" of tabular and array environments, taken from the LaTeX User's Guide, shows some of the current capabilities and limitations TeX4ht has in dealing with such tables.




GG&A Hoofed Stock








Price


year
high
low
Comments




1971
97-
245
Bad year for farmers in the west.




72
245-
245
Light trading due to a heavy winter.




73
245-
2001
No gnus was very good gnus this year.




       \begin{tabular}{|r||r@{--}l|p{1.25in}|}
       \hline
       \multicolumn{4}{|c|}{GG\&A Hoofed Stock}
         \\ \hline\hline
       & \multicolumn{2}{c|}{Price}& \\ \cline{2-3}
       \multicolumn{1}{|c||}{year}
       & \multicolumn{1}{l@{\,\vline\,}}{high}
       &low & \multicolumn{1}{c|}{Comments}
         \\ \hline
       1971 & 97 & 245 & Bad year for
                  farmers in the west.   \\ \hline
         72 & 245 & 245 & Light trading due to a
                         heavy winter.   \\ \hline
         73 & 245 & 2001 & No gnus was very
                         good gnus this year. \\ \hline
       \end{tabular}

Tables with \multicolum entries need a few LaTeX compilations to stabilize.

1\Configure{table} {before-tbl} {after-tbl} {before-row} {after-row} {before-entry} {after-entry}

Lists and Environments

The appearances of lists and \begin-\end environments are configured with the following commands.

1\ConfigureList{list-name} {before-list} {after-list} {before-label} {after-label}
2\ConfigureEnv{environment-name} {before-environment} {after-environment} {before-list} {after-list}

Pictures

The next command imports external pictures, and the two commands that follow request pictorial representations for local content. The attributes, and the replacement parameters with their enclosing rectangular brackets, are optional.

1\Picture[replacement-for-textual-browser]{file-name attributes}
2\Picture+[replacement-for-text-browsers]{file-name attributes}content\EndPicture
3\Picture*[replacement-for-text-browsers]{file-name attributes}content\EndPicture

Mathematical Formulas

In the default setting, the math environments `\(...\)', and the display math environments `\[...\]', request pictorial representations for their content. On the other hand, the math environments `$...$', and the display math environments `$$...$$', ask for no special treatment. Simple features like mathematical symbols, subscripts, and superscripts, are translated into html, and more complex entities like roots and fractions are translated into pictures (example).

1\Configure{[]} {before$$at-start} {at-end$$after}, \Configure{()}{before$at-start}{at-end$after}
\Configure{$$}{before}{after}{at-start}
\Configure{$}{before}{after}{at-start}
2\Configure{SUB}{before}{after}
\Configure{SUP}{before}{after}
\Configure{SUBSUP}{before}{between}{after}
3no_, no^
4Package parameter `math'

Paragraphs

The insertions of code at paragraph breaks are controlled by the following commands.

1\Configure{HtmlPar} {noindent-P} {indent-P} {from-noindent-P} {from-indent-P}
2\IgnorePar
3\ShowPar
4\NoIndent
5\Indent

Configuration Files

The \usepackage{tex4ht} implicitly assumes a configuration file of the following form.

\Preamble{html}\begin{document}\EndPreamble

Similarly, a command of the form `\usepackage[html,option,option,...]{tex4ht}' implicitly assumes a file of the following form.

\Preamble{html,option,option,...}\begin{document}\EndPreamble

On the other hand, a command of the form `\usepackage[file,options]{tex4ht}' assumes a configuration file obeying the following format (example). The extension `cfg' is assumed for names of configuration files that are listed without their extension.

...early definitions...
\Preamble{options}
...definitions...
\begin{document}
...insertions into the header of the html file...
\EndPreamble

It is up to the user to decide the distribution of parameters between the \Preamble and the \usepackage commands.

One can avoid using configuration files, by including their implicit and explicit content within the source files. In such a case, the `\begin{document}' of the source file should be replaced with a code segment of the following format (example).

\input tex4ht.sty
...early definitions...
\Preamble{options}
...definitions...
\begin{document}
...insertions into the header of the html file...
\EndPeamble

Listed below are a few additional parameters available for LaTeX.

1pic-array, pic-eqnarray, pic-tabbing, pic-tabular
2pic-displaylines
3no-halign
4pictex
5jpg, png

Cascade Style Sheets (CSS)

Cascade style sheets define presentations to the content of hypertext pages, in a manner similar to the way that `.sty' files define the presentations to the content of source LaTeX files. TeX4ht produces a CSS file for each document that is translated to HTML transitional 4.0 code. The following are related commands.

1\Css{content}
2\Css content\EndCss
3\CssFile[list-of-css-files]content\EndCssFile

Xml

XML (eXtensible Markup Language) is in a sense a meta language for customizing markup languages for arbitrary applications. The following features can become handy for tailoring XML markups in LaTeX documents.

1Package parameter `0.0'
2Parameter `hooks'
3Option `hooks+'
4Package parameter `edit'
\Tg<...>
\Tg</...>
\Tg<.../>
5\Configure{edit} {before} {after}
\Configure{ hooks} {before} {after} {}{}
6\Configure<...>{before}{after}
\Configure</...>{before}{after}
\Configure<.../>{before}{after}
7 \Configure<...>-{replacement}
\Configure</...>-{replacement}
\Configure<.../>-{replacement}
8 Package parameter `edit+'

This parameter is a generalization of the `edit' parameter, which introduces configuration information into the log file.

9Package parameter `verify'
\Verify...\EndVerify
10Package parameter `verify+'

HTML Voyager, Unicode, and MathML

1Package parameter `voyager'
2\Hinclude[*]{unicode.4ht}
\Hinclude[*]{mathml.4ht}
3-i/.../ht-fonts/unicode/iso88591/

Fonts

TeX4ht has an elaborated machinery for handling fonts, through special virtual hypertext fonts stored in `.htf' files. Instead of providing a design for each symbol, as is the case in standard fonts, the virtual fonts provide a content for each symbol. The following commands offer some control, from within the source LaTeX documents, over the content provided to the symbols.

1\NoFonts
2\EndNoFonts
3\Configure{htf} {class} {delimiter} {template-1} {template-2} {template-3} {template-4} {template-5} {template-6} {template-7}
4\Configure{htf-sty} {class/font} {CSS-instructions}

The htf fonts might request pictorial representations for symbols. In such cases, the sizes of the pictures depend on the sizes of the TeX fonts in use. Size changes through the \magnification command should be made before loading the tex4ht.sty package.

The design of a virtual hypertext font might take some labor, but it does not require too much sophistication.

Configurable Hooks

Much of the look and feel of TeX4ht is achieved through configurable hooks which are defined with the following commands.

1\NewConfigure{name}[i]{body}
2\Configure{name}{parameter-1}...{parameter-i}

Literate Programs (with ProTeX) and Scripts

Literate programming is a discipline that promotes the writing of programs the way one explains them to human beings. ProTeX is a literate programming system fully implemented in terms of TeX, and it is compatible with LaTeX and other TeX-base systems. TeX4ht, and ProTeX itself, are examples of applications written in ProTeX.

1\input ProTex.sty
\AlProTex{extension,<<<>>>,list,title,escape-character}
2\<title\><<<
code fragment
>>>
3`<title`>
4\OutputCode\<...\>

Scripts produce the content in verbatim format with no decorations.

1\ScriptEnv{environment} {prefix} {postfix}
2\ScriptCommand{\command} {prefix} {postfix}
3\JavaScript...\EndJavaScript

TeX

Source TeX files are treated in a manner similar to the way LaTeX source files are treated, with the obvious restriction that only TeX commands are allowed. In particular, the \usepackage command is not valid in TeX, implying a requirement for configuration files to be explicitly integrated into the source TeX files.

The following are possible package parameters of \Preamble available for TeX only.
1plain-
2pic-eqalign

A \TableOfContents command, similar to the generalized command of \tableofcontents offered to LaTeX, is also provided for TeX.

[up]