The translation of a LaTeX source file into HTML involves of loading tex4ht.sty and *.4ht style files, choosing the desirable options for the translation, compiling the source into dvi code with the native LaTeX engine, and postprocessing the outcome with the tex4ht and t4ht programs (see overview).
The htlatex command loads a script which takes on itself to invoke the different steps of the process, without user intervention. The command assumes the form
where the first set of options is for the tex4ht.sty and *.4ht style files, the second set is for the tex4ht postprocessor, the third for the t4ht postprocessor, and the last one is for the LaTeX compiler. For instance,
In addition, the command requests a break up of the output into separate web pages, in accordance to the two top sectioning levels of the document.
Moreover, it asks for a listing in the log file of the information available for the style files in use. That information, among other things, also introduces additional values available for the first list of options.
The fields of option1 should be separated by commas. An ‘info’ field requests a listing in the .log file of many of the the available values. If the list is not empty, it must start with the entry ‘html’, ‘xhtml’, or a name of a private configuration file.
The fields of option2 and options3 should be separated by spaces. The available values can be listed by executing the postprocessors tex4ht.c and t4ht.c, respectively, without arguments (or with wrong sets of arguments).
The first field of option2 should be empty or a subdirectory of ht-fonts (typically augmented with an exclamation mark ‘!’). A space should separate the first field from the second one, also when the first field is empty.
The underlying output formats of available htlatex-like commands are tailored into the commands through fields of option1. The names of these fields are defined in tex4ht.4ht and tex4ht.usr (see General Configuration Files). These values should be of little interest to most users.
Different variants of the htlatex command may be invoked by introducing the commands as arguments to a driver named mk4ht. When provided without arguments, the driver lists the commands it recognizes.
mk4ht mzlatex filename "html,3" | (htlatex filename "html,3,xhtml,mozilla" " -cmozhtf") |
mk4ht oolatex filename | (htlatex filename "xhtml,ooffice" "ooffice/! -cmozhtf" "-coo") |
Alternatively, a compilation ‘latex mkht-scripts.4ht’ produces different named scripts of similar functionality.
To request a Unicode representation of symbols, the first list of options should include the ‘uni-html4’ entry, and the second list should include the ‘-cunihtf’ entry preceded by space. For instance, ‘xhlatex filename "xhtml,uni-html4" " -cunihtf"’.
Unicode representations of symbols in UTF-8 encoding may be requested with the entry ‘-utf8’ added to the second list. For instance, ‘xhlatex filename "xhtml,charset=utf-8" " -cunihtf -utf8"’.
To request expanded usage of unicode values in iso-8859-1 output employ commands similar to
or introduce a similar charset path in tex4ht.env. Otherwise, non iso-8859-1 characters might obtain bitmap representations.
TeX4ht has different configurations for different modes of output. It is distributed with pre-tailored base configurations for translating LaTeX math into MathML, and extra configurations for adjusting the outcome to Mozilla, MathPlayer, and PMathML CSS. Only presentational MathML is supported.
For XHTML+MathML to be served both by Mozilla and MSIE+MathPlayer use the command line option ‘mathplayer’.
The mzlatex command is a short cut representation for the command ‘htlatex filename "xhtml,mozilla" " -cmozhtf" "-cvalidate"’. It take into account special needs of browsers. The xhmlatex command is a short cut representation for the command ‘htlatex filename "xhtml,mathml" " -cunihtf" "-cvalidate"’; it does not make any compromizes toward browsers.
It might be worthwhile to notice some of the more common sources of problems for MathML. The ‘mathml-’ options asks for a degraded MathML output that sidetracks some of the problems.
A translation for an OpenDocument format can be requested by the ‘\oolatex’ command. The command is a variant of htlatex in which the first list of options holds the entries ‘xhtml,ooffice’, the second list holds the entry ‘-cmozhtf’ preceded by a space, and the third list contains ‘-coo’ (htlatex filename "xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"). The output of a command ‘oolatex filename’ is a zipped file named with a ‘.odt’ extension.
The OpenDocument code employs MathML for formulas, and XSL-FO for formatting. It can be viewed by the OpenOffice word processor which, in turn, can export RTF and other MicroSoft-based formats (see also, Maarten Wisse, “Hacking TeX4ht for XML Output: The Road toward a TeX to Word Convertor”, MAPS 28 (2002), pp. 28-35).
A command of the form ‘htlatex filename "html,word" "symbol/!" "-cvalidate"’ asks for HTML output tuned toward MicroSoft Word. Such a format, however, relies on bitmaps for mathematical formulas.
The following commands may be used for requesting DocBook and TEI output.
dbmlatex: | htlatex filename "xhtml,docbook-mml" " -cunihtf" "-cdocbk" |
dblatex: | htlatex filename "xhtml,docbook" " -cunihtf" "-cdocbk" |
teimlatex: | htlatex filename "xhtml,tei-mml" " -cunihtf" "-cdocbk" |
teilatex: | htlatex filename "xhtml,tei" " -cunihtf" "-cdocbk" |
JavaHelp is an online documentation system for use by Java-based applications. Such documents can be produced from LaTeX files through commands similar to ‘jhlatex filename’ for JavaHelp version 2.0.
The above invocation stands for ‘htlatex filename "html,3.2,xml,javahelp,unicode" " -cmozhtf -u10" "-dfilename-doc/ -cjavahelp"’. The ‘-u10’ asks for entity references in base 10—JavaHelp doesn’t seem to support hexadecimal representations. The -cjavahelp invokes the JavaHelp indexer to produce the search database at ‘jobname-doc/jobname-jhs’ with a command similar to ‘java -jar ${HOME}/jh2.0/javahelp/bin/jhindexer.jar -db jobname-doc/jobname-jhs jobname*.html’.
The Java program is to be distributed with the jobname-doc directory.
The leading entry, in the first list of options of the htlatex-like commands, can equal ‘html’ or ‘xhtml’. If this is not the case, the entry is assumed to be the name of a configuration file. The extension ‘cfg’ is assumed for names of configuration files that are listed without their extension.
A configuration file should take the following form for LaTeX files.
It is up to the user to decide the distribution of entries between the \Preamble and the htlatex-like commands.
For instance, a definition of the form \renewcommand\mycommand{...} within a configuration file provided for the following LaTeX source.
A htlatex-like script foolatex.bat can be obtained from the compilation under LaTeX of a file similar to the following one.
A call of the form
is then equivalent to a call of the following form.
Scripts obtained in such a manner can embed parameters within their bodies instead of expecting the parameters to be provided in command lines.
Details regarding the available options can be found by compiling under LaTeX a file of the following form.
The compilation requires the ProTex.sty and AlProTex.sty files available at http://www.cse.ohio-state.edu/~gurari/systems.html.
Given a LaTeX file
the ‘htlatex filename’ command produces a call ‘latex filename’ to LaTeX on an implicit file of the following form.
Similarly, the command ‘htlatex filename "options"’ produces a call to a ‘latex filename’ command on an implicit file of the following form.
From the perspective of TeX4ht, the htlatex-like commands, and the \usepackage, are indirect approaches for getting LaTeX files of the following form. Such files can be explicitly provided for compilations requested through the ‘ht latex filename’ command.
Commands similar to those offered for LaTeX are also offered for TeX (dbmtex, dbtex, ht, httex, mztex, ootex, t4ht, teimtex, teitex, tex4ht, xhmtex, xhtex) and TeXi (dbmtexi, dbtexi, httexi, mztexi, ootexi, teimtexi, teitexi, xhmtexi, xhtexi). In the case of TeX, the fragment of code ‘\csname tex4ht\endcsname’ should be introduced by the user into the source file, after the preamble of the file where the document definitions reside (example). In the case of TeXi, such a code fragment is introduced implicitly.
The private configuration files are similar to those of LaTeX, with the instruction ‘\begin{document}’ excluded.
For ConTeXt similar instructions apply with suffixes ‘context’ instead of ‘latex’, ‘tex’, or ‘texi’. For instance, ‘htcontext’ .
This utility is reported to produce fast high quality output with much smaller files than other convertors.
The outcome of the translations should be checked by validators for proper syntax. Typically, with the presence of validators, errors are easy to detect and correct, but they require human intervention.
TeX4ht doesn’t offer a built-in parser to verify the correctness of the outcome. However, external validator(s) can quite easily be integrated into the compilation process.
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 private configuration files to be loaded by htlatex-like commands.
On the other hand, it should be noted that hypertext markings should adhere to strict rules specified by different standards. Consequently, it is strongly advised to check the output obtained from the default configurations, before trying to tailor new ones.
Generated August 24, 2020 - tex4ht home page