HEAD PREVIOUS

5  Mathematics

5.1  Equations

Equations are translated internally into HTML. TTH uses HTML tables for layout of built-up fractions in display equations. It also uses the HTML tag < font face="symbol" > to render Greek and large delimiters etc. Untranslatable TEX math tokens are inserted verbatim.
The internal approach to equation translation is a major area where TTH departs from the philosophy of LATEX2html and its derivatives. TTH  does not use any images to try to represent hard-to-translate constructs like equations. Instead it uses the native ability of HTML to the fullest in providing a semantically correct rendering of the equation. The aesthetic qualities obtained are in practice no worse on average than LATEX2html's inlined images, which are generally slightly misaligned and of uncertain scaling relative to the text. Some limitations in the HTML code are inevitable, of course, but one ends up with a compact representation that can be rendered directly by the browser without the visitor having to download any additional helper code (e.g. Java equation renderer).
The option [-i]   to TTH makes italic the default font within equations, and thus the style more TEX-like. The italic font appearance in browsers is not as satisfactory as TEX's math italic, so for many documents roman looks better.
Spacing   in equations is handled slightly differently by TTH than by TEX. The reason is that most browsers use fonts that will crowd the characters horizontally too close for comfort in many cases (for example: M||/2). Also, built-up HTML equations are more spread out vertically than in TEX. Therefore TTH equations look better if spaces are added between some characters. So TTH  does not remove spaces in the original TEX file between characters in equations. The author is thus able to control this detail of layout in the HTML without messing up their TEX file - since TEX will ignore any spaces inserted. Legacy TEX code that contains a lot of spurious whitespace (ignored by TEX) may, as a result, occasionally become too spread-out when translated.

5.2  In-line Equation Limitations

Some TEX capabilities are extremely difficult or impossible to translate into HTML, because of browser limitations, and are best avoided if possible. Arrays or matrices or built-up fractions in in-line equations cannot be properly supported because tables cannot be placed in-line in HTML. TTH output often will be strangely disjointed. As an option, TTH provides switch -t to convert inline equations that use built-up constructs into a sort of half display, half in-line equation. Each time a new in-line equation is encountered [$ ... $ or \( ... \)] that needs to be built up, an HTML table that starts a new line is begun, and the text then flows on afterwards. For example
1
2 + n

This option gives a slightly strange layout for simple equations but is a big improvement for some situations, e.g. in-line matrices.
Likewise most over- and under-accents, and indeed anything that requires specific placement on the page other than simple subscript or superscript and underline, cannot be rendered in-line in plain HTML, although TTH will render them well in displaystyle. These latter constructs are nevertheless commonly used in in-line TEX. By default TTH renders these constructs in a relatively intuitive way. For example $\hat{a}$ is rendered a. The result is rarely elegant but it is unambiguous.

5.3  Mathematics Layout Style Improvement using CSS

Some of the mathematics rendering limitations just mentioned can be overcome using Cascading Style Sheets. These are an extension of HTML that allows finer control over the layout. Most modern browsers support some fraction of the CSS specification, but historically its implementation has been slow and buggy. So it used to be awkward and dangerous to adopt CSS for authoring because of never knowing whether one was producing HTML that would simply be broken on a particular browser. Moreover using style sheets slows down the browser's rendering.
Vertical Compression   of the otherwise sometimes rather spread-out mathematics is implemented on TTH using a simple built-in style sheet to reduce unwanted vertical space. The implementation works around the different idiosyncrasies of the browsers' implementations as well as it can, and is designed to degrade gracefully in browsers without CSS support or with the support switched off. This compression can be controlled by the switch -y, which permits a numeric argument, e.g. -y1. Compression is on by default, which corresponds to the first bit of the -y switch value being 1 (in other words the value is odd). It may be switched off by using the switch -y with an even numeric argument (or none at all), e.g. -y2 or -y.
In-line over-accents   can be rendered explicitly using the relative positioning available in CSS2. The result is visually preferable to the the indicative base rendering. However, it does not fall-back gracefully, and the application of over accents to multiple-character groups produces a poorly aligned result. Nevertheless, since TTH version 3.87 it is used as default. It can be turned off using the -y switch with the second bit (2) zeroed in the numeric argument. For example -y1 or -y0 turns it off.

HEAD NEXT