Previous Up Next

B.7  Mathematical Formulae

B.7.1  Math Mode Environment

The three ways to use math mode ($...$, \(...\) and \begin{math}...\end{math}) are supported. The three ways to use display math mode ($$...$$, \[...\] and \begin{displaymath}... \end{displaymath}) are also supported. Furthermore, \ensuremath behaves as expected.

The equation, eqnarray, eqnarray* environments are supported. Equation labeling and numbering is performed in the first two environments, using the equation counter. Additionally, numbering can be suppressed in one row of an eqnarray, using the \nonumber command.

Math mode is not as powerful in HEVEA as in LATEX. The limitations of math mode can often be surpassed by using math display mode. As a matter of fact, math mode is for in-text formulas. From the HTML point of view, this means that math mode does not close the current flow of text and that formulas in math mode must be rendered using text-level elements only. By contrast, displayed formulas can be rendered using block-level elements. This means that HEVEA have much more possibilities in display context than inside normal flow of text. In particular, stacking text elements one above the over is possible only in display context. For instance compare how HEVEA renders $\frac{1}{\sum_{i=1}^{\infty}$ as: 1/Σi=1 ii, and $$\frac{1}{\sum_{i=1}^{\infty}$$ as:
1
Σ
i=1
ii


B.7.2  Common Structures

HEVEA admits, subscript (_), superscripts (^) and fractions (\frac{numer}{denom}). The best effect is obtained in display mode, where HTML TABLE element is extensively used. By contrast, when not in display mode, HEVEA uses only SUB and SUP text-level elements to render superscrits and subscript, and the result may not be very satisfying.

However, simple subscripts and superscripts, such as x_i or x^2, are always rendered using the SUB and SUP text-level elements and their appearance should be correct even in in-text formulas.

When occurring outside math mode, characters _ and ^ act as ordinary characters and get echoed to the output. However, a warning is issued.

An attempt is made to render all ellipsis constructs (\ldots, \cdots, \vdots and \ddots). The effect may be strange for the latter two.

B.7.3  Square Root

The nth root command \sqrt is supported only for n=3,4, thanks to the existence of unicode entities for the same. For the others, we shift to fractional exponents, in which case, the \sqrt command is defined as follows:
\newcommand{\sqrt}[3][2]{\left(#2\right)^{1/#1}}
Then, the source fragment: $$\sqrt[5]{\frac{1}{n!}} + \sqrt[3]{\pi} + \sqrt{\pi}$$ gets rendered as follows:



1
n!



1
5



 
+
π
+
π


B.7.4  Fractions and labelled arrows

The amsmath command \frac works as in LATEX. \cfrac proccesses its optional argument and typesets material to the left or right accordingly. The LATEX fragment
$$1+\cfrac[r]{\sqrt[5]{right-align}}{1 + right-align}$$
would typeset in HEVEA as follows
1+
rightalign
1 + rightalign
The commands \xleftarrow and \xrightarrow also work well in display mode. However, the arguments are ignored when outside display mode, and an appropriate warning is issued.

Thus the fragment a \xrightarrow[2]{1} b \xleftarrow{3} c would appear as
a
 
 
b
 
  
c
in display mode, but as abc in simple math mode.

B.7.5  Unicode and mathematical symbols

The support for unicode symbols offered by modern browsers allows to translate almost all math symbols correctly. However, some of the unicode encodings are not supported by all browsres. They are usually replaced by the best approximations. Outputing such “advanced” characters is turned on by the command line option -moreentities. A new explicit command line option -symbols allows the user to revert to rendering using iso-latin1 and symbol fonts (and also disables unicode translation), that is reverts to previous behavior. Using the option -symbols is not recommended, as output is not rendered satisfactorily by more and more browsers.

Log-like functions and variable sized-symbols are recognized and their subscripts and superscripts are put where they should in display mode. Subscript and superscript placement can be changed using the \limits and \nolimits commands. Big delimiters are also handled.

B.7.6  Putting one thing above/below/inside

The commands \stackrel, \underline and \overline are recognized. They produce sensible output in display mode. In text mode, these macros call the \textstackrel, \textunderline and \textoverline macros. These macros perform the following default actions
\textstackrel
Performs ordinary superscripting.
\textunderline
Underlines its argument, using the U text-level element.
\textoverline
Overlines using style-sheets (used <SPAN> with a top border).
The command \boxed works well both in display and normal math mode. Input of the form \boxed{\frac{\pi}{2}} produces π/2 in normal math, and
π
2
in display-math mode. The commands \bigl,\bigr etc. are also rendered well. Some examples can be found here.

B.7.7  Math accents

Math accents (\hat, \tilde, etc.) are not handled by default. However, the distribution includes a mathaccents.hva file that provides definitions for almost all math accents commands, except \check and \breve.

Rendering is far from perfect, but should get better as unicode encodings for these begin to be supported by browsers.

More precisely, the accent is put (too far) above the symbol in display mode, and as an ordinary superscript in text mode.

For instance, given the formula \tilde{v} \cdot \vec{U}, we get “v~U” in text mode and
~
v
 
U
 
in display mode.

If such a rendering is considered too ugly, one should not load the mathaccents.hva file and write alternative definitions. For instance, the following custom definitions issue color changes:
\newcommand{\tilde}[1]{{\blue#1}}
\newcommand{\vec}[1]{{\red#1}}
With such definitions the previous example now appears as: we get “vU” in text mode and
vU
in display mode. Of course, such a trick probably requires looking closely at HTML output to check whether the document is still understandable or not. It may be better to stay with a poorly formatted document that remains closer to universally understood notations for mathematics.

B.7.8  Spacing

By contrast with LATEX, space in the input matters in math mode. One or more spaces are translated to one space. Furthermore, spaces after commands (such as \alpha) are echoed except for invisible commands (such as \tt). This allows users to control space in their formulas, output being near to what can be expected.

Explicit spacing commands (\,, \!, \: and \;) are recognized, the first two commands do nothing, while the others two output one space.

B.7.9  Changing Style

Letters are italicized inside math mode and this cannot be changed. The appearance of other symbols can be changed using LATEX 2є style changing commands (\mathbf, etc.). The commands \boldmath and \unboldmath are not recognized. Whether symbols belonging to the symbol font are affected by style changes or not is browser dependent.

The \cal declaration and the \mathcal command (that yield calligraphic letters in LATEX) exist. They yield red letters by default.

Observe that this does not corresponds directly to how LATEX manage style in math mode and that, in fact, style cannot really change in math mode.

Math style changing declarations \displaystyle and \textstyle do nothing when HEVEA is already in the requested mode, otherwise they issue a warning. This is so because HEVEA implements displayed maths as tables, which require to be both opened and closed and introduce line breaks in the output. As a consequence, warnings on \displaystyle are to be taken seriously.

The commands \scriptstyle and \scriptscriptstyle perform type size changes.


Previous Up Next