\documentclass[reqno]{report} % utf8-encoded

%% tralics compilation needs testmath.ult
%% tralics testmath -noentnames -nostraightquotes -nozerowidthspace -mathvariant

\newif\ifTeXone \TeXonetrue
\newif\ifTeXtwo \TeXtwotrue
\newif\ifTeXthree \TeXthreetrue
\newif\ifTeXfour \TeXfourtrue
\newif\ifLatex \Latextrue
\newif\ifMml \Mmltrue
\newif\ifOther \Othertrue





%% cp testmath.html ../www/quadrat/testmath.xml
%%NO_BAD_MINUS; 
\makeatletter \let\@@not\not \makeatother % make a copy

\usepackage{amsmath,amscd,delarray,amsxtra,braket}
\usepackage{fancyvrb}
\usepackage{RR}



\newcommand\LTC[1]{\xbox{latexcode}{#1}}
\newcommand\XC[1]{\xbox{xmlcode}{#1}}
\newcommand\cmd[1]{\LTC{\textbackslash#1}}
\newcommand\argument[1]{\LTC{\{#1\}}}
\newcommand\elt[1]{\XC{<#1>}}
\newcommand\entity[1]{\XC{\&#1;}}

\newcommand\xmlcolor[1]{\xbox{xmlcolor}{#1}}
%\newcommand\verbatim@hook{}
\renewcommand\verbatimnumberfont[1]{\xbox{vbnumber}{#1}}
\newcommand\Tralics{\textit{Tralics}} 
\newcommand\htmlprefix[1]{\addattributestodocument{htmlprefix}{#1}}

\newcommand*\attpair[2]{\trait{#1}\,=\,`#2'}
\newcommand\trait[1]{\textsf{#1}}
\newcommand\filename[1]{\textsf{#1}}
\newcommand\xmltex{\textsf{xmltex}}
\let\none\mmlnone
\newcommand\ex[1]{\par\textbf{Exercise #1:}}

\newcommand\Apply[2]{\mathbox{apply}{\mathbox{#1}{}#2}}

\RRetitle{Producing MathML with Tralics}
\RRtitle{Produire du MathML avec Tralics}
\RRdate{May 2007}
\RRdater{29 November 2007}
\RRversion{2}
\RRauthor{Jos\'e Grimm}
\RRnote{The software and the documentation is available
at \url{http://www-sop.inria.fr/apics/tralics}}
\email{Jose.Grimm[at]sophia.inria.fr}
\RRabstract{The purpose of this paper is to show that it is possible to
  translate almost every mathematical formula from \LaTeX\ syntax to XML. 
  The document you are reading contains a great number of formulas extracted
  from   the \TeX book, the \LaTeX\ companion, the MathML recommendation, and 
  translated into XML by \Tralics; it is available in Pdf or HTML version.  

The HTML version was produced using a very simple style sheet; mathematics are
left unchanged, and you need a MathML-aware browser, like Firefox, or
adequate plugins, and a set of fonts for the symbols or operators. 
The Pdf version was obtained by use of \filename{xmltex} (a
package by D. Carlisle that makes \TeX\ an XML interpreter), and a great number
of modifications to the file \filename{mathml2.xmt} (that interprets elements in
the MathML namespace). All files needed to produce this document are part of
the \Tralics\ bundle (version 2.10 or more).

This document was compiled with the experimental version 2.10.8, in which examples
in section \ref{additional} should work fine. 
}

\RRresume{Le but de ce papier est de d\'emontrer qu'il est possible de
  traduire presque toutes les formules de math\'ematiques de la syntaxe
  \LaTeX\ vers le langage XML. Le document que vous lisez contient un grand
  nombre de formules extraites du \TeX book, du \LaTeX\ companion, de la
  recommandation MathML, et traduites en XML par le logiciel \Tralics. Il est
  disponible en  HTML et en Pdf.

La version HTML est obtenue en utilisant une feuille de style assez simple,
qui laisse les formules de math\'ematiques inchang\'ees; pour la lire, il
vous faut un navigateur ou un plugin qui sache interpr\'eter le MathML et les
fontes associ\'ees pour les symboles et les op\'erateurs.
 La version Pdf a \'et\'e obtenue gr\^ace au package
\filename{xmltex} de D. Carlisle (qui fait de \TeX\  un interpr\`ete XML),
et un grand nombre de modifications  dans le fichier  \filename{mathml2.xmt},
qui contient le code d'interpr\'etation des math\'ematiques. Tous les fichiers
n\'ecessaires pour obtenir ce document sont distribu\'es avec le package
\Tralics\ \`a partir de la  version 2.10.
}
\keyword{Tralics, XML, MathML, mathematics, LaTeX, HTML, Pdf}
\motcle{Tralics, XML, MathML, math\'ematiques, LaTeX, HTML, Pdf}
\RRNo{6181}
\URSophia
\RRtheme{\THNum}
\RRprojet{Apics}


\begin{document}
\makeRR

\def\mtext#1{\mathbox{mtext}{\mathcnothing{#1}}}
\def\BMS{\mathbox{mphantom}{~~\mathbox{mpadded}[width][0pt][height][20pt]{(}}}
\def\UnimplementedOperator#1{\mathbox{mstyle}[color][red]{\string#1}}
\def\not{\UnimplementedOperator\not}


\DefineVerbatimEnvironment{verbatim}{Verbatim}
{listparameters={\topsep0pt }, pre=pre,style=latex}
\chardef\HAT`\^
\chapter{Introduction}

The technical reports \cite{Tralics1} and \cite{Tralics2} describe
some features of the \Tralics\ software, a \LaTeX\ to XML translator,
and associated tools. In particular, we explain how the XML file 
can be converted
to HTML, or to Pdf (using the excellent work of D. Carlisle 
and S. Rahtz (\cite{Passive-tex}, \cite{CGR2000}, \cite{xmltex}).
One application is RalyX (Inria's Annual Activity Report), where all math
formulas are converted to images before inclusion in the HTML document.

Recently, the cedram (Centre de diffusion de revues acad\'emiques de
math\'ematiques, \href{http://www.cedram.org/}{http://www.cedram.org/}) 
has decided to convert the metadata of some collections (including the
Annales de l'institut Fourier) from \LaTeX\ to HTML, \cite{Bouche}. The
\Tralics\ software has been adapted for this purpose, the idea being the
following: there are nowadays some browsers with a high quality math
renderer, where native MathML formulas are more readable than images;
thus the web site presents each document in two versions, neither of which 
containing an image. By default you see something like 
$L^1(\mathbb{T})$, and the alternate version contains
\LTC{\$L\char`\^1(\textbackslash mathbb\{T\})\$}. This looks like the source
code, but non-trivial operations are performed, as explained below.

There is a torture file that comes with \Tralics; the purpose is to make sure
that no error occurs while compiling expressions like \cmd{cfrac12}, but it is
hard to check that the result is correctly translated. For this reason, we
decided to create a sample file containing, not only all examples of the
\LaTeX\ companion second edition \cite{companion2}, but also those of the
\TeX book \cite{texbook}, or the MathML recommendation \cite{mathml2},
 and to convert it to HTML. 
Translation is correct if the HTML page prints correctly. This file is
available on the Web, we hope that it will convince you to use the \Tralics\
software, and put your math documents on the Web. We have inserted comments
explaining why some constructions do not work, if you have a solution or
suggestions, please send mail to the author. Additional examples are welcome.



We also wanted to make sure that the RalyX still works: more than one hundred
teams use \Tralics\ once a year, asking sometimes silly questions, like: how to
add color to the text, or a page break; the answer is generally either `not yet
implemented, wait for next year', or `incompatible with the Raweb semantics'.
This document uses colors and page breaks, as explained below; no modification
to the translator was needed, but, unless the style sheets are modified, these
additions are ignored.

For these reasons we converted the whole
document to Pdf. This was not trivial, especially because of a lack of font
families (this will be discussed later).  Note also the format of the
document: in the HTML version all metadata (author, title, abstract, etc.) are
placed at the start of the document by the XML to HTML processor. In the case
of the Pdf version, this was not so easy: something as trivial as
\cmd{newpage} \cmd{null} \cmd{vskip-2cm} is impossible to express in XSL/FO
(said otherwise, all my attempts failed), and I had to add a new element
\elt{vspace} for this purpose. 

The source file \filename{testmath.tex} is part of the \Tralics\ distribution;
translating it requires  \Tralics\ version 2.10, and some packages,
like \filename{amsmath} (do not try to include the file \filename{amsmath.sty},
this is not possible; you must use \filename{amsmath.plt} instead).
In most cases we show the \TeX\ source before the translation. There are some
exceptions, for instance we leave as an exercise to find out how we solved  
the exercises of the \TeX book. 
Examples of the \LaTeX\ companion \cite{companion2}  are available on
the CD that comes with the book.


The XML file was converted into HTML, math formulas are left unchanged.
We explain in some cases that what we see is not what we expected. Here 
\textit{FL} means Firefox on Linux (unless specified, it is Firefox 2.0, 
on Fedora Core 3) and \textit{FM} means Firefox on MacIntosh (unless
specified, it is Firefox 2.0 on a PowerBook G4, MacOS 10.4). 
We also tested Amaya, bot \textit{AM} (version 9.55 on Mac) and \textit{AL}
(version 9.99 on Linux FC5).

Installing math fonts for use with a web browser is not always easy:
they are installed as explained on the Mozilla web page, but this page
seems unclear to me: on one Linux machine, Firefox is happy with the fonts,
but uses the wrong font when printing, on another one, Firefox says that fonts
Math1, Math2 and Math4 are missing, but the printed result is correct. 

\clearpage

\section{Special features}
You are not supposed to insert page breaks in your document, but if you put
twenty tables in a row, you will get error messages of the form: to many
unprocessed floats, and then you are in trouble. In this case, the only remedy
is to insert some \cmd{clearpage} commands; in this document, we used the
\cmd{xbox} command in order to produce an empty \elt{clearpage} element in the
XML document, and we adapted the style sheets.

There is a \cmd{clearpage} before this section; you will not notice it because
there is a natural page break there. On the other hand, it is likely that you
will see the page breaks in Chapter three, but there is no easy solution:
there is no text in the current chapter to fill the gaps.
In order to improve the layout, we changed the ordering of
the figures, starting with tables \ref{Tbl-bin1} and  \ref{Tbl-rel1}, that
occupy a full page, and inserting smaller tables after that. Moreover,
table \ref{Tbl-rel1} was too big to fit on a page (the baseline in this
document is much larger than in the \LaTeX\ companion) and we split it into
two parts.  We are happy since this gives 8 full pages with floats, and a
single bad page, the last text page of the chapter.


Concerning colors, you can put any attribute you like to any object
(there is no attempt to validate the document against some DTD).
In the case of math formulas, identifiers, numbers and operators accept
some common attributes including font information and colors, these are
currently ignored when converting XSL/FO into Pdf (but this can easily be
changed, it suffices to add some lines 
of code to the \filename{raweb-cfg.sty} file. However, the color attribute is
honored for the \elt{mstyle} element (all symbols appearing in the \LaTeX\
companion for which no Unicode element has been found are replaced by a 
{\catcode`\#12\xdef\Sharp{#}}
\xbox{inline}{\XMLaddatt{color}{\Sharp F00000}\XMLaddatt{style}{color:\Sharp E00000}red}
$\mathbox{mstyle}[color][\#D00000]{X}$ using this method). 
For the text case, the 
\elt{inline} element is translated into \elt{span} element in the HTML and a
\elt{fo:inline} element in the Pdf, all attributes are copied; in the previous
sentence we have used
\begin{verbatim}[style=latex]
\xbox{inline}{\XMLaddatt{color}{#F00000}\XMLaddatt{style}{color:#E00000}red}
$\mathbox{mstyle}[color][\#D00000]{X}$
\def\UnimplementedOperator#1{\mathbox{mstyle}[color][red]{X}}
\end{verbatim}
This example shows that you can use a named color, or one defined in RGB
syntax, using six hexadecimal digits; use sharp or backslash sharp as
indicated here. 

\section{Compiling the example file}
These are the options you can use when compiling the file
\filename{testmath.tex} 
\begin{verbatim}[style=latex]
-noentnames -trivialmath=7 -leftquote=2018 -rightquote=2019 -nozerowidthspace
\end{verbatim}
The first option says that you prefer \entity{\#x21DA} to \entity{Lleftarrow}
(this is useless if you use an XSLT processor to convert the XML document).
Option `trivialmath=7' says that simple math expressions are translated as
text;  option `mathvariant' says that a command like \cmd{mathbb} should add a
mathvariant attribute;  these two options set initial values to some counters,
they are not needed, because the associated file \filename{testmath.ult}
resets them to the values needed here. Following options are
problematic. If you say `nostraightquotes', this changes the translation of
the apostrophe character to character U+B4, this option produces a nice HTML
file,  but  the Pdf is not so nice.  Here we modify left and right quotes to
U+2018 and U+2019.
If you say `zerowidthspace', \Tralics\ inserts an
invisible character in verbatim mode, that is supposed to inhibit ligatures
when converting the XML file into Pdf file, the trouble is that this character
is shown as a normal space by my browser in certain cases. In \Tralics\
version 2.10, the translation changed: the old behavior can be obtained by
saying \texttt{-nozerowidthelt}. Otherwise an element is created, this element
is transformed into a zerowidthspace character  when the document is converted
to Pdf, is omitted when the document is converted to HTML. This means that the
option is useless.

The following files are needed for the compilation: 
\begin{itemize}
\item a configuration file, that
behaves like the default one; namely one that defines the root element to be
\elt{std} and the dtd file to be \filename{classes.dtd};
\item the source file \filename{testmath.tex}, and the associated
  \filename{testmath.ult} file;
\item the class file \filename{report.clt} (and the auxiliary file
  \filename{std.clt});
\item the standard math packages \filename{amsmath.plt}, \filename{amscd.plt},
  \filename{delarray.plt}, \filename{amsxtra.plt}, \filename{amsgen.plt},
\filename{amsbsy.plt}, \filename{amsopn.plt};
\item the file \filename{fancyvrb.plt} for the special verbatim mode; and
\item the file \filename{RR.plt} for the meta data.
\end{itemize}

When converting the document to HTML, we use the `xsltproc' program. The style
sheet is \filename{testmathhtml.xsl}; this is a short style sheet; but it
needs \filename{cls.xsl} and \filename{RR.xsl}. Conversion to XSL/FO uses
\filename{RRfo.xsl} as style sheet, it needs \filename{clsfo.xsl}, that
includes \filename{raweb3-param.xsl}, \filename{rrrafo3.xsl},
\filename{clspages.xsl}, \filename{RRfosimple.xsl},
\filename{clsfotable.xsl}. Note: this list is likely to change; we have 
to separate clearly the RA (activity report), the RR (research report) and CLS
(standard classes). All these files are in the directory \filename{xml} or
\filename{styles} of the \Tralics\ distribution, but the XSLT processor wants
to see them in the current directory.  

Conversion from XSL/FO to pdf is achieved by compiling the file
\filename{wtestmath.tex} containing the following lines
\begin{verbatim}[numbers=left,style=latex]
\def\xmlfile{testmath.fo}
\def\LastDeclaredEncoding{T1}
\input{xmltex.tex}
\end{document}
\end{verbatim}
It requires \filename{xmltex.tex} and other files from the xmltex
distribution, so that you must install these files first.
There are some bugs or incompatibilities in
the fotex distribution, so that you must use the two files 
\filename{fotex.xmt}, \filename{fotex.sty} as distributed in the xml
directory. Additional required files are  \filename{fotex-add.sty},
\filename{raweb-uni.sty}, and \filename{fotex.cfg}.
Finally the file \filename{wtestmath.cfg} should be a
symbolic link to \filename{raweb-cfg.sty}.


\section{Overview of math mode}

The main change between \Tralics\ version 2.9 and 2.10 concerns handling of
math formulas. Two steps are required for processing them: first a tree is
created, after that, it is converted. This mechanism is similar to the
behavior of \TeX, but some details are not yet implemented, and some
information is lost (for instance, \cmd{mathbin} is a command that says that
the object that follows should be of type `binary'; this information is used
by the program, but the resulting XML tree does not contain this information
(we cannot simply add an attribute pair class=bin to the object). 

When \Tralics\ sees a math formula, it constructs recursively a tree, also
called a math list.
The action after a token has been read is the following:
If the token is expandable (a user defined command for instance), expansion
takes place, this can read some tokens, it can add new tokens to the stream
(to be read again).
If the token is a mode-independent command it will be executed (for instance,
you can change the meaning of some commands). Otherwise, the token is added
to the tree, but there are some exceptions. The easy case is when a whole
subtree is read, for instance when the token is a left brace, a \cmd{begin}
command, etc. In some cases, the execution level is incremented (said
otherwise, the 
behavior is the same as a group defined by braces in non-math mode). In a case
of \cmd{begin}, a token list is read, and the behavior depends on whether
this is a user defined environment (normal expansion rules apply), or a
built-in one. Most built-in environments are matrix-like, and each cell is
evaluated in a group; this has the following consequence: if the math formula
contains an unwanted ampersand character, an error will be signaled when that
character tries to finish the cell-group (because the current group is of type
math), and an error is signaled at the end of the math expression (because the
ampersand character has added a second group after the first, a cell-group,
where the end-of-math character expected a math-group). A third error will be
signaled later: when the tree is converted into a MathML object, \Tralics\ may
complain about non-math tokens in the expression. 
A font change command like \cmd{mathbb}
changes the internal state and adds two tokens to the tree, one that selects
the blackboard font (before the argument) and a token that selects the current
font (after the argument). 

In the case of \LTC{\$L\char`\^1(\textbackslash mathbb\{T\})\$}
the tree has eight nodes. One is a
subtree, containing the argument of the command. They are six
characters, and two commands (select double-struck font, or select normal
font). When the tree is converted into a MathML expression, some nodes are
converted to basic XML elements (the letters), some are ignored (the font
change commands), and others are used to construct an XML tree. 
We shall see later that parentheses, braces, and tokens like that can induce
\elt{mrow} elements; translation of the hat character is non-obvious, because
MathML provides \elt{msub} and \elt{mover} as possible translations; a command
like \cmd{nolimits} placed after a token is an indication for the translation
of the hat that follows. When the tree is converted the current style is looked
at, this quantity depends on the position in the tree (the style of the
numerator of a fraction or the style of an exponent after the hat is smaller
than the current style, while the style of the numerator of a \cmd{cfrac} is
always text style) or the presence of style change commands. Some commands
depend on the style (for instance \cmd{mathchoice}) and are conditionally
interpreted.

The characters in the formula above are of type letter (L, T), or type
non-letter (the digit, or the parentheses), or other (the hat). An interesting
question is: 
what happens if the single L (or any other character) is replaced by a double
one?  A first answer is that this just adds a new token to the tree (there is
a special case: \LTC{\HAT\HAT1} is a non-obvious way to represents the
character q). Spaces are ignored, so that doubling them has no effect. 
Two hat characters in a row signal an error (assume for instance that a space
between them inhibits the double-hat feature mentioned above). Two consecutive
new line characters are replaced by \cmd{par}, this is illegal.
Characters that are neither letters nor digits generally translate to a
\elt{mo} element. No attempt is made to convert two plus characters into a
double plus character (some people use `:=' as an operator, meaning `is equal
by definition', and expect no white space between the two
characters). In a case like \cmd{sqrt}\cmd{frac}\argument{1}\argument{2},
where we have two consecutive commands that take arguments, the argument of
the root operator is the fraction operator, not the full fraction (this
expression is accepted by \LaTeX, as an unexpected consequence of the
implemented of the fraction operator that provides that braces that delimit
the argument of the square root, it is rejected by \Tralics).

The superscript and subscript operators (generally associated to
hat and underscore characters) are hybrid commands: most commands, for
instance \cmd{frac}, are prefix commands (they come before their arguments), a
few commands, like \cmd{over}, are infix operators (the first argument is
before the operator). In the case of hat, there is one argument after the
operator, but the operator acts on the kernel that is to its left 
(in the example the kernel is L, but a kernel can have an index and an
exponent, so that the order of tokens can be: kernel, underscore, index, hat, 
exponent). 
 Translation of character L is a \elt{mi} element; \Tralics\ tries to
converts LL or TT into a single element, according to the following rule.
Assume that \cmd{T} is defined to be \cmd{mathbb}\argument{T} and \cmd{TT}
is defined to be \cmd{mathbb}\argument{TT}. Then \cmd{TT} produces a single
element with two characters, while \cmd{T}\cmd{T} produces two elements with a 
single character. On the other hand, a strange rule of MathML says that the
font used for a \elt{mi} element (that lacks font attributes) depends on the
number of characters in it; for this reason, in a formula like $xy$, the
translation is a sequence of two \elt{mi} elements, without attributes,
containing a single character (implicit product). In a case like  $17$, a
single \elt{mn} element is constructed, because this represents a number (in a
case like $x_{12}$, an implicit comma could be added in the case where the
expression refers to row 1 column 2 of the matrix $x$; however, do not expect
such a behavior in a near future). The source code of the expression above is
\LTC{\$x\_\argument{12}\$}. Without the braces, the translation is $x_12$
(if you do not see the difference, there is a bug somewhere).

If the internal counter \cmd{@nomathml} is negative, the tree is converted to
a character string in a trivial manner; in a case like 
\cmd{cfrac12}, you will see \cmd{cfrac}\argument{1}\argument{2}, because we
have a sub-tree with two nodes (the two arguments of the command). In reality,
the command takes an optional argument, and its value is printed only if it is
not empty. In a case like $L^1(\mathbb{T})$, you will see two font changes
as explained above. If you want to see the characters \cmd{mathbb} there are
two solutions: the easy one works only since version 2.10:
\Tralics\ inserts in the tree all commands that behave like
\cmd{relax}; these commands are ignored when converting the tree into a MathML
expression, but the name is used otherwise; thus \cmd{let} \cmd{mathbb}
\cmd{relax} does the job. Otherwise, it suffices to redefine \cmd{mathbb} in
order to expand to the desired string (using \cmd{string} for instance). 
Note: since version 2.10, a font change command that takes an argument defines
a semi-simple group, by inserting \cmd{begingroup} and \cmd{endgroup} commands.

\chapter{Examples from the TEXbook}


\section{Typing math formulas, TB 16}
\ifTeXone
The \TeX\ book starts slowly; first Knuth explains that math formulas are
enclosed in special math brackets, dollar signs. He also says that
spaces are ignored in math mode.
\begin{verbatim}[numbers=left,style=latex]
`$x$', `$2$', `$ x$', `$ 2 $', 
`$(x + y)/(x - y)$', `$(x+y) / (x-y)$' 
\end{verbatim}
Easy formulas: `$x$', `$2$', `$ x$', `$ 2 $',
`$(x + y)/(x - y)$', `$(x+y) / (x-y)$'.

We show here some Greek letters, and some other symbols:
\begin{verbatim}[numbers=left,style=latex,firstnumber=last]
$\Gamma, \nu,\kappa$,
$\phi,\emptyset, \epsilon,\in,\approx,\mapsto$
$(\phi,\theta,\epsilon,\rho)$, 
$(\varphi,\vartheta,\varepsilon,\varrho)$, 
$$\alpha, \beta, \gamma, \delta.$$
\end{verbatim}


Greek letters $\Gamma, \nu,\kappa$, and other symbols:
$\phi,\emptyset, \epsilon,\in,\approx,\mapsto$; 
standard Greek\footnote{AM does not show the epsilon} letters, $(\phi,\theta,\epsilon,\rho)$, 
and variants $(\varphi,\vartheta,\varepsilon,\varrho)$, 
a display math formula:
$$\alpha, \beta, \gamma, \delta.$$



\begin{verbatim}[numbers=left,style=latex,firstnumber=last]
\begingroup
\catcode`\*=3
*x^2*, \( x_2\), \begin{math}\Sigma\end{math}
**A** \[ B\] \begin{displaymath} C \end{displaymath}
\endgroup
\end{verbatim}

\begingroup
\catcode `\*=3
We show here that any character of category code 3 can be used as math
delimiter: 
*x^2*, as well as two alternative ways introduced by \LaTeX:
\( x_2\), \begin{math}\Sigma\end{math}. We show that display math can be
entered by doubling the character of category 3 (actual rules are more
complicated, see the \TeX Book), or using a \LaTeX\ environment (additional
environments will be explained in later chapters), or using brackets. 
Note that brackets are very useful, because they are so easy to type.
**A**\[ B\] \begin{displaymath} C \end{displaymath}
\endgroup


\ex{16.1} $\gamma+\nu\in\Gamma$.

\ex{16.2} \cmd{le},\cmd{ge},\cmd{ne}, 
\cmd{leq},\cmd{geq}, and \cmd{neq}:
$\le,\ge,\ne$,
$\leq,\geq,\neq$.

Complex formulas with superscripts\textsuperscript{(up high)} and subscripts
\textsubscript{(down low)}. 

\begin{verbatim}[numbers=left,firstnumber=last]
$x^2$, $x_2$, $2^x$, $x^2y^2$, $x ^ 2y ^ 2$, $x_2y_2$, $_2F_3$,
$x^{2y}$, $2^{2^x}$, $2^{2^{2^x}}$, $y_{x_2}$, $y_{x^2}$.
\end{verbatim}
Translation $x^2$, $x_2$, $2^x$, $x^2y^2$, $x ^ 2y ^ 2$, $x_2y_2$, $_2F_3$,
$x^{2y}$, $2^{2^x}$, $2^{2^{2^x}}$, $y_{x_2}$, $y_{x^2}$.

Consider now the following two formulas:
\begin{verbatim}[numbers=left,firstnumber=last]
$((x^2)^3)^4$,  ${({(x^2)}^3)}^4$.
\end{verbatim}
Translation of the first formula
\begin{verbatim}[numbers=left,firstnumber=last,style=xml]
<formula type='inline'>
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
    <mrow>
      <mo>(</mo>
      <mo>(</mo>
      <msup><mi>x</mi> <mn>2</mn> </msup>
      <msup><mo>)</mo> <mn>3</mn> </msup>
      <msup><mo>)</mo> <mn>4</mn> </msup>
    </mrow>
  </math>
</formula>
\end{verbatim}
Translation of the second formula

\begin{verbatim}[numbers=left,firstnumber=last,style=xml]
<formula type='inline'>
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
    <msup>
      <mrow><mo>(</mo>
        <msup>
          <mrow> 
            <mo>(</mo> 
            <msup><mi>x</mi> <mn>2</mn> </msup>
            <mo>)</mo>
          </mrow> 
          <mn>3</mn> 
        </msup>
        <mo>)</mo>
      </mrow> 
      <mn>4</mn> 
    </msup>
  </math>
</formula>
\end{verbatim}
The current \Tralics\ uses some hacks, so that the translation is actually
different. You will get first $\mathord(\mathord(x^2\mathord)^3\mathord)^4$, second
${\mathord({\mathord(x^2\mathord)}^3\mathord)}^4$, third 
$((x^2)^3)^4$, and fourth ${({(x^2)}^3)}^4$. Here the first two formulas
correspond to the XML fragment shown above (they were produced by prefixing
each parenthesis with \cmd{mathord}, and after that we have the
actual translation. The MathML
recommendation says that some operators are \emph{stretchy}, so that the width
and height can depend on the context. This is not the case in \xmltex, so
that, in the Pdf version, all parentheses have the same size. The \cmd{mathop}
prefix tells \Tralics\ to not consider parentheses as stretchy, so no hack is
applied. We shall not explain the hack here; moreover we modified it in
version 2.10.8.  We originally wrote \textit{
All parentheses have the same  size in the pdf version, the same is true for
the HTML 
version in the first formula. Now, the \elt{mrow} elements delimit a scope, 
so that inner parentheses are smaller than outer parentheses (but only for
HTML, second formula); note that the placement of the exponent depend on the
context, so that, in the second formula, all three superscripts at placed at
different positions.
 In the case of the first formula, placement of the
exponent depends only on the the size of the parentheses (hence, in the Pdf
version, they should be aligned, in the HTML version, they are not).}
Firefox on Mac shows the following: all superscript are aligned. Big
parentheses are used but for case 2. Amaya shows only small parentheses,
scripts are not aligned, but this is hard to see.


The MathML recommendation says that the second alternative is
better; but Knuth says:
``The first alternative is preferable, because it is much easier to type, and
it is just as easy to read.'' 

\begin{verbatim}[numbers=left,firstnumber=last]
`${}_2F_3$', `${_2}F_3$', `${_2F_3}$' 
\end{verbatim}

\ex{16.3} Three ways to have an empty kernel:
`${}_2F_3$', `${_2}F_3$', `${_2F_3}$'. The translation is the same in all
cases because of the following two rules: if a math list starts with a
subscript or superscript operator, an empty math list is added before, it
serves as 
kernel (thus, braces in the first example are useless); 
a math list is packaged by putting it in a \elt{mrow} element, unless
the list has one element (in the second example, there are two tokens between
the braces, converted to a single \elt{msub} element, the math list has a
single element, braces are useless). In these two cases, the main math list
has two \elt{msub} elements, and a \elt{mrow} is added. In the last case, the
main math list has a single element, a \elt{mrow}, thus, no  \elt{mrow} is
added and braces are useless. 

\begin{verbatim}[numbers=left,firstnumber=last]
`$x+_2F_3$' and `$x+{}_2F_3$'.
\end{verbatim}
Effect of braces after plus sign:
`$x+_2F_3$' and `$x+{}_2F_3$'. The MathML recommendation says that the distance
between the plus sign and the letter F should be the same in both cases; in the
first case, index 2 is attached to the plus sign, in the second case to the
letter F (\textit{AM} shows both formulas with index attached to F).


\begin{verbatim}[numbers=left,firstnumber=last]
${x_2}_3$, $\displaystyle {\sum}'$ 
\end{verbatim}

Note that an \elt{mrow} element is added for a
math list with a single element in the case where it is followed by a
subscript or a subscript. Reason one: in a case like ${x_2}_3$, you will get
an error if braces are omitted; in the same fashion, an error is signaled 
(when converting to Pdf) if \elt{mrow} is missing. Reason two, in a case like
$\displaystyle {\sum}'$, the apostrophe is not placed above the sum if there
is a \elt{mrow} (the sum operator has type Op, but not the group, unless there
is a \cmd{mathop} before it).



\ex{16.4} Double superscript, ${x^y}^z$, $x^{y^z}$.

\begin{verbatim}[numbers=left,firstnumber=last]
$x^2_3$, $x_3^2$, $x^{31415}_{92}+\pi$, $x_{y^a_b}^{z_c^d}$.
$P_2^2$ and $P{}_2^2$.
\end{verbatim}
Simultaneous superscripts and subscripts $x^2_3$, $x_3^2$,
$x^{31415}_{92}+\pi$, $x_{y^a_b}^{z_c^d}$. 

Vertical alignment: $P_2^2$ and $P{}_2^2$. In the first case, scripts are
attached to the letter P, and alignment can depend on the slant of the letter.
(Amaya has extra space in the second formula).

\begin{verbatim}[numbers=left,firstnumber=last]
`$\prime$', $y_1^\prime$, $y_2^{\prime\prime}$, $y_3^{\prime\prime\prime}$,
$f'[g(x)]g'(x)$, $y_1'+y_2''$, $y'_1+y''_2$, $y'''_3+g'^2$
\end{verbatim}
Primes and shorthand:
{\let\prime\varprime
`$\prime$', $y_1^\prime$, $y_2^{\prime\prime}$, $y_3^{\prime\prime\prime}$,
$f'[g(x)]g'(x)$, $y_1'+y_2''$, $y'_1+y''_2$, $y'''_3+g'^2$.}
In the code shown here, the character used as delimiter for XML attributes is
character U+39, the quotes around the math formulas are U+60 and U+B4 (this
character can be changed via an option of the program, in verbatim mode it is
always U+39, straight quote).
The
prime character used in the formula is U+2032. This is not the right character.
Thus, in \Tralics\ 2.9.5, translation of prime changed, it is now
character U+39. The same formula is now:
`$\prime$', $y_1^\prime$, $y_2^{\prime\prime}$, $y_3^{\prime\prime\prime}$,
$f'[g(x)]g'(x)$, $y_1'+y_2''$, $y'_1+y''_2$, $y'''_3+g'^2$. It is unclear
whether this is the good solution. It seems that Firefox  uses the same font
metrics as \TeX, i.e., a very large prime character that has a normal size
when used at script size, while Amaya uses a normal size prime, that is small
when used as a superscript. In the case of f-prime, the slant of the letter is
not taken into account by Amaya, and the prime sign is hard to see.



\begin{verbatim}[numbers=left,firstnumber=last]
$x\varprime y^\varprime, x\Prime y^\Prime,
x\tprime y^\tprime,x\bprime y^\bprime,x\qprime y^\qprime$
\end{verbatim}
The amsmath package provides the symbols shown above; as you can see (at least
with FM), these characters are not meant
to be used as an exponent: 
$x\varprime y^\varprime, x\Prime y^\Prime,
x\tprime y^\tprime,x\bprime y^\bprime,x\qprime y^\qprime$.
Note that \cmd{qprime} is unkown to Amaya, and the prime subscript in the
following exercice is hard to see.

\ex{16.5} $F'(w,z)=\partial F(w,z)/\partial z$ and $F_\prime(w,z)=\partial F(w,z)/\partial w$.

\begin{verbatim}[numbers=left,firstnumber=last]
\let\none\mmlnone
$R_i{}^{jk}{}_l$ versus $\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$
\end{verbatim}
\ex{16.6} 
$R_i{}^{jk}{}_l$ versus $\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$
(MathML example,  section 3.4.7.2, only second index raised). 

\begin{verbatim}[numbers=left,firstnumber=last]
$\sqrt 2$, $\sqrt{x+2}$, $\underline4$, $\overline{x+y}$, 
$\overline x+ \overline y$, $x^{\underline n}$, $x^{\overline{m+n}}$, 
$\sqrt{x^3+\sqrt\alpha}$
\end{verbatim}
Translation $\sqrt 2$, $\sqrt{x+2}$, $\underline4$, $\overline{x+y}$, 
$\overline x+ \overline y$, $x^{\underline n}$, $x^{\overline{m+n}}$, 
$\sqrt{x^3+\sqrt\alpha}$. 
There are problems with underline and overline on \textit{FM}. Vertical
position is not always good, and the length is sometimes incorrect. On the
fifth formula, rules are sometimes invisible in the printed version.
There is a text version in \Tralics:
$\underline{\text{Mfoo}}$, \underline{Tfoo},  
$\overline{\text{Mfoo}}$, \overline{Tfoo},
$\overline{\underline{\text{Mfoo}}}$, \overline{\underline{Tfoo}}. 


\begin{verbatim}[numbers=left,firstnumber=last]
$\root 3 \of 2$, $\root n \of {x^n + y^n}$, $\root n+1 \of a$,
$\sqrt[3]{2}$, $\sqrt[n]{x^n + y^n}$, $\sqrt[n+1]a$, `$\sqrt[3]{~~}$'.
\end{verbatim}
Translation
 $\root 3 \of 2$, $\root n \of {x^n + y^n}$, $\root n+1 \of a$,
$\sqrt[3]{2}$, $\sqrt[n]{x^n + y^n}$, $\sqrt[n+1]a$, `$\sqrt[3]{~~}$'.

\begin{verbatim}[numbers=left,firstnumber=last]
$\sqrt{\mathstrut a} + \sqrt{\mathstrut d} + \sqrt{\mathstrut y}$,
$\sqrt{a} + \sqrt{d} + \sqrt{y}$,
$\overline{a} + \overline{d} + \overline{y}$,
$\overline{\mathstrut a} + \overline{\mathstrut d} + \overline{\mathstrut y}$.
\end{verbatim}
Translation $\sqrt{\mathstrut a} + \sqrt{\mathstrut d} + \sqrt{\mathstrut y}$,
$\sqrt{a} + \sqrt{d} + \sqrt{y}$,
$\overline{a} + \overline{d} + \overline{y}$,
$\overline{\mathstrut a} + \overline{\mathstrut d} + \overline{\mathstrut y}$.


\ex{16.7} $10^{10}$, $2^{n+1}$, $(n+1)^2$, $\sqrt{1-x^2}$,
$\overline{w+\overline{z}}$, $p_1^{e_1}$, $a_{b_{c_{d_e}}}$,
$\sqrt[3]{h''_n(\alpha x)}$.

\ex{16.8} If$ x=y$,then $x$ is equal to $y.$ (this exercise says what you
should not do).

\ex{16.9} Deleting an element from an $n$-tuple leaves an $(n-1)$-tuple.

\ex{16.10} Letters with descenders are Qfgjpqy.

\begin{verbatim}[numbers=left,firstnumber=last]
$x+y-z$, $x+y*z$, $x*y/z$ 
\end{verbatim}
Basic binary operators: $x+y-z$, $x+y*z$, $x*y/z$.

\begin{verbatim}[numbers=left,firstnumber=last]
$x\times y\cdot z$, $x\circ y\bullet z$, $x\cup y\cap z$,
$x\sqcup y\sqcap z$, $x\vee y\wedge z$, $x\pm y \mp z$. 
Aliases   $x\land y\lor z$.
\end{verbatim}
Many more binary operators 
$x\times y\cdot z$, $x\circ y\bullet z$, $x\cup y\cap z$,
$x\sqcup y\sqcap z$, $x\vee y\wedge z$, $x\pm y \mp z$.
Aliases   $x\land y\lor z$.

\begin{verbatim}[numbers=left,firstnumber=last]
$x=+1$, $3.142-$, $(D*)$
$x=\mathmo[form][prefix]{+}1$
$3.142\mathmo[form][prefix]{-}$
$(D\mathmi[mathvariant][normal]{*})$
$(D\mathmo[lspace][0][rspace][0]{*})$
\end{verbatim}
Binary as ordinary symbols: $x=+1$, $3.142-$, $(D*)$. 
The HTML version is slightly different from the \TeX\ version. 
You can declare the plus sign as prefix operator, this gives
$x=\mathmo[form][prefix]{+}1$, you can define the minus sign as prefix
operator, this gives $3.142\mathmo[form][prefix]{-}$. Removing the space around
the star is more complicated, a solution consists of using an identifier in
upright variant like this $(D\mathmi[mathvariant][normal]{*})$, or by setting
the lspace and rspace attributes to zero:
 $(D\mathmo[lspace][0][rspace][0]{*})$.

\begin{verbatim}[numbers=left,firstnumber=last]
$K_n^+,K_n^-$, $z^*_{ij}$, $g^\circ\mapsto g^\bullet$, $f^*(x)\cap f_*(y)$
\end{verbatim}
Binary  operators in superscripts
$K_n^+,K_n^-$, $z^*_{ij}$, $g^\circ\mapsto g^\bullet$, $f^*(x)\cap f_*(y)$.

\ex{16.11} $z^{*2}$ and $h'_*(z)$.

\begin{verbatim}[numbers=left,firstnumber=last]
$x=y>z$, $x:=y$, $x\le y\ne z$, $x\sim y\simeq z$, $x\equiv y\not\equiv z$,
$x\subset y\subseteq z$
\end{verbatim}
 $x=y>z$, $x:=y$, $x\le y\ne z$, $x\sim y\simeq z$, 
$x\equiv y\not\equiv z$,
$x\subset y\subseteq z$. In the Pdf version there is no space between the
colon and the equals sign, but the HTML version shows some, because the rules
are not the same for \TeX\ and MathML. The best solution would be to use a
single operator instead of two consecutive ones; the user can define a command
\cmd{coloneq} that behaves like colon-eq in normal \TeX, or \Tralics\ could be
modified in order to recognise sequences like this. Translation of \cmd{not} is
problematic: in this document we consider it as an undefined operator, and you
see a red X. We should add rules like: \cmd{not=} should give \cmd{ne}.


\begin{verbatim}[numbers=left,firstnumber=last]
$f(x,y;z)$, $f:A\to B$, $f\colon A\to B$
%\def\colon{\mathmo[lspace][0]{:}} 
\end{verbatim}
Punctuation $f(x,y;z)$, $f:A\to B$, $f\colon A\to B$. Note that \cmd{colon} is
a colon with \attpair{lspace}{0pt}, but the attribute is ignored in the Pdf
version. It seems that Amaya uses a zero lspace by default.


\begin{verbatim}[numbers=left,firstnumber=last]
$12,345x$, $12{,}245x$, $\mathcn{12,345}x$, $\mathmn{12,345}x$
\end{verbatim}
$12,345x$, $12{,}245x$, $\mathcn{12,345}x$, $\mathmn{12,345}x$. The translation
of the first two expressions is the same, braces are useless here.  A silly
bug of my F browser: the second digit of the first number disappears; this does
not happen if the number is not the first word of a paragraph (this is why the
sentence starts with a number). You should use
one of the last two variants if you want the sequence of digits plus the comma
to be considered as a number.



\ex{16.12}  $3{\cdot}1416$, but \cmd{mathmn}\argument{3\HAT\HAT b71416} gives 
$\mathmn{3^^b71416}$ (less space in the HTML version).

\begin{verbatim}[numbers=left,firstnumber=last]
$\hat a$, $\check a$, $\tilde a$, $\acute a$, $\grave a$, $\dot a$,
$\ddot a$, $\breve a$, $\bar a$, $\vec a$
\def\ihat{{\hat \imath}} \def\jhat{{\hat\jmath}} $\ihat$, $\jhat$
\end{verbatim}

 $\hat a$, $\check a$, $\tilde a$, $\acute a$, $\grave a$, $\dot a$,
$\ddot a$, $\breve a$, $\bar a$, $\vec a$,
\def\ihat{{\hat \imath}} \def\jhat{{\hat\jmath}} $\ihat$, $\jhat$.
Character \cmd{jmath} is a normal j, because there is no dotless j in most
fonts. There is also a problem with the rendering of grave accents on FM.

\begin{verbatim}[numbers=left,firstnumber=last]
$\hat{I+M}$, $\bar z+ \overline z$, $\widehat x, \widetilde x$,
$\widehat{xy}, \widetilde{xy}$
$\widehat{xy}, \widetilde{xy}$
$\widehat{xyz}, \widetilde{xyz}$
% $\ghat\in{(H^{\pi_1^{-1}})}' -> Ex16.13 below
\end{verbatim}
Large accents
 $\hat{I+M}$, $\bar z+ \overline z$, $\widehat x, \widetilde x$,
$\widehat{xy}, \widetilde{xy}$,
$\widehat{xy}, \widetilde{xy}$,
$\widehat{xyz}, \widetilde{xyz}$. As you can see, there is no difference
between wide and non-wide operators. My browser (AM as well as FM) shows a small hat, and a
variable length tilde. For the Pdf version, we have decided to use the
variable size variant. 



\def\ghat{{\hat g}}
\ex{16.13} $e^{-x^2}$, $D\sim p^\alpha M+l$, $\ghat\in{(H^{\pi_1^{-1}})}'$,
(braces added), 
$\ghat\in(H^{\pi_1^{-1}})'$ (without braces). In \Tralics\ 2.11, there shuld
be no difference between the version with and without braces.
\fi


\section{More about Math, TB 17}
\ifTeXtwo
\begin{verbatim}[numbers=left,firstnumber=last]
$$ {1\over 2}\qquad {\rm and}\qquad {n+1 \over 3} \qquad {\rm and}\qquad {n+1
  \choose 3}\qquad {\rm and}\qquad \sum_{n=1}^3Z_n^2. \label{eq17.1}$$
\[ \frac{1}{2}\qquad \text{and}\qquad \frac{n+1}{3} \qquad \text{and}\qquad 
\binom{n+1}{3}\qquad \text{and}\qquad \sum_{n=1}^3Z_n^2.\label{eq17.2}\]
\end{verbatim}
Example of vertical alignment. Translation of the first three expressions is a
\elt{mfrac} element, subexpressions are in text style (normal size). In the
case of the last expression scripts are in script style (small size) and we
have a \elt{munderover} element for the sum (it is an operator with limits in
display style) and a \elt{msubsup} element for the Z (that is not an operator).
$$ {1\over 2}\qquad {\rm and}\qquad {n+1 \over 3} \qquad {\rm and}\qquad {n+1
  \choose 3}\qquad {\rm and}\qquad \sum_{n=1}^3Z_n^2. \label{eq17.1}
$$
The same, using \LaTeX\ syntax
\[ \frac{1}{2}\qquad \text{and}\qquad \frac{n+1}{3} \qquad \text{and}\qquad 
\binom{n+1}{3}\qquad \text{and}\qquad \sum_{n=1}^3Z_n^2.\label{eq17.2}\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[{x+y^2\over k+1},\qquad {x+y^2\over k}+1,\qquad
x+{y^2\over k}+1,\qquad x+{y^2\over k+1},\qquad x+y^{2\over k+1}\]
\[\frac{x+y^2}{k+1},\qquad \frac{x+y^2}{k}+1,\qquad
x+\frac{y^2}{k}+1,\qquad x+\frac{y^2}{k+1},\qquad x+y^{\frac{2}{k+1}}\]
\end{verbatim}
Single over. The only difference in these expressions is the placement of the
braces.
\[{x+y^2\over k+1},\qquad {x+y^2\over k}+1,\qquad
x+{y^2\over k}+1,\qquad x+{y^2\over k+1},\qquad x+y^{2\over k+1}.
\label{eq17.3}\]
\LaTeX\ style: this uses a command with two arguments, that behaves without
surprise. 
\[\frac{x+y^2}{k+1},\qquad \frac{x+y^2}{k}+1,\qquad
x+\frac{y^2}{k}+1,\qquad x+\frac{y^2}{k+1},\qquad x+y^{\frac{2}{k+1}}.
\label{eq17.4}\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[{ {a \over b}\over 2} \qquad \text{and}\qquad { a\over {b\over 2}} 
\qquad \text{and}\qquad { a/ b\over 2} \qquad \text{and}\qquad { a\over b/2} 
 \]
\[ \frac{\frac{a}{b}}{2} \qquad \text{and}\qquad \frac{a}{\frac{b}{2}}  
\qquad \text{and}\qquad  \frac{a/b}{2} \qquad \text{and}\qquad \frac{a}{b/2} \]
\end{verbatim}
Double over.  It is an error if you say A over B over C without adding
braces. As you can see, if a fraction is in text style, its numerator and
denominator are in script style, so that it is sometimes better to use a slash. 
\[{ {a \over b}\over 2} \qquad \text{and}\qquad { a\over {b\over 2}} 
\qquad \text{and}\qquad { a/ b\over 2} \qquad \text{and}\qquad { a\over b/2}. 
\label{eq17.5} \]
\LaTeX\ style (nothing special here).
\[ \frac{\frac{a}{b}}{2} \qquad \text{and}\qquad \frac{a}{\frac{b}{2}} 
\qquad \text{and}\qquad \frac{a/b}{2} \qquad \text{and}\qquad \frac{a}{b/2}.
\label{eq17.6}  \]



\ex{17.1} Compare $x+y^{\frac{2}{k+1}}$ with $x+y^{2/(k+1)}$. If a fraction is
in script style, its numerator and denominator are in script script style,
i.e. smaller. In \TeX, there are four styles and three sizes (display style and
text style have the same size). In MathML, the size is defined by a level,
zero, one, or two, but larger levels are possible; thus more than three sizes
are possible. There is however a minimal font size.
 
\ex{17.2} Compare $\frac{a+1}{b+1}x$ with $((a+1)/(b+1))x$.
\ex{17.3} Wrong use of \cmd{over} in $\displaystyle{ x=(y^2\over k+1)}$. 
\ex{17.4} $7\frac12\textcent$, using the \cmd{textcent} command.
\ex{17.5} Same as in the \TeX book, but not cramped.

\begin{verbatim}[numbers=left,firstnumber=last]
\[n+\scriptstyle n + \scriptscriptstyle n\]
\[n+{\scriptstyle n + {\scriptscriptstyle n}}\]
\end{verbatim}
\[n+\scriptstyle n + \scriptscriptstyle n\]
\[n+{\scriptstyle n + {\scriptscriptstyle n}}\]
Note: In the current version of \Tralics, it is unclear what happens when you
put style commands randomly in a math formula; in any case, \Tralics\ uses the
correct math style, but has difficulties in inserting \elt{mstyle}
elements: what is the scope? Currently such an element is added to the current
math list, if it contains a style change command; in the example above,
we have two such commands, thus three different styles,
and a single list (first example) or three lists (second example).
Translation of the first example is wrong, translation of the second example is
correct because the style command is the first token of the
list\footnote{Amaya seems to ignore the style attribute}.


\begin{verbatim}[numbers=left,firstnumber=last]
\[a_0+{1\over\displaystyle a_1 +
  {\strut 1\over\displaystyle a_2+
    {\strut 1\over\displaystyle a_3+
       {\strut 1\over a_4}}}}\]
\end{verbatim}
Translation
\[a_0+{1\over\displaystyle a_1 +
  {\strut 1\over\displaystyle a_2+
    {\strut 1\over\displaystyle a_3+
       {\strut 1\over a_4}}}}\]
Without \cmd{displaystyle}
{\let\displaystyle\relax
\[a_0+{1\over\displaystyle a_1 +
  {\strut 1\over\displaystyle a_2+
    {\strut 1\over\displaystyle a_3+
       {\strut 1\over a_4}}}}\]
}
Without \cmd{strut}. Since a \cmd{strut} is an invisible object of the size of
a parenthesis, more or less the size of the digit one, its effect is hard to
see.\footnote{The width of the strut should be zero; this is incorrectly
  rendered by Amaya, that shows a non-centered numerator; there is also
  additional space in the formulas before exercide 16.7}
{\let\strut\empty
\[a_0+{1\over\displaystyle a_1 +
  {\strut 1\over\displaystyle a_2+
    {\strut 1\over\displaystyle a_3+
       {\strut 1\over a_4}}}}\]
}
Without both
{\let\strut\empty\let\displaystyle\relax
\[a_0+{1\over\displaystyle a_1 +
  {\strut 1\over\displaystyle a_2+
    {\strut 1\over\displaystyle a_3+
       {\strut 1\over a_4}}}}\]
}

Until version 2.9.4, commands of the form \cmd{hfill} were illegal in math
mode. Since then, they are allowed as first or last element in arguments of 
commands like \cmd{overline}. They are ignored, unless the result is a
fraction;  we demonstrate here that \cmd{hfill} placed at the end of the list
produces a left alignment, in the case of \cmd{over}, \cmd{genfrac}, or
\cmd{frac}. Note that  the \cmd{cfrac} command can be used for continued
fractions: its optional argument says whether the numerator is centered, left
aligned or right aligned, under the assumption that the denominator is much
larger than the numerator.\footnote{As previously, the struts induce unwanted
  space in Amaya}.
\[
a_0+{1\hfill\over\displaystyle a_1 +
  {\strut 1\hfill\over\displaystyle a_2+
    {\strut 1\hfill\over\displaystyle a_3+
       {\strut 1\over a_4}}}}
\qquad \genfrac(){}{}{12345}{1\hfill}\qquad \frac{1\hfill}{12345}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[ {x\atop y+2}, {n \choose k}, \text{latex},
\genfrac{}{}{0pt}{}{x}{y+2},\binom{n}{k} \]
\end{verbatim}
The \cmd{atop} construction is like \cmd{over}, without fraction rule; you
should not use it in \LaTeX, you should use \cmd{genfrac} instead. The command
\cmd{atopwithdelims} (see below for an example) is followed by two delimiters,
say A and B, it puts A before the fraction and B after it. You can use
\cmd{genfrac} with A and B as arguments (third argument is line thickness,
fourth argument is style). The \cmd{choose}
command is nothing else than \cmd{atopwithdelims()}. You should not use it.
\[ {x\atop y+2}, {n \choose k}, \text{latex},
\genfrac{}{}{0pt}{}{x}{y+2},\binom{n}{k} \]

\begin{verbatim}[numbers=left,firstnumber=last]
\[{ {n\choose k}\over 2} \text{ or } { n\choose{k\over2} } 
\text{ or } { n\choose k/2} \text{ or } {n\choose{1\over2}k}\]
\end{verbatim}
As mentioned above, a construction like A over B over C needs braces, 
where over is a generic name for \cmd{over} and variants, including
\cmd{choose}. Nothing special is required for \cmd{frac} or \cmd{binom}, so
that \LaTeX\ variant is omitted.
\[{ {n\choose k}\over 2} \text{ or } { n\choose{k\over2} }
\text{ or } { n\choose k/2} \text{ or } {n\choose{1\over2}k}\]

\begin{verbatim}[numbers=left,firstnumber=last]
%%$${1\over2}{n\choose k}$$; $$\displaystyle{n\choose k}\over2}$$ : TeXbook
$\displaystyle \frac{1}{2}\binom{n}{k}$, 
$\displaystyle{n\choose k}\over \displaystyle 2$,
$\dfrac{\dbinom{n}{k}}2$.
{\def\P{\mathchoice{D}{T}{S}{SS}}
$\displaystyle{\P\choose \P}\P\over \displaystyle \P$,
$\dfrac{\dbinom{\P}{\P}\P}\P$.}
\end{verbatim}
\ex{17.6} $\displaystyle \frac{1}{2}\binom{n}{k}$ and 
$\displaystyle{n\choose k}\over \displaystyle2$; \LaTeX\ version
$\dfrac{\dbinom{n}{k}}2$; version with \cmd{P}:
 {\def\P{\mathchoice{D}{T}{S}{SS}}
$\displaystyle{\P\choose \P}\P\over \displaystyle \P$,
$\dfrac{\dbinom{\P}{\P}\P}\P$}. 
Note that the `d' in \cmd{dfrac} or \cmd{dbinom}
means that the expression is in display style, hence numerator and
denominator are in text style; as a consequence the \cmd{choose} is same as the
\cmd{dbinom}; on the other hand, the \cmd{over} produces a fraction in text
style, with numerator and denominator in display style, while the \cmd{dfrac}
produces a fraction in display style, with numerator and denominator in 
text style. In the dvi file, the distance between D and the fraction rule is
the same as the width of the rule, and the distance between the T and the
rule is approximatively one third of the height of the T; my HTML FM browser uses
larger values, making the difference more obvious.

\ex{17.7} $\displaystyle \binom p2\,x^2y^{p-2} - \frac 1{1-x}\,\frac1{1-x^2}$.
 Fine space added for legibility.

\begin{verbatim}[numbers=left,firstnumber=last]
\[{\displaystyle{a\over b}\above3pt\displaystyle{c\over d}}
\text{~~and~~} \genfrac{}{}{3pt}{}{\dfrac{a}{b}}{\dfrac{c}{d}}\]
\end{verbatim}
There are six operators that behave alike: \cmd{over}, \cmd{atop} and
\cmd{above}, and the same with delimiters. The `above' commands read a
dimension, the thickness of the fraction rule. In the current version of
\Tralics, this has better to be explicit (if you want the value of
\cmd{parskip}, you must use \cmd{genfrac}).
\[{\displaystyle{a\over b}\above3pt\displaystyle{c\over d}}
\text{~~and~~} \genfrac{}{}{3pt}{}{\dfrac{a}{b}}{\dfrac{c}{d}}.\]

\begin{verbatim}[numbers=left,firstnumber=last]
${\displaystyle \sum x_n}, {\textstyle \sum x_n}, 
{\scriptstyle \sum x_n}, {\scriptscriptstyle \sum x_n}$
\end{verbatim}
Different sums ${\displaystyle \sum x_n}, {\textstyle \sum x_n}, 
{\scriptstyle \sum x_n}, {\scriptscriptstyle \sum x_n}$. The position of the
index is unaffected by the style.

\begin{verbatim}[numbers=left,firstnumber=last]
\[ {\displaystyle \int_{-\infty}^{\infty} \sum_{n=1}^m},  
{\textstyle \int_{-\infty}^{\infty} \sum_{n=1}^m},
{\displaystyle\int\limits_0^{\frac{\pi}{2}} \sum\nolimits_{n=1}^m} \]
\end{verbatim}
This example demonstrates that the position of scripts depends on the style if
the kernel is a math operator, and the presence of key words like `limits',
`nolimits' or `displaylimits'. Scripts can be added to a MathML object using
m/sub/sup, and for an operator using m/under/over.  In this last case, the
attribute movablelimits corresponds to the `displaylimits' keyword. If set,
`under' means `sub' if the style is not display. \Tralics\ uses `under' or
`sub', depending on where the indices should be placed, and never sets the
attribute. On the other hand, when \TeX\ typesets a `under' or `sub', it 
sometimes uses a wrong strategy. The last expression (display style sum
without limits) uses a \cmd{msubsup} element; in this case, there is an
implicit \cmd{nolimits}, we cannot make it explicit, because such a command
has to follow an operator, and there is no easy way to check that the first
child of the element is an operator (it is easy to see that it is a \elt{mo}
element, a bit more complicated to see that it contains a Unicode character,
and quite impossible to say that its translation leaves \TeX\ in state where
\cmd{nolimits} is allowed). Note also that we could convert the argument to an
operator, but this is not always a good idea. In this example the HTML version
is correct, the Pdf version is wrong\footnote{Amaya places the   $\pi/2$ too low}.

\[ {\displaystyle \int_{-\infty}^{\infty} \sum_{n=1}^m},  
{\textstyle \int_{-\infty}^{\infty} \sum_{n=1}^m},
{\displaystyle\int\limits_0^{\frac{\pi}{2}} \sum\nolimits_{n=1}^m} \]

\begin{verbatim}[numbers=left,firstnumber=last]
\[\lim_ax+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_ax\]
\[\textstyle \lim_lx+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_lx\]
\[\sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_ax\]
\[\textstyle \sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_lx\]
\end{verbatim}
More about limits. Knuth says that \cmd{nolimits}\cmd{limits} produces limits;
so that \cmd{sin}\cmd{limits} produces limits; a special feature of amsmath
is that the token that follows the \cmd{sin} is ignored if it is a
\cmd{limits} token.
According to amsmath, an index A should be below the operator, an index L is a
normal subscript; the example here shows that \Tralics\ behaves more like \TeX.
\[\lim_ax+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_ax\]
\[\textstyle \lim_lx+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_lx\]
\[\sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_ax\]
\[\textstyle \sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_lx\]



\begin{verbatim}[numbers=left,firstnumber=last]
\[\operatorname*{sin}_a \operatornamewithlimits{sin}_a \qopname\relax{n}{sin}_a
\operatorname{sin}_l  \qopname\relax{o}{sin}_l
\mathop{\rm sin}_a\mathop{\rm sin}\limits_a\]
\[\textstyle\operatorname*{sin}_l \operatornamewithlimits{sin}_l
 \qopname\relax{n}{sin}_l\operatorname{sin}_l  \qopname\relax{o}{sin}_l
\mathop{\rm sin}_l\mathop{\rm sin}\limits_a\]
\end{verbatim}
These are \LaTeX\ commands that can define operators like sin or lim:
\[\operatorname*{sin}_a \operatornamewithlimits{sin}_a \qopname\relax{n}{sin}_a
\operatorname{sin}_l  \qopname\relax{o}{sin}_l
\mathop{\rm sin}_a\mathop{\rm sin}\limits_a\]
\[\textstyle\operatorname*{sin}_l \operatornamewithlimits{sin}_l
 \qopname\relax{n}{sin}_l\operatorname{sin}_l  \qopname\relax{o}{sin}_l
\mathop{\rm sin}_l\mathop{\rm sin}\limits_a\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[\sum_{\scriptstyle0\le i\le m\atop\scriptstyle0<j<n}P(i,j)\qquad
\sum_{\stackrel{0\le i\le m}{0<j<n}}P(i,j)\]
\end{verbatim}
In the first expression given here, and in exercise 17.9 that follows, scripts
use an explicit `script style' command, hence should be typeset in scriptstyle
size. This is not the case in the HTML version: we have an atop in an atop,
and the style of the inner one is wrong.  The second formula uses a \LaTeX\
command, this is not the right command for stacking indices because the first
argument uses a smaller style than the second. It seems to me that the top
line of first formula, bottom line of the second formula have the right
size. Other lines are too big (in Firefox) or much too small (in Amaya).

\[\sum_{\scriptstyle0\le i\le m\atop\scriptstyle0<j<n}P(i,j), \qquad
\sum_{\stackrel{0\le i\le m}{0<j<n}}P(i,j)\]

\ex{17.8} $\displaystyle \sum_{i=1}^p\sum_{j=1}^q\sum_{k=1}^ra_{ij}b_{jk}c_{ki}$. 
\ex{17.9} 
\def\Atop#1#2{\genfrac{}{}{0pt}{1}{#1}{#2}}
 $\displaystyle \sum\limits_{{\scriptstyle1\le i\le n\atop\scriptstyle 1\le
  j\le q}\atop \scriptstyle 1\le k\le r}
a_{ij}b_{jk}c_{ki}$ or 
 $\displaystyle \sum\limits_{\scriptstyle1\le i\le n\atop{\scriptstyle 1\le
  j\le q\atop \scriptstyle 1\le k\le r}}
a_{ij}b_{jk}c_{ki}$.  

\begin{verbatim}[numbers=left,firstnumber=last]
\[\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+x}}}}}}}\]
\end{verbatim}
\[\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+x}}}}}}}.\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \left(\left[\left\lbrack a\left\{\left\lbrace\left\lfloor b
\left\lceil\left\langle\left/ c\left|\left\|\left\uparrow d
\left\downarrow\left\updownarrow\frac 12 \right\Updownarrow
\right\downarrow t
\right\Uparrow\right\Vert\right\vert x\right\backslash\right\rangle
\right\rceil y \right\rfloor\right\rbrace\right\} z\right\rbrack\right]\right)\]
\end{verbatim}
\[ \left(\left[\left\lbrack a\left\{\left\lbrace\left\lfloor b
\left\lceil\left\langle\left/ c\left|\left\|\left\uparrow d
\left\downarrow\left\updownarrow\frac 12 \right\Updownarrow
\right\downarrow t
\right\Uparrow\right\Vert\right\vert x\right\backslash\right\rangle
\right\rceil y \right\rfloor\right\rbrace\right\} z\right\rbrack\right]\right)\]
We would expect all delimiters to be of the same size; but not all characters
can be indefinitely extensible. On Firefox, we see a large slash, reverse
slash and angle brackets; all other characters have maximum size. On Amaya,
slash and reverse slash have a normal size, as well as double vertical bars;
on \textit{AM} some delimiters are replaced by a question sign, namely floor,
ceiling, angle brackets, reverse slash and arrows (on following formulas,
arrows are however visible). AF uses floor instead of ceiling and vice-versa. 
On \textit{FM} the rendering of up-down-array is wrong.  



There are problems  with slash, backslash, double vertical bar on \Tralics\
2.9.4. Concerning the double vertical bar, the following expression contains
two different characters: $\csname @Vert\endcsname=\Vert$. The first
character is Unicode U+2016 (entity \entity{Vert} in the file
\filename{mmlalias.ent}), obtained by \cmd{Vert} in \Tralics\ 2.9.4, accessible
as \cmd{@Vert} in following versions, it is not shwon by Amaya; 
the second character is Unicode U+2225
(entity \entity{DoubleVerticalBar}, \entity{parallel} and \entity{shortparallel}
in the file \filename{mmlalias.ent}), obtained by \cmd{parallel} in \Tralics\
2.9.4, and also by \cmd{Vert} in following versions. We changed this because  
the first character has fixed size as the following demonstrates
 $\csname@Vert\endcsname\frac12\Vert$ (the effect is  only visible in HTML
 with FM).


Translation of backslash changed: it is now Unicode U+2216, you can use
the backslash character (Unicode U+5C) by saying \cmd{char`}\cmd{\HAT\HAT5c}.
Example: old is $X\char`\^^5c Y$, new is $X\backslash Y$, note the different
spacing. 


Example of \cmd{bigl} and \cmd{bigr}, followed by the same code without these
operations; currently there is no difference in the HTML version; in the Pdf
there is more space in the equations on the LHS between closing brace and
opening brace (same for bracket).
\[ \bigl (x-s(x)\bigr)\bigl(y-s(y)\bigr) \qquad (x-s(x))(y-s(y))\]
\[ \bigl [x-s[x]\bigr]\bigl[y-s[y]\bigr] \qquad [x-s[x]][y-s[y]]\]
\[ \bigl| |x|- |y| \bigr| \qquad | |x|- |y| |\]

Example of big
\begin{verbatim}[numbers=left,firstnumber=last]
\[ \big(\big[\big\lbrack \big\{\big\lbrace\big\lfloor 
\big\lceil\big\langle\big/ \big|\big\|\big\uparrow 
\big\downarrow\big\updownarrow\frac 12 \big\Updownarrow
\big\downarrow \big\Uparrow\big\Vert\big\vert \big\backslash\big\rangle
\big\rceil\big\rfloor\big\rbrace\big\}\big\rbrack\big]\big)\]
\end{verbatim}
\[ \big(\big[\big\lbrack \big\{\big\lbrace\big\lfloor 
\big\lceil\big\langle\big/ \big|\big\|\big\uparrow 
\big\downarrow\big\updownarrow\frac 12 \big\Updownarrow
\big\downarrow \big\Uparrow\big\Vert\big\vert \big\backslash\big\rangle
\big\rceil\big\rfloor\big\rbrace\big\}\big\rbrack\big]\big)\]
I see the following: every up to the slash,  and starting with the backslash
is big; remaining items are small in the Pdf version, big in Firefox, 
sometimes small, sometimes large in Amaya.

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \big(\bigl[\Big\lbrack \Bigl\{\bigg\lbrace\biggl\lfloor 
\Bigg\lceil\Biggl\langle /|\|\uparrow \downarrow\updownarrow\frac 12 
\Updownarrow\downarrow\Uparrow\Vert\vert\backslash
\Biggr\rangle\Bigg\rceil\biggr\rfloor\bigg\rbrace\Bigr\}\Big\rbrack\bigr]\big)\]
\end{verbatim}
A formula with all variants

\[ \big(\bigl[\Big\lbrack \Bigl\{\bigg\lbrace\biggl\lfloor 
\Bigg\lceil\Biggl\langle /|\|\uparrow \downarrow\updownarrow\frac 12 
\Updownarrow\downarrow\Uparrow\Vert\vert\backslash
\Biggr\rangle\Bigg\rceil\biggr\rfloor\bigg\rbrace\Bigr\}\Big\rbrack\bigr]\big)\]
Up to version 2.9.4, there was a bug in handling these big things.
Currently, \Tralics\ inserts \cmd{left} and \cmd{right} delimiters wherever
possible. In the Pdf version, this formula is identical to the previous one.
In firefox, operators between slash and backslash (that have no big) are small
before the fraction, large after that. This is strange. In Amaya, everything
between the slash and the backslash is small, except the \cmd{vert}. 

\ex{17.10} $\displaystyle\biggl({\partial^2\over\partial x^2}+
{\partial^2\over\partial y^2}\biggr)\bigl|\varphi(x+iy)\bigr|^2=0$.

\begin{verbatim}[numbers=left,firstnumber=last]
Phi is $\phi,^^^^03c6$, ^^^^03c6  and varphi is $\varphi,^^^^03d5$, ^^^^03d5, 
\end{verbatim}
There is a problem in the rendering of the letter phi; the straight phi
character is Unicode  U+03D5. As the example given here shows, the rendering
of phi and varphi in math mode, at least on my machine: 
Phi is $\phi,^^^^03c6$, ^^^^03c6  and varphi is $\varphi,^^^^03d5$, ^^^^03d5, 
epsilon is $\epsilon$, varepsilon is $\varepsilon$. We changed the
translation, so that the Firefox and Pdf versions show, in math mode, the
desired result. Note that AM shows the same characeter for phoi ad varphi in
math mode, and has trouble with epsilon(shown as a square).

\begin{verbatim}[numbers=left,firstnumber=last]
$\bigl (x\in A(n)\bigm|x\in B(n)\bigr)$, 
$\bigcup_n X_n\bigm\|\bigcap_n Y_n$,
$\displaystyle{ {a+1\over b}\bigg/{c+1\over d}}$
\end{verbatim}
Other big $\bigl( x\in A(n)\bigm|x\in B(n)\bigr)$ and
$\bigcup_n X_n\bigm\|\bigcap_n Y_n$ and
$\displaystyle{ {a+1\over b}\bigg/{c+1\over d}}$.
\ex{17.12} $\bigl(x+ f(x)\bigr)\big/\bigl(x- f(x)\bigr)$.
\begin{verbatim}[numbers=left,firstnumber=last]
\[1+\left(\frac{1}{1-x^2}\right)^3,\qquad \pi(n)=\sum_{k=2}^n 
\left\lfloor\frac{\phi(k)}{k-1}\right\rfloor, \qquad
\left|\left|x\right|-|\left|y\right|\right|, \qquad
\left(\sum_{k=1}^n A_k\right),\qquad  \biggl(\sum_{k=1}^n A_k\biggr)\]
\end{verbatim}
\ex{17.13}
Comparison between \cmd{left} and \cmd{bigl}; translation is the same in
\Tralics. 
\[1+\left(\frac{1}{1-x^2}\right)^3,\qquad \pi(n)=\sum_{k=2}^n 
\left\lfloor\frac{\phi(k)}{k-1}\right\rfloor, \qquad
\left|\left|x\right|-\left|y\right|\right|, \qquad
\left(\sum_{k=1}^n A_k\right),\qquad  \biggl(\sum_{k=1}^n A_k\biggr).\]

\ex{17.14} was wrong in \Tralics\ 2.9.4.
\[\pi(n) = \sum_{m=2}^n\left\lfloor\biggl(\sum_{k=1}^{m-1}\bigl\lfloor
(m/k)\big/\lceil m/k\rceil\bigr\rfloor\biggr) ^{-1}
\right\rfloor
\]

\[
|x|= \begin{cases}x,&\text{if } x\ge 0\\-x,&\text{if }x<0
\end{cases}
\]
\TeX\ sets \cmd{nulldelimiterspace}, unused by \Tralics.
\[\bigl<\frac 12\bigr> = \left<\frac 12\right> =
 \bigl\langle\frac 12\bigr\rangle = \left\langle\frac 12\right\rangle 
\]

The \cmd{vcenter} command is not implemented. 
Any box can be put into a formula by simply saying 
\cmd{hbox} or \cmd{vbox} or \cmd{vtop} or \cmd{box} or \cmd{copy}; this is not
implemented in \Tralics, you can insert text in math mode via \cmd{text} or
\cmd{hbox}. 

\ex{17.15} This shows the use of \cmd{mathchoice}.
\begin{verbatim}[numbers=left,firstnumber=last]
\def\puzzle{\mathchoice{D}{T}{S}{SS}}
\[\puzzle{\puzzle \over\puzzle^{\puzzle^\puzzle}} \qquad
\frac{\puzzle}{\puzzle^{\puzzle^\puzzle}} \]
\end{verbatim}
\def\puzzle{\mathchoice{D}{T}{S}{SS}}
\[\puzzle{\puzzle \over\puzzle^{\puzzle^\puzzle}} \qquad 
\frac{\puzzle}{\puzzle^{\puzzle^\puzzle}}\]
\ex{17.16} The \cmd{square} command is built-in: $\square$.

The \cmd{mathpalette} command is introduced in \Tralics\ 2.9.5, not tested
yet.
\begin{verbatim}[numbers=left,firstnumber=last]
\def\legendre{\overwithdelims()}\def\Legendre{\genfrac(){}{}}
\def\euler{\atopwithdelims<>}\def\Euler{\genfrac<>{0pt}{}}
\def\grimm{\abovewithdelims][4pt}\def\Grimm{\genfrac][{4pt}{}}
\[{a\legendre b}, \Legendre{a}{b}, {n \euler k}, \Euler{n}{k}, 
{\dfrac ab \grimm \dfrac cd}\Grimm{x}{y} \]
\end{verbatim}
\ex{17.17} Knuth says: the size of the surrounding delimiters depends only on
the  size, not on the size of the fractions, this is false for \Tralics:
\def\legendre{\overwithdelims()}\def\Legendre{\genfrac(){}{}}
\def\euler{\atopwithdelims<>}\def\Euler{\genfrac<>{0pt}{}}
\def\grimm{\abovewithdelims][4pt}\def\Grimm{\genfrac][{4pt}{}}
\[{a\legendre b}, \Legendre{a}{b}, {n \euler k}, \Euler{n}{k}, 
{\dfrac ab \grimm \dfrac cd}\Grimm{x}{y} \]

If $f$ is the value of \cmd{delimiterfactor} and $\delta$ the value of  
\cmd{delimitershortfall}, and we have a formula that extents $y_1$ units
above the axis, and $y_2$ units below, if $y=2\max(y_1,y_2)$, then the
delimiter size is at least $y\cdot f/1000$, and at least $y-\delta$.
This does not apply to \Tralics.

The remainder of the chapter discusses some low-level commands that are not 
fully implemented in \Tralics. The commands \cmd{textfont}, \cmd{scriptfont}
and \cmd{scriptscriptfont} take a small number as argument, and provide a
reference to a font. The following code
\begin{verbatim}[numbers=left,firstnumber=last]
\font\tenrm=somefont at 12pt
\font\Helvetica=someotherfont scaled 1013
\textfont0=\tenrm
\scriptscriptfont2=\scriptfont3
\the\fontdimen3\scriptscriptfont15
$\textfont0=\tenrm 9\hbox{$9\textfont0=\Helvetica$}$%
${\textfont0=\Helvetica 9}$ % exercise 17.18
\end{verbatim}
gives:
\font\tenrm=somefont at 12pt
\font\Helvetica=someotherfont scaled 1013
\textfont0=\tenrm
\scriptscriptfont2=\scriptfont3
\the\fontdimen3\scriptscriptfont15
$\textfont0=\tenrm 9\hbox{$9\textfont0=\Helvetica$}$%
${\textfont0=\Helvetica 9}$. % exercise 17.18. 
The dimension should be
zero, and the math formula contains three identical digits. Exercise 17.18
says that the fonts used by \TeX\ in the last case is not Helvetica.

You cannot use more than 16 different math fonts in a formula. Assume that you
need symbol A from font a; you can say that \cmd{textfont6} is your font a,
and your symbol is character 137 in that font. What if you want 
symbol B from font b? you can use font number 7, but this is obviously not the
solution. We explain here the amsmath strategy by telling what happens if you
use \cmd{tt} in a math formula. First of all, in a formula, this evaluates to
\cmd{mathtt}, and the real command is \cmd{@mathtt}. This is a self-modifying
command; after first use it is equivalent to \cmd{fam9} (this means that
normal characters in text size use the \cmd{textfont9}). The first use
allocates the number 9, and defines the font, moreover the font information is
remembered (the font \cmd{textfont9} will be defined for all subsequent math
formulas). Note that the value of \cmd{textfont9} can be cmtt12, but this is
recomputed if the current font size changes. For most other commands, the
number is allocated when the font is declared, this means that a slot is
allocated even when the font is never used.

Four slots are preallocated, with the names operators, letters, symbols and
largesymbols. If you load packages  amsmath, amscd, amssymb, and bm, four
other slots are used, and there are only 8 slots remaining. In the case of
this document, we test all 14 MathML fonts. How is this possible?
In fact some characters are typeset outside math mode (sans-serif characters
for instance) and in some cases poor-man-bold is used. Moreover, we had to
remove some font families (these are commented out in the file
\filename{raweb-uni.sty}). 

\ex{17.19} Math code are not implemented in \Tralics, \cmd{oplus} is character
U+2295 and \cmd{bullet} is character U+2022.

\begin{verbatim}[numbers=left,firstnumber=last]
\mathcode`<="2203 \mathcode`*="313C
\mathcode`a="8000 {\catcode`a=13 \gdef a{A}}
$a<b*c$ 
%\mathchardef\@M=10000
\end{verbatim}
In \TeX, the previous code is equivalent to $A*b<c$, in \Tralics, it gives:
{\mathcode`<="2203 \mathcode`*="313C
\mathcode`a="8000 {\catcode`a=13 \gdef a{A}}
$a<b*c$}. Since version 2.9.10, a capital letter A is produced.
The last line is commented out: the assignment is done at bootstrap.
You should use \cmd{@M} as the constant 10000, not as control-P in family 7
(binary operation).

Following code is unlikely to work
\begin{verbatim}[numbers=left,firstnumber=last]
\def\sum\{\mathchar"1350}
\mathchardef\sum"1350
\def\n@space{\nulldelimiterspace\z@ \m@th}
\newdimen\p@ \p@=1pt 
\def\bigl#{\mathopen{\hbox{$\left#1\vbox to8.5\p@{}\right.\n@space$}}}
\delcode `x="123456
\def\langle{\delimiter"426830A }
\bigl\delimiter"426830A
\def\sqrt{\radical"270370 }
\def\idehat{\mathaccent"362 }
\end{verbatim}
\fi

\section{Fine points of Mathematics Typing, TB 18}
\ifTeXthree

\subsection{Punctuation}
Say: If $x<0$, we have shown that \[y=f(x).\]
Do not say: for $x = a, b$, or $c$, but: for $x=a$, $b$, $c$, or use a tie:
or~$c$. 
\ex{18.1} $R(n,t)=O(t^{n/2})$, as $t\to0^+$. Adding braces improves the Html version: ${R(n,t)}=O(t^{n/2})$.
\subsection{Non-italics letters in formulas}

\TeX\ has 32 predefined operators, some of them behave like sums according to
the placement of limits. 
\[\arccos_x +\arcsin_x + \arctan_x + \arg_x + \cos_x +
\cosh_x + \cot_x + \coth_x + \csc_x + \deg_x \]
\[\det_x +\dim_x + \exp_x + \gcd_x + \hom_x +\inf_x +\ker_x+
  \lg_x+  \lim_x+  \liminf_x\]
\[  \limsup_x+ \ln_x+   \log_x+  \max_x +  \min_x+  \Pr_x +
  \sec_x +   \sin_x +   \sinh_x +   \sup_x \]
\[   \tan_x  +\tanh_x + \injlim_x +\projlim_x\]
The last two operators are defined by amsmath. Variants shown later. More
formulas (there should be small space around these operators, that is
invisibile on my browser).
\begin{gather}
\sin2\theta=2\sin\theta\cos\theta\\
O(n\log n\log\log n)\\
Pr(X>x)=\exp(-x/\mu)\\
\displaystyle \max_{1\le n\le m}\log_2P_n\\
\displaystyle \lim_{x\to0}\frac{\sin x}{x}=1
\end{gather}
\ex{18.2}
\[p_1(n)=\lim_{m\to\infty}\sum_{\nu=0}^\infty\big(1-\cos^{2m}(\nu!^n\pi/n)\big)\]
Example of formulas using \cmd{rm}:
$\sqrt{{\rm Var}(X)}$, $x_{\rm max}-x_{\rm min}$,
${\rm LL}(k)\Rightarrow{\rm LR}(k)$, $\exp(x+{\rm constant})$,
and $x^3+{\rm lower\ order\ terms}$.

Some formulas using \cmd{hbox} for roman font:
$\sqrt{\hbox{Var}(X)}$,
$\hbox{LL}(k)\Rightarrow\hbox{LR}(k)$, $\exp(x+\hbox{constant})$,
and $x^3+\hbox{lower order terms}$.

The same formulas using \cmd{text} for roman font:
$\sqrt{\text{Var}(X)}$,
$\text{LL}(k)\Rightarrow\text{LR}(k)$, $\exp(x+\text{constant})$,
and $x^3+\text{lower order terms}$.

\begin{verbatim}[numbers=left,firstnumber=last]
\def\Varliminf{\mathop{\underline{\mathmo{lim}}}}
\def\Varlimsup{\mathop{\overline{\mathmo{lim}}}}
\[\lim_{n\to\infty}x_n\text{ exists}\iff 
\Varlimsup_{n\to\infty}x_n=\Varliminf_{n\to\infty}x_n.\]
\end{verbatim}

\ex{18.3}
\def\Varliminf{\mathop{\underline{\mathmo{lim}}}}
\def\Varlimsup{\mathop{\overline{\mathmo{lim}}}}
\[
\lim_{n\to\infty}x_n\text{ exists}\iff 
\limsup_{n\to\infty}x_n=\liminf_{n\to\infty}x_n.\]

\[
\lim_{n\to\infty}x_n\text{ exists}\iff 
\Varlimsup_{n\to\infty}x_n=\Varliminf_{n\to\infty}x_n.\]

The code above is wrong, because `lim' is a known operator, with movable
limits, hence, in non-display mode, both the underline and the real subscript
will move. The real definitions adds
\attpair{movablelimits}{false} to the operator. 

\begin{verbatim}[numbers=left,firstnumber=last]
$\gcd(m,n)=\gcd(n,m\bmod n)$, or $x\equiv y+1\pmod{m^2}$
$x\equiv0(\pmod y^n)$.
\end{verbatim}
Modulo: $\gcd(m,n)=\gcd(n,m\bmod n)$, or $x\equiv y+1\pmod{m^2}$
\ex{18.4} B.L. User got the unexpected formula $x\equiv0(\pmod y^n)$. 


\ex{18.5} In this example, there are braces around \LTC{n/p}, but not
\LTC{k/p}; this can affect the size of the slash operator (HTML version only).
\[\binom nk \equiv\binom{\lfloor {n/p}\rfloor}{\lfloor k/p\rfloor}
\binom{n \bmod p}{k \bmod p}\pmod p\]

Example of bold face $\bf a+b=\Phi_m$; normal Phi is U+03A6, bold Phi is
U+1D6BD, italic Phi is U+1D6F7, bold italic Phi is U+1D731, sans serif bold
Phi is U+1D76B, sans serif bold italic Phi is U+1D7A5. In the current version
of \Tralics, font changes apply only to ASCII letters. Commands like \cmd{cal}
are robust, so that 
\LTC{\$\textbackslash cal Ab\textbackslash Phi\$} produces $\cal Ab\Phi$;
command \cmd{mit} is not implemented. Note that in some cases, digits and
lower case letters do not exist in the font, and may be replaced by random
glyphs. 


\ex{18.6} If you want
$\bf\bar x^{\rm T}Mx={\rm0}\iff x=0$ in 
\Tralics\ 2.9.4, you have to explicitly say that you want a bold face zero, 
and an upright T, see below. In version 2.9.5, nothing special needed.
Note how we use colon-equal here.
\begin{verbatim}[numbers=left,firstnumber=last]
$\bf\bar x^{\mathmo{T}}Mx={\rm0}\iff x=\mathmn[mathvariant][bold]{0}$
Compare $This\ is\ math\ italics$ with {\it This is text italics}.
Compare $different$ and $\it different$. We have also
$\it last\mathmo{:=}first$, $\it x\_coord(point\_2)$
\end{verbatim}
Compare $This\ is\ math\ italics$ with {\it This is text italics}.
Compare $different$ and $\it different$. We have also
$\it last\mathmo{:=}first$, $\it x\_coord(point\_2)$. 

\ex{18.8} We use \cmd{mathit} instead of \cmd{it} here.
\[\mathit{available} +\sum_{i=1}^n\max(\mathit{full}(i),
\mathit{reserved}(i))= \mathit{capacity}\]

\ex{18.9} 
The following code was obtaining by taking the answer from the \TeX
book, with the following modifications: the \cmd{sfcode} of the semi colon not
changed; math formulas put outside scope of \cmd{bf}, because my browser shows
letters (not digits) in bold face otherwise. Note that the XML to HTML
processor converted the whole environment (seven paragraphs) into a single
paragraph 
with \elt{br} as separator (inter-paragraph width too big), and a huge
left margin (for fun). We show here the start of the code:
\begin{verbatim}[numbers=left,firstnumber=last]
\begin{xmlelement+}{pseudocode}\XMLaddatt{leftskip}{5cm}
\obeylines
\def\coleq{\mathmo{:=}}
\textbf{for} $j\coleq 2$ \textbf{step} $1$ \textbf{until} $n$ \textbf{do}
...
\end{xmlelement+}
\end{verbatim}


\begin{xmlelement+}{pseudocode}\XMLaddatt{leftskip}{5cm}
\obeylines
\def\coleq{\mathmo{:=}}
\textbf{for} $j\coleq 2$ \textbf{step} $1$ \textbf{until} $n$ \textbf{do}
\quad \textbf{begin} $\textit{accum}\coleq A[j]$; $k\coleq j-1$; $A[0]\coleq \mathit{accum}$;
\quad \textbf{while} $A[k]>\textit{accum}$ \textbf{do}
\qquad \textbf{begin} $A[k+1]\coleq A[k]$; $k\coleq k-1$;
\qquad \textbf{end};
\quad $A[k+1]\coleq \textit{accum}$;
\quad \textbf{end}.\par
\end{xmlelement+}

\subsection{Spacing between formulas}
Compare
\[F_n=F_{n-1}+F_{n-2}, n\ge 2.\]
with (lot of white space in the formula)
\[ F_n = F_{n-1} + F_{n-2}, \qquad n \ge 2. \]
and (no unnecessary white space in the formula)
\[F_n=F_{n-1}+F_{n-2},\hskip2em\relax n\ge2.\]
Normally, the spacing should be the same in the last two formulas. 
In fact, Knuth says that \cmd{quad} is the same as \cmd{hskip 1em}\cmd{relax}.
The translation of a \cmd{quad} in math mode is \elt{mspace width="1.em"},
but the \cmd{hskip} command reads a dimension, and converts one em into ten
points\footnote{Maybe, one day, \Tralics\ will have an em that depends on the context}. 

\ex{18.10} Three versions:

Let $H$~be a Hilbert space, \ $C$~a closed bounded convex subset
of~$H$, \ $T$~a non-expansive self map of~$C$. Suppose that as 
$n\to\infty$, \ $a_{n,k}\to0$ for each~$k$, and 
$\gamma_n=\sum_{k=0}^\infty(a_{n,k+1}-a_{n,k})^+\to0$. 
Then for each $x$~in~$C$, \ $A_nx=\sum_{k=0}^\infty a_{n,k}T^kx$ converges
weakly to a fixed point of~$T$.

Let $H$~be a Hilbert space,~~$C$~a closed bounded convex subset
of~$H$,~~$T$~a non-expansive self map of~$C$. Suppose that as 
$n\to\infty$,~~$a_{n,k}\to0$ for each~$k$, and 
$\gamma_n=\sum_{k=0}^\infty(a_{n,k+1}-a_{n,k})^+\to0$. 
Then for each $x$~in~$C$,~~$A_nx=\sum_{k=0}^\infty a_{n,k}T^kx$ converges
weakly to a fixed point of~$T$.

Let $C$ be a closed, bounded, convex subset of a Hilbert space $H$,
and let $T$ be a non-expansive self map of $C$. Suppose that as 
$n\to\infty$, we have $a_{n,k}\to0$ for each $k$, and 
$\gamma_n=\sum_{k=0}^\infty(a_{n,k+1}-a_{n,k})^+\to0$. 
Then for each $x$ in $C$, the infinite sum 
$A_nx=\sum_{k=0}^\infty a_{n,k}T^kx$ converges weakly to a fixed point of $T$.

Comments: the translation of the three characters: space, backslash, space is
formed of two spaces. Such a construct is used four times in the first
version. This produces a nice dvi file, but HTML interprets the double space
the same as a single space. In the second version, we have used a double tilde
character. This inhibits line breaks. (My browser does not seem to honor this).
No special characters appear in the last example. 

\subsection{Spacing within formulas}
\begin{verbatim}[numbers=left,firstnumber=last]
$a\,b\>c\;d\!e\quad f\qquad g\ h$~j
%\the\thinmuskip\the\medmuskip\the\thickmuskip
\end{verbatim}
The math spacing commands: $a\,b\>c\;d\!e\quad f\qquad g\ h~j$.
In \TeX, the value of the glue inserted depends on three registers:
\cmd{thinmuskip} (3mu), \cmd{medmuskip}
(4mu plus 2mu minus 4mu) and \cmd{thickmuskip} (5mu plus 5mu). You can try to
execute the line above that is commented out: all dimensions come out as 0mu
in \Tralics, but the math formula contains  0.166667em, 0.222222em, 0.277778em,
etc, this is the same as 3mu, 4mu and 5mu, because  1em=18mu. In \Tralics,
\cmd{mskip 18mu} is equivalent to \cmd{hskip1em}, and, as said above, this is
the same as \cmd{hskip10pt}. The same is true for \cmd{mkern18mu}; the
translation is an empty \elt{mspace} element, with attribute
\attpair{value}{10.0pt}. The amount of space given by backslash-space changed
from 6pt to 4pt (this is the same amount of space used by the \cmd{text}
command). 

\begin{verbatim}[numbers=left,firstnumber=last]
$\int_0^\infty f(x)\,dx$, $y\,dx-x\,dy$, $dx\,dy=r\,dr\,d\theta$, $x\,dy/dx$
\end{verbatim}
Translation $\int_0^\infty f(x)\,dx$, $y\,dx-x\,dy$, $dx\,dy=r\,dr\,d\theta$,
$x\,dy/dx$.
\ex{18.11}
\[ \int_1^x\frac{dt}{t}\qquad \int_0^\infty\frac{t-ib}{t^2+b^2}e^{iat}\,dt=
e^{ab}E_1(ab),\qquad a,b>0\]
\begin{verbatim}[numbers=left,firstnumber=last]
$55\,\mathrm{mi/hr}$, $g=9.8\,\mathrm{m/sec}^2$,
$1\mathrm{ml}=1.000028\,\mathrm{cc}$ 
\end{verbatim}
Units: $55\,\mathrm{mi/hr}$, $g=9.8\,\mathrm{m/sec}^2$,
$1\mathrm{ml}=1.000028\,\mathrm{cc}$. Note that digits are outside the scope
of \cmd{mathrm}.
\ex{18.12} Inline math, displaystyle: 
$\displaystyle\hbar=1.054\times10^{-27}\,\mathrm{erg}\,\mathrm{sec}.$
\begin{verbatim}[numbers=left,firstnumber=last]
$(2n)!/\bigl(n!\,(n+1)!\bigr)$, $\sqrt2\,x$,
$\sqrt{\,\log x}$, $O\bigl(1/\sqrt n\,\bigr)$,
$[\,0,1)$, $\log n\,(\log\log n)^2$, $x^2\!/2$, $n/\!\log n$, 
$\Gamma_{\!2}+\Delta^{\!2}$, $R_i{}^j{}_{\!kl}$, $\int_0^x\!\int_0^y dF(u,v)$ 
 \[\frac{52!}{13!\,13!\,26!}\qquad \int\!\!\!\int_D dx\,dy\]
\end{verbatim}
Test:
$(2n)!/\bigl(n!\,(n+1)!\bigr)$, $\sqrt2\,x$,
$\sqrt{\,\log x}$, $O\bigl(1/\sqrt n\,\bigr)$,
$[\,0,1)$, $\log n\,(\log\log n)^2$, $x^2\!/2$, $n/\!\log n$, 
$\Gamma_{\!2}+\Delta^{\!2}$, $R_i{}^j{}_{\!kl}$, $\int_0^x\!\int_0^y dF(u,v)$ 
\[\frac{52!}{13!\,13!\,26!}\qquad \int\!\!\!\int_D dx\,dy\]
%
Same formulas, without thin spaces\\
Test:
$(2n)!/\bigl(n!(n+1)!\bigr)$, $\sqrt2 x$,
$\sqrt{\log x}$, $O\bigl(1/\sqrt n\bigr)$,
$[0,1)$, $\log n(\log\log n)^2$, $x^2/2$, $n/\log n$, 
$\Gamma_{2}+\Delta^{2}$, $R_i{}^j{}_{kl}$, $\int_0^x\int_0^y dF(u,v)$ 
\[\frac{52!}{13!13!26!}\qquad \int\int_D dx\,dy\]

Amaya shows a strange behavior here. Without the space the first integral is
larger than the second. In thee case of negative space, the absolute value is
used. 

\ex{18.14} intervals with left/right: 
$\left]-\infty,T\right[\times\left]-\infty,T\right[$;
with mathopen, mathclose 
$\mathopen]-\infty,T\mathclose[\times\mathopen]-\infty,T\mathclose[$;
with nothing $]-\infty,T[\times]-\infty,T[$. And with left/right: 
$\left]-\infty,\frac{3}{4}\right[\times\left]-\infty,\frac{3}{4}\right[$;
with mathopen, mathclose 
$\mathopen]-\infty,\frac{3}{4}\mathclose[\times\mathopen]-\infty,\frac{3}{4}\mathclose[$;
with nothing $]-\infty,\frac{3}{4}[\times]-\infty,\frac{3}{4}[$.

\ex{18.15} The spacing in $x++1$  differs between \TeX\ and MathML.

\subsection{Ellipses}
\begin{verbatim}[numbers=left,firstnumber=last]
$x_1+\cdots+x_n$, $x_1=\cdots=x_n=0$, $A_1\times\cdots\times A_n$,
$f(x_1,\ldots,x_n)$, $x_1x_2\ldots x_n$, $(1-x)(1-x^2)\ldots(1-x^n)$,
$n(n-1)\ldots(1)$.
\end{verbatim}
Translation of these formulas $x_1+\cdots+x_n$, $x_1=\cdots=x_n=0$, $A_1\times\cdots\times A_n$,
$f(x_1,\ldots,x_n)$, $x_1x_2\ldots x_n$, $(1-x)(1-x^2)\ldots(1-x^n)$,
$n(n-1)\ldots(1)$.
\ex{18.16} Answer $x_1+x_1x_2+\cdots+ x_1x_2\ldots x_n$,
$(x_1,\ldots,x_n)\cdot(y_1,\ldots,y_n)=x_1y_1+\cdots+x_ny_n$.
Prove that $(1-x)^{-1}=1+x+x^2+\cdots\,$. Clearly $a_i<b_i$, for $i=1$,~2,
$\ldots\,$,~$n$. The coefficients $c_0$,~$c_1$, \dots,~$c_n$ are positive.
With braces surrounding the LHS: ${(1-x)^{-1}}=1+x+x^2+\cdots\,$.

\ex{18.17} Clearly $a_i<b_i$, for $i=1,2,\ldots,n$.  Note that the `2' here is
a math digit, while it is text digit in the sentence above.
\ex{18.18} Knuth used \cmd{dots}.

\subsection{Line breaking}
The \TeX\ book explains how \TeX\ can break a math formula. This does not
apply to \Tralics. Commands \cmd{nobreak} and \cmd{allowbreak}
do nothing in math mode.

\subsection{Braces}
You should use braces only for grouping. You can use a brace character via
\cmd{\char`\{} in text or math mode. This character is a delimiter (it can be
preceded by \cmd{left} or \cmd{big}).
\begin{verbatim}[numbers=left,firstnumber=last]
$\{a,b,c\}$, $\{1,2,\ldots,n\}$, $\{\mathrm{red,white,blue}\}$
$\{\,x\mid x>5\,\}$, $\{\,x:x>5\,\}$, 
$\bigl\{\,\bigl(x,f(x)\bigr)\bigm|x\in D\,\big\}$
$\bigl\{\,\bigl(x,f(x)\bigr)\bigm\mid x \in D\,\big\}$
$\bigl\{\,\bigl(x,f(x)\bigr)\mid x\in D\,\big\}$
\end{verbatim}

Translation
$\{a,b,c\}$, $\{1,2,\ldots,n\}$, $\{\mathrm{red,white,blue}\}$,
$\{\,x\mid x>5\,\}$, $\{\,x:x>5\,\}$,
$\bigl\{\,\bigl(x,f(x)\bigr)\bigm|x\in D\,\big\}$
$\bigl\{\,\bigl(x,f(x)\bigr)|x\in D\,\big\}$.
Note that \cmd{mid} gives better spacing than a single bar
$\bigl\{\,\bigl(x,f(x)\bigr)\bigm\mid x \in D\,\big\}$,
$\bigl\{\,\bigl(x,f(x)\bigr)\mid x\in D\,\big\}$.
\ex{18.21} $\bigl\{x^3\mid h(x) \in\{-1,0,+1\}\,\bigr\}$
\ex{18.22} $\{\,p\mid p$~and $p+2$ are prime$\,\}$.

We show here the use of the cases enviroment, this is a two-column cmatrix,
with a left brace delimiter on the left.
\[|x| = \begin{cases}x,&\text{if } x\ge 0;\\-x,&\text{otherwise}.
 \end{cases}\]
\[f(x) = \begin{cases}1/3&\text{if } 0\le x\le 1;\\
2/3&\text{if } 3\le x\le 4;\\[3mm]
1/3&\text{elsewhere};
\end{cases}\]
\ex{18.23} The \cmd{cases} command is not implemented, but there is 
a environment. You cannot use \cmd{noalign}. After a double backslash you can
put a dimension in brackets, but this is currently ignored. 
\begin{verbatim}[numbers=left,firstnumber=last]
\[\overbrace{x+\cdots+x}^{k\; \textrm{times}} \qquad \underbrace{x+y+z}_{>\,0}\]
\end{verbatim}
We show here braces can stretch horizontally, when used as over-accent or
under-accent.  
\[
\overbrace{x+\cdots+x}^{k\; \textrm{times}} \qquad 
\underbrace{x+y+z}_{>\,0}
\]

\subsection{Matrices}
The plain \TeX\ command \cmd{matrix} should not be used. The `array'
environment can be used in math mode, and you must specify for each column the
alignment method. The `matrix' environment can be used, cells are centered. He
we use `pmatrix', because it adds automatically parentheses. In
\Tralics\ 2.14.2 there is a possibility to put an attribute pair on
the current table. 
\begin{verbatim}[numbers=left,firstnumber=last]
\[A=\begin{pmatrix}x-\lambda&1&0\\0&x-\lambda&1\\0&0&x-\lambda\end{pmatrix}\]
\[\begin{pmatrix}a&b&c\\d&e&f\tableattribute{A}{B}\end{pmatrix}\mathattribute{C}{D}
\begin{pmatrix}u&x\\v&y\\w&z\end{pmatrix}\]
\end{verbatim}
\[A=\begin{pmatrix}x-\lambda&1&0\\0&x-\lambda&1\\0&0&x-\lambda\end{pmatrix}\]
\[\begin{pmatrix}a&b&c\\d&e&f\tableattribute{A}{B}\end{pmatrix}\mathattribute{C}{D}
\begin{pmatrix}u&x\\v&y\\w&z\end{pmatrix}\]
\ex{18.24} This looks bad in the HTML version, but it OK is Pdf. Delimiters
are \cmd{lgroup} and \cmd{rgroup}.
\[\left\lgroup\begin{matrix}a&b&c\\d&e&f\end{matrix}\right\rgroup
\left\lgroup\begin{matrix}u&x\\v&y\\w&z\end{matrix}\right\rgroup\]

\ex{18.25}
\[A=\begin{pmatrix}
a_{11}&a_{12}&\ldots&a_{1n}\\
a_{21}&a_{22}&\ldots&a_{2n}\\
\vdots&\vdots&\ddots&\vdots\\
a_{m1}&a_{m2}&\ldots&a_{mn}\\
\end{pmatrix}\qquad \begin{pmatrix}y_1\\\vdots\\y_k\end{pmatrix}\]

Border matrix\footnote{Command \cmd{bordermatrix} not yet implemented}

\def\Atop#1#2{\genfrac{}{}{0pt}{}{#1}{#2}}
Small matrices $\binom{1\,1}{0\,0}$ and $\bigl(
\Atop{a}{l}\Atop{b}{m}\Atop{c}{n}\bigr)$. Note that horizontal alignment is
only approximative.

\subsection{Vertical Spacing}
\begin{verbatim}[numbers=left,firstnumber=last]
\def\Limsup{\mathop{\smash\limsup\vphantom\liminf}}
$\Limsup\limits_3=\limsup\limits_3$
\end{verbatim}
\def\Limsup{\mathop{\smash\limsup\vphantom\liminf}}
Compare: $\Limsup\limits_3=\limsup\limits_3$! The second index should be lower
than the first.

Commands \cmd{raise} and  \cmd{lower} not yet implemented. 
Commands \cmd{llap} and  \cmd{rlap} not yet implemented.\footnote{Fixme}

\begin{verbatim}[numbers=left,firstnumber=last]
\def\undertext#1{$\underline{\hbox{#1}}$}
\undertext{This} \undertext{does} \undertext{not} \undertext{always}
\undertext{work} \undertext{right}. 
\def\undertext#1{$\underline{\smash{\hbox{#1}}}$}
\undertext{This} \undertext{does} \undertext{not} \undertext{always}
\undertext{work} \undertext{right}.
\end{verbatim}
\ex{18.26} 
\def\undertext#1{$\underline{\hbox{#1}}$} A sentence where each word is an
underlined math formula (text only):
\undertext{This} \undertext{does} \undertext{not} \undertext{always}
\undertext{work} \undertext{right}. The same, where the \cmd{smash} is used to
hide the depth of the text (all lines vertically aligned):
\def\undertext#1{$\underline{\smash{\hbox{#1}}}$}
\undertext{This} \undertext{does} \undertext{not} \undertext{always}
\undertext{work} \undertext{right}.

\begin{verbatim}[numbers=left,firstnumber=last]
$\rm Fe_2^{+2}Cr_2^{\vphantom{+2}}O_4^{\vphantom{+2}}$
\end{verbatim}
Use of phantoms: $\rm Fe_2^{+2}Cr_2^{\vphantom{+2}}O_4^{\vphantom{+2}}$

\subsection{Special features for math hackers}

Commands \cmd{nonscript}, \cmd{everymath} and \cmd{everydisplay} are OK.
\begin{verbatim}[numbers=left,firstnumber=last]
{\everydisplay{a}\everymath{b} \def\X{x\nonscript\qquad y}
\[u = \text{ v $w$ }\frac{\X}{\textstyle\X} \]}
\end{verbatim}
{\everydisplay{a}\everymath{b} \def\X{x\nonscript\qquad y}
\[u = \text{ v $w$ }\tfrac{\scriptstyle\X}{\textstyle\X} \]}


\subsection{Summary}

\ex{18.27} $n^{\rm th}$ from the \TeX book, $n^{\mathrm{th}}$ is \LaTeX, and
$n$\textsuperscript{th} is textsuperscript.  
\ex{18.28} $\textbf{S^{\mathnormal{-1}} TS=dg}(\omega_1,\ldots,\omega_n)
\textbf{\Lambda}$, uses \cmd{mathnormal}, no bf lambda?
\ex{18.29} $\Pr(\,m=n\mid m+n=3\,)$.
\ex{18.30} $\sin18^\circ=\frac14(\sqrt5-1)$.
\ex{18.31} $k=1.38\times10^{-16}\,\mathrm{erg}/^\circ \mathrm{K}$.
\ex{18.32} $\bar\Phi\subset NL_1^*/N=\bar L_1^*\subseteq\cdots\subseteq 
NL_n^*/N=\bar L_n^*$.
\ex{18.33} $I(\lambda)=\int\!\!\int_Dg(x,y)e^{i\lambda h(x,y)}\,dx\,dy$.
\ex{18.34} $\int_0^1\!\cdots\int_0^1f(x_1,\ldots,x_n)\,dx_1\ldots\,dx_n$.
Note: Firefox shows small integral signs, and larger ones in the previous
exercise. 
\ex{18.35} Using cases environment
\[x_{2m}\equiv\begin{cases}Q(X_m^2-P_2W_m^2)-2S^2& (m\text{ odd})\\[2pt]
P_2^2(X_m^2-P_2W_m^2)-2S^2& (m\text{ even})
\end{cases} \pmod N.\]
\ex{18.36} with a \cmd{frac}
\[(1+x_1z+x_1^2z+\cdots\,)\ldots(1+x_nz+x_n^2z^2+\cdots\,)=
\frac{1}{(1-x_1z)\ldots(1-x_nz)}\]
\ex{18.37}
\[\prod_{j\ge0}\biggl(\sum_{k\ge0}a_{jk}z^k\biggr)=\sum_{n\ge0}z^n\,\Biggl(
\sum_{\scriptstyle k_0,k_1,\ldots\ge0\atop\scriptstyle k_0+k_1+\cdots=n}
a_{0k_0}a_{1k_1}\ldots\,\biggr).\]
\ex{18.38} Using \cmd{frac} and \cmd{binom}
\[\frac{(n_1+n_2+\cdots+n_m)!}{n_1!\,n_2!\ldots n_m!}=
\binom{n_1+n_2}{n_2}\binom{n_1+n_2+n_3}{n_3}\ldots\binom{n_1+n_2+\cdots+n_m}{n_m}.\]
\ex{18.39} Using \cmd{genfrac}
\[\def\\#1#2{(1-q^{#1_#2+n})}
\Pi_R\genfrac[]{0pt}{}{a_1,a_2,\ldots,a_M}{b_1,b_2,\ldots,b_M}=
\prod_{n=0}^R\frac{\\a1\\a2\ldots\\aM}{\\b1\\b2\ldots\\bN}.\]
\ex{18.40}
\[\sum_{p\;\mathrm{prime}}f(p)=\int_{t>1}f(t)\,d\pi(t).\]
\begin{verbatim}[numbers=left,firstnumber=last]
\def\X{\char`'}
\[{
\{\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a\X\mathrm{s}},
  \overbrace{\mathstrut
    b,\ldots,b}^{l\;b\X\mathrm{s}}}_{k+l\;\mathrm{elements}}\}
}\quad\text{vs}\qquad {
{\{\,}\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a'\mathrm{s}},
  \overbrace{\mathstrut
    b,\ldots,b}^{l\;b'\mathrm{s}}}_{k+l\;\mathrm{elements}}{\}\,}.}\]
\end{verbatim}
\ex{18.41} In this formula, we want the denote the plural of the token $a$ by
as apostrophe followed by the letter s. The first attempt is not good. The
second is a bit better, because it is a-prime followed by s. The first
expression is formed of open brace, underbraced formula, closing brace; and this
produces large braces in the HTML version; small braces are obtaing by
replacing the first token by a list, containing the brace and little bit space. 
\def\X{\char`'}
\[{
\{\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a\X\mathrm{s}},
  \overbrace{\mathstrut
    b,\ldots,b}^{l\;b\X\mathrm{s}}}_{k+l\;\mathrm{elements}}\}
}\quad\text{vs}\qquad {
{\{\,}\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a'\mathrm{s}},
  \overbrace{\mathstrut
    b,\ldots,b}^{l\;b'\mathrm{s}}}_{k+l\;\mathrm{elements}}{\}\,}.}\]


\ex{18.42}
\[\begin{pmatrix}
\begin{pmatrix}a&b\\c&d\end{pmatrix}&
\begin{pmatrix}e&f\\g&h\end{pmatrix}\\
0&\begin{pmatrix}i&j\\k&k\end{pmatrix}
\end{pmatrix}.\]

A non trivial question: what is the distance $X$ between two lines in a matrix
like these? or said otherwise, what is the vertical glue $Y$ added between two
lines? Let $x$ be the value of \cmd{baselineskip}, $y$ the value of
\cmd{lineskiplimit} and $z$ the value of \cmd{lineskip}. Then, the quantity
$y$ is computed so that $X=x$, unless this gives $Y<y$, case where $z$ is used
instead. Typically, for a normal paragraph, $x=12$, $y=0$, $z=1$, and for a
`align' environment, we have $x=15$, $y=3$, $z=4$. In the case of an array,
all three values are zero. This means: normal baseline in a paragraph is 12pt,
but there is at least one pt between two lines, and in the case of multiline
equations, the baseline is larger, as well as the clearance. In the case of an
array, no extra space is added. However, a strut is added to each line, this
is an invisible rule; as a consequence, the total height plus depth of each
line is the matrix is at least 12pt, hence $X$ is at least 12pt.

This has as consequence that, in the big matrix above, parentheses do touch.
We changed, in the file \filename{raweb-cfg.sty}, the code of the \cmd{@array} command:
$z=5$,  and $y$ is 3 or 5, depending on whether the `displaystyle' attribute
array of the  array is true (if the attribute is true, then all entries are
typeset in \cmd{display} mode; this is the case for all environments like
`gather' or `align' that are translated by \Tralics\ as an array).


\ex{18.43} Note: entries are left aligned because of explicit \cmd{hfil}.
\[\det\begin{vmatrix}
c_0\hfil&c_1\hfil&c_2\hfil&\ldots&c_n\hfil\\
c_1\hfil&c_2\hfil&c_3\hfil&\ldots&c_{n+1}\hfil\\
c_2\hfil&c_3\hfil&c_4\hfil&\ldots&c_{n+2}\hfil\\
\vdots\hfil&\vdots\hfil&\vdots\hfil&&\vdots\hfil\\
c_n\hfil&c_{n+1}\hfil&c_{n+2}&\ldots&c_{2n}\hfil\\
\end{vmatrix}
\]

\ex{18.44} 
\[\mathop{{\sum}'}_{x\in A}f(x)\mathrel{\mathop=^{\mathrm{def}}}
\sum_{\scriptstyle x\in A\atop\scriptstyle x\ne 0}f(x).\]

\ex{18.45} This is not so nice 
\[{2\uparrow\uparrow k}\mathmo{^^^^225d}2^{2^{2^{\cdot^{\cdot^{\cdot^2}}}}}
\left.\vphantom{\frac12}\right\}k\]

\ex{18.46} Vertical arrow centered via the use of phantom on the left;
command \cmd{hidewidth} not used (the purpose of the command is to make
\cmd{halign} believe that the cell has a very small width; this will produce
an overfull box, but who cares: there is enough white space at both ends).

\[
\def\mapright#1{\smash{\mathop{\rightarrow}\limits^{#1}}}
\def\mapdown#1{\hphantom{{\scriptstyle#1}}\downarrow{\scriptstyle#1}}
\begin{matrix}
&&&&&&0\\
&&&&&&\mapdown{}\\
0&\mapright{}&\mathcal{O}_k&\mapright\iota&\mathcal{E}&\mapright\rho&
\mathcal{L}&\mapright{}&0\\
&&\Vert&&\mapdown\phi&&\mapdown\psi\\
0&\mapright{}&\mathcal{O}_C&\mapright{}&\pi_*\mathcal{O}_D&\mapright\delta&
R^1f_*\mathcal{O}_V(-D)&\mapright{}&0\\
&&&&&&\mapdown{\theta_i\otimes\gamma^{-1}}\\
&&&&&&R^1f_* \big(\mathcal{O}_V(-iM)\big)\otimes\gamma^{-1}\\
&&&&&&\mapdown{}\\
&&&&&&0
\end{matrix}
\]

\fi
\section {Displayed Equations, TB19}
\ifTeXfour

\subsection{One-line displays}
\tagasattribute
Example of a display, containing only text
$$\hbox{Displayed Text}$$
Another one, with text and math
$$X_n=X_k \qquad\hbox{if and only if}\qquad Y_n=Y_k\quad
   \text{and}\quad Z_n=Z_k.$$

Compare the following two examples: the translation is the same, but you cannot
put arbitrary text in a math formula! 
\begin{verbatim}[numbers=left,firstnumber=last]
$$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q \qquad\hbox{for all }n\ge 0.$$
$$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q\qquad\hbox{for all $n\ge0$}.$$
\end{verbatim}
$$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q \qquad\hbox{for all }n\ge 0.$$
$$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q \qquad\hbox{for all $n\ge 0$}.$$
%$

\ex{19.1} The exercise  contains four formulas; for the first three ones, we
give a \LaTeX\ variant. For the first formula, the delimiters hace different
sizes. 
\begin{verbatim}[numbers=left,firstnumber=last]
$$\sum_{n=0}^\infty a_nz^n\qquad \hbox{converges if}\qquad |z| <
\Bigl(\limsup_{n\to\infty}\root n\!\of{|a_n|}\,\Bigr)^{-1}.$$
\[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| <
(\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}{\,)}^{-1}. \]
\[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| <
(\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}\,)^{-1}. \]
\end{verbatim}
$$\sum_{n=0}^\infty a_nz^n\qquad \hbox{converges if}\qquad |z| <
\Bigl(\limsup_{n\to\infty}\root n\!\of{|a_n|}\,\Bigr)^{-1}.$$
\[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| <
(\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}{\,)}^{-1}. \]
\[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| <
(\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}\,)^{-1}. \]

Next two formulas.
\begin{verbatim}[numbers=left,firstnumber=last]
$${f(x+\Delta x)-f(x)\over\Delta x}\to f'(x)\qquad \hbox{as $\Delta\to0$.}$$
\[\frac{f(x+\Delta x)-f(x)}{\Delta x}\to f'(x)\qquad \text{as }\Delta\to0.\]
$$\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\hbox{if $i\ne j$.}$$
\[\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\text{if } i\ne j.\]
\end{verbatim}
$${f(x+\Delta x)-f(x)\over\Delta x}\to f'(x)\qquad \hbox{as $\Delta\to0$.}$$
\[\frac{f(x+\Delta x)-f(x)}{\Delta x}\to f'(x)\qquad \text{as }\Delta\to0.\]
$$\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\hbox{if $i\ne j$.}$$
\[\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\text{if } i\ne j.\]
Last formula; you cannot use the \cmd{matrix} command defined by plain \TeX,
but you have to use the \LTC{matrix} environment.
\begin{verbatim}[numbers=left,firstnumber=last]
\[\it\text{The confluent image of}\quad
\begin{Bmatrix}\text{an arc}\hfill\\\text{a circle}\hfill\\\text{a fan}\hfill
\end{Bmatrix}
\quad\text{is}\quad
\begin{Bmatrix}\text{an arc}\hfill\\\text{an arc or a circle}\hfill\\
\text{a fan or an arc}\hfill\end{Bmatrix}.\]
\end{verbatim}
\[\it\text{The confluent image of}\quad
\begin{Bmatrix}\text{an arc}\mathattribute{mathvariant}{italic}
\hfill\\\text{a circle}\hfill\\\text{a fan}\hfill
\end{Bmatrix}
\quad\text{is}\quad
\begin{Bmatrix}\text{an arc}\hfill\\\text{an arc or a circle}\hfill\\
\text{a fan or an arc}\hfill\end{Bmatrix}.
\]

Since version 2.9.5, you can use font changes in \cmd{text} commands and
friends (the previous formula is in italics). This is a more elaborate example
\begin{verbatim}[numbers=left,firstnumber=last,style=latex]
$\hbox{upright} \it \text{Italic\bf Boldface} {\tt \text{x = y$^2$}}$
\end{verbatim}
Translation: $\hbox{upright} \it \text{Italic\bf Boldface} {\tt \text{x = y$^2$}}$.

\ex{19.2} Compare B. L. User's solution, Knuth's solutions and \cmd{tfrac}:
\[y=\frac{\scriptstyle 1}{\scriptstyle 2}x
\quad\text{vs}\quad{\textstyle y=\frac 12x}\quad\text{vs}\quad \tfrac12x\]


\ex{19.3} We demonstrate in this example that using 
\LTC{\$\$\cmd{hbox}\argument{\$formula\$}\$\$} is non-trivial.
\begin{verbatim}[numbers=left,firstnumber=last]
\everymath={A}
\everyhbox={B}
\def\X{\ifhmode H\else \ifvmode V \else \ifmmode M \else U\fi\fi\fi}
\def\Y{\X\ensuremath{\beta}}
$$ \Y\hbox{\X$\Y $\X}\Y \text{\X}$$
\end{verbatim}

%$

\begingroup
\everymath={A}
\everyhbox={B}
\def\X{\ifhmode H\else \ifvmode V \else \ifmmode M \else U\fi\fi\fi}
\def\Y{\X\ensuremath{\beta}}
$$ \Y\hbox{\X$\Y $\X}\Y \text{\X}$$
\endgroup

Guess what happens if \cmd{X} were replaced by \cmd{Y}? the problem might be
solved in a future version. Note that \cmd{text} does not insert the
every-hbox token list.


\ex{19.4} Look at these four identical formulas.
\[1-\frac 12+\frac 13-\frac 14 +\cdots = \ln2 
\]
\[1-\frac 12+\frac 13-\frac 14 +\cdots = \ln2 
\eqno(14)
\]
\[1-\frac 12+\frac 13-\frac 14 +\cdots = \ln2 
   \formulaattribute{eqleft}{true}%
\eqno(14)
\]
\[1-\frac 12+\frac 13-\frac 14 +\cdots = \ln2 
   \formulaattribute{eqleft}{true}%
\]


In \TeX, equations are centered, and an equation number is added to the left
or the right. In the HTML version, an equation-with-number is a 3-column
table, columns 1 and 3 are of width 4em (this is defined in the CSS file),
one of them contains the equation number. If the equation  number is big, the
width of the column might be larger than 4em, columns 1 and 3 could have
different widths, so that column 2 is not centered. Otherwise it is centered,
and the equation is centered in column 2 (is there a way to do this better?)

Normally, there should be a way to put the equation at some position (say 3cm
from the left margin). This is done in \LaTeX\ via a package option (can we
easily modify \LaTeX\ so that each equation can be centered or not?). In this
examples, first two formulas should be centered, other ones should flushed
left. Equations two and three have a number. 

{\bf Note on Equation Numbering} For a very long time, I have used the
\cmd{eqno} command without any difficulty; of course, you have to be very
careful if you introduce an equation between equations (11) and (12), you
have to change every reference for any equation starting with 12. A big
advantage of \LaTeX\ is its automatic numbering scheme; more precisely if
you flag an equation with \cmd{label}\argument{eq+12}, you can get its number
via \cmd{ref}\argument{eq+12} (the only difficulty then is to find mnemonic
tag names). In a first pass, \LaTeX\ computes the value of the label, and
stores it in a file, in a second pass, it reads the file, and uses this
number. No number is computed by \Tralics, in some cases, this can be
annoying. A side effect of the translation of the \cmd{label} command is the
addition of an id (for instance `id12' to the equation\footnote{The label name
provided by the user cannot be used since it is an invalid XML id in this case}), and translation of
the \cmd{ref} is a \elt{ref} element with a reference to the id. 

Equation numbers are computed by the XML-to-whathever processor.
In fact, in the case of conversion from XML to HTML, the style sheet computes
the equation number twice: once when the equation is converted, and once when
the \elt{ref} is converted. In the case of XML to XSL/FO, a number is computed
only for \elt{ref}, the equation number is added to the equation by \LaTeX,
when the  XSL/FO is converted to Pdf (this is not really important, because
nobody looks at the FO file).


Assume that you have hundreds of equations, and you want to refer the previous
one; very often it is tagged `(*)', in some cases `(**)'. Some people use
`(***)'. Exercise 19.7 that follows says that, in math mode, these come out as
$(*)$, in some cases $(**)$ and $(***)$. In particular, a non-trivial question
is: should equation numbers by typeset as math or as text? In \Tralics, we
implemented  \cmd{eqno} and \cmd{tag}; that's a bit tricky, let's explain
some difficulties.

\begin{itemize}
\item The MathML recommendation says: automatic equation numbering and
  automatically resolving references to equations is outside the scope of
  MathML, but can be done by use of style sheets or other means. ``The
\elt{mlabeledtr} construction provides support for both of these functions in
a way that is intended to facilitate XSLT processing''.  The idea is to
construct an array, the first column contains equation numbers, with an
attribute that says if the tag should be on the left or the right.
This allows more than one tag per formula (there can be more than one row).
The problem is that my browser ignores the whole line. This is bad news.
\item The current implementation is: if the formula has a label, it has an
  equation number. It cannot have more than one label/id/equation number.
(here `formula' designates the element that contains the translated math
formula). The style sheet computes the equation number via
  \XC{<xsl:number} \XC{level='any'} \XC{count='formula[@id]'} \XC{/>}.
\item What happens if a formula has a tag and a label? Currently the tag is
  ignored. What we should do is modify the template above (count all formulas
  with id and without tags), this gives a value if the equation has no tag,
  and use the value of the tag otherwise. Note that, if you say
  \cmd{tag}\argument{x}, this gives $(x)$ as equation number, and \cmd{eqref}
  gives this value back. On the other hand, \cmd{eqno(x)} is equivalent to
\cmd{tag*}\argument{(x)}.
\item If a tag is part of a math formula, it can consist in any math
  construct. In our implementation, it may be an attribute so that only
  characters are allowed. You cannot use $\alpha$ or $\beta$ as tag. 
In \LaTeX, tags are typeset in text mode, and math shift characters are
sometimes used. These are removed by \Tralics.
\item A tag can appear anywhere in a formula, and more than one tag can be
  used. Thus \Tralics\ reads all tags and merges them (it complains if more
  than one label appears in a formula).
\item The final tag, after merge, removal of special characters, etc., is
  passed to a command; you can redefine it. In general it will either typeset
  the tag, or convert it to an attribute.
\end{itemize}


Summary: There are three ways to obtain an equation number.
First, if an equation has a label, an equation number will be assigned to it
automatically, when converting from XML to HTML, or whatever. The second method
consists in using the amsmath command \cmd{tag}, described below. Finally, you
can use the \TeX\ command \cmd{eqno}. This command reads everything up to the
end of the formula, expanding tokens when needed; if this yields \LTC{foo},
then \cmd{y@tag}\argument{foo} is evaluated again; this the same as if you said
\cmd{tag*}\argument{foo}. Its effect by default is to convert the tag as an
attribute to the formula.
 Moreover, the attribute \XC{eqnpos} is added to the
formula, with a value of \XC{left} and \XC{right}, depending on whether
\cmd{leqno} or \cmd{eqno} has been used. The equals signs should be aligned
for the five next formulas.
$$x^2-y^2=(x+y)(x-y).\eqno(15R)$$
$$x^2-y^2=(x+y)(x-y).\leqno(15L)$$

Equation number of \eqref{xxleft} is on the left, of \eqref{xxright} on the
right, and \eqref{xxdefault} depends on the class option.
$$x^2-y^2=(x+y)(x-y).\label{xxleft}\formulaattribute{eqnpos}{left}$$
$$x^2-y^2=(x+y)(x-y).\label{xxright}\formulaattribute{eqnpos}{right}$$
$$x^2-y^2=(x+y)(x-y).\label{xxdefault}$$


\ex{19.5} 

\[\prod_{k\ge0}\frac{1}{1-q^kz}=\sum_{n\ge0}z^n/ \,\,\prod_{1\le k\le
  n}(1-q^k).\eqno(16')\]

\ex{19.6} In \TeX, you can put an en-dash in an equation number by using
\cmd{hbox}. This is not allowed in \Tralics: the equation $1=1$ below gives an
error. On the other hand, any character can be put in an equation number; the
case of an apostrophe is a bit special: it is not converted to an exponent,
but replaced by \cmd{apostrophe}.

The example below illustrates one complexity. The end of the tag (via
\cmd{eqno}) is the end of the formula. In order to get the end of the formula,
all tokens have to be expanded. The question is what to do with \cmd{char}:
remember that this command reads and typesets a character. In this case it
cannot typeset a character; assume that we delay its interpretation. In this
case, the command that follows the backquote will be expanded (this is wrong:
we do not want to put an acute accent somewhere). Hence, the \cmd{char}
command reads a character, and pushes back a character token, with the same
value, but category code 12. We explained above that \cmd{mathchar} is not
implemented. This means that there is one and only one active math character:
the apostrophe, it produces a prime exponent even when it has category code
12. This is not desired: a tag should consist in characters only. This
explains why something special is done. You can define the \cmd{apostrophe}
command as you like (the default value is character U+B4, but you can use an
apostrophe, case where an exponent will be created when the token list is read
again; formula $2=2$ gives a double superscript error, guess why).
Note how we insert an en-dash (of course \cmd{textendash} is a
non-math command, we had to modify some files in order to allow this character
in the Pdf).

\begin{verbatim}[numbers=left,firstnumber=last]
\[1=1\eqno\hbox{(3--1)} \]
\[0=0\eqno(*,{**},{***},16'\char`\'\char`\^,3^^^^20131)\]
\[\def\apostrophe{'} 2=2\eqno(16'\char`\')\]
\[\def\apostrophe{'} 3=3\eqno(16')\]
\end{verbatim}
\[0=0\eqno(*,{**},{***},16'\char`\'\char`\^,3^^^^20131)\]


\ex{19.7} It is possible to insert the equation number in the formula.
What you can see here is that the spacing for two and three stars is the same:
Knuth says that \TeX\ converts binary star to type Ord, in the case of three
stars, the middle one is of type Ord.
\begingroup
\tagatendofformula
\[0=0\eqno(*,{**},{***},16'\char`\'\char`\^,3^^^^20131)\]
\[\def\apostrophe{'} 3=3\eqno(16')\]
\endgroup
\ex{19.8} Knuth says: if \cmd{hsize} is less than 10000pt, then the natural
width of the equation will be too large. \Tralics\ ignores the shrink part of
the glue. In the case of the HTML document, the
text will flush in the right margin (and the equation number will be far
away). We have replaced 10000 by 600, this should be big enough to see
something. 
\begin{verbatim}[numbers=left,firstnumber=last]
\[\quad x=y\hskip10000pt minus 1fill\eqno(5)\]
\end{verbatim}
\[\quad x=y\hskip600pt minus 1fill\eqno(5)\]

\subsection{Multi-line displays}

\ex{19.9} The \cmd{eqalign} feature of plain \TeX\ is not implemented; you can
use the \LTC{align} environment like here: 
\begin{align}
T(n)\le T(2^{\lceil\lg n \rceil})&
\le c(3^{\lceil\lg n \rceil})-c(2^{\lceil\lg n \rceil})\\
&<3c\cdot3^{\lg n}\\
&=3c\,n^{\lg3}.
\end{align}
Using \LTC{aligned}, you can get
\[\left\{\begin{aligned}\alpha&=f(z)\\\beta&=f(z^2)\\\gamma&=f(z^3)\end{aligned}
  \right\}\qquad\left\{
\begin{aligned}x&=\alpha ^2-\beta\\y&=2\gamma\end{aligned}\right\}
\]
\ex{19.10}
\begin{align}
\label{eq19-10}
P(x)&=a_0+a_1x+a_2x^2+\cdots+a_nx^n,\\
P(-x)&=a_0-a_1x+a_2x^2+\cdots+{(-1)^n}a_nx^n.
\end{align}

Currently, the following code does not work.
\begin{verbatim}[numbers=left,firstnumber=last]
\begin{eqalignno}
(x+y)(x-y)&=x^2-xy+yx-y^2\\
&=x^2-y^2;&(4)\\
(x+y)^2&=x^2+2xy+y^2 ;
\end{eqalignno}
\begin{leqalignno}
(x+y)(x-y)&=x^2-xy+yx-y^2\\
&=x^2-y^2;&(4)\\
(x+y)^2&=x^2+2xy+y^2 .
\end{leqalignno}
\end{verbatim}
The best we can do is using phantoms:
\begin{verbatim}[numbers=left,firstnumber=last]
\def\xcenter#1#2#3{\phantom{#3}{#1#2#3}\phantom{#1}}
\[\xcenter{(x+y)(x-y)}{=}{x^2-xy+yx-y^2} \]
\[\xcenter{{}}{=}{x^2-y^2;}\label{192-0}\]
\[\xcenter{{(x+y)^2}}{=}{x^2+2xy+y^2 .}\label{192-5}\]
\end{verbatim}
\def\xcenter#1#2#3{\phantom{#3}{#1#2#3}\phantom{#1}}
\[\xcenter{(x+y)(x-y)}{=}{x^2-xy+yx-y^2} \]
\[\xcenter{{}}{=}{x^2-y^2;}\label{192-0}\]
\[\xcenter{{(x+y)^2}}{=}{x^2+2xy+y^2 .}\label{192-5}\]

\ex{19.12} First two equations use \cmd{leqno},
Equations \eqref{e19.12.a} and \eqref{e19.12.b} have a label.
\[\xcenter{\gcd(u,v)}{=}{\gcd(v,u);}\leqno(9) \]
\[\xcenter{\gcd(u,v)}{=}{\gcd(-u,v).}\leqno(10) \]
\[\xcenter{\gcd(u,v)}{=}{\gcd(v,u);}\label{e19.12.a}
\formulaattribute{eqleft}{true} \]
\[\xcenter{\gcd(u,v)}{=}{\gcd(-u,v).}\label{e19.12.b} \formulaattribute{eqleft}{true}\]

\ex{19.13} Note: Knuth has a small space before the first \LTC{dx}, this seems
unnecessary. Some operators are big by default in MathML, so that no \cmd{big}
is required. However, there is a rule in \Tralics\ that says that small
parentheses are used in $\int f(x)dx$, even when the integral has limits. 
In this cases, this mechanism produces small parentheses. The remedy is to put
\LTC{f(x)} in a group; the size of the parentheses depend only on what is in
the group. In a case like $(x^2+y^2)$, large parentheses are used. If you want
small ones, you must use the \cmd{smash} command, and you get 
$(\smash{x^2+y^2})$. In the pdf version, the vertical bar is too small.
\begin{verbatim}[numbers=left,firstnumber=last]
\[\xcenter{\left(\int_{-\infty}^{\infty}e^{-x^2}dx\right)^2}{=}
{\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-(\smash{x^2+y^2})}dx\,dy}\]
\[\xcenter{}{=}{\int_0^{2\pi}\int_0^\infty e^{-r^2}r\,dr\,d\theta}\]
\[\xcenter{}{=}{\int_0^{2\pi}{\left(-\frac{e^{-r^2}}{2}|
        _{r=0}^{r=\infty}\right)}\,d\theta}\]
\[\xcenter{}{=}{\pi.}\label{e19.13}\]
\end{verbatim}
\[\xcenter{\left(\int_{-\infty}^{\infty}e^{-x^2}dx\right)^2}{=}
{\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-(\smash{x^2+y^2})}dx\,dy}\]
\[\xcenter{}{=}{\int_0^{2\pi}\int_0^\infty e^{-r^2}r\,dr\,d\theta}\]
\[\xcenter{}{=}{\int_0^{2\pi}{\left(-\frac{e^{-r^2}}{2}|_{r=0}^{r=\infty}
\right)}\,d\theta}\]
\[\xcenter{}{=}{\pi.}\label{e19.13}\]

\ex{19.14} Knuth explains that \LTC{eqalign} and \LTC{eqalignno} environments
are based on \cmd{halign}, so that \cmd{noalign} can be used. In environments
like \LTC{gather}, you can try \cmd{multicolumn}. As you can see here, the word
`and' occurs at the left of the table, not at the left margin; this is the same
as what happens with \cmd{eqalign}.
\begin{gather}
x=y+z\\
\multicolumn{1}{l}{\text{and}}\\
x^2=y^2z^2
\end{gather}

\ex{19.16} This uses \cmd{gather}. There are no equation numbers, because
\cmd{hfil}, \cmd{hfill} or \cmd{hfilneg} are not allowed.
\begin{gather}
x\equiv x\\
\text{if}\quad x \equiv y \quad\text{then}\quad y\equiv x\\
\text{if} \quad x\equiv y \quad \text{and} \quad y\equiv z \quad\text{then}
\quad x\equiv z.
\end{gather}

\subsection{Long formulas}
\def\formA{\sigma(2^{34}-1,2^{35},1)}
\def\formB{-3+(2^{34}-1)/2^{35}+2^{35}\!/(2^{34}-1)}
\def\formC{7/2^{35}(2^{34}-1)-\sigma(2^{35},2^{34}-1,1)}
The long formula is
\[\formA=\formB+\formC.\]
It can be split as
\begin{align}
\formA&=\formB\\&\qquad{}+\formC.
\end{align}
\ex{19.17}
\begin{align}
x_nu_1+\cdots+x_{n+t-1}u_t &= x_nu_1+(ax_n+c)u_2+ \cdots\\
&\qquad{}+(a^{t-1}x_n+c(a^{t-2}+\cdots+1))u_t\\
&=(u_1+au_2+\cdots+a^{t-1}u_t)x_n+h(u_1,\ldots,u_t).\label{e19.17}
\end{align}

Attempt to use \LTC{multline} for the long formula. 
\begin{multline}
\formA=\formB\\{}+\formC.
\end{multline}

\ex{19.18}
\begingroup
\def\FF#1#2{(x_{#1}-x_{#2})}
\def\F#1{(x-x_{#1})}
\begin{multline}
\sum_{1\le j \le n}\frac{1}{\FF j1\ldots\FF j{j-1}\F j\FF j{j+1}\ldots
\FF j n}\\
=\frac{1}{\F 1\ldots\F n}.\label{e19.18}
\end{multline}
\endgroup

\ex{19.19} This is a silly expression. It is formed of A and B over C. 
We show here the code of A, B and C, using the shorthands of Knuth. We redefine
locally the \cmd{\textbackslash} command. The \cmd{Paren} command puts
parentheses around the argument., the \cmd{Slash} command produces a slash.
\begin{verbatim}[numbers=left,firstnumber=last]
{
\def\\#1;{\noexpand\Paren{#1;q^2}_\infty}
\xdef\formA{q^{\frac 12 n(n+1)}\\ea;\\eq\noexpand\Slash a;}
\xdef\formB{\\caq\noexpand\Slash e;\\cq^2\!\noexpand\Slash ae;}
\xdef\formC{(e;q)_\infty(cq/e;q)_\infty}
}
\end{verbatim}

The question is: What is the size of the parentheses? 
In the case of $\int f(x)dx$ some browsers  show parentheses whose size are the
same as that of the current group; if nothing special is done, it includes the
integral sign and the bounds, this is wrong. For this reason, \Tralics\
inserts some braces for opening and closing delimiters. If a group is created
for the parenthesis, it contains no big objects (e.g., something with
exponents).  If possible, opening and closing parentheses are part of the same
group. The algorithm is not obvious: consider what should be done if $x$ or
$f(x)$ is replaced by its square. The following exercise is interesting. Note:
in the Pdf version, all formulas look the same, this is because parentheses
have fixed size. See also discussion after exercise 16.2:  there are no
multiple scripts here.

We give here four
variants. In case one, there is no group, and the size of the parentheses is
given by the exponent of the q. Hence they are too big. \Tralics\ tries to
compensate, but this does not work well, because of the index attached to
parenthesis; there are two parts $(ea;$ and $q^2)_\infty$.
In the second case, we have added an empty group. In this case,
we have a group with $(ea;$ followed by $q^2$ followed by a group with $)$
followed by $_\infty$. This gives small parentheses. Variant three is
logically better: we put the parentheses in a group, so that its size depends
only on the content of the group; in this case \Tralics\ leaves the formula
unchanged. If you feel that the parentheses are too big, you can reduce them:
variant four uses \cmd{smash}.

A non trivial point is that the size of the slash character is also
variable. In the case where a group is used (variant 3 and 4), it size depends
on the $q^2$ that follows. Otherwise, when \Tralics\ tries to insert a group,
in order to reduce the size of the parentheses, it uses a complicated
algorithm: when a group is created for the parentheses, it does not include
big objects. In particular, since each semi-colon is followed by $q^2$, this
group cannot contain both parentheses. Expressions can be split after binary
operators or relations, in the case of $a/b=c$, only the equals sign is
considered. Understanding exactly where the expression is split is not
easy. Obviously, in the case when there are two $q^2$ in the expression, none
of them is in a group. Since the slash character is between these two
expressions, it is outside of the group, its size is affected by the exponent
of the first $q$. This gives a very big slash (in the case of the Pdf version,
only small characters are used).

One fundamental change in \Tralics\ 2.10.8 concerns the case where a
superscript or subscript is attatched to a parenthesis. In this case, the
script is detached, the soliiting algorithme is called, and the script is
attached to what preceeds. An like \LTC{(x)\HAT2}, will be  converted into
\LTC{(x)\argument{}\HAT2}, that can be converted into
\LTC{{(x)}\argument{}\HAT2}, and after removal of the dummy group into  
\LTC{{(x)}\HAT2}.

\begin{verbatim}[numbers=left,firstnumber=last]
\def\Paren#1{(#1)}
\def\Paren#1{(#1){}}
\def\Paren#1{{(#1)}}
\def\Paren#1{{(\smash{#1})}}
\def\Slash{/}
\[ \frac{\formA\formB}{\formC} \]
\[ \frac{\textstyle\formA\qquad \atop\hfill\textstyle\formB}{\formC} \]
\end{verbatim}

{
\def\\#1;{\noexpand\Paren{#1;q^2}_\infty}
\xdef\formA{q^{\frac 12 n(n+1)}\\ea;\\eq\noexpand\Slash a;}
\xdef\formB{\\caq\noexpand\Slash e;\\cq^2\!\noexpand\Slash ae;}
\xdef\formC{(e;q)_\infty(cq/e;q)_\infty}
}
\def\Slash{/}

The whole formula version 1
\def\Paren#1{(#1)}
\[ \frac{\formA\formB}{\formC} \]
Version two
\def\Paren#1{(#1){}}
\[ \frac{\formA\formB}{\formC} \]
Version 3
\def\Paren#1{{(#1)}}
\[ \frac{\formA\formB}{\formC} \]
Version 4
\def\Paren#1{{(\smash{#1})}}
\[ \frac{\formA\formB}{\formC} \]
\def\Paren#1{{(#1)}}
The split formula
\[ \frac{\textstyle\formA\qquad \atop\hfill\textstyle\formB}{\formC} \]

One trick in order to get a smaller slash: define \cmd{Slash} to be a group
consisting of a slash (and something else, here a \cmd{kern} of width minus 1pt). 
\def\Slash{{\kern-1.pt/}}
The whole formula version two
\def\Paren#1{(#1){}}
\[ \frac{\formA\formB}{\formC} \]
Version 4
\def\Paren#1{{(\smash{#1})}}
\[ \frac{\formA\formB}{\formC} \]
\def\Paren#1{{(#1)}}
The split formula, version 4
\[ \frac{\textstyle\formA\qquad \atop\hfill\textstyle\formB}{\formC} \]

\fi


\chapter{Higher Mathematics, TLC2}
\tagatendofformula
In this chapter we present examples from the \LaTeX\ companion, second
edition, chapter 8; the book is distributed with a CDrom containing all
examples. These examples are formed of two parts; black and blue, the blue
part contains material to be inserted before the
\cmd{begin}\argument{document}; whenever needed, we shall explain what these
commands are assumed to do, what they do, and how the feature might be
implemented.  Unless stated otherwise, the black part is taken verbatim.

\section{Introduction to amslatex}
The following packages are defined for use with \Tralics:
\begin{itemize}
\item amsmath is the main package, it loads amstext, amsbsy, amsopn; Options
  are sumlimits, nosumlimits, namelimits, nonamelimits, centertags, tbtags,
  cmex10, and fleqn.
\item amsgen contains some useful commands (currently unused).
\item amstext defines the \cmd{text} command, which is built-in in \Tralics.
\item amsbsy loads amsgen. It provides \cmd{boldsymbol} and \cmd{bm}, which do
  nothing in \Tralics. 
\item amsopn, no options. The package defines commands like \cmd{lim}, that
  are built-in in \Tralics.
\item amscd, implementes commutative diagrams.
\item amsthm, not yet implemented (theorems are built-in in \Tralics).
\item amsxtra, not yet implemented.
\item upref, not yet implemented.
\item amsfonts, not yet implemented; this package and the following recognize 
options psamsfonts.
\item amssymb. The package defines 204 symbols, all of them implemented in the
 \Tralics\ kernel, except the following one, that are declared undefined by
 the amsmath package: \cmd{vartriangle}, \cmd{doublebarwedge}, 
\cmd{varpropto}, \cmd{smallsmile}, \cmd{smallfrown}, \cmd{lvertneqq}
\cmd{gvertneqq}, \cmd{npreceq}, \cmd{nsucceq}, \cmd{varsubsetneq(q)} 
\cmd{varsupsetneq(q)}, \cmd{nsubseteqq},
\cmd{nsupseteqq}, \cmd{(n)shortmid}, \cmd{(n)shortparallel}.

\item eufrak. The package defines family \cmd{Eufrak}  (this command is
  \cmd{mathfrak} in \Tralics), this is assumed to use the font family `euf'.
The eufrak package is redundant if the  amsfonts package is used.
\item eucal. 
The package defines  family \cmd{Euscript}  (this command is \cmd{mathcal} in
\Tralics), this is assumed to use the font family `eus'.
Accepts options `mathcal' and `mathscr' (this make \cmd{mathscr}
equivalent to \cmd{mathcal}. 
\end{itemize}

All undefined math symbols are defined to be \cmd{ams@unimp}, a command that
expands to an undefined command, the one defined here to produce a red X.
\begin{verbatim}[numbers=left,firstnumber=last]
\def\UnimplementedOperator#1{\mathbox{mstyle}[color][red]{X}}
\end{verbatim}

\ifLatex


\section{Display and alignment structures for equations}
Source code for some formulas used below:
\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation} (a+b)^2 = a^2+2ab+b^2\end{equation}
\[  \sin^2\eta+\cos^2\eta = 1  \]
\begin{equation} x^2 + y^2  =  z^2 \end{equation}
\begin{align} x^2 + y^2 &=  z^2 \\ x^3 + y^3 &<  z^3 \end{align}
\begin{eqnarray} x^2 + y^2 &=& z^2 \\ x^3 + y^3 &<& z^3 \end{eqnarray}
\begin{equation*}  n^2 + m^2 = k^2 \end{equation*}
\begin{equation} n^p +m^p \neq k^p  \qquad p > 2 \end{equation}
\begin{multline}  \tag{2}
  \sum_{t \in \mathbf{T}} \int_a^t
    \biggl\lbrace \int_a^t f(t - x)^2 \,
            g(y)^2 \,dx \biggr\rbrace \,dy \\
  = \sum_{t \notin \mathbf{T}} \int_t^a
      \biggl\lbrace g(y)^2 \int_t^a
        f(x)^2 \,dx \biggr\rbrace \,dy
\end{multline}
\end{verbatim}

Example 8-2-1. This uses the `leqno' option of the amsmath package, 
that is assumed to put equation numbers on the left. In \Tralics, this will
set the attribute \attpair{equation-number}{left} of the document element.

In \Tralics, if a formula has no \cmd{label}, no number
is associated to it. Here we have a formula using the \LTC{equation}
environment, or a displaymath formula enclosed in a \cmd{[}, \cmd{]} pair.
\begin{equation} (a+b)^2 = a^2+2ab+b^2\end{equation}
\[  \sin^2\eta+\cos^2\eta = 1  \]

Example 8-2-2. This uses options `reqno' option of the amsmath package
(equations to the right), it puts
\attpair{equation-number}{left} on the document element. It uses also
`fleqn', that sets \attpair{flushed-equation}{true}; in \LaTeX, you must
define \cmd{mathindent}, here to 1pc, as the distance between the left margin
and the formula; ignored by \Tralics. Same formulas as above, with a label
added, in order to show the difference.
\setlength\mathindent{1pc}
\begin{equation} (a+b)^2 = a^2+2ab+b^2  \label{eq-8-2-2}\end{equation}
\[  \sin^2\eta+\cos^2\eta = 1  \]

Example 8-2-3. The code was modified in order to add labels; you see three 3
numbers; one per environment, equation, align, and eqnarray. Also text added
between the groups of equations. First environment is \LTC{equation}:
\begin{equation}
  x^2 + y^2  =  z^2 \label{8-2-3-a}
\end{equation}
Second environment is \LTC{align}:
\begin{align}
  x^2 + y^2 &=  z^2 \\
  x^3 + y^3 &<  z^3\label{8-2-3-b}
\end{align}
Third environment is \LTC{eqnarray}:
\begin{eqnarray}
x^2 + y^2 &=& z^2 \\
x^3 + y^3 &<& z^3\label{8-2-3-c}
\end{eqnarray}

Note: amsmath adds a new complexity to how spaces are handled: spaces after
\cmd{\textbackslash} are no more ignored. This mechanism is not implemented in
\Tralics. 

Example 8-2-4.  We modified the examples by adding a label; you can see that
this produces an equation number for  \LTC{equation*}, \eqref{8-2-4-a}
as well as \LTC{equation}, \eqref{8-2-4-b}. 
\begin{equation*}
  n^2 + m^2 = k^2\label{8-2-4-a}
\end{equation*}
\begin{equation}
  n^p +m^p \neq k^p  \qquad p > 2\label{8-2-4-b}
\end{equation}

Example 8-2-5. Translation of \cmd{multline}
is a table, elements are centered, except first, last, and lines using
\cmd{shoveleft} or \cmd{shoveright}.
No \verb=&= 
should be given; last line should not be terminated with \verb=\\=. 
\begin{multline}
 \text{First line of a multline}    \\
 \text{Centered Middle line}        \\
 \shoveright{\text{A right Middle}} \\
 \text{Another centered Middle}     \\
 \text{Yet another centered Middle} \\
 \shoveleft{\text{A left Middle}}   \\
 \text{Last line of the multline}
\end{multline}

Example 8-2-6. This is the default behavior for tags.
\begin{multline}  \tag{2}
  \sum_{t \in \mathbf{T}} \int_a^t
    \biggl\lbrace \int_a^t f(t - x)^2 \,
            g(y)^2 \,dx \biggr\rbrace \,dy \\
  = \sum_{t \notin \mathbf{T}} \int_t^a
      \biggl\lbrace g(y)^2 \int_t^a
        f(x)^2 \,dx \biggr\rbrace \,dy
\end{multline}

Same formulas, with \cmd{multlinegap} set to zero. This has no effect in
\Tralics 
\setlength\multlinegap{0pt}
\begin{multline}  \tag{2}
  \sum_{t \in \mathbf{T}} \int_a^t
    \biggl\lbrace \int_a^t f(t - x)^2 \,
            g(y)^2 \,dx \biggr\rbrace \,dy \\
  = \sum_{t \notin \mathbf{T}} \int_t^a
      \biggl\lbrace g(y)^2 \int_t^a
        f(x)^2 \,dx \biggr\rbrace \,dy
\end{multline}

From now on, we redefine the \cmd{tag} command via \cmd{tagasattribute}; 
the second equation with a tag gives:
\tagasattribute
\[  \sin^2\eta+\cos^2\eta = 1  \tag{3}\]

The magic is that this uses \cmd{formulaattribute}, a command added in
\Tralics\ 2.9.5 that adds an attribute pair to the formula; our style sheet
handles a formula with a tag in the same way as a formula with an id (after
converting the id into a tag). There are four commands of the form \cmd{XXattribute}
that add an attribute to an element under construction: the math formula, the
math expression, the current row, the current cell. In these cases
\cmd{mathattribute} cannot be used (it adds an attribute to the last element
created). It is not possible to use \cmd{XMLaddatt} in math mode, and it is
not possible to use this command after a math formula in order to add an
attribute (If the token that follows a display math formula is not a
\cmd{par}, then \cmd{noindent} is inserted, thus, if this token is
\cmd{XMLaddatt}, the current element is an empty paragraph). Example
\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align}
\formulaattribute{tag}{8-2-3}
\thismathattribute{background}{white}\tableattribute{color}{black}
\rowattribute{mathvariant}{bold} x^2 + y^2+100 &=  z^2 \\
\cellattribute{columnalign}{left}  x^3 + y^3+1 &<  z^3
\end{align}
\end{verbatim}

Translation (bold attribute ignored in the Pdf version):
\begin{align}
\formulaattribute{tag}{8-2-3}
\thismathattribute{background}{white}\tableattribute{color}{black}
\rowattribute{mathvariant}{bold} x^2 + y^2+100 &=  z^2 \\
\cellattribute{columnalign}{left}  x^3 + y^3+1 &<  z^3
\end{align}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation} \begin{split} % 8-2-7
 (a + b)^4
   &= (a + b)^2 (a + b)^2      \\
   &= (a^2 + 2ab + b^2)   (a^2 + 2ab + b^2)        \\
   &= a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4
 \end{split}\end{equation}
\begin{equation} \begin{split} % 8-2-8
  (a + b)^3 &= (a + b) (a + b)^2        \\
            &= (a + b)(a^2 + 2ab + b^2) \\
            &= a^3 + 3a^2b + 3ab^2 + b^3
 \end{split}\end{equation}
\end{verbatim}

Example 8.2.7 Single equation on several lines with alignment
\begin{equation}
 \begin{split}
 (a + b)^4
   &= (a + b)^2 (a + b)^2      \\
   &= (a^2 + 2ab + b^2)
      (a^2 + 2ab + b^2)        \\
   &= a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4
 \end{split}
\end{equation}

Example 8.2.8. The \LaTeX\ companion explains that the amsmath
 package can be loaded
with options `centertags' or `tbtags'. In the first case, tags centered with
the formula (left or right), in the second case, tags are on the first line
(on the left) or last line (on the right). By default, \Tralics\ does
nothing, and in the case of `tbtags', it sets \attpair{split-tags}{tb} on the
root element. 
\begin{equation}
 \begin{split}
  (a + b)^3 &= (a + b) (a + b)^2        \\
            &= (a + b)(a^2 + 2ab + b^2) \\
            &= a^3 + 3a^2b + 3ab^2 + b^3
 \end{split}
\end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\newcommand\relphantom[1]{\mathrel{\phantom{#1}}}
\newcommand\ve{\varepsilon}  \newcommand\tve{t_{\varepsilon}}
\newcommand\vf{\varphi}      \newcommand\yvf{y_{\varphi}}
\newcommand\bfE{\mathbf{E}}

\begin{equation} \begin{split}
  f_{h, \ve}(x, y)
    &= \ve \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve u)} \vf(x) \,du  \\
    &= h \int L_{x, z} \vf(x) \rho_x(dz)                             \\
    &\relphantom{=} {} + h \biggl[
       \frac{1}{\tve}
       \biggl( \bfE_{y} \int_0^{\tve}  L_{x, y^x(s)} \vf(x) \,ds
               - \tve \int L_{x, z} \vf(x) \rho_x(dz)      \biggr) + \\
    &\relphantom{=} \phantom{{} + h \biggl[ }
       \frac{1}{\tve}
       \biggl( \bfE_{y} \int_0^{\tve}  L_{x, y^x(s)} \vf(x) \,ds
               - \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve s)}
                                            \vf(x) \,ds    \biggr) \biggr]
\end{split} \end{equation}
\end{verbatim}

Example 8-2-9
\begingroup
\newcommand\relphantom[1]{\mathrel{\phantom{#1}}}
\newcommand\ve{\varepsilon}  \newcommand\tve{t_{\varepsilon}}
\newcommand\vf{\varphi}      \newcommand\yvf{y_{\varphi}}
\newcommand\bfE{\mathbf{E}}


\begin{equation} \begin{split}
  f_{h, \ve}(x, y)
    &= \ve \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve u)} \vf(x) \,du  \\
    &= h \int L_{x, z} \vf(x) \rho_x(dz)                             \\
    &\relphantom{=} {} + h \biggl[
       \frac{1}{\tve}
       \biggl( \bfE_{y} \int_0^{\tve}  L_{x, y^x(s)} \vf(x) \,ds
               - \tve \int L_{x, z} \vf(x) \rho_x(dz)      \biggr) + \\
    &\relphantom{=} \phantom{{} + h \biggl[ }
       \frac{1}{\tve}
       \biggl( \bfE_{y} \int_0^{\tve}  L_{x, y^x(s)} \vf(x) \,ds
               - \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve s)}
                                            \vf(x) \,ds    \biggr) \biggr]
\label{e-8-2-9}
\end{split} \end{equation}
\endgroup

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather}
  (a + b)^2 = a^2 + 2ab + b^2          \\
  (a + b) \cdot (a - b) = a^2 - b^2
\end{gather}
\end{verbatim}
Example 8-2-10, equation groups without alignment.
\begin{gather}
  (a + b)^2 = a^2 + 2ab + b^2          \\
  (a + b) \cdot (a - b) = a^2 - b^2
\end{gather}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather}
  D(a,r) \equiv \{ z \in \mathbf{C}   \colon |z - a| < r \}    \notag \\
  \operatorname{seg} (a, r) \equiv    \{ z \in \mathbf{C} \colon
      \Im z < \Im a, \ |z - a| < r \}    \\
    C (E, \theta, r) \equiv    \bigcup_{e \in E} c (e, \theta, r)
\end{gather}
\end{verbatim}
Example 8-2-11
\begin{gather}
  D(a,r) \equiv \{ z \in \mathbf{C}
         \colon |z - a| < r \}    \notag \\
  \operatorname{seg} (a, r) \equiv
    \{ z \in \mathbf{C} \colon
      \Im z < \Im a, \ |z - a| < r \}    \\
    C (E, \theta, r) \equiv
    \bigcup_{e \in E} c (e, \theta, r)
\end{gather}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align}
  (a + b)^3  &= (a + b) (a + b)^2        \\
             &= (a + b)(a^2 + 2ab + b^2) \\
             &= a^3 + 3a^2b + 3ab^2 + b^3
\end{align}
\begin{align} x^2  + y^2 & = 1 \\ x  & = \sqrt{1-y^2}\end{align}
\end{verbatim}
Example 8-2-12
\begin{align}
  (a + b)^3  &= (a + b) (a + b)^2        \\
             &= (a + b)(a^2 + 2ab + b^2) \\
             &= a^3 + 3a^2b + 3ab^2 + b^3
\end{align}
and
\begin{align}
  x^2  + y^2 & = 1                       \\
  x          & = \sqrt{1-y^2}
\end{align}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align}
 \text{Compare } x^2 + y^2 &= 1 &  x^3 + y^3 &= 1 \\
  x &= \sqrt   {1-y^2} & x &= \sqrt[3]{1-y^3}
\end{align}
\begin{align}
x&= y & X  &= Y  &a  &= b+c \\
x' &= y'& X' &= Y' &a' &= b\\
 x + x' &= y + y'  &  X + X' &= Y + Y' & a'b &= c'b
\end{align}
\end{verbatim}

Example 8-2-13.
This example has two column-pairs.
\begin{align}    \text{Compare }
  x^2 + y^2 &= 1               &
  x^3 + y^3 &= 1               \\
  x         &= \sqrt   {1-y^2} &
  x         &= \sqrt[3]{1-y^3}
\end{align}
This example has three column-pairs.
\begin{align}
    x    &= y      & X  &= Y  &
      a  &= b+c               \\
    x'   &= y'     & X' &= Y' &
      a' &= b                 \\
  x + x' &= y + y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{align}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{flalign}  \text{Compare }
  x^2 + y^2 &= 1               &  x^3 + y^3 &= 1               \\
  x         &= \sqrt   {1-y^2} &  x         &= \sqrt[3]{1-y^3}
\end{flalign}
\begin{flalign}
    x    &= y      & X  &= Y  &      a  &= b+c               \\
    x'   &= y'     & X' &= Y' &      a' &= b                 \\
  x + x' &= y + y'            &  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}
\end{verbatim}
Example 8-2-14
This example has two column-pairs.
\begin{flalign}  \text{Compare }
  x^2 + y^2 &= 1               &
  x^3 + y^3 &= 1               \\
  x         &= \sqrt   {1-y^2} &
  x         &= \sqrt[3]{1-y^3}
\end{flalign}
This example has three column-pairs.
\begin{flalign}
    x    &= y      & X  &= Y  &
      a  &= b+c               \\
    x'   &= y'     & X' &= Y' &
      a' &= b                 \\
  x + x' &= y + y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}

\begin{verbatim}[numbers=left,firstnumber=last]
\renewcommand\minalignsep{0pt}
\begin{align}    \text{Compare }
  x^2 + y^2 &= 1               &  x^3 + y^3 &= 1              \\
  x         &= \sqrt   {1-y^2} &  x         &= \sqrt[3]{1-y^3}
\end{align}
\renewcommand\minalignsep{15pt}
\begin{flalign}
    x    &= y      & X  &= Y  &      a  &= b+c              \\
    x'   &= y'     & X' &= Y' &      a' &= b                \\
  x + x' &= y + y'            &  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}
\end{verbatim}
Example 8-2-15
This example has two column-pairs.
\renewcommand\minalignsep{0pt}
\begin{align}    \text{Compare }
  x^2 + y^2 &= 1               &
  x^3 + y^3 &= 1              \\
  x         &= \sqrt   {1-y^2} &
  x         &= \sqrt[3]{1-y^3}
\end{align}
This example has three column-pairs.
\renewcommand\minalignsep{15pt}
\begin{flalign}
    x    &= y      & X  &= Y  &
      a  &= b+c              \\
    x'   &= y'     & X' &= Y' &
      a' &= b                \\
  x + x' &= y + y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}

\begin{verbatim}[numbers=left,firstnumber=last]
\renewcommand\minalignsep{2em}
\begin{align}
  x      &= y      && \text{by hypothesis} \\
      x' &= y'     && \text{by definition} \\
  x + x' &= y + y' && \text{by Axiom 1}
\end{align}
\end{verbatim}
Example 8-2-16

\renewcommand\minalignsep{2em}
\begin{align}
  x      &= y      && \text{by hypothesis} \\
      x' &= y'     && \text{by definition} \\
  x + x' &= y + y' && \text{by Axiom 1}
\end{align}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation}
\begin{aligned}
  x^2 + y^2  &= 1 \\ x &= \sqrt{1-y^2} \\ \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}
 (a + b)^2 = a^2 + 2ab + b^2    \\ (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}      \end{equation}
\end{verbatim}
Example 8-2-17
\begin{equation}
\begin{aligned}
  x^2 + y^2  &= 1               \\
  x          &= \sqrt{1-y^2}    \\
 \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}
 (a + b)^2 = a^2 + 2ab + b^2    \\
 (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}      \end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation}
\begin{aligned}[b]
  x^2 + y^2  &= 1\\ x &= \sqrt{1-y^2}    \\ \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}[t]
 (a + b)^2 = a^2 + 2ab + b^2    \\ (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}\end{equation}
\end{verbatim}
Example 8-2-18 \footnote{We should do something with the optional argument }
\begin{equation}
\begin{aligned}[b]
  x^2 + y^2  &= 1               \\
  x          &= \sqrt{1-y^2}    \\
 \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}[t]
 (a + b)^2 = a^2 + 2ab + b^2    \\
 (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}
\end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\newenvironment{rcase}{\left.\begin{aligned}} {\end{aligned}\right\rbrace}
\begin{equation*}
  \begin{rcase}
    B' &= -\partial\times E  \\  E' &=  \partial\times B - 4\pi j \,
  \end{rcase}
  \quad \text {Maxwell's equations}
\end{equation*}

\end{verbatim}
Example 8-2-19\footnote{Translation/rendering of apostrophe not always correct}

\newenvironment{rcase}
    {\left.\begin{aligned}}
    {\end{aligned}\right\rbrace}

\begin{equation*}
  \begin{rcase}
    B' &= -\partial\times E          \\
    E' &=  \partial\times B - 4\pi j \,
  \end{rcase}
  \quad \text {Maxwell's equations}
\end{equation*}

\begin{verbatim}[numbers=left,firstnumber=last]
\renewcommand\minalignsep{5pt}
\begin{equation} \begin{aligned}
  V_j &= v_j &  X_i &= x_i - q_i x_j &      &= u_j + \sum_{i\ne j} q_i \\
  V_i &= v_i - q_i v_j &  X_j &= x_j &  U_i &= u_i
\end{aligned} \end{equation}
\end{verbatim}
Example 8-2-20

\renewcommand\minalignsep{5pt}
\begin{equation} \begin{aligned}
  V_j &= v_j                      &
  X_i &= x_i - q_i x_j            &
      &= u_j + \sum_{i\ne j} q_i \\
  V_i &= v_i - q_i v_j            &
  X_j &= x_j                      &
  U_i &= u_i
\end{aligned} \end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align}
  A_1 &= N_0 (\lambda ; \Omega') -  \phi ( \lambda ; \Omega')   \\
  A_2 &= \phi (\lambda ; \Omega') \phi (\lambda ; \Omega)     \\
\intertext{and finally}
  A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}
\end{verbatim}
Example 8-2-21
\begin{align}
  A_1 &= N_0 (\lambda ; \Omega')
         -  \phi ( \lambda ; \Omega')   \\
  A_2 &= \phi (\lambda ; \Omega')
            \phi (\lambda ; \Omega)     \\
\intertext{and finally}
  A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}

Example 8-2-22, 8-2-23, 8-2-24 explain that spacing around equations can be
wrong; we omit them.

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align}
  x^2+y^2 &= z^2 \label{eq:A}            \\
  x^3+y^3 &= z^3 \notag                  \\
  x^4+y^4 &= r^4 \tag{$*$}               \\
  x^5+y^5 &= r^5 \tag*{$*$}              \\
  x^6+y^6 &= r^6 \tag{\ref{eq:A}$'$}     \\
      A_1 &= N_0 (\lambda ; \Omega')
             - \phi ( \lambda ; \Omega') \\
      A_2 &= \phi (\lambda ; \Omega')
             \, \phi (\lambda ; \Omega)
             \tag*{ALSO (\theequation)}  \\
      A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}
\end{verbatim}

Example 8-2-25. In the Companion, first equation is numbered \LTC{(1)},
second equation has no number, third is \LTC{(*)}, then come \LTC{*},
\LTC{(1')}, \LTC{(2)}, \LTC{ALSO (2)} and \LTC{(3)}. Since \Tralics\ does not 
compute equation numbers, you will not see \LTC{(1)}, \LTC{(2)}, \LTC{(3)}.
Since \LTC{(1')} is obtained by a reference to the first equation, the whole
set of equations is numbered, namely \eqref{eq:A}.  It is currently impossible
to use a reference,  we locally change \cmd{ref}, so that it produces a
number, here 17. This is also the current value of the equation counter.
Hence, the full tag, concatenation of all four tags is
\LTC{*,*,17x,ALSO (17)}; we have replaced the apostrophe by x, because 
of a bug in current \Tralics. This full tag is put on the math formula.

\textbf{Note:} the style sheet that converts XML to HTML attributes a number
to each equation that has a label, and \cmd{ref} uses this number. If the
equation has a tag, no number should be attributed, and \cmd{ref} should use
the tag. This might change.

\textbf{Note:} \LaTeX\ uses \cmd{text} to format the tag, and as a
consequence, spaces are not ignored. In \Tralics, nothing special is done, and
they are ignored. Should be fixed some day.

\setcounter{equation}{17}
\let\oref\ref
\def\ref#1{17}
\begin{align}
  x^2+y^2 &= z^2 \label{eq:A}            \\
  x^3+y^3 &= z^3 \notag                  \\
  x^4+y^4 &= r^4 \tag{$*$}               \\
  x^5+y^5 &= r^5 \tag*{$*$}              \\
  x^6+y^6 &= r^6 \tag{\ref{eq:A}$x$}     \\
      A_1 &= N_0 (\lambda ; \Omega')
             - \phi ( \lambda ; \Omega') \\
      A_2 &= \phi (\lambda ; \Omega')
             \, \phi (\lambda ; \Omega)
             \tag*{ALSO (\theequation)}  \\
      A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}

\begingroup
Same example, with default behavior of \cmd{tag}. Note that the equation
number is still the same. The equation has an another label, it is now
equation \eqref{eq:A1}, but \cmd{ref}  is still defined to be 17.
\tagatcurpos
\begin{align}
  x^2+y^2 &= z^2 \label{eq:A1}            \\
  x^3+y^3 &= z^3 \notag                  \\
  x^4+y^4 &= r^4 \tag{$*$}               \\
  x^5+y^5 &= r^5 \tag*{$*$}              \\
  x^6+y^6 &= r^6 \tag{\ref{eq:A1}$'$}     \\
      A_1 &= N_0 (\lambda ; \Omega')
             - \phi ( \lambda ; \Omega') \\
      A_2 &= \phi (\lambda ; \Omega')
             \, \phi (\lambda ; \Omega)
             \tag*{ALSO (\theequation)}  \\
      A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}
\endgroup
\let\ref\oref


\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation}  \begin{split} \label{e-8-2-26}
  \lvert I_2 \rvert  &=    \left\lvert \int_{0}^T \psi(t)
      \left\{  u(a, t) - \int_{\gamma(t)}^a \frac{d\theta}{k}
        (\theta, t) \int_{a}^\theta c (\xi) u_t (\xi, t) \,d\xi
      \right\} dt \right\rvert                                     \\
                     &\le  C_6  \Biggl\lvert
      \left\lvert f \int_\Omega \left\lvert
          \widetilde{S}^{-1,0}_{a,-} W_2(\Omega, \Gamma_l)
        \right\rvert \ \right\rvert
      \left\lvert \lvert u \rvert
        \overset{\circ}{\to} W_2^{\widetilde{A}} (\Omega; \Gamma_r,T)
      \right\rvert              \Biggr\rvert
\end{split} \end{equation}
\end{verbatim}
Example 8-2-26. The book explains that the tag is not correctly positioned.
We modified the example by adding a label, and this gives an equation number
in the HTML file. This number is vertically centered, whatever the size of
the formula. 
\begin{equation}  \begin{split} \label{e-8-2-26}
  \lvert I_2 \rvert  &=    \left\lvert \int_{0}^T \psi(t)
      \left\{  u(a, t) - \int_{\gamma(t)}^a \frac{d\theta}{k}
        (\theta, t) \int_{a}^\theta c (\xi) u_t (\xi, t) \,d\xi
      \right\} dt \right\rvert                                     \\
                     &\le  C_6  \Biggl\lvert
      \left\lvert f \int_\Omega \left\lvert
          \widetilde{S}^{-1,0}_{a,-} W_2(\Omega, \Gamma_l)
        \right\rvert \ \right\rvert
      \left\lvert \lvert u \rvert
        \overset{\circ}{\to} W_2^{\widetilde{A}} (\Omega; \Gamma_r,T)
      \right\rvert              \Biggr\rvert
\end{split} \end{equation}

Example 8-2-27. Equation \eqref{e-8-2-27} should be the same as 
\eqref{e-8-2-26}; but in order to test our algorithm we have replaced some
\cmd{lvert} and \cmd{rvert} by \cmd{lVert} and \cmd{rVert}, that are the same
as \cmd{Vert}, but declared as mathopen and mathclose symbols 
\begin{align}
  \lvert I_2 \rvert &= \label{e-8-2-27}
    \left\lvert \int_{0}^T \psi(t)
      \left\lbrace
        u(a, t) - \int_{\gamma(t)}^a \frac {d\theta} k(\theta, t)
        \int_{a}^\theta c (\xi) u_t (\xi, t) \,d\xi
      \right\rbrace dt
    \right\rvert                                          \notag \\
        &\le  C_6
    \Bigg\lVert
      \left\lvert f \int_\Omega
        \left\lvert
          \widetilde{S}^{-1,0}_{a,-} W_2(\Omega, \Gamma_l)
        \right\rvert \
      \right\rvert
      \left\lvert
        \lvert u \rvert \overset{\circ}{\to} W_2^{\widetilde{A}}
        (\Omega; \Gamma_r,T)
      \right\rvert
    \Bigg\rVert
\end{align}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather}   \raisetag{-40pt}
 \text{The sign function: \ } \mathcal{S}(x) = 
 \begin{cases}-1   &  x < 0 \\ 0   &  x = 0 \\ 1   &  x > 0\end{cases}
\end{gather}
\end{verbatim}
Example 8-2-28, showing the command \cmd{raisetag}.
It is defined as doing nothing in \Tralics\ (the tag, i.e., the equation
number, is inserted by the style sheet that converts from XML to HTML.)
We have redefined here the command as follows
\begin{verbatim}[numbers=left,firstnumber=last]
\def\raisetag#1{%
\dimen0=#1\relax
\ifdim\dimen0<0pt 
  \dimen0=-\dimen0
   \formulaattribute{tag-down}{\the\dimen0}%
\else
\formulaattribute{tag-up}{\the\dimen0}\fi}
\end{verbatim}


\def\raisetag#1{%
\dimen0=#1\relax
\ifdim\dimen0<0pt 
  \dimen0=-\dimen0
   \formulaattribute{tag-down}{\the\dimen0}%
\else
\formulaattribute{tag-up}{\the\dimen0}\fi}
Thus \cmd{raisetag} with a value of \LTC{-10pt} will add 
\attpair{tag-down}{10pt} to the formula element. In this case, the style sheet
adds \attpair{style}{padding-top:10pt} to the cell containing the equation
number. In the case of a positive value, padding-bottom is used instead.
In this example, we use 40pt. 

\begin{gather}   \raisetag{-40pt} \label{e-8-2-28}
  \text{The sign function: \ }
     \mathcal{S}(x) =  \begin{cases}
                         -1   &  x < 0 \\
                          0   &  x = 0 \\
                          1   &  x > 0
                       \end{cases}
\end{gather}



\begin{verbatim}[numbers=left,firstnumber=last]
begin{subequations}  \label{eq:1}
\begin{align}  f  &= g            \label{eq:1A} \\
               f' &= g'           \label{eq:1B} \\
    \mathcal{L}f  &= \mathcal{L}g \label{eq:1C}
\end{align}
\end{subequations}
\begin{subequations}  \label{eq:2}
\renewcommand\theequation{\theparentequation\roman{equation}}
\begin{align}  f  &= g            \label{eq:2A} \\
               f' &= g'           \label{eq:2B} \\
    \mathcal{L}f  &= \mathcal{L}g + K  \label{eq:2C}
\end{align}
\end{subequations}
Note the relationship between~\eqref{eq:1}
and~\eqref{eq:2}: only~\ref{eq:1C} and~\ref{eq:2C} differ.
\end{verbatim}
Example 8-2-29: the amsmath package provides a \LTC{subequations} environment
to support ``equation subnumbering'' with tags of the form (2a), (2b), (2c),
and so on. All the tagged equations within it use this sub-numbering scheme
based on two normal \LaTeX\ counters \LTC{parentequation} and \LTC{equation}.
First group, with only labels \LTC{eq:1} and \LTC{eq1:C}
\begin{subequations}  \label{eq:1}
\begin{align}  f  &= g \\
               f' &= g'\\
    \mathcal{L}f  &= \mathcal{L}g \label{eq:1C}
\end{align}
\end{subequations}
The \Tralics\ implementation is trivial: the environment does nothing. 
Thus, the \cmd{label} command in the \LTC{subequations} corresponds to the
current section. Second group, with only labels \LTC{eq:2} and \LTC{eq2:C}.
\def\theparentequation{}
\begin{subequations} \label{eq:2}
\renewcommand\theequation{\theparentequation\roman{equation}}
\begin{align}  f  &= g  \\
               f' &= g'  \\
    \mathcal{L}f  &= \mathcal{L}g + K  \label{eq:2C}
\end{align}
\end{subequations}
We have removed two \cmd{label}s from the \LTC{align},
because it produces a single equation number and accepts a single label.
Thus, the text after the equations reads:
 \textit{Note the relationship between~\eqref{eq:1}
and~\eqref{eq:2}: only~\ref{eq:1C} and~\ref{eq:2C} differ.}




\section{Matrix-like environments}
\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation}    P_{r - j} =
 \begin{cases}
    0   &  \text{if $r - j$ is odd,} \\
    r! \, (-1)^{(r - j)/2}
        &  \text{if $r - j$ is even.}
 \end{cases}                \end{equation}
\end{verbatim}
Example 8-3-1
\begin{equation}    P_{r - j} =
 \begin{cases}
    0   &  \text{if $r - j$ is odd,} \\
    r! \, (-1)^{(r - j)/2}
        &  \text{if $r - j$ is even.}
 \end{cases}                \end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather*}
  \begin{matrix}  0 &  1 \\ 1 &  0 \end{matrix}  \quad
  \begin{pmatrix} 0 & -i \\ i &  0 \end{pmatrix} \\
  \begin{bmatrix} 0 & -1 \\ 1 &  0 \end{bmatrix} \quad
  \begin{Bmatrix} 1 &  0 \\ 0 & -1 \end{Bmatrix} \\
  \begin{vmatrix} a &  b \\ c &  d \end{vmatrix} \quad
  \begin{Vmatrix} i &  0 \\ 0 & -i \end{Vmatrix}
\end{gather*}
\end{verbatim}

Example 8-3-2, using a single equation\footnote{The delimiter for Vmatrix is 
badly rendered by Amaya}
\[
  \begin{matrix}  0 &  1 \\ 1 &  0 \end{matrix}  \quad
  \begin{pmatrix} 0 & -i \\ i &  0 \end{pmatrix} \quad
  \begin{bmatrix} 0 & -1 \\ 1 &  0 \end{bmatrix} \quad
  \begin{Bmatrix} 1 &  0 \\ 0 & -1 \end{Bmatrix} \quad
  \begin{vmatrix} a &  b \\ c &  d \end{vmatrix} \quad
  \begin{Vmatrix} i &  0 \\ 0 & -i \end{Vmatrix}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\newcommand\hdotsfor[2][x]{\multicolumn{5}{c}{.\ .\ .\ .\ .\ .\ .\ .\ .}} 
\setcounter{MaxMatrixCols}{20}
\[
 \begin{Vmatrix}
  \,a&b&c&d&e&f&g&h&i&j &\cdots\,{} \\
     &a&b&c&d&e&f&g&h&i &\cdots\,{} \\
     & &a&b&c&d&e&f&g&h &\cdots\,{} \\
     & & &a&b&c&d&e&f&g &\cdots\,{} \\
     & & & &\ddots&\ddots&\hdotsfor[2]{5}%\,{}
 \end{Vmatrix} \]
\end{verbatim}
Example 8-3-3.
The example uses \cmd{hdotsfor}, a command equivalent to
\cmd{multicolumn}\argument{5}\argument{c}\argument{leaders}. Leaders cannot be
implemented in MathML, so that the command is redefined in this case.

\renewcommand\hdotsfor[2][x]{\multicolumn{5}{c}{.\ .\ .\ .\ .\ .\ .\ .\ .}}
\setcounter{MaxMatrixCols}{20}
\[
 \begin{Vmatrix}
  \,a&b&c&d&e&f&g&h&i&j &\cdots\,{} \\
     &a&b&c&d&e&f&g&h&i &\cdots\,{} \\
     & &a&b&c&d&e&f&g&h &\cdots\,{} \\
     & & &a&b&c&d&e&f&g &\cdots\,{} \\
     & & & &\ddots&\ddots&\hdotsfor[2]{5}%\,{}
 \end{Vmatrix} \]
In the example above, there was a \cmd{,}\argument{} at the end of each
line. We had to remove it on the last line, because \Tralics\ complains if a
cell contains \cmd{multicolumns} and additional commands. The following
example is refused by \Tralics; but \LaTeX\ is happy with it, but x is typeset
outside math mode. Thus the question: what is the exact effect of the last
\cmd{,}\argument{} in the \LaTeX\ case?
\begin{verbatim}[numbers=left,firstnumber=last]
$\begin{array}{ccc}
111&222&333\\
\hdotsfor{2}x&t\\
\end{array}$
\end{verbatim}


Example 8-3-4. This example uses the environment \LTC{smallmatrix}, which is
defined by \Tralics\ to be the same as \LTC{matrix}, i.e.,  a matrix without
delimiters, $\begin{smallmatrix} 1 & 0 \\ 0 & -1   \end{smallmatrix}$
the same with  \cmd{left} and \cmd{right} parentheses
$ \left( \begin{smallmatrix}1 & 0 \\ 0 & -1 \end{smallmatrix}  \right) $.
There is some text after the matrix. It happens that matrices in text style
are badly rendered by Firefox. There is a huge amount of white space on the
left of each column.

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather}
  \sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i, j) \\
  \sum_{\begin{subarray}{l}  i \in \Lambda   \\
                             0 \le i \le m   \\
                             0 < j < n
        \end{subarray}}  P(i, j)
\end{gather}
\end{verbatim}
Example 8-3-5. The style of the subarray should be smaller
\begin{gather}
  \sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i, j) \\
  \sum_{\begin{subarray}{l}  i \in \Lambda   \\
                             0 \le i \le m   \\
                             0 < j < n
        \end{subarray}}  P(i, j)
\end{gather}

\begin{verbatim}[numbers=left,firstnumber=last]
\DeclareMathOperator\add{add}
\DeclareMathOperator\cf {cf}
\DeclareMathOperator\cov{cov}
\DeclareMathOperator\non{non}
\DeclareMathOperator\End{End}
\[ \begin{CD}
     \cov (L) @>>> \non (K) @>>> \cf (K)  \\
       @VVV          @AAA          @AAA   \\
     \add (L) @>>> \add (K) @>>> \cov (K) \\
   \end{CD} \]
\end{verbatim}
Example 8-3-6. You must be careful with the CD environment, because the
at-sign is an active character, that reads some text, depending on the
character that follows; more examples are given below.
\begingroup
\DeclareMathOperator\add{add}
\DeclareMathOperator\cf {cf}
\DeclareMathOperator\cov{cov}
\DeclareMathOperator\non{non}
\DeclareMathOperator\End{End}

\[ \begin{CD}
     \cov (L) @>>> \non (K) @>>> \cf (K)  \\
       @VVV          @AAA          @AAA   \\
     \add (L) @>>> \add (K) @>>> \cov (K) \\
   \end{CD} \]
\endgroup

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \begin{CD}
     S^{W_\Lambda}\otimes T @>j>>      T       \\
      @VVV                        @VV{\End P}V \\
    (S \otimes T)/I         @=   (Z\otimes T)/J
   \end{CD} \]
\end{verbatim}
Example 8-3-7 
\[ \begin{CD}
  S^{W_\Lambda}\otimes T @>j>>      T       \\
  @VVV                        @VV{\End P}V \\
  (S \otimes T)/I         @=   (Z\otimes T)/J
\end{CD} \]

Example 8-3-8. This uses \cmd{longrightarrow}, that produces character
U+27F9, unknown to \textit{FM}. 
\makeatletter
\def\XX{\cd@arrow@right{\End P}\downarrow}
\makeatother
\[\begin{array}{ccc}
    S^{\mathcal{W}_\Lambda}\otimes T &  \stackrel{j}{\longrightarrow}  & T  \\
    \Big\downarrow  &   &    \XX\\
    (S\otimes T)/I  & = &    (Z\otimes T)/J
  \end{array}
\]


\begin{verbatim}[numbers=left,firstnumber=last]
\[ \mathcal{Q} =
\begin{delarray}[t] ( {cc} ) X & Y \end{delarray}
\begin{delarray}[t] [ {cc} ] A & B \\ C & D   \end{delarray}
\begin{delarray}[b] \lgroup{cc}\rgroup L \\ M \end{delarray}
\]
\end{verbatim}
Example 8-3-9. This example uses the \LTC{delarray} package that changes
the meaning of the \LTC{array} environment. In the current version of \Tralics,
there is no \cmd{array} command, hence no possibility to redefine it.
The \filename{delarray.plt} file defines a \LTC{delarray} environment that is
used here.  
\[ \mathcal{Q} =
\begin{delarray}[t] ( {cc} ) X & Y \end{delarray}
\begin{delarray}[t] [ {cc} ] A & B \\ C & D   \end{delarray}
\begin{delarray}[b] \lgroup{cc}\rgroup L \\ M \end{delarray}
\]

\section{Compound structures and decorations}

\begin{verbatim}[numbers=left,firstnumber=last]
\[   0 \xleftarrow [\zeta]{}  F \times \Delta (n - 1)
     \xrightarrow {\partial_0 \alpha(b)} E^{\partial_0 b}\]
\end{verbatim}
Example 8-4-1
\[
   0 \xleftarrow [\zeta]{}  F \times \Delta (n - 1)
     \xrightarrow {\partial_0 \alpha(b)} E^{\partial_0 b}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation*}
\cfrac {1}{\sqrt{2} +
 \cfrac {1}{\sqrt{3} +
  \cfrac {1}{\sqrt{4} +
   \cfrac[r] {1}{\sqrt{5} +
    \cfrac[l] {1}{\sqrt{6} + \dotsb }
   }}}}
\end{equation*}
\end{verbatim}

Example 8-4-2
\begin{equation*}
\cfrac {1}{\sqrt{2} +
 \cfrac {1}{\sqrt{3} +
  \cfrac {1}{\sqrt{4} +
   \cfrac[r] {1}{\sqrt{5} +
    \cfrac[l] {1}{\sqrt{6} + \dotsb }
   }}}}
\end{equation*}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation} \boxed { W_t - F \subseteq V(P_i) \subseteq W_t }\end{equation}
\end{verbatim}
Example 8-4-3
\begin{equation}
   \boxed { W_t - F \subseteq V(P_i) \subseteq W_t }
\end{equation}

\begin{verbatim}[numbers=left,firstnumber=last]
\[  \sum_{i=1}^n \qquad \int_0^\infty \qquad \lim_{n \to 0} \]
Text: $\sum_{i=1}^n$, $\int_0^\infty$, $\lim_{n \to 0}$.
\end{verbatim}
Example 8-4-4
\[
  \sum_{i=1}^n \qquad \int_0^\infty \qquad \lim_{n \to 0}
\]
Text: $\sum_{i=1}^n$, $\int_0^\infty$, $\lim_{n \to 0}$.

\begin{verbatim}[numbers=left,firstnumber=last]
\[
   \sum\nolimits_{i=1}^n \qquad \int\limits_0^\infty
   \qquad  \lim\displaylimits_{n \to 0}
\]
Text: $\sum\nolimits_{i=1}^n$, $\int\limits_0^\infty$,
$\lim\displaylimits_{n \to 0}$.
\end{verbatim}
Example 8-4-5 (limits placement is wrong in the Pdf version, text style).
\[
   \sum\nolimits_{i=1}^n \qquad \int\limits_0^\infty
   \qquad  \lim\displaylimits_{n \to 0}
\]
Text: $\sum\nolimits_{i=1}^n$, $\int\limits_0^\infty$,
$\lim\displaylimits_{n \to 0}$.



\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather*}
 \xiint     \limits _V \mu(v,w)   \,du \,dv  \quad
 \xiiint    \limits _V \mu(u,v,w)   \,du \,dv \,dw  \quad
 \xiiiint   \limits _V \mu(t,u,v,w)   \,dt \,du \,dv \,dw  \\
 \idotsint \limits _V \mu(z_1, \dots, z_k)   \,\mathbf{dz}\\
 \iint     \limits _V \mu(v,w)   \,du \,dv \qquad 
 \iiint    \limits _V \mu(u,v,w)   \,du \,dv \,dw  \qquad
 \iiiint   \limits _V \mu(t,u,v,w)    \,dt \,du \,dv \,dw  \\ \textstyle
 \iint     \limits _V \mu(v,w)   \,du \,dv \qquad 
 \iiint    \limits _V \mu(u,v,w)   \,du \,dv \,dw  \qquad  
 \iiiint   \limits _V \mu(t,u,v,w)   \,dt \,du \,dv \,dw  
\end{gather*}
\end{verbatim}
Example 8-4-6. Modified, using \cmd{xiint}, \cmd{xiiint}, \cmd{xiiiint}
command that produce Unicode character U+222c, U+222D and U+2A0C,
or simple integrals.
\begin{gather*}
 \xiint     \limits _V \mu(v,w)
   \,du \,dv                      \quad
 \xiiint    \limits _V \mu(u,v,w)
   \,du \,dv \,dw                 \quad
 \xiiiint   \limits _V \mu(t,u,v,w)
   \,dt \,du \,dv \,dw            \\
 \idotsint \limits _V \mu(z_1, \dots, z_k)
   \,\mathbf{dz}\\
 \iint     \limits _V \mu(v,w)
   \,du \,dv \qquad
 \iiint    \limits _V \mu(u,v,w)
   \,du \,dv \,dw  \qquad
 \iiiint   \limits _V \mu(t,u,v,w) 
   \,dt \,du \,dv \,dw  \\ \textstyle
 \iint     \limits _V \mu(v,w)
   \,du \,dv \qquad
 \iiint    \limits _V \mu(u,v,w)
   \,du \,dv \,dw  \qquad
 \iiiint   \limits _V \mu(t,u,v,w)
   \,dt \,du \,dv \,dw  
\end{gather*}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align*}
  u & \equiv v + 1 \mod{n^2}  \\
  u & \equiv v + 1 \bmod{n^2} \\
  u &   =    v + 1 \pmod{n^2} \\
  u &   =    v + 1 \pod{n^2}
\end{align*}
The in-text layout: $ u = v + 1 \pmod{n^2} $
\begin{gather*}
   (m \bmod n) = k^2 \, ; \quad
  x \equiv y \pmod b \, ;     \\
  x \equiv y \mod c \, ;  \quad
  x \equiv y \pod d\, .
\end{gather*}
\end{verbatim}
Example 8-4-7
\begin{align*}
  u & \equiv v + 1 \mod{n^2}  \\
  u & \equiv v + 1 \bmod{n^2} \\
  u &   =    v + 1 \pmod{n^2} \\
  u &   =    v + 1 \pod{n^2}
\end{align*}
The in-text layout: $ u = v + 1 \pmod{n^2} $
\begin{gather*}
   (m \bmod n) = k^2 \, ; \quad
  x \equiv y \pmod b \, ;     \\
  x \equiv y \mod c \, ;  \quad
  x \equiv y \pod d\, .
\end{gather*}


\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation} \frac{1}{k} \log_2 c(f)
          \quad \tfrac{1}{k} \log_2 c(f) \end{equation}
Text: $ \sqrt{ \frac{1}{k} \log_2 c(f) } \quad
        \sqrt{ \dfrac{1}{k} \log_2 c(f) }\, $.
\end{verbatim}
Example 8-4-8
\begin{equation} \frac{1}{k} \log_2 c(f)
          \quad \tfrac{1}{k} \log_2 c(f) \end{equation}
Text: $ \sqrt{ \frac{1}{k} \log_2 c(f) } \quad
        \sqrt{ \dfrac{1}{k} \log_2 c(f) }\, $. 

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{equation} \binom{k}{2} 2^{k - 1}
          + \tbinom{k - 1}{2} 2^{k - 2} \end{equation} 
Text: $ \binom{k}{2} 2^{k - 1} + \dbinom{k - 1}{2} 2^{k - 2} $.
$ \dot{S} \quad \ddot{P} \quad \dddot{Q} \quad \ddddot{R} $
\end{verbatim}        
Example 8-4-9
\begin{equation} \binom{k}{2} 2^{k - 1}
          + \tbinom{k - 1}{2} 2^{k - 2} \end{equation}
Text: $ \binom{k}{2} 2^{k - 1}
        + \dbinom{k - 1}{2} 2^{k - 2} $.


Example 8-4-10: Four dots above: character unknown by FM.
$ \dot{S} \quad \ddot{P} \quad \dddot{Q} \quad \ddddot{R} $

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \accentset{\ast}{X}                 \quad
   \hat{\accentset{\star}{\hat h}}     \quad
   \underaccent{\diamond}{\mathcal{M}} \quad
   \undertilde{C}\quad\undertilde{M}\quad\undertilde{ABC} \]
\end{verbatim}

Example 8-4-11. Commands \cmd{accentset} and \cmd{underaccent}
are defined in the amsmath.plt file, they produce a \elt{munder} or 
\elt{mover} element, with attribute accent or mathaccent set to true.
Note that accents might be too big.

\[ \accentset{\ast}{X}                 \quad
   \hat{\accentset{\star}{\hat h}}     \quad
   \underaccent{\diamond}{\mathcal{M}} \quad
   \undertilde{C}\quad\undertilde{M}\quad\undertilde{ABC}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
$(xyz)\spdddot$ \quad $(xyz)\spddot$ \quad $(xyz)\spdot$
$(xyz)\spbreve$ \quad $(xyz)\spcheck$ 
$(xyz)\sphat$   \quad $(xyz)\sptilde$
\end{verbatim}
   
Example 8-4-12. (breve and hat are invisible on Firefox, too high on Amaya).
$(xyz)\spdddot$ \quad $(xyz)\spddot$ \quad $(xyz)\spdot$ \quad
$(xyz)\spbreve$ \quad $(xyz)\spcheck$  \quad
$(xyz)\sphat$   \quad $(xyz)\sptilde$

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \overset{*}{X} > \underset{*}{X}
     \iff \sideset{}{'}\sum_{a,b \in \mathbf{R^*}}
                       \overset{a}{\underset{b}{X}} = X \]
\end{verbatim}
Example 8-4-13.  Commands \cmd{overset} and \cmd{underset}
are defined in the \filename{amsmath.plt} file, they produce a \elt{munder} or 
\elt{mover} element.
\[ \overset{*}{X} > \underset{*}{X}
     \iff \sideset{}{'}\sum_{a,b \in \mathbf{R^*}}
                       \overset{a}{\underset{b}{X}} = X 
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \sideset{_{i = 1}^n}{_{j = 2}^m}\prod_{k > 1}  \mathcal{T}_{i, j}^k \]
\end{verbatim}
Example 8-4-14.
\[ \sideset{_{i = 1}^n}{_{j = 2}^m}\prod_{k > 1}  \mathcal{T}_{i, j}^k \]


\section{Variable symbol commands}

\begin{verbatim}[numbers=left,firstnumber=last]
A series $H_1, H_2, \dots, H_n$, a sum
$H_1 + H_2 + \dots + H_n$, an orthogonal product
$H_1 \times H_2 \times \dots \times H_n$.
A series $H_1, H_2, \dotsc\,$, a sum
$H_1 + H_2 + \dotsb\,$, an orthogonal product
$H_1 \times H_2 \times \dotsm\,$, and an infinite
integral:   \[ \int_{H_1} \int_{H_2} \dotsi \;  {-\Gamma}\, d\Theta \]
\end{verbatim}

Example 8-5-1.
A series $H_1, H_2, \dots, H_n$, a sum
$H_1 + H_2 + \dots + H_n$, an orthogonal product
$H_1 \times H_2 \times \dots \times H_n$.

Example 8-5-2.
A series $H_1, H_2, \dotsc\,$, a sum
$H_1 + H_2 + \dotsb\,$, an orthogonal product
$H_1 \times H_2 \times \dotsm\,$, and an infinite
integral:   \[ \int_{H_1} \int_{H_2} \dotsi \;
                           {-\Gamma}\, d\Theta \]

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{align*}
\widehat  {\psi_\delta(t) E_t h} &= \widetilde   {\psi_\delta(t) E_t h}    \\
\overline  {\psi_\delta(t) E_t h}&= \underline   {\psi_\delta(t) E_t h}    \\
\overbrace      {\psi_\delta(t) E_t h}&= \underbrace  {\psi_\delta(t) E_t h}
& & \text{Do not change style}            \\
\overrightarrow {\psi_\delta(t) E_t h}&= \overleftarrow {\psi_\delta(t) E_t h}
& &   \text{Do not change style}     \\[-3pt]
& & & \text{without \textsf{amsmath}}     \\
\underrightarrow  {\psi_\delta(t) E_t h}
&= \underleftarrow  {\psi_\delta(t) E_t h}
& & \text{Do need \textsf{amsmath}}       \\
\overleftrightarrow {\psi_\delta(t) E_t h}
&=\underleftrightarrow{\psi_\delta(t) E_t h}
& & \text{Do need \textsf{amsmath}}
\end{align*}
\end{verbatim}
                           
Example 8-5-3
\begin{align*}
\widehat        {\psi_\delta(t) E_t h}
&= \widetilde   {\psi_\delta(t) E_t h}    \\
\overline       {\psi_\delta(t) E_t h}
&= \underline   {\psi_\delta(t) E_t h}    \\
\overbrace      {\psi_\delta(t) E_t h}
&= \underbrace  {\psi_\delta(t) E_t h}
& & \text{Do not change style}            \\
\overrightarrow {\psi_\delta(t) E_t h}
&= \overleftarrow {\psi_\delta(t) E_t h}
& &   \text{Do not change style}     \\[-3pt]
& & & \text{without \textsf{amsmath}}     \\
\underrightarrow  {\psi_\delta(t) E_t h}
&= \underleftarrow  {\psi_\delta(t) E_t h}
& & \text{Do need \textsf{amsmath}}       \\
\overleftrightarrow {\psi_\delta(t) E_t h}
&=\underleftrightarrow{\psi_\delta(t) E_t h}
& & \text{Do need \textsf{amsmath}}
\end{align*}

\begin{verbatim}[numbers=left,firstnumber=last]
\[   \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 +
      \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 + x}}}}}} \]
\end{verbatim}
Example 8-5-4
\[
   \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 +
      \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 + x}}}}}}
\]




\begin{table}\XMLaddatt{simple-table}{true}
\begin{tabular}{clclcl}
$(\BMS)$ & \LTC{( )} & $\{\BMS\}$ & \cmd{\{} \cmd{\}}& $\lVert \BMS\rVert$&
\cmd{lVert} \cmd{rVert}\\
$\langle\BMS\rangle$ & \cmd{langle} \cmd{rangle} & $\lbrace\BMS\rbrace$ & 
\cmd{lbrace} \cmd{rbrace}& $\lvert \BMS\rvert$&\cmd{lvert} \cmd{rvert}\\
$\lgroup\BMS\rgroup$ & \cmd{lgroup} \cmd{rgroup} & $[\BMS]$ & \LTC{[ ]} 
& $| \BMS$& \LTC{|}\\
$\lmoustache\BMS\rmoustache$ & \cmd{lmoustache} \cmd{rmoustache} & 
$\lbrack\BMS\rbrack$ & \cmd{lbrack} \cmd{rbrack}& $\vert \BMS$&\cmd{vert}\\
$\Downarrow\BMS$ & \cmd{Downarrow}  & $\lceil\BMS\rceil$ & 
\cmd{lceil} \cmd{rceil}& $\arrowvert \BMS$&\cmd{arrowvert}\\
$\Uparrow\BMS$ & \cmd{Uparrow}  & $\lfloor\BMS\rfloor$ & 
\cmd{lfloor} \cmd{rfloor}& $\bracevert \BMS$&\cmd{bracevert}\\
$\Updownarrow\BMS$ & \cmd{Updownarrow}  & $\llbracket\BMS\rrbracket$ & 
\cmd{llbracket} \cmd{rrbracket}& $\Arrowvert \BMS$&\cmd{Arrowvert}\\
$\downarrow\BMS$ & \cmd{downarrow}  & $/\BMS$ & 
\LTC{/}& $\| \BMS$&\cmd{|}\\
$\uparrow\BMS$ & \cmd{uparrow}  & $\backslash\BMS$ & 
\cmd{backslash}& $\Vert \BMS$&\cmd{Vert}\\
$\updownarrow\BMS$ & \cmd{updownarrow}  & $\BMS$ & 
\LTC{.}& $\sqrtsign{\BMS~~~~~~~}$&\cmd{sqrtsign}\\
\end{tabular}
\caption{Vertically extensible symbols}
\end{table}



\section{Words in mathematics}

\begin{table}\XMLaddatt{simple-table}{true}
\begin{tabular}{clclclcl}
$\arccos$ &\cmd{arccos} & v$\arcsin$ &\cmd{arcsin}& $\arctan$ &\cmd{arctan}
&$\arg$&\cmd{arg}\\
$\cos$&\cmd{cos}& $\cosh$&\cmd{cosh}& $\cot$&\cmd{cot}& $\coth$&\cmd{coth}&\\ 
$\csc$&\cmd{csc}& $\deg$&\cmd{deg}& $\det$&\cmd{det}& $\dim$&\cmd{dim}&\\ 
$\exp$&\cmd{exp}& $\gcd$&\cmd{gcd}& $\hom$&\cmd{hom}& $\inf$&\cmd{inf}&\\ 
$\injlim$&\cmd{injlim}& $\ker$&\cmd{ker}& $\lg$&\cmd{lg}& $\lim$&\cmd{lim}&\\ 
$\liminf$&\cmd{liminf}& $\limsup$&\cmd{limsup}& $\ln$&\cmd{ln}& $\log$&\cmd{log}&\\ 
$\max$&\cmd{max}& $\min$&\cmd{min}& $\Pr$&\cmd{Pr}& $\projlim$&\cmd{projlim}&\\ 
$\sec$&\cmd{sec}& $\sin$&\cmd{sin}& $\sinh$&\cmd{sinh}& $\sup$&\cmd{sup}&\\ 
$\tan$&\cmd{tan}& $\tanh$&\cmd{tanh}& $\varinjlim$&\cmd{varinjlim}& $\varliminf$&\cmd{varliminf}&\\ 
$\varlimsup$&\cmd{varlimsup}& $\varprojlim$&\cmd{varprojlim}
\end{tabular}
\caption{Predefined operators and functions}
\end{table}

\begin{verbatim}[numbers=left,firstnumber=last]
\begin{gather}
  \text{Also, if } \Delta_{\text{max up}}
           = \Delta_{\text{min down}} \notag \\
  \text{(for all ups and downs) then} \notag \\
  \Delta_{\text{sum of ups}}
           = \Delta_{\text{sum of downs}}
\end{gather}
\end{verbatim}
Example 8-6-1
\begin{gather}
  \text{Also, if } \Delta_{\text{max up}}
           = \Delta_{\text{min down}} \notag \\
  \text{(for all ups and downs) then} \notag \\
  \Delta_{\text{sum of ups}}
           = \Delta_{\text{sum of downs}}
\end{gather}

\begin{verbatim}[numbers=left,firstnumber=last]
\newcommand\abs[1]{\lvert#1\rvert}
\setlength\mathindent{0pt}
\begin{gather*}
  \lim_{x \rightarrow 0} \frac{ \sin^2(x) }{ x^2 } = 1 \\
  \varliminf_{n \rightarrow \infty}
    \abs{a_{n+1}} / \abs{a_n} = 0                      \\
 %{ JG
 \varinjlim (m_i^\lambda \cdot M)^* 
  %} JG
\le \varprojlim_{A/p \rightarrow \lambda(A)}A_p \le 0
\end{gather*}
\end{verbatim}
Example 8-6-2. Braces uncommented out for the last equation.
\newcommand\abs[1]{\lvert#1\rvert}
\setlength\mathindent{0pt}
\begin{gather*}
  \lim_{x \rightarrow 0} \frac{ \sin^2(x) }{ x^2 } = 1 \\
  \varliminf_{n \rightarrow \infty}
    \abs{a_{n+1}} / \abs{a_n} = 0                      \\
  \varinjlim (m_i^\lambda \cdot M)^* \le
    \varprojlim_{A/p \rightarrow \lambda(A)}A_p \le 0 \\
{ \varinjlim (m_i^\lambda \cdot M)^*} \le
    \varprojlim_{A/p \rightarrow \lambda(A)}A_p \le 0
\end{gather*}


\begin{verbatim}[numbers=left,firstnumber=last]
\let\abs\relax
\DeclareMathOperator \meas    {meas}
\DeclareMathOperator*\esssup  {ess \, sup}
\DeclareMathOperator*\supminus{sup - minus*}
\newcommand\abs [1]{\lvert#1\rvert}
\newcommand\norm[1]{\lVert#1\rVert}
\begin{gather*}
  \norm{f}_\infty = \esssup_{x \in R^n} \abs{f(x)}  \\
  \norm{f}_\infty = \smash{\esssup_{x \in R^n}} \abs{f(x)}  \\
  \meas_1 \{ u \in R_+^1 \colon f^*(u)>\alpha \} =  
   \esssup_{x \in R^i} \; \meas_i
     \{ u \in R^n \colon \abs{f(u)} \geq \alpha \}  \\
  \quad (\forall \alpha \in \supminus_{f^*} R_{*+})
\end{gather*}
\end{verbatim}
Example 8-6-3. We removed the line break between equations 2 and 3. Note that
an asterisk is printed as a normal character. Note the use of the \cmd{smash}
command: 

\let\abs\relax
\DeclareMathOperator \meas    {meas}
\DeclareMathOperator*\esssup  {ess \, sup}
\DeclareMathOperator*\supminus{sup - minus*}
\newcommand\abs [1]{\lvert#1\rvert}
\newcommand\norm[1]{\lVert#1\rVert}
\begin{gather*}
  \norm{f}_\infty = \esssup_{x \in R^n} \abs{f(x)}  \\
  \norm{f}_\infty = \smash{\esssup_{x \in R^n}} \abs{f(x)}  \\
  \meas_1 \{ u \in R_+^1 \colon f^*(u)>\alpha \} =  
   \esssup_{x \in R^i} \; \meas_i
     \{ u \in R^n \colon \abs{f(u)} \geq \alpha \}  \\
  \quad (\forall \alpha \in \supminus_{f^*} R_{*+})
\end{gather*}


\begin{verbatim}[numbers=left,firstnumber=last]
\[\varlimsup_{n\to\infty}\calQ (u_n, u_n - u^{\#}) \ge \csc (\calQ' (u^{\#})) \]
\end{verbatim}
Example 8-6-4 
\newcommand\calQ{\mathcal{Q}}
\[ 
\let\csc\relax
\DeclareMathOperator\csc{cosec}
\varlimsup_{n\to\infty} \calQ (u_n, u_n - u^{\#})  \ge \csc (\calQ' (u^{\#})) \]



\section{Fine tuning the mathematical layout}

\begin{verbatim}[numbers=left,firstnumber=last]
\let\LB\relax\let\RB\relax\let\DS\relax
\def\Test{
   b                       %% D
    ^0                     %% S
   +                       %% D
   \frac{\LB(k + p)        %% T
          _{j'}\RB         %% S'
         \DS% \displaystyle
         \pm               %% T  [D]
         \frac{(f + q)     %% S  [T]
                ^{(pk)     %% SS [S]
                   ^y      %% SS
                   _{j'}}} %% SS'
              {(h + y)}}   %% S' [T']
        {(l + q)           %% T'
          ^{(pk)}}         %% S'
}
\[\Test\qquad \let\LB={ \let \RB=} \Test \]
\end{verbatim}

Example 8-7-1. Original \LaTeX\ version, plus version with braces added.

\normalsize                %% Style:
\let\LB\relax\let\RB\relax\let\DS\relax
\def\Test{
 b                       %% D
    ^0                     %% S
   +                       %% D
   \frac{\LB(k + p)           %% T
          _{j'}\RB            %% S'
         \DS% \displaystyle
         \pm               %% T  [D]
         \frac{(f + q)     %% S  [T]
                ^{(pk)     %% SS [S]
                   ^y      %% SS
                   _{j'}}} %% SS'
              {(h + y)}}   %% S' [T']
        {(l + q)           %% T'
          ^{(pk)}}         %% S'
}
\[\Test\qquad \let\LB={ \let \RB=} \Test \]


Example 8-7-2. Same, with \cmd{DS} replaced by \cmd{displaystyle}
\let\DS\displaystyle
\[\Test\qquad \let\LB={ \let \RB=} \Test \]

\begin{verbatim}[numbers=left,firstnumber=last]
\[ \biggl( \mathbf{E}_{y} \int_0^{t_\varepsilon}
   L_{x, y^x(s)} \varphi(x)\, ds \biggr) \]
\end{verbatim}
Example 8-7-3. This demonstrates that commands like \cmd{Large} do affect the
size delimiters as \cmd{biggl}. In \Tralics, translation of math formulas is
unaffected by font size commands. Thus, second part of example omitted.
\[ \biggl( \mathbf{E}_{y} \int_0^{t_\varepsilon}
   L_{x, y^x(s)} \varphi(x)\, ds \biggr) \]


\begin{verbatim}[numbers=left,firstnumber=last]
\[
   \sqrt[\beta]{k} \qquad
   \sqrt[\leftroot{2}\uproot{4} \beta]{k} \qquad
   \sqrt[\leftroot{1}\uproot{3} \beta]{k}
\]
\end{verbatim}
Example 8-7-4 Commands \cmd{leftroot} and \cmd{uproot} implemented as no-op.
\[
   \sqrt[\beta]{k} \qquad
   \sqrt[\leftroot{2}\uproot{4} \beta]{k} \qquad
   \sqrt[\leftroot{1}\uproot{3} \beta]{k}
\]


\begin{verbatim}[numbers=left,firstnumber=last]
$\sqrt{x} + \sqrt{y}            + \sqrt{z}$,
$\sqrt{x} + \sqrt{\mathstrut y} + \sqrt{z}$,
$\sqrt{x} + \sqrt{\smash{y}}    + \sqrt{z}$,
$\sqrt{x} + \sqrt{\smash[b]{y}} + \sqrt{z}$
\end{verbatim}
Example 8-7-5, explaining smash.
$\sqrt{x} + \sqrt{y}            + \sqrt{z}$,
$\sqrt{x} + \sqrt{\mathstrut y} + \sqrt{z}$,
$\sqrt{x} + \sqrt{\smash{y}}    + \sqrt{z}$,
$\sqrt{x} + \sqrt{\smash[b]{y}} + \sqrt{z}$


More uses of smash (top, bottom, all):
\[\sqrt{x} + \sqrt{\frac12}            + \sqrt{z},
\sqrt{x} + \sqrt{\smash[t]{\frac12}} + \sqrt{z},
\sqrt{x} + \sqrt{\smash[b]{\frac12}}    + \sqrt{z},
\sqrt{x} + \sqrt{\smash{\frac12}} + \sqrt{z}. \]

\begin{verbatim}[numbers=left,firstnumber=last]
\[
  f_p (x) =
  \begin{cases}
    \frac{1}{\smash[b]{p}}                & x = p  \\
    \frac{\strut
          \smash[t]{\frac{(1 - x)^{\frac{1}{2}} }
                         { x - \sin (x - p)     } } }
         {\sqrt{1 - p} \, \cos (x - p)}   & x \neq p
  \end{cases}
\]
\end{verbatim}
Example 8-7-6. The \cmd{strut} above needed by amsmath, see TLC2.
\[
  f_p (x) =
  \begin{cases}
    \frac{1}{\smash[b]{p}}                & x = p  \\
    \frac{\strut
          \smash[t]{\frac{(1 - x)^{\frac{1}{2}} }
                         { x - \sin (x - p)     } } }
         {\sqrt{1 - p} \, \cos (x - p)}   & x \neq p
  \end{cases}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[
   \sqrt{ \frac{a+b}{x_j} }           \quad
   \sqrt{ \frac{a+b}{\smash{x_j}} }   \quad
   \sqrt{ \frac{a+b}{{}\smash{x_j}} } \quad
   \sqrt{ \frac{a+b}{\smash{x_j+b}} }
\]
\end{verbatim}
Example 8-7-7. The empty group above needed by amsmath, see TLC2.
\[
   \sqrt{ \frac{a+b}{x_j} }           \quad
   \sqrt{ \frac{a+b}{\smash{x_j}} }   \quad
   \sqrt{ \frac{a+b}{{}\smash{x_j}} } \quad
   \sqrt{ \frac{a+b}{\smash{x_j+b}} }
\]

\section{Fonts in formulas}
\begin{verbatim}[numbers=left,firstnumber=last]
$ \forall n \in \mathbb{N} : \mathfrak{M}_n \leq \mathfrak{A} $
\DeclareMathAlphabet\mathbb{U}{fplmbb}{m}{n}
$ \lbrace n,m \in \mathbb{N} \mid  \mathfrak{N}_{n,m} \rbrace $
\DeclareMathAlphabet\mathscr{T1}{hlcw}{m}{it}
$A_B \neq \mathscr{A}_\mathscr{B} \neq \mathcal{A}_\mathcal{B}$
\end{verbatim}
Example 8-8-1
$ \forall n \in \mathbb{N} : \mathfrak{M}_n \leq \mathfrak{A} $

Example 8-8-2
\DeclareMathAlphabet\mathbb{U}{fplmbb}{m}{n}
$ \lbrace n,m \in \mathbb{N} \mid  \mathfrak{N}_{n,m} \rbrace $

Example 8-8-3
The \cmd{DeclareMathAlphabet} command takes five arguments and defines the
first one to be \cmd{relax}.
\DeclareMathAlphabet\mathscr{T1}{hlcw}{m}{it}
$A_B \neq \mathscr{A}_\mathscr{B} \neq \mathcal{A}_\mathcal{B}$

\begin{verbatim}[numbers=left,firstnumber=last]
\newcommand\bfB{\mathbf{B}}   \newcommand\bfx{\mathbf{x}}
\bmdefine\bpi{\pi}            \bmdefine\binfty{\infty}
\section{The bold equivalence
  $\sum_{j < B} \prod_\lambda : \bm{\sum_{x_j} \prod_\lambda}$}
\begin{gather}
  B_\infty + \pi B_1 \sim  \bfB_{\binfty} \bm{+}\bpi \bfB_{\bm{1}}
    \bm {\sim B_\infty + \pi B_1}                                   \\
  B_\binfty + \bpi B_{\bm{1}} \bm{\in} \bm{\biggl\lbrace}
    (\bfB, \bfx) : \frac {\partial \bfB}{\partial \bfx}
    \bm{\lnapprox} \bm{1} \bm{\biggr\rbrace}
\end{gather}
\end{verbatim}
Example 8-8-4. %Replaced \cmd{section} by \cmd{subsection}. 
Currently \cmd{bndefine} is \cmd{def} and \cmd{bm} is \cmd{mathbf}.
\newcommand\bfB{\mathbf{B}}   \newcommand\bfx{\mathbf{x}}
\bmdefine\bpi{\pi}            \bmdefine\binfty{\infty}


\section{The bold equivalence
  $\sum_{j < B} \prod_\lambda : \bm{\sum_{x_j} \prod_\lambda}$}
\begin{gather}
  B_\infty + \pi B_1 \sim  \bfB_{\binfty} \bm{+}\bpi \bfB_{\bm{1}}
    \bm {\sim B_\infty + \pi B_1}                                   \\
  B_\binfty + \bpi B_{\bm{1}} \bm{\in} \bm{\biggl\lbrace}
    (\bfB, \bfx) : \frac {\partial \bfB}{\partial \bfx}
    \bm{\lnapprox} \bm{1} \bm{\biggr\rbrace}
\end{gather}

Example 8-8-5: same code different packages

\begin{verbatim}[numbers=left,firstnumber=last]
$\bm{\Biggl\lbrace\biggl\lbrace\Bigl\lbrace\bigl\lbrace \lbrace
     \mathcal{Q}
     \rangle \bigr\rangle\Bigr\rangle\biggr\rangle\Biggr\rangle}$
\end{verbatim}

Example 8-8-6
$\bm{\Biggl\lbrace\biggl\lbrace\Bigl\lbrace\bigl\lbrace \lbrace
     \mathcal{Q}
     \rangle \bigr\rangle\Bigr\rangle\biggr\rangle\Biggr\rangle}$

Example 8-8-7: same code different packages.


\begin{verbatim}[numbers=left,firstnumber=last]
$ \bm{\sqrt[2]{x \times \alpha}} $  but
$\let\unboldmath\relax
 \bm{\sqrt[2]{x \mathbin{\mbox{\unboldmath$\times$}} \alpha}} $
  or the similar
\def\sqrtsign{\sqrt{}}
$ \bm{\sqrtsign}{\bm{x} \times \bm{\alpha}} $
%% $\bf \sqrt \it {\bf x \IT \times \bf \alpha \IT } $ see below A
%% $\bf {\sqrt} \it {\bf {x} \IT \times \bf {\alpha} \IT } $ see below B
\end{verbatim}
Example 8-8-8. Second formula modified: you cannot use \cmd{unboldmath}. Third
formula: the command \cmd{sqrtsign} is identical to \cmd{sqrt}; you may wonder
what the argument is. Currently \cmd{bm} is the same as \cmd{mathbf}, it takes
one argument and typesets it in bold face font. Hence, \Tralics\ executes the
line shown above, marked `see below A'. Here \cmd{bf} and \cmd{it} are the
tokens inserted by the \cmd{bm} command corresponding to the new and old font
(in reality, these tokens have complicated names). 
Thus, the argument of \cmd{sqrt} is the \cmd{it}
command. Note that the \cmd{sqrt} command uses a local group (is this good
idea?), so that the \cmd{it} command changes font locally; said otherwise,
current font remains bold, and \cmd{IT} is \cmd{bf}. It is a wonder that this
works. We noticed that \LaTeX\ font change commands like \cmd{mathbf} typeset
their arguments in a group, and modified the \Tralics\ code; thus the
equivalent of line marked `see below B' is executed. Suddenly \cmd{sqrt}
looses its argument. For this reason, we changed the command \cmd{sqrtsign} 
to \cmd{sqrt}\argument{}. The example is
$ \bm{\sqrt[2]{x \times \alpha}} $  but
$\let\unboldmath\relax
 \bm{\sqrt[2]{x \mathbin{\mbox{\unboldmath$\times$}} \alpha}} $
  or the similar
$\def\sqrtsign{\sqrt{}} \bm{\sqrtsign}{\bm{x} \times \bm{\alpha}} $

\begin{verbatim}[numbers=left,firstnumber=last]
\bmdefine\bhat{\hat}
% This does not work
%$\hat a \neq \bm{\hat a} \neq \bm{\hat a} = \bhat a \neq \bm{\widehat a}$
$\hat a \neq \bm{\hat a} \neq \bm\hat a = \bhat a \neq \bm\widehat a$
\end{verbatim}
Example 8-8-9 modified
\bmdefine\bhat{\hat}
$\hat a \neq \bm{\hat a} \neq \bm{\hat a} = \bhat a \neq \bm{\widehat a}$

\begin{verbatim}[numbers=left,firstnumber=last]
\section{Sample page of mathematical typesetting}

First some large operators
both in text: \( \iiint\limits_{\mathcal{Q}}
f(x,y,z)\,dx\,dy\,dz \) and
\(\prod_{\gamma\in\Gamma_{\widetilde{C}}}
\partial(\widetilde{X}_\gamma)\); and also on display:

\begin{equation}
\begin{split}
%%     This line is deliberately long so as to show
%%     differences in widths; it is a little over the measure
%%     in article/cmr.
\iiiint\limits_{\mathbf{Q}} f(w,x,y,z)\,dw\,dx\,dy\,dz  &\leq
\oint_{\bm{\partial Q}} f' \left( \max \left\lbrace
\frac{\lVert w \rVert}{\lvert w^2 + x^2 \rvert} ;
\frac{\lVert z \rVert}{\lvert y^2 + z^2 \rvert} ;
\frac{\lVert w \oplus z \rVert}{\lVert x \oplus y \rVert}
\right\rbrace\right)
\\
&\precapprox \biguplus_{\mathbb{Q} \Subset \bar{\mathbf{Q}}}
\left[ f^{\ast} \left(
    \frac{\left\lmoustache\mathbb{Q}(t)\right\rmoustache}
         {\sqrt {1 - t^2}}
    \right)\right]_{t=\alpha}^{t=\vartheta}
\\
\end{split}
\end{equation}

For $x$ in the open interval \( \left] -1, 1 \right[ \)
the infinite sum in Equation~\eqref{eq:binom1} is convergent;
however, this does not hold
throughout the closed interval \( \left[ -1, 1 \right] \).
\begin{align}
  (1 - x)^{-k} &=
    1 + \sum_{j=1}^{\infty} (-1)^j \ibinom{k}{j} x^j
    \quad \text{ for } k \in \mathbb{N}; k \neq 0.
    \label{eq:binom1}
\end{align}
\end{verbatim}
Example 8-8-10. Changed a little bit: it is currently not possible to put a
\cmd{quad} in a \cmd{text} in math mode. Thus, the \cmd{text} contains only
the word `for'.



\section{Sample page of mathematical typesetting}

First some large operators
both in text: \( \iiint\limits_{\mathcal{Q}}
f(x,y,z)\,dx\,dy\,dz \) and
\(\prod_{\gamma\in\Gamma_{\widetilde{C}}}
\partial(\widetilde{X}_\gamma)\); and also on display:

\begin{equation}
\begin{split}
%%     This line is deliberately long so as to show
%%     differences in widths; it is a little over the measure
%%     in article/cmr.
\iiiint\limits_{\mathbf{Q}} f(w,x,y,z)\,dw\,dx\,dy\,dz  &\leq
\oint_{\bm{\partial Q}} f' \left( \max \left\lbrace
\frac{\lVert w \rVert}{\lvert w^2 + x^2 \rvert} ;
\frac{\lVert z \rVert}{\lvert y^2 + z^2 \rvert} ;
\frac{\lVert w \oplus z \rVert}{\lVert x \oplus y \rVert}
\right\rbrace\right)
\\
&\precapprox \biguplus_{\mathbb{Q} \Subset \bar{\mathbf{Q}}}
\left[ f^{\ast} \left(
    \frac{\left\lmoustache\mathbb{Q}(t)\right\rmoustache}
         {\sqrt {1 - t^2}}
    \right)\right]_{t=\alpha}^{t=\vartheta}
\\
\end{split}
\end{equation}

For $x$ in the open interval \( \left] -1, 1 \right[ \)
the infinite sum in Equation~\eqref{eq:binom1} is convergent;
however, this does not hold
throughout the closed interval \( \left[ -1, 1 \right] \).
\begin{align}
  (1 - x)^{-k} &=
    1 + \sum_{j=1}^{\infty} (-1)^j \ibinom{k}{j} x^j
    \quad \text{ for } k \in \mathbb{N}; k \neq 0.
    \label{eq:binom1}
\end{align}


Other examples here omitted.
\section{Symbols in formulas}

\begin{verbatim}[numbers=left,firstnumber=last]
\[ a          \#          \top _x^\alpha x^\alpha_b \]
\[ a \mathrel{\#} \mathop{\top}_x^\alpha x^\alpha_b \]
\thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu
\[ a  -  b  =  -\max \{ x , y \}\]
\end{verbatim}

Example 8-9-1. In this example, \cmd{\char`\#} and \cmd{top} are changed into a
Rel and a Op operator, so that \elt{msub} or \elt{mover} is used in the
translation, but in the current version of \Tralics, 
no information is attached to the symbol.
\[ a          \#          \top _x^\alpha x^\alpha_b \]
\[ a \mathrel{\#} \mathop{\top}_x^\alpha x^\alpha_b \]

Example 8-9-2. This example demonstrates that spacing in math formulas depend
on three registers that the user can change, but the value is ignored by
\Tralics. 
\thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu
\[
     a  -  b  =  -\max \{ x , y \}
\]

Example 8-9-3. This demonstrates that different spacing is used for
\cmd{bigl}/\cmd{bigr} or \cmd{left}/\cmd{right}. \Tralics\ tries  very hard to
convert big open/close pairs to left-right ones. 
 
\begin{verbatim}[numbers=left,firstnumber=last]
\thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu
\[ a \Bigl( \sum x \Bigr) \neq  a \left( \sum x \right) \]
\end{verbatim}
\thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu
\[ a \Bigl( \sum x \Bigr) \neq  a \left( \sum x \right) \]

\begin{verbatim}[numbers=left,firstnumber=last]
\DeclareMathSymbol\bneg   {\mathbin}{symbols}{"3A}
\DeclareMathSymbol\rsquare{\mathrel}{AMSa}{"03}
\[ a \neg b           \qquad  x \square           y + z \]
\[ a \mathbin{\neg} b \qquad  x \mathrel{\square} y + z \]
\[ a \bneg          b \qquad  x \rsquare          y + z \]
\end{verbatim}
Example 8-9-4. This example demonstrates that 1) spacing is wrong if an
ordinary symbol is used instead of a binary symbol, 2) adding \cmd{mathrel} or
\cmd{mathbin} in \Tralics\ does not change this behavior, 3) using the
declare-something command is not enough in \Tralics: no error is signaled, but
no symbol appears.

\DeclareMathSymbol\bneg   {\mathbin}{symbols}{"3A}
\DeclareMathSymbol\rsquare{\mathrel}{AMSa}{"03}
\[ a \neg b           \qquad  x \square           y + z \]
\[ a \mathbin{\neg} b \qquad  x \mathrel{\square} y + z \]
\[ a \bneg          b \qquad  x \rsquare          y + z \]

\begin{verbatim}[numbers=left,firstnumber=last]
\[  a = b  \text{ but }  a \tilde{=} b
   \text{ which is not } a \mathrel{\tilde{=}} b  \]
\end{verbatim}

Example 8-9-5. This example indicates how embellished operators can have type
Rel or whatever. As usual, nothing special is added to the XML file. This
means that the equal-with-hat should be a relation in the HTML file, an
ordinary symbol in the Pdf version.
\[  a = b  \text{ but }  a \tilde{=} b
   \text{ which is not } a \mathrel{\tilde{=}} b  \]

\begin{verbatim}[numbers=left,firstnumber=last]
$ u \not< v$ or $a \not\in \mathbf{A} $, 
{\makeatletter\let\not\@@not $ u \not< v$ or $a \not\in \mathbf{A} $}
$ \not\leq \ \not\succeq \ \not\sim $ $ \nleq \ \nsucceq \ \nsim $
\end{verbatim}
Example 8-9-6. By default \cmd{not<} is translated at \cmd{neg<}; this is
wrong, so that we redefined it. The only trouble is that
\cmd{not}\cmd{in} does not work. We show here both behaviors:

$ u \not< v$ or $a \not\in \mathbf{A} $, 
{\makeatletter\let\not\@@not $ u \not< v$ or $a \not\in \mathbf{A} $}


Example 8-9-7. This is not really good.
$ \not\leq \ \not\succeq \ \not\sim $ and
 $ \nleq    \ \nsucceq    \ \nsim    $

\begin{verbatim}[numbers=left,firstnumber=last]
$\Longarrownot\longleftrightarrow \qquad  \arrownot\hookleftarrow$
\end{verbatim}
Example 8-9-8, demonstrating how to negate an arrow
$\Longarrownot\longleftrightarrow \qquad  \arrownot\hookleftarrow$,
this is not implemented in \Tralics.


\def\X#1{$\csname#1\endcsname$&\cmd{#1}}



\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$*$&\LTC{*}&$+$&\LTC{+}&$-$&\LTC{-}\\
\X{amalg}&\X{ast}&\X{baro}\\
\X{barwedge}&\X{bbslash}&\X{bigtriangledown}\\
\X{bigtriangleup}&\X{Cap}&\X{cap}\\
\X{Cup}&\X{cup}&\X{curlyvee}\\
\X{curlywedge}&\X{dag}&\X{dagger}\\
\X{ddag}&\X{ddagger}&\X{diamond}\\
\X{divideontimes}&\X{div}&\X{dotplus}\\
\X{doublecap}&\X{doublecup}&\X{fatbslash}\\
\X{fatsemi}&\X{fatslash}&\X{gtrdot}\\
\X{intercal}&\X{interleave}&\X{land}\\
\X{lbag}&\X{leftslice}&\X{leftthreetimes}\\
\X{lessdot}&\X{lor}&\X{ltimes}\\
\X{merge}&\X{minuso}&\X{moo}\\
\X{mp}&\X{nplus}&\X{pm}\\
\X{rbag}&\X{rightslice}&\X{rightthreetimes}\\
\X{rtimes}&\X{setminus}&\X{smallsetminus}\\
\X{sqcap}&\X{sqcup}&\X{sslash}\\
\X{star}&\X{talloblong}&\X{times}\\
\X{triangleleft}&\X{triangleright}&\X{uplus}\\
\X{varbigtriangledown}&\X{varbigtriangleup}&\X{varcurlyvee}\\
\X{varcurlywedge}&\X{vartimes}&\X{veebar}\\
\X{vee}&\X{wedge}&\X{wr}\\
\X{Ydown}&\X{Yleft}&\X{Yright}\\
\X{Yup}
\end{tabular}
\caption{Symbols of class \cmd{mathbin}, miscellaneous}\label{Tbl-bin1}
\end{table}


\let\xhpos0
\def\nexthpos{
\ifx\xhpos0\global\let\xhpos1&
\else \ifx\xhpos1\global\let\xhpos2&
\else\global\let\xhpos0\\\fi\fi
}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\let~\nexthpos
\begin{tabular}{clclclclclcl}
\X{circlearrowleft}~ \X{circlearrowright}~
\X{curvearrowleft}~\X{curvearrowright}~\X{dasharrow}~
\X{dashleftarrow}~\X{dashrightarrow}~\X{Downarrow}~
\X{downarrow}~\X{downdownarrows}~\X{downharpoonright}~
\X{gets}~\X{hookleftarrow}~\X{hookleftarrow}~
\X{hookrightarrow}~\X{Leftarrow}~\X{leftarrow}~
\X{leftarrowtail}~\X{leftarrowtriangle}~\X{leftrightarrowtriangle}~
\X{leftharpoondown}~\X{leftharpoonup}~\X{leftleftarrows}~
\X{Leftrightarrow}~\X{leftrightarrows}~\X{leftrightarrow}~
\X{leftrightharpoons}~\X{leftrightsquigarrow}~\X{Lleftarrow}~
\X{Longleftarrow}~\X{longleftarrow}~\X{Longleftarrow}~
\X{longleftrightarrow}~\X{Longmapsfrom}~\X{longmapsfrom}~
\X{Longmapsto}~\X{longmapsto}~\X{Longrightarrow}~
\X{longrightarrow}~\X{looparrowleft}~\X{looparrowright}~
\X{Lsh}~\X{Mapsfrom}~\X{mapsfrom}~
\X{Mapsto}~\X{mapsto}~\X{multimap}~
\X{nearrow}~
\X{nwarrow}~\X{restriction}~\X{rightarrowtail}~
\X{rightarrowtriangle}~\X{Rightarrow}~\X{rightarrow}~
\X{rightharpoondown}~\X{rightharpoonup}~\X{rightleftarrows}~
\X{rightleftharpoons}~\X{rightrightarrows}~\X{rightsquigarrow}~
\X{Rrightarrow}~\X{Rsh}~\X{searrow}~
\X{shortdownarrow}~\X{shortleftarrow}~\X{shortrightarrow}~
\X{shortuparrow}~
\X{swarrow}~\X{to}~\X{twoheadleftarrow}~
\X{twoheadrightarrow}~\X{Uparrow}~
\X{uparrow}~\X{upharpoonleft}~\X{upharpoonright}~
\X{Updownarrow}~\X{updownarrow}~\X{upuparrows}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (arrows)}\label{Tbl-rel1}
\end{table}

\clearpage

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{curlyveedownarrow}&\X{curlyveeuparrow}&\X{curlywedgedownarrow}\\
\X{curlywedgeuparrow}&\X{nnearrow}&\X{nnwarrow}\\
\X{ssearrow}&\X{sswarrow}\\
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (arrows, continued)}
\end{table}

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclcl}
\X{Delta}&\X{Gamma}&\X{Lambda}&\X{Omega}&\X{Phi}\\
\X{Pi}&\X{Psi}&\X{Sigma}&\X{Theta}&\X{Upsilon}\\
\X{Xi}&\X{alpha}&\X{beta}&\X{chi}&\X{delta}\\
\X{digamma}&\X{epsilon}&\X{eta}&\X{gamma}&\X{iota}\\
\X{kappa}&\X{lambda}&\X{mu}&\X{nu}&\X{omega}\\
\X{phi}&\X{pi}&\X{psi}&\X{rho}&\X{sigma}\\
\X{tau}&\X{theta}&\X{upsilon}&\X{varepsilon}&\X{varkappa}\\
\X{varphi}&\X{varpi}&\X{varrho}&\X{varsigma}&\X{vartheta}\\
\X{xi}&\X{zeta}
\end{tabular}
\caption{Symbols of class \cmd{mathord}, Greek}
\end{table}

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclcl}
$\$$&\cmd{\$}& \X{Im}&\X{Re}&\X{aleph}\\
\X{Bbbk}& \X{beth}&\X{circledS}&\X{complement}\\
\X{daleth}&\X{ell}&\X{eth}&\X{Finv}\\
\X{Game}&\X{gimel}&\X{hbar}&\X{hslash}\\
\X{imath}&\X{jmath}&\X{mathdollar}&\X{mathparagraph}\\
\X{mathsection}&\X{mathsterling}&\X{mho}&\X{P}&\\
\X{partial}&\X{pounds}&\X{S}&\X{wp}
\end{tabular}
\caption{Symbols of class \cmd{mathord}, letter-shaped}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$!$&\LTC{!}&$.$&\LTC{.}&$/$&\LTC{/}&$?$&\LTC{?}\\
$@$&\LTC{@}&$|$&\LTC{|}&$\#$&\cmd{\#}&$\%$&\cmd{\%}\\
$\&$&\cmd{\&}&$\_$&\cmd{\_}& \X{|}&\X{angle}\\
\X{Arrowvert}&\X{arrowvert}&\X{backprime}&\X{backslash}\\
\X{bracevert}&\X{bigstar}&\X{blacklozenge}&\X{blacksquare}\\
\X{blacktriangledown}&\X{blacktriangle}&\X{bot}&\X{clubsuit}\\
\X{copyright}&\X{diagdown}&\X{diagup}&\X{diamondsuit}\\
\X{emptyset}&\X{exists}&\X{flat}&\X{forall}\\
\X{heartsuit}&\X{infty}&\X{lightning}&\X{lnot}\\
\X{lozenge}&\X{measuredangle}&\X{nabla}&\X{natural}\\
\X{neg}&\X{nexists}&\X{prime}&\X{sharp}\\
\X{spadesuit}&\X{sphericalangle}&\X{square}&\X{surd}\\
\X{top}&\X{triangledown}&\X{triangle}&\X{varcopyright}\\
\X{varnothing}&\X{Vert}&\X{vert}
\end{tabular}
\caption{Symbols of class \cmd{mathord}, miscellaneous}
\end{table}

\def\XY#1#2{$\csname#1\endcsname{#2}$&\cmd{#1}\argument{#2}}
\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\XY{acute}{x}&\XY{bar}{x}&\XY{breve}{x}&\XY{check}{x}\\
\XY{ddddot}{x}&\XY{dddot}{x}&\XY{ddot}{x}&\XY{dot}{x}\\
\XY{grave}{x}&\XY{hat}{x}&\XY{mathring}{x}&\XY{tilde}{x}\\
\XY{vec}{x}&\XY{widehat}{xyz}&\XY{widetilde}{xyz}
\end{tabular}
\caption{Mathematical accents}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{boxast}&\X{boxbar}&\X{boxbox}&
\X{boxbslash}&\X{boxcircle}&\X{boxdot}\\
\X{boxempty}&\X{boxminus}&\X{boxplus}&
\X{boxslash}&\X{boxtimes}&\X{oblong}
\end{tabular}
\caption{Symbols of class \cmd{mathbin}, (boxes)}
\end{table}

\clearpage
%\count0="2980
%\count1="2A00
%\loop\ifnum\count0<\count1 $\mathmo{\char\count0}$ \advance\count0 by1 \repeat



\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{bullet}&\X{cdot}&\X{centerdot}&\X{bigcirc}\\
\X{circledast}&\X{circledcirc}&\X{circleddash}&\X{circ}\\
\X{oast}&\X{obar}&\X{ocircle}&\X{obar}\\
\X{odot}&\X{ogreaterthan}&\X{olessthan}&\X{ominus}\\
\X{oplus}&\X{oslash}&\X{otimes}&\X{ovee}\\
\X{owedge}&\X{varobslash}&\X{varocircle}&\X{varodot}\\
\X{varogreaterthan}&\X{varolessthan}&\X{varominus}&\X{varoplus}\\
\X{varoslash}&\X{varotimes}&\X{varovee}&\X{varowedge}
\end{tabular}
\caption{Symbols of class \cmd{mathbin}, (circles)}
\end{table}





\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$<$&\LTC{<} &$=$&\LTC{=}&$>$&\LTC{>}& \X{approxeq}\\
\X{approx}&\X{asymp}&\X{backsimeq}&\X{backsim}\\
\X{Bumpeq}&\X{bumpeq}&\X{circeq}&\X{cong}\\
\X{curlyeqprec}&\X{curlyeqsucc}&\X{Doteq}&\X{doteqdot}\\
\X{doteq}&\X{eqcirc}&\X{eqsim}&\X{eqslantgtr}\\
\X{eqslantless}&\X{equiv}&\X{fallingdotseq}&\X{geqq}\\
\X{geqslant}&\X{geq}&\X{ge}&\X{gggtr}\\
\X{ggg}&\X{gg}&\X{gtrapprox}&\X{gtreqless}\\
\X{gtreqqless}&\X{gtrless}&\X{gtrsim}&\X{leftrightarroweq}\\
\X{leqq}&\X{leqslant}&\X{leq}&\X{lessapprox}\\
\X{lesseqgtr}&\X{lesseqqgtr}&\X{lessgtr}&\X{lesssim}\\
\X{le}&\X{llless}&\X{lll}&\X{ll}\\
\X{precapprox}&\X{preccurlyeq}&\X{preceq}&\X{prec}\\
\X{risingdotseq}&\X{simeq}&\X{sim}&\X{succapprox}\\
\X{succcurlyeq}&\X{succeq}&\X{succsim}&\X{succ}\\
\X{thickapprox}&\X{thicksim}&\X{triangleq}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (equality and order)}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{gnapprox}& \X{gneqq} &\X{gneq}& \X{gnsim}\\
\X{gvertneqq}&\X{lnapprox}&\X{lneqq}&\X{lneq}\\
\X{lnsim}&\X{lvertneqq}&\X{ncong}&\X{neq}\\
\X{ne}&\X{ngeqq}& \X{ngeqslant}&\X{ngeq}\\
\X{ngtr}&\X{nleqq}&\X{nleqslant}&\X{nleq}\\
\X{nless}&\X{npreceq}&\X{nprec}&\X{nsim}\\
\X{nsucceq}&\X{nsucc}&\X{precnapprox}&\X{precneqq}\\
\X{precnsim}&\X{precsim}&\X{succnapprox}&\X{succneqq}\\
\X{succnsim}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (equality and order---negated)}
\end{table}



\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{blacktriangleleft}&\X{blacktriangleright}&\X{inplus}\\
\X{in}&\X{niplus}&\X{ni}\\
\X{ntriangleleftsqslant}&\X{ntrianglerightsqslant}&\X{owns}\\
\X{sqsubseteq}&\X{sqsubset}&\X{sqsupseteq}\\
\X{sqsupset}&\X{Subset}&\X{Supset}\\
\X{subseteqq}&\X{subseteq}&\X{subsetpluseq}\\
\X{subsetplus}&\X{subset}&\X{supseteqq}\\
\X{supseteq}&\X{supsetpluseq}&\X{supsetplus}\\
\X{supset}&\X{trianglelefteq}&\X{trianglerighteq}\\
\X{trianglerighteqslant}&\X{trianglelefteqslant}&\X{vartriangleleft}\\
\X{vartriangleright}&\X{vartriangle}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (sets and inclusions)}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$,$ &\LTC{,}\quad & \X{cdots}\quad& \X{hdots}\quad & \X{ldots}\quad &\X{mathellipsis}\\
$;$ & \LTC{;}& \X{colon} & \X{ddots}&\X{vdots}
\end{tabular}
\caption{Symbols of class \cmd{mathpunct}, \cmd{mathord}, \cmd{mathinner} (punctuation)}
\end{table}

\clearpage

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{notin}&\X{nsubseteqq} &\X{nsubseteq} &\X{nsupseteqq} \\
\X{nsupseteq} &\X{ntrianglelefteq}&\X{ntriangleleft}&\X{ntrianglerighteq}\\
\X{ntriangleright}&
\X{subsetneqq}&\X{subsetneq}&\X{supsetneqq}\\
\X{supsetneq}\\\X{varsubsetneqq}&\X{varsubsetneq}&
\X{varsupsetneqq}&\X{varsupsetneq}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (sets and inclusions---negated)}
\end{table}

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{nLeftarrow}\qquad&\X{nLeftrightarrow}\qquad&\X{nRightarrow}\\
\X{nleftarrow}&\X{nleftrightarrow}&\X{nrightarrow}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (arrows---negated)}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
\X{Arrownot}&\X{Longarrownot}&\X{Mapsfromchar}&\X{Mapstochar}\\
\X{arrownot}&\X{longarrownot}&\X{mapsfromchar}&\X{mapstochar}\\
\X{lhook}&\X{not}&\X{rhook}
\end{tabular}
\caption{Symbols of class \cmd{mathrel}, (negation  and arrow
  extensions). These are currently unimplemented.}
\end{table}




\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$:$& \LTC{:}& \X{backepsilon}& \X{because}&\X{between}\\
\X{bowtie}&\X{dashv}&\X{frown}&\X{Join}\\
\X{mid}&\X{models}&\X{nmid}&\X{nparallel}\\
\X{nshortmid}&\X{nshortparallel}&\X{nVDash}&\X{nvDash}\\
\X{nVdash}&\X{nvdash}&\X{parallel}&\X{perp}\\
\X{pitchfork}&\X{propto}&\X{shortmid}&\X{shortparallel}\\
\X{smallfrown}&\X{smallsmile}&\X{smile}&\X{therefore}\\
\X{varpropto}&\X{Vdash}&\X{vDash}&\X{vdash}\\\X{Vvdash}
\end{tabular}
\caption{Symbols of class \cmd{mathrel} (miscellaneous). Symbols short-foo,
  small-foo, var-foo not implemented.}
\end{table}


\def\Y#1{${\displaystyle\csname#1\endcsname}{\textstyle\csname#1\endcsname}$
&\cmd{#1}}
\begin{table}\XMLaddatt{simple-table}{true}
\begin{tabular}{clclclclclcl}
\Y{int}&\Y{oint}&\Y{bigbox}\\
\Y{bigcap}&\Y{bigcup}&\Y{bigcurlyvee}\\
\Y{bigcurlywedge}&\Y{biginterleave}&\Y{bignplus}\\
\Y{bigodot}&\Y{bigoplus}&\Y{bigotimes}\\
\Y{bigparallel}&\Y{bigsqcap}&\Y{bigsqcup}\\
\Y{bigtriangledown}&\Y{bigtriangleup}&\Y{biguplus}\\
\Y{bigvee}&\Y{bigwedge}&\Y{coprod}\\
\Y{prod}&\Y{smallint}&\Y{sum}
\end{tabular}
\caption{Symbol pairs of class \cmd{mathop} }
\end{table}

\begin{table}\XMLaddatt{simple-table}{true}
\begin{tabular}{clclclclclcl}
 $[\BMS]$ &\LTC{[]}&
 $\{\BMS\}$& \cmd{\{}\cmd{\}}& 
 $\lVert\BMS\rVert$ &\cmd{lVert}\cmd{rVert}&\\
 $\lbrack\BMS\rbrack$ &\cmd{lbrack}\cmd{rbrack}&
 $\lbrace\BMS\rbrace$ &\cmd{lbrace}\cmd{rbrace}&
 $\lvert\BMS\rvert$ &\cmd{lvert}\cmd{rvert}&\\
 $\lceil\BMS\rceil$ &\cmd{lceil}\cmd{rceil}&
$(\BMS)$ &\LTC{()}&
 $\lgroup\BMS\rgroup$ &\cmd{lgroup}\cmd{rgroup}&\\
 $\lfloor\BMS\rfloor$ &\cmd{lfloor}\cmd{rfloor}&
 $\langle\BMS\rangle$ &\cmd{langle}\cmd{rangle}&
 $\lmoustache\BMS\rmoustache$ &\cmd{lmoustache}\cmd{rmoustache}&\\
 $\llbracket\BMS\rrbracket$ &\cmd{llbracket}\cmd{rrbracket}&
\end{tabular}
\caption{Symbol pairs of class \cmd{mathopen} and \cmd{mathclose} extensible.
\cmd{bgroup} and \cmd{lgroup} wrong on HTML, not better in Pdf. Moustaches
not good in Pdf.}
\end{table}

\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{clclclclclcl}
$\llceil\rrceil$&\cmd{llceil}\cmd{rrceil} &$\binampersand\bindnasrepma$&
\cmd{binampersand}\cmd{bindnasrepma}& $\Lbag\Rbag$ &\cmd{Lbag}\cmd{Rbag}\\
$\llfloor\rrfloor$&\cmd{llfloor}\cmd{rrfloor}&
$\llparenthesis\rrparenthesis$&\cmd{llparenthesis}\cmd{rrparenthesis}
\end{tabular}
\caption{Symbol pairs of class \cmd{mathopen} and \cmd{mathclose} 
non-extensible> Lets of symbols missing in Unicode}
\end{table}


\begin{table}\XMLaddatt{simple-table}{true}
\centering
\begin{tabular}{c}
$ABCDEFGHIJKLMNOPQRSTUVWXYZ$\\
$abcdefghijklmnopqrstuvwxyz$\\
$0123456789$ 
\end{tabular}
\caption{Latin letters and arabic numerals}
\end{table}

\clearpage
\fi


\chapter{Other Examples}

\begin{verbatim}[numbers=left,firstnumber=last]
\def\EXP{\frac{x^1_2}3Foo}
\[\dfrac {\EXP1}{\phantom{\EXP}1}=\dfrac {\EXP1}{\hphantom{\EXP}1}=\dfrac21=
\dfrac{\EXP1}{\EXP1}=
\dfrac{\EXP1}{\vphantom{\EXP}1}\]
\end{verbatim}

Example of a \cmd{phantom}, a \cmd{hphantom} and a \cmd{vphantom}. In the case
of a \cmd{hphantom}, the 1 should be vertically aligned as in the case of 2/1,
otherwise should be aligned as in the case E/E (where E is the big expression);
in the case of a \cmd{vphantom}, it should be centered otherwise flushed
right (aligned with the numerator).  
\def\EXP{\frac{x^1_2}3Foo}
\[\dfrac {\EXP1}{\phantom{\EXP}1}=\dfrac {\EXP1}{\hphantom{\EXP}1}=\dfrac21=
\dfrac{\EXP1}{\EXP1}=
\dfrac{\EXP1}{\vphantom{\EXP}1}\]


Test of multiscripts: 
$\mathbox{mmultiscripts}{F1\none\mathbox{mprescripts}{}0\none}$,
$\mathbox{mmultiscripts}{F 1 2 3 4\mathbox{mprescripts}{}a\none b\none cd}$,
$\mathbox{mmultiscripts}{F 1\none 2\none 3\none 4\none
5 6\mathbox{mprescripts}{}a\none b\none cde\none \none f}$,


\ifOther
\begin{verbatim}[numbers=left,firstnumber=last]
\[\sideset{}{_d^c}\sum _xy \qquad \sideset{^a_b}{}\sum _xy \qquad
\sideset{'^a}{^c}\sum_xy\qquad \sideset{_b}{_d}\sum_xy \qquad
\sideset{^{aA}_{bB}}{^{cC}_{dD}}\sum_xy 
\]
\end{verbatim}
More examples of sideset

\[\sideset{}{_d^c}\sum _xy \qquad \sideset{^a_b}{}\sum _xy \qquad
\sideset{'^a}{^c}\sum_xy\qquad \sideset{_b}{_d}\sum_xy \qquad
\sideset{^{aA}_{bB}}{^{cC}_{dD}}\sum_xy 
\]

Differences between \cmd{uplus} and \cmd{biguplus}. Consider the following 
input lines.
\begin{verbatim}[numbers=left,firstnumber=last]
\[{\uplus a}, {\uplus _ab}, {\mathop \uplus_ab}, {\mathop \uplus\limits_ab} \]
\[{x\uplus a}, {x\uplus _ab}, {x\mathop \uplus_ab}, {x\mathop \uplus\limits_ab} \]
\end{verbatim}
%
Initial code
\[{\uplus a}, {\uplus _ab}, {\mathop \uplus_ab}, {\mathop \uplus\limits_ab}
\label{uplus1} \]
\[{x\uplus a}, {x\uplus _ab}, {x\mathop \uplus_ab}, {x\mathop \uplus\limits_ab}\label{uplus2}  \]
%
Unicode character U+2A04 used instead of \cmd{uplus}.
{
\def\uplus{\mathmo{^^^^2a04}}
\[{\uplus a}, {\uplus _ab}, {\mathop \uplus_ab}, {\mathop \uplus\limits_ab} \label{uplus3} \]
\[{x\uplus a}, {x\uplus _ab}, {x\mathop \uplus_ab}, {x\mathop \uplus\limits_ab} \label{uplus4} \]
}

In \Tralics\ 2.9.4,
translation of \cmd{uplus} was a character \entity{uplus}, translation of 
\cmd{biguplus} was  \entity{biguplus}, characters
U+22E8 (multiset union) and U+2A04 (n-ary union operator with plus). 
Thus lines \ref{uplus1}  and \ref{uplus2}  correspond to \cmd{uplus}, 
while  lines \ref{uplus3}  and \ref{uplus4} 
correspond to \cmd{biguplus}. On FL, I see a big operator on line
\ref{uplus1}, a  smaller one on line \ref{uplus2}  
(the version without index being smaller than the
other ones), and small operators on lines \ref{uplus3}  and \ref{uplus4}. 
On FM, I see a very big
operator on line \ref{uplus1}, a small one on line \ref{uplus2},  
question marks on lines \ref{uplus3} and \ref{uplus4}, and Amaya gives the
same for\ref{uplus3} and \ref{uplus4}. 
Thus, translation of \cmd{biguplus} seems to be wrong. Thus, we changed it:
in \Tralics\ 2.9.5, \cmd{biguplus} is the same character as \cmd{uplus}.
Same formulas as above, with
command \cmd{biguplus} used instead of \cmd{uplus}
\[{\biguplus a}, {\biguplus _ab}, {\mathop \biguplus_ab}, {\mathop \biguplus\limits_ab} \label{uplus5} \]
\[{x\biguplus a}, {x\biguplus _ab}, {x\mathop \biguplus_ab}, {x\mathop \biguplus\limits_ab} \label{uplus6} \]
Same, with \cmd{textstyle}
\[{\textstyle \biguplus a}, {\textstyle\biguplus _ab}, {\textstyle\mathop \biguplus_ab}, {\textstyle\mathop \biguplus\limits_ab} \label{uplus7} \]
\[{\textstyle x\biguplus a}, {\textstyle x\biguplus _ab}, {\textstyle x\mathop
  \biguplus_ab}, {\textstyle x\mathop \biguplus\limits_ab} \label{uplus8} \]


\begin{verbatim}[numbers=left,firstnumber=last]
\[ A\xleftarrow{u}B\xleftarrow[d]{}C\xleftarrow[d]{u}
   D\xrightarrow{u}E\xrightarrow[d]{}F\xrightarrow[d]{u}G \]
\end{verbatim}

This example shows the use of \cmd{xleftarrow} and \cmd{xrightarrow}.
Optional argument below the arrow, mandatory argument below.
\[
A\xleftarrow{u}B\xleftarrow[d]{}C\xleftarrow[d]{u}
D\xrightarrow{u}E\xrightarrow[d]{}F\xrightarrow[d]{u}G
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[\begin{CD}
@.  0               @.     0\\
@.       @VVV                @VVV\\
0 @>>> D^{1 \times q} @>.R>> D^{1 \times p} @>\pi>> M @>>> 0\\
@.     @|  @VV.UV\\
0 @>>> D^{1 \times q} @>.J>> D^{1 \times p} @>\kappa>> D^{1 \times (p-q)} @>>>0\\
@.       @VVV                @VVV\\
@.  0               @.     0\\
\end{CD}\]
\end{verbatim}

This example shows how to produce a commutative diagram (adapted from 
\cite{FABIANSKA:2007:INRIA-00131035:2})
\[\begin{CD}
  @.  0               @.     0\\
@.       @VVV                @VVV\\
0 @>>> D^{1 \times q} @>.R>> D^{1 \times p} @>\pi>> M @>>> 0\\
@.     @|  @VV.UV\\
0 @>>> D^{1 \times q} @>.J>> D^{1 \times p} @>\kappa>> D^{1 \times (p-q)} @>>>0\\
@.       @VVV                @VVV\\
@.  0               @.     0\\
\end{CD}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
\[\begin{CD}
@.  0               @.     0\\
@.       @VLLVV                @VVDV\\
0 @<\mathrm{above}<< D      @))\mathrm{below}) D @>\mathrm{above}>\mathrm{below}> 0\\
@.     @\vert  @VLLVDV\\
@.  0               @.     0\\
\end{CD}\]
\end{verbatim}
% Emacs >>

A variant that shows how to put data above and below the arrows.
\[\begin{CD}
@.  0               @.     0\\
@.       @VLLVV                @VVDV\\
0 @<\mathrm{above}<< D      @))\mathrm{below}) D @>\mathrm{above}>\mathrm{below}> 0\\
@.     @\vert  @VLLVDV\\
@.  0               @.     0\\
\end{CD}
\]
% Emacs >>




Some formulas that were badly rendered:
$u(t)=\displaystyle{\frac{1}{2} \, (\dot x_1(t-h)-\ddot x_1(t)),}$
$\displaystyle{z_2(t)=-\frac{1}{2} \, (\ddot \psi(t)+2 \, \psi(t)),} $
$\displaystyle{v(t)=\frac{1}{2} \, (-\ddot \psi(t)+\dot \psi(t)).}$

More formulas:
formula A:
$u(t)=\displaystyle{\frac{1}{2}}$,
formula B:
$u(t)=\dfrac{1}{2}$,
formula C:
$u(t)=\displaystyle \frac{1}{2}$,
formula D:
$u(t)={\frac{1}{2}}$,
and finally $u(t)={\frac{1}{2}}+1$.
Using display style
$\displaystyle \frac{1}{2} \, (x (1)+ \psi(t)) $


\subsection{The connexion examples}
\label{additional}
These are example where Tralics 2.10.5 produces the wrong size for closing
delimiters. 

\def\x{x}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the following are examples where closing parentheses, braces, norm symbols, etc.
% have a larger sizing than their opening counterparts in the MathML generated
% by Tralics

Example 1: $d'_{fine} = \{d'_{j,\lambda}\}_{\lambda \in
\Delta_{J-1}\cup\cdots\cup\Delta_{j_{max}}}$ and
 \[d'_{fine} = \{d'_{j,\lambda}\}_{\lambda \in
\Delta_{J-1}\cup\cdots\cup\Delta_{j_{max}}}\]


Example 2: $\mu_{1}(d)=d(1-e^{-d^{2}/2})^{-1}-2d^{-1}$.


%***************************************************************************

Example 3: $a_k^* \leq \|(a_n)\|_{\ell_p}k^{-\frac{1}{p}}$.


%***************************************************************************

Example 4: $\sigma_{n}(x)_{\ell_p} \leq
Cn^{-r}\norm{x}_{w_{l_\tau}}, \qquad \frac{1}{\tau} = r+
\frac{1}{p}$.


%***************************************************************************

Example 5: $\# \Lambda_k \ 2^{(-k-1)p} \leq \sum_{c_j \in
\Lambda_k} |c_j|^p \leq \norm{f}_{X_p}^p$ and 
\[\# \Lambda_k \ 2^{(-k-1)p} \leq \sum_{c_j \in
\Lambda_k} |c_j|^p \leq \norm{f}_{X_p}^p.\]

%***************************************************************************

Example 6: $d^n(K)_X \le E_n(K)_X$.


%***************************************************************************

Example 7: $||\x-\Delta\Phi(\x)||_{\ell_2} \leq
\frac{C \sigma_k(\x)_{\ell_1}}{\sqrt{k}}$.

Example 8:
smaller parens $\bar f(\frac{n}{\lambda A})$ versus larger parens
$f(\frac{n}{A\lambda})$.

%***************************************************************************

Example 9:
\begin{eqnarray}
||\eta_0||_{\ell_2} & \leq & \frac{C_2^2}{\sqrt{k}} \sum_{j=2}^s ||\eta_{T_{j-1}}+\eta_{T_j}||_{\ell_1} \nonumber \\
& \leq & \frac{C_2^2}{\sqrt{k}} \sum_{j=2}^s ||\eta_{T_{j-1}}||_{\ell_1}+||\eta_{T_j}||_{\ell_1} \nonumber \\
& \leq & \frac{2C_2^2}{\sqrt{k}} \sum_{j=1}^s ||\eta_{T_j}||_{\ell_1} \nonumber \\
& \leq & \frac{2C_2^2}{\sqrt{k}} \sigma_{2k}(\eta)_{\ell_1}.
\label{eqn:main2}
\end{eqnarray}

\subsection{Test of brackets}
\begin{verbatim}[numbers=left,firstnumber=last]
$\bra{X}=\bra{x^2}=\ket{Y}=\ket{y^2} = \braket{X|Y}=\braket{x^2| y^2}$
$\Bra{X}=\Bra{x^2}=\Ket{Y}=\Ket{y^2} = \Braket{X|Y}=\Braket{x^2| y^2}$
$\Braket{x|y||z}$, $\Braket{x\|y|z}$
$\Braket{x+x_2|y+y^3||z+z^4+-5}$, $\Braket{x+x_2\|y+y^2|z+z^4_5}$
$   \Braket{ \phi | \frac{\partial^2}{\partial t^2} | \psi } $
$   \Set{ x\in\mathbf{R}^2 | 0<{|x|}<5 }$
\end{verbatim}

Formula one $\bra{X}=\bra{x^2}=\ket{Y}=\ket{y^2} = \braket{X|Y}=\braket{x^2| y^2}$\\
Formula two $\Bra{X}=\Bra{x^2}=\Ket{Y}=\Ket{y^2} = \Braket{X|Y}=\Braket{x^2| y^2}$\\
Formula three $\Braket{x|y||z}$, $\Braket{x\|y|z}$\\
Formula four $\Braket{x+x_2|y+y^3||z+z^4+-5}$, \\
Formula five $\Braket{x+x_2\|y+y^2|z+z^4_5}$.

These are from the style file
$\Braket{ \phi | \frac{\partial^2}{\partial t^2} | \psi } $
and
$\Set{ x\in\mathbf{R}^2 | 0<{|x|}<5 }$.

\section{Recursion test}

\[\mathopen\|\mathopen|f\mathclose|^2 - \mathopen|\frac{p_n}{q_n}\mathclose|^2
\mathclose\|_{L^\infty(T)} <\varepsilon,\]
\[
\|g\|_{L^2(d \mu)}^2=\frac{1}{2\pi} \int_{-\pi}^{\pi}|g(e^{i\theta})|^2
d\mu(\theta),
\]

$$\mbox{ letting: }
E_{n,m}(K,K')=\{p\in P_m(K),q \in P_n(K') \mbox{ such that } \forall x \in
I\,,\, \left|\frac{p(x)}{q(x)}\right| \leq 1 \},$$

\chapter{Font tests}
We assume that the property of each math font is one (later one we shall set
it to zero), and the translation of a character is an ASCII character
with an attribute. Otherwise, it is a Unicode character between
U+1D400 and U+1F7FF. In our test we use internal font commands
like \cmd{mml@font@italic}.


\begin{verbatim}[numbers=left,firstnumber=last]
\def\F#1{\mbox{#1: }\csname mml@font@#1\endcsname}
\def\La{AB=c+1+23}
\def\Lb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\def\Lc{$\Lx abcde$ $\Lx fghijklm$ $\Lx nopqrs$ $\Lx tuvwxyz$}
\def\Ld{0123456789}
\def\Test#1{\par Test of #1: \def\Lx{\csname mml@font@#1\endcsname}
  $\Lx\La$, $\Lx\Lb$, \Lc, $\Lx\Ld$.}

\Test{normal}
\Test{upright}
\Test{bold}
\Test{italic}
\Test{bolditalic}
\Test{script}
\Test{boldscript}
\Test{fraktur}
\Test{doublestruck}
\Test{boldfraktur}
\Test{sansserif}
\Test{boldsansserif}
\Test{sansserifitalic}
\Test{sansserifbolditalic}
\Test{monospace} 
\end{verbatim}
\def\F#1{\mbox{#1: }\csname mml@font@#1\endcsname}
\def\La{AB=c+1+23}
\def\Lb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\def\Lc{$\Lx abcde$ $\Lx fghijklm$ $\Lx nopqrs$ $\Lx tuvwxyz$}
\def\Ld{0123456789}
\def\Test#1{\par Test of #1: \def\Lx{\csname mml@font@#1\endcsname}
  $\Lx\La$, $\Lx\Lb$, \Lc, $\Lx\Ld$.}

\Test{normal}
\Test{upright}
\Test{bold}
\Test{italic}
\Test{bolditalic}
\Test{script}
\Test{boldscript}
\Test{fraktur}
\Test{doublestruck}
\Test{boldfraktur}
\Test{sansserif}
\Test{boldsansserif}
\Test{sansserifitalic}
\Test{sansserifbolditalic}
\Test{monospace} 

In the Pdf version, we have problems with script and bold script for lower
letters and digits. In the MTML version, Firefox has no script, fraktur or
double struck font.

\begin{verbatim}[numbers=left,firstnumber=last]
\mathfontproperty0=0
\mathfontproperty1=0
\mathfontproperty2=0
\mathfontproperty3=0
\mathfontproperty4=0
\mathfontproperty5=0
\mathfontproperty6=0
\mathfontproperty7=0
\mathfontproperty8=0
\mathfontproperty9=0
\mathfontproperty10=0
\mathfontproperty11=0
\mathfontproperty12=0
\mathfontproperty13=0
\mathfontproperty14=0
\end{verbatim}

\mathfontproperty0=0
\mathfontproperty1=0
\mathfontproperty2=0
\mathfontproperty3=0
\mathfontproperty4=0
\mathfontproperty5=0
\mathfontproperty6=0
\mathfontproperty7=0
\mathfontproperty8=0
\mathfontproperty9=0
\mathfontproperty10=0
\mathfontproperty11=0
\mathfontproperty12=0
\mathfontproperty13=0
\mathfontproperty14=0



\Test{normal}
\Test{upright}
\Test{bold}
\Test{italic}
\Test{bolditalic}
\Test{script}
\Test{boldscript}
\Test{fraktur}
\Test{doublestruck}
\Test{boldfraktur}
\Test{sansserif}
\Test{boldsansserif}
\Test{sansserifitalic}
\Test{sansserifbolditalic}
\Test{monospace} 

The Pdf version should be the same. The HTML version is different; only
characters in the BMP are shown (for instance, the set of integers, complex
numbers, etc, are often represented using a blackboard font, using characters
U+2124, U+2102, these are not repeated at U+1D551 and UD1D3A).   

Testing internal commands that read/write math font properties.
\begin{verbatim}[numbers=left,firstnumber=last]
\def\entity#1{\xmllatex{\&\#x#1;}{}}
\makeatletter
\mathfontproperty2=3 $\mathbf{x}$
Font property:\the\mathfontproperty\mml@font@bold,
Character propery:\the\setmathchar\mathbf`x.\\
\mathfontproperty\mathbf=0
Bold x: \setmathchar\mathbf`x={\entity{1d431}}$\mathbf{x}$
ComplexC: \setmathchar\mathbf`c={\entity{2102}}$\mathbf{c}$ 
\setmathchar 5 6 7 ok 
\end{verbatim}


\def\xentity#1{\xmllatex{\&\#x#1;}{}}
\makeatletter
\mathfontproperty2=3 $\mathbf{x}$
Font property:\the\mathfontproperty\mml@font@bold,
Character property:\the\setmathchar\mathbf`x.
\mathfontproperty\mathbf=0
Bold x: \setmathchar\mathbf`x={\xentity{1d431}}$\mathbf{x}$
ComplexC: \setmathchar\mathbf`c={\xentity{2102}}$\mathbf{c}$
\setmathchar 5 6 7 ok 



\mathfontproperty0=1
\mathfontproperty1=1
\mathfontproperty2=1
\mathfontproperty3=1
\mathfontproperty4=1
\mathfontproperty5=1
\mathfontproperty6=1
\mathfontproperty7=1
\mathfontproperty8=1
\mathfontproperty9=1
\mathfontproperty10=1
\mathfontproperty11=1
\mathfontproperty12=1
\mathfontproperty13=1
\mathfontproperty14=1

\fi

\chapter{Examples from the MathML recommendation}
Examples and italic text taken from \cite{mathml2} (Mathematical Markup
Language (MathML) Version 2.0, W3C recommendation 21 October 2003.


\ifMml

\section{Introduction}
\begin{verbatim}[numbers=left,firstnumber=last]
\newcommand\Apply[2]{\mathbox{apply}{\mathbox{#1}{}#2}}
$\mathbox{mfenced}{{a+b}}^2$  % F1
$\Apply{power}{\Apply{plus}{\mathci{a}\mathci{b}} \mathcn{2}}$ %F2
${(a+b)}^2$ % F3
\end{verbatim}
The four lines above show a command and three math formulas, representing the
square of the sum of $a$ and $b$. The MathML recommendation, in its
introduction, explains that there are three types of elements: presentation
elements (formula F1) and content elements (formula F2), as well as interface
elements (the toplevel \elt{math} element, not discussed here).  In any case,
a formula is a tree; leafs are token elements or canonically empty elements.
The main difference between these two types is the following: in the case of
formula F2, there is a possibility to evaluate the formula, for instance,
with a=2 and b=3, this should yield 25. In the case of F1, we have a formula
with a superscript; in a case like $x^2$, it is impossible to tell if this
means the square of the variable $x$, or the second component of the vector
$x$.

In the example F3, there are five leafs, two identifiers, a number, two
operators. The default translation is a token element in presentation markup.
This means that the translation of `a' is implicitly a \elt{mi}
obtained by \cmd{mathmi}, instead of a \elt{ci} obtained by \cmd{mathci}.
A non-trivial question is how to translate `xy25' (the default is one or two
identifiers, followed by a number). Our formulas contain characters that are
neither letters nor digits: parenthesis, plus sign, superscript
character. These are operators; in the case of presentation markup,
an operator can be represented as a special element (\elt{msup} for a
construction base plus exponent), or a token element (a \elt{mo} element for a
sum). In the case of content markup, special element can be used (for instance
\elt{list}, or empty elements, like \elt{plus/}.

In content markup, the sum of two objects is specified by a \elt{apply}
element, whose children are the operator \elt{plus/} followed by the objects,
and a list of three objects is represented by a \elt{list} element whose children are the
objects. In presentation markup, a sum is a sequence (an explicit or implicit
\elt{mrow} element) containing the arguments and operators in order. In the
same fashion, a list can be defined as the sequence of all elements, plus the
separators (opening parentheses, closing parentheses, commas, etc.); it can
also be specified by a \elt{mfenced} element, whose attributes define what is
at the start of the list, the end of the list, and between the
elements. These attributes have a default value adapted for lists, meaning
that $f(x,y,z)$ can be obtained by the juxtaposition of $f$ and a
\elt{mfenced} element containing $x$, $y$ and $z$. In the case of formula F1,
the content of \elt{mfenced} element is the translation of \argument{a+b};
because of the braces this is a \elt{mrow} element, with three children.
Formulas F1 and F3 are equivalent: a base and an exponent, the base contains
an opening parenthesis, the identifier a, the operator plus,  the identifier b,
and a closing parenthesis. The renderer gives $\mathbox{mfenced}{{a+b}}^2$.

The second formula renders as
$\Apply{power}{\Apply{plus}{\mathci{a}\mathci{b}} \mathcn{2}}$.
My Web browser knows only some of the operators; hence it is possible that you
see the same as $ab2$. In the Pdf version, we implement the \elt{apply}
element as follows: first the operator, then the arguments as a list. We could
do better, but all n-ary operators can have implicit arguments: it is possible
to represent the sum of all $f(x)$ such that $x$ satisfies some condition,
for instance, $x\in\mathbb{N}$ and $x$ is a square.
Since \Tralics\ does not generate content markup, this is not implemented at
all. 

\begin{verbatim}[numbers=left,firstnumber=last]
${\mathbox{apply}{\mathbox{minus}{}\mathci{a}\mathci{b}}}$ %2.1.3
\end{verbatim}
Simple example of presentation markup:
${\mathbox{apply}{\mathbox{minus}{}\mathci{a}\mathci{b}}}$. Note that the
minus operator takes one or two arguments.


\section{More complicated examples}

\begin{verbatim}[numbers=left,firstnumber=last]
${x^2+{4\*x}+4}=0$
\end{verbatim}
Rendering:
${x^2+{4\* x}+4}=0$. 
\textsl{Note the use of nested elements, to denote terms, for example, the
  left-hand side of the equation}; this is obtained here by simply putting
braces in the \TeX\ source. \textsl{The \entity{InvisibleTimes} MathML
  character entity is used here to indicate to a renderer that there are
  special spacing rules between the 4 and the x and that the 4 and the x should not be broken
  onto separate lines}. This special character can be obtained by the \cmd{*}
command whose meaning is: do not consider any special spacing rule, but allow
a break here. We decide to translate \cmd{*} in this way because it converts
an invisible product into an invisible product. We do not believe in
hyphenation for math formulas (inline formulas should be small, and not split,
big formulas should be in display mode).
Translation from XML to Pdf is empty for this character.


\begin{verbatim}[numbers=left,firstnumber=last]
$x=\frac{{-b}\pm\sqrt{b^2-{4\* a\* c}}}{2\* a}$
\end{verbatim}
Second example, 
$x=\frac{{-b}\pm\sqrt{b^2-{4\* a\* c}}}{2\* a}$.
\textit{Notice that the `plus or minus' sign is given by the entity name
  \&PlusMinus; this is equivalent to using the character reference
  \&\#00B1;}. When converting an XML document into Pdf,  the character
reference is 
required (notice that the style sheet that converts from XML to XSL/FO
replaces entity names by character references, so that this is not a
problem). On the other hand, there are cases where entity names are refused in
a HTML document: if that document is presented as XML, and the DTD makes no
reference to MathML (this very document is likely to be XHTML1.0 strict).


\begin{verbatim}[numbers=left,firstnumber=last]
$z\mathbox{mfenced}{{x+y}}$
$A=\begin{bmatrix}x&y\\z&w\end{bmatrix}$
\end{verbatim}

Example three: $z\mathbox{mfenced}{{x+y}}$. The MathML recommendation says
that there is some ambiguity: what is the relation between $z$ and the
expression $x+y$ that follows? implicit product or function application? A
translator like \Tralics\ cannot guess.

Example four
$A=\begin{bmatrix}x&y\\z&w\end{bmatrix}$.
\textsl{Most elements have a number of attributes that control the details of
  their screen and print rendering. The attributes for operator elements given
using \elt{mo} are set to default values determined by a
dictionary}. Translation of the environment is a \elt{mfenced} element, with
two attributes; all other attributes are ignored in the XML to Pdf
conversion. No dictionary is currently used; translation of a \elt{mo} is
complicated:  the difference between $\lim$ and $\sum$ is that we have a
sequence of 3 ASCII characters, and a character reference (that could be
given in base 10, in base 16, or directly as a UTF-8 character). The XML
reader converts this into a command (with a complicated name) that expands to
\cmd{sum}, that expands to whatever is defined by the style files. 

\begin{verbatim}[numbers=left,firstnumber=last]
\def\Cx{\mathci{x}} \def\Dz{\mathcn{0}}
\def\Dt{\mathcn{2}} \def\Df{\mathcn{4}}
$\Apply{eq}{ 
  \Apply{plus}{ \Apply{power}{\Cx\Dt} \Apply{times}{\Df\Cx}\Df}
  \Dz}$
\end{verbatim}

Example 2.3.2, content markup.
\def\Cx{\mathci{x}} \def\Dz{\mathcn{0}}
\def\Dt{\mathcn{2}} \def\Df{\mathcn{4}}
$\Apply{eq}{ 
  \Apply{plus}{ \Apply{power}{\Cx\Dt} \Apply{times}{\Df\Cx}\Df}
  \Dz}$
This example shows that content markup is sometimes easier. 

\begin{verbatim}[numbers=left,firstnumber=last]
\def\Ca{\mathci{a}}\def\Cb{\mathci{b}} \def\Cc{\mathci{c}}
\def\Cpm{\mathcsymbol{^^b1}}
$\Apply{eq}{
   \Cx 
   \Apply{divide}{
     \mathbox{apply}{
       \Cpm
       \Apply{minus}{\Cb}
       \Apply{root}{\mathbox{degree}{\Dt}
          \Apply{minus}{
            \Apply{power}{\Cb\Dt}
            \Apply{times}{\Df\Ca\Cc}}}}
     \Apply{times}{\Dt\Ca}}}$
\end{verbatim}

Next example
\def\Ca{\mathci{a}}\def\Cb{\mathci{b}} \def\Cc{\mathci{c}}
\def\Cpm{\mathcsymbol{^^b1}}
$\Apply{eq}{
   \Cx 
   \Apply{divide}{
     \mathbox{apply}{
       \Cpm
       \Apply{minus}{\Cb}
       \Apply{root}{\mathbox{degree}{\Dt}
          \Apply{minus}{
            \Apply{power}{\Cb\Dt}
            \Apply{times}{\Df\Ca\Cc}}}}
     \Apply{times}{\Dt\Ca}}}$.
This example has two interesting points. The first one is that some operators
can have optional arguments (in this case, the default value 2 is used). The
second point is that the first child of \elt{apply} can be any function; 
in this example, it is a \elt{csymbol} element (equivalent of \elt{mo}), whose
value is the character $\pm$ (that has to be entered as a character, not a
command). Other content markup examples omitted.
%


\begin{verbatim}[numbers=left,firstnumber=last]
$\mathbox{mrow}{\mathbox{apply}{\mathbox{eq}{}\mathci{A}
\mathbox{matrix}{\mathbox{matrixrow}{\mathci{x}\mathci{y}}
\mathbox{matrixrow}{\mathci{z}\mathci{w}}}}}$
\end{verbatim}

Next example
$\mathbox{mrow}{\mathbox{apply}{\mathbox{eq}{}\mathci{A}
\mathbox{matrix}{\mathbox{matrixrow}{\mathci{x}\mathci{y}}
\mathbox{matrixrow}{\mathci{z}\mathci{w}}}}}$. This example is badly rendered
in the Pdf (matrix operators not implemented), and my favorite HTML browser
shows the same result! 



\section{Presentation Markup}
\begin{verbatim}[numbers=left,firstnumber=last]
\def\X#1#2{\mathbox{#1}{\mathcnothing{\char32#2\char32}}}
$\X{mi}{x}\X{mo}{+}{\X{mi}{a}\X{mo}{/}\X{mi}{b}}$
$x+{a/b}$ 
\end{verbatim}

\def\X#1#2{\mathbox{#1}{\mathcnothing{\char32#2\char32}}}
Compare
`$\X{mi}{x}\X{mo}{+}{\X{mi}{a}\X{mo}{/}\X{mi}{b}}$'
with `$x+{a/b}$'. 
These two examples  should look the same; in the first case the content of each
element is a space, a character, a space; for the second example, there are no
spaces. 

\begin{verbatim}[numbers=left,firstnumber=last]
$\mathmi[fontweight][bold][mathvariant][normal]{a}$
$\mathmi[fontweight][bold][mathvariant][sans-serif]{a}$
$\mathmi[fontweight][bold][mathvariant][fraktur]{a1}$
$\mathbox{mstyle}[fontstyle][italic]{\mathbf{a}b}$
\end{verbatim}

Deprecated styles: `$\mathmi[fontweight][bold][mathvariant][normal]{a}$'
should be a normal a, `$\mathmi[fontweight][bold][mathvariant][sans-serif]{a}$'
should be a sans-serif a, and 
`$\mathmi[fontweight][bold][mathvariant][fraktur]{a1}$' should be fraktur.
In the case of 
`$\mathbox{mstyle}[fontstyle][italic]{\mathbf{a}b}$', the a should be bold
upright, and the b should be italic. The MathML recommendation says that
`mathvariant' should have precedence over `fontstyle', which is deprecated,
and not used by \Tralics. In the Pdf, attributes of \cmd{mstyle} are
currently ignored. 

\begin{verbatim}[numbers=left,firstnumber=last]
$x$ $\mathmi{\char32x\char32}$
$D$ $\mathmi{\char32sin\char32}$ $\mathmi[mathvariant][script]{L}$
$\mathmi{}$
\end{verbatim}

Examples for 3.2.3: `$x$' (an x without spaces), 
`$\mathmi{\char32x\char32}$' (an x with spaces), 
`$D$', `$\mathmi{\char32sin\char32}$', '$\mathmi[mathvariant][script]{L}$'
and `$\mathmi{}$' (empty identifier). An italic font should be used unless
defined by an attribute, or an upright font if the element has more than 
one character. In the Pdf, spaces are incorreclty counted as characters.

\begin{verbatim}[numbers=left,firstnumber=last]
$\sin(x)$ $\mathmi{sin}\ApplyFunction x$ $1+x+\mathmo{...}+n$
$1+x+\mathmi{...}+n$ $\pi, \ImaginaryI,\ExponentialE$
\end{verbatim}
This is $\sin(x)$, using \&ApplyFunction;, Unicode character U+2061:
`$\mathmi{sin}\ApplyFunction x$'. Ellipses using \elt{mo}: `$1+x+\mathmo{...}+n$'
and \elt{mi}: `$1+x+\mathmi{...}+n$', constants $\pi, \ImaginaryI,\ExponentialE$
(these are somehow unusual in Pdf).

\begin{verbatim}[numbers=left,firstnumber=last]
$2, \mathmn{0.123}, \mathmn{1,000,000}, \mathmn{2.1e10},
\mathmn{0xFFEF}, \mathmn{MCMLXIX}, \mathmn{twenty one}$.
$2+{3\*\ImaginaryI},\frac12, \pi, \ExponentialE$.
\end{verbatim}
A \elt{mathmn} element represents a number, typeset with an upright font,
for instance
$2$, $\mathmn{0.123}$, $\mathmn{1,000,000}$, $\mathmn{2.1e10}$,
$\mathmn{0xFFEF}$, $\mathmn{MCMLXIX}$, $\mathmn{twenty one}$. 
Numbers, that could be \elt{mathcn} (content markup numbers), but are not
\elt{mathmn} (presentation markup numbers): 
$2+{3\*\ImaginaryI},\frac12, \pi, \ExponentialE$. 

\begin{verbatim}[numbers=left,firstnumber=last]
$+, <,\le, \mathmo{<=}, \mathmo{++}, \sum,\mathmo{.NOT}, \mathmo{and},
\*,\mathmo[mathvariant][bold]{+}$
$({a+b})$, $[{0,1})$, $f\ApplyFunction {({x,y})}$
 $x\* y$, $f\ApplyFunction{(x)}$, $\sin\ApplyFunction x$
and $m_{1\InvisibleComma2}$.
\end{verbatim}
Example of \elt{mathmo} (operators): 
$+, <,\le, \mathmo{<=}, \mathmo{++}, \sum,\mathmo{.NOT}, \mathmo{and},
\*,\mathmo[mathvariant][bold]{+}$. In the Pdf version, font attributes are
ignored for operators (they are complicated to implement, and only `bold'
variant is available with the current math fonts).

More examples: $({a+b})$, $[{0,1})$, $f\ApplyFunction {({x,y})}$.

Invisible operators: $x\* y$, $f\ApplyFunction{(x)}$, $\sin\ApplyFunction x$
and $m_{1\InvisibleComma2}$.

\begin{verbatim}[numbers=left,firstnumber=last]
$\frac{\DifferentialD}{\DifferentialD x}$
\end{verbatim}
Embellishment $\frac{\DifferentialD}{\DifferentialD x}$. The MathML
recommendation says that the spacing around an embellished operator like $+_4$
should be the same as that of the operator at its core. An expression like
$4_+$ is not an embellished operator, but phantoms are. More surprising: a
fraction whose numerator is an operator  is an embellished  operator, the
example shown here being the motivation. 


\begin{verbatim}[numbers=left,firstnumber=last]
$\underline{(}\frac ab \overline)$. 
$\mathmo[maxsize][1]{(} \frac ab\mathmo[maxsize][1]{)}$,
$(\frac ab)$
$x\mathop\rightarrow\limits_{\mtext{ maps to }}y$
\end{verbatim}

Stretching: $\underline{(}\frac ab \overline)$. With maxsize
$\mathmo[maxsize][1]{(} \frac ab\mathmo[maxsize][1]{)}$, and without
$(\frac ab)$. The rule is the following. An enbellished operator (for
instance an underlined parenthesis) should stretch vertically, 
as it it were not embellished, this is not
implemented in the Pdf. A maximum size can be given (either as a dimension, or
a ratio to the default size, a value of 1 says that the operator should not
stretch. Horizontal stretching: 
$x\mathop\rightarrow\limits_{\mtext{ maps to }}y$. In the Pdf version, we have
a normal arrow. 

\begin{verbatim}[numbers=left,firstnumber=last]
$\mtext{ Theorem 1: }$
$X\mathbox{mtext}{\mathcnothing{^^^^2009}}X$
$X\mathbox{mtext}{\mathcnothing{^^^^2009^^^^200a^^^^200a^^^^2009%
^^^^200a^^^^200a}}X$'
$X\mkern10muX$
$X\mtext{ /* a comment */ }X$'
$\mathmo{ there exists }{{\delta>0}\mathmo{ such that
}{{f\ApplyFunction{(x)}}<1}}$
\end{verbatim}
Text: `$\mtext{ Theorem 1: }$',
`$X\mathbox{mtext}{\mathcnothing{^^^^2009}}X$'
`$X\mathbox{mtext}{\mathcnothing{^^^^2009^^^^200a^^^^200a^^^^2009%
^^^^200a^^^^200a}}X$' (expression obtained by inserting twice three characters:
thickspace, thinspace and verythinspace, should be the same as 
`$X\mkern10muX$',
`$X\mtext{ /* a comment */ }X$'. Other example:
$\mathmo{ there exists }{{\delta>0}\mathmo{ such that
  }{{f\ApplyFunction{(x)}}<1}}$. The MathML rules say that initial and final
space should be removed and consecutive space characters should be replaced by
a single space character in elements like \elt{mtext} or \elt{mo}. This is not
done in the Pdf version, and you will see the following: normally \elt{mtext}
is typeset via \cmd{text}, and spaces are typeset as usual outside math mode;
the default for all other operators is a math font, and spaces are ignored. 
A non-trivial question is: what amount of space is inserted between the
`exists' and the $\delta$ that follows? Firefox uses none, this is not good,
\TeX\ uses a small space, but ignores the space before it, the MathML
recommendation is unclear, and the sample renderings of the MathML test suite
show no space between two \elt{mtext} elements or between  a \elt{mtext} and a
comma. 

\begin{verbatim}[numbers=left,firstnumber=last]
${x\mathbox{malignmark}[edge][right]{}}^2$
\end{verbatim}

Alignment: ${x\mathbox{malignmark}[edge][right]{}}^2$.  The empty element used
in this formula is ignored in the Pdf version, (and, it seems,  by my browser
also). It defines an alignment mark, that is ignored outside  tables.
The idea is the following. If you want a table where all elements are
centered, except for the first row, first column, and element at position
(2,2), the easy way is to use a \elt{mtable} element, specifying that
alignment is left, center, etc, specify alternative alignment for the first
row, or some specific elements. If this is not sufficient, an alternate method
is provided. Typically each row contains a single cell, with some empty
\elt{maligngroup} elements. You can specify alignments for groups in the same
way as alignment for cells, with two additions: if the group contains numbers,
you can say that decimal points are aligned (there is an implicit point at the
end of the group); moreover you can explicitly set a mark. In the example
above, the mark is between the letter x and the superscript. Using a mark does
not alter rendering of the expression.

\begin{verbatim}[numbers=left,firstnumber=last]
$\mathbox{ms}{\mathcnothing{\&}}$
$\mathbox{ms}{\mathcnothing{\&amp;}}$
$\mathbox{ms}{\mathcnothing{double quote is "}}$ 
$\mathbox{ms}[lquote][aa][rquote][bb]{\mathcnothing{test}}$ 
\end{verbatim}

Literals $\mathbox{ms}{\mathcnothing{\&}}$,
$\mathbox{ms}{\mathcnothing{\&amp;}}$,
$\mathbox{ms}{\mathcnothing{double quote is "}}$, 
$\mathbox{ms}[lquote][aa][rquote][bb]{\mathcnothing{test}}$.
This element is not yet correctly converted in Pdf. There should be some kind
of quotes around the expression, the quotes may be given by attributes; my
browser shows strange characters.

\begin{verbatim}[numbers=left,firstnumber=last]
${2\* x}+y-z$, $({x,y})$
\end{verbatim}

Example of \elt{mrow}: ${2\* x}+y-z$, $({x,y})$. 

\begin{verbatim}[numbers=left,firstnumber=last]
\[\frac{(\frac ab\mathattribute{linethickness}{0})\qquad 
\frac ab}{\frac cd}\mathattribute{linethickness}{2}\qquad
\frac{1}{x^3+\frac x3} = \frac{1}{x^3+\frac x3}
\mathattribute{bevelled}{true}\qquad \frac{1+\sqrt 5}{2}
\]
\end{verbatim}
Example of \elt{mfrac}; if the bevelled attribute is true, a diagonal line
should separate numerator and denoninator (not implemented in Pdf).
\[\frac{(\frac ab\mathattribute{linethickness}{0})\qquad 
\frac ab}{\frac cd}\mathattribute{linethickness}{2}\qquad
\frac{1}{x^3+\frac x3} = \frac{1}{x^3+\frac x3}
\mathattribute{bevelled}{true}\qquad \frac{1+\sqrt 5}{2}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
$\mathbox{mstyle}[maxsize][1]{(\frac ab)}$
\end{verbatim}
Example of \elt{mstyle}: $\mathbox{mstyle}[maxsize][1]{(\frac ab)}$. 
Attributes of the element are used by children as default value. In the
example, both opening and closing parentheses should use maxsize=1.
This mechanism is not yet implemented in the Pdf.

\begin{verbatim}[numbers=left,firstnumber=last]
$\mathbox{merror}{
\mtext{ Unrecognised element: mfraction; arguments were: }
{1+\sqrt5}\mtext{ and } 2}$
\end{verbatim}
Error: $\mathbox{merror}{
\mtext{ Unrecognised element: mfraction; arguments were: }
{1+\sqrt5}\mtext{ and } 2}$.

\begin{verbatim}[numbers=left,firstnumber=last]
\def\test{C\mathbox{mpadded}[width][0em]{\kern-0.3em\text{|}}}
$\test$, $\mathbox{semantics}
{\test\mathbox{annotation-xml}[encoding][MathML-Presentation]{\mathbb{C}}}$
$\mathbb{C}$
$\mathbox{mpadded}[width][0em]{C}\kern0.3em\text{|}$
\end{verbatim}

\def\test{C\mathbox{mpadded}[width][0em]{\kern-0.3em\text{|}}}
Padding: $\test$, $\mathbox{semantics}
{\test\mathbox{annotation-xml}[encoding][MathML-Presentation]{\mathbb{C}}}$.
The previous expression contains two letters C with a vertical bar over
it. None of them looks OK on my browser, because of the negative space. The Pdf
version contains a third C because the \elt{semantics} element is not
implemented. The formula should mimic $\mathbb{C}$. 
Positive padding $\mathbox{mpadded}[width][0em]{C}\kern0.3em\text{|}$ is
better in my browser.

\begin{verbatim}[numbers=left,firstnumber=last]
$\frac{x+y+z}{x\phantom{\mathmo[form][infix]{+}y}+z}$
$\frac{x+y+z}{x\phantom{+}\phantom{y}+z}$
\end{verbatim}
Phantom: $\frac{x+y+z}{x\phantom{\mathmo[form][infix]{+}y}+z}$ 
and $\frac{x+y+z}{x\phantom{+}\phantom{y}+z}$. These two expressions should
produce the same result, the numerator and the denoninator have the same
width. Said otherwise, spacing around the plus symbol (inside or outside
phantom) should be that of a prefix plus operator if it is the first 
element in a row, followed by something else, should be infix if it is the
sole element, or neither first nor last, should be postfix otherwise.


\begin{verbatim}[numbers=left,firstnumber=last]
\def\mfence{\mathbox{mfenced}}
Fences: $\mfence{x}$, $(x)$, $\mfence{xy}$, $f\ApplyFunction\mfence{xy}$,
$(x,y)$, $\mfence{{a+b}}$, $\mfence[open][[]{0\relax1}$.
Wrong $\mfence{a+b}$, $\mfence{01}, \bf\mfence{xy}$,
right: $\bf\mfence{x y}$, $\bf\mfence{{x}{y}}$.
\end{verbatim}
\def\mfence{\mathbox{mfenced}}
Fences: $\mfence{x}$, $(x)$, $\mfence{xy}$, $f\ApplyFunction\mfence{xy}$,
$(x,y)$, $\mfence{{a+b}}$, $\mfence[open][[]{0\relax1}$.
Wrong $\mfence{a+b}$, $\mfence{01}, \bf\mfence{xy}$,
right: $\bf\mfence{x y}$,  $\bf\mfence{{x}{y}}$.
Note that separators do not show in the Pdf, so that it is unclear why some
expressions are wrong. 

The first expression is wrong, because the MathML
documentation says that a \elt{mrow} is necessary so that the \elt{mfenced}
has just one argument; a pair of braces should be added, this gives the 
\cmd{mrow}. Examples that follow are wrong because `01' or `xy' produce a
single \elt{mn} or \elt{mi} element; in the case of an identifier this may
depend on the font. You can use a separator (space or
\cmd{relax}) or uses braces (no \elt{mrow} is produced if there is a single
element in the math list). Note: spaces are ignored in math mode; it is not
completely clear whether or not a space is allowed as separator.

\begin{verbatim}[numbers=left,firstnumber=last]
\[
\def\mtr{\mathbox{mtr}}
\def\mtdr{\mathbox{mtd}[columnalign][right]}
\def\ralign{\cellattribute{columnalign}{right}}
\def\X#1#2{\mathbox{menclose}[notation][#1]{#2}}
\mathbox{mtable}[columspacing][0pt][rowspacing][0pt]{
  \mtr{\mathbox{mtd}{}\mtdr{10}}
  \mtr{\mtdr{131}\mtdr{\X{longdiv}{1413}}}
  \mtr{\mathbox{mtd}{}\mtdr{{\underline{131}\phantom{3}}}}
  \mtr{\mathbox{mtd}{}\mtdr{103}}}
\qquad
a_{\X{actuarial}{n}\*i}
\qquad
\begin{array}{cc}
  &\ralign10\\
\ralign131&\ralign\X{longdiv}{1413}\\
  &\ralign \underline{131}\phantom{3}\\
  &\ralign 103
\end{array}\mathattribute{columspacing}{0pt}\mathattribute{rowspacing}{0pt}
\]
\end{verbatim}

Examples of menclose (Does not work in the Pdf or with Firefox; works with Amaya).
\[
\def\mtr{\mathbox{mtr}}
\def\mtdr{\mathbox{mtd}[columnalign][right]}
\def\ralign{\cellattribute{columnalign}{right}}
\def\X#1#2{\mathbox{menclose}[notation][#1]{#2}}
\mathbox{mtable}[columspacing][0pt][rowspacing][0pt]{
  \mtr{\mathbox{mtd}{}\mtdr{10}}
  \mtr{\mtdr{131}\mtdr{\X{longdiv}{1413}}}
  \mtr{\mathbox{mtd}{}\mtdr{{\underline{131}\phantom{3}}}}
  \mtr{\mathbox{mtd}{}\mtdr{103}}}
\qquad
a_{\X{actuarial}{n}\*i}
\qquad
\begin{array}{cc}
  &\ralign10\\
\ralign131&\ralign\X{longdiv}{1413}\\
  &\ralign \underline{131}\phantom{3}\\
  &\ralign 103
\end{array}\mathattribute{columspacing}{0pt}\mathattribute{rowspacing}{0pt}
\]

\begin{verbatim}[numbers=left,firstnumber=last]
$(x+y)^2$ ${(x+y)}^2$ $\int_0^1{\ExponentialE^x\*{\DifferentialD x}}$
\end{verbatim}
Scripts:
Compare $(x+y)^2$ (without braces) with ${(x+y)}^2$ (recommended), 
$\int_0^1{\ExponentialE^x\*{\DifferentialD x}}$

\begin{verbatim}[numbers=left,firstnumber=last]
$\underbrace{x+y+z}\mathattribute{accentunder}{true} \text{~versus~} 
\underbrace{x+y+z}\mathattribute{accentunder}{false}
$, $\hat x \text{~versus~}\hat x\mathattribute{accent}{false}$,
$\overbrace{x+y+z}\mathattribute{accent}{true} \text{~versus~}
\overbrace{x+y+z}\mathattribute{accent}{false}$, 
$\mathop{\int\limits_0}\limits^\infty \text{~versus~} \int\limits_0^\infty$
\end{verbatim}

Underscript, overscripts:
$\underbrace{x+y+z}\mathattribute{accentunder}{true} \text{~versus~} \underbrace{x+y+z}\mathattribute{accentunder}{false}
$, $\hat x \text{~versus~}\hat x\mathattribute{accent}{false}$,
$\overbrace{x+y+z}\mathattribute{accent}{true} \text{~versus~}
\overbrace{x+y+z}\mathattribute{accent}{false}$. Converting mathml to Pdf is
not obvious because if a brace character is an accent-declared overscript, we
must apply some command to the kernel. In order for this example to work,
another command must be applied if the brace is non-accent (we use the same
command, that's simplier). In a case like 
$\mathop{\int\limits_0}\limits^\infty \text{~versus~} \int\limits_0^\infty$
there is no difference between an operator with underscript  to which an
overscript is added, and an operator with two scripts. 

\begin{verbatim}[numbers=left,firstnumber=last]
$\mathbox{mmultiscripts}{F1\none\mathbox{mprescripts}{}0\none}
\ApplyFunction{({;a;z})}$
$\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$
\end{verbatim}
Multiscripts:
$\mathbox{mmultiscripts}{F1\none\mathbox{mprescripts}{}0\none}
\ApplyFunction{({;a;z})}$ and 
$\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$.

\begin{verbatim}[numbers=left,firstnumber=last]
$(\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\end{array})$,
$\mathbox{mtable}{\mathbox{mlabeledtr}[id][e-is=m-c-square]{
\mathbox{mtd}{\text{(2.1)}}
\mathbox{mtd}{{E={m\*c^2}}}}}$.
\end{verbatim}
Tables: a matrix
$(\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\end{array})$,
and an numbered equation:
$\mathbox{mtable}{\mathbox{mlabeledtr}[id][e-is=m-c-square]{
\mathbox{mtd}{\text{(2.1)}}
\mathbox{mtd}{{E={m\*c^2}}}}}$. 

\begin{verbatim}[numbers=left,firstnumber=last]
$\def\X{\mathbox{maligngroup}{}}
\def\A{{{\X\mathmn{8.44}\*\X x} \X +{\X \mathmn{55} \*\X y}}\X=\X0}
\def\B{{{\X\mathmn{3.1} \*\X x} \X -{\X \mathmn{0.7}\*\X y}}\X=\X{-\mathmn{1.1}}}
\mathbox{mtable}[groupalign][\char`\{decimalpoint left left decimalpoint left
decimalpoint\char`\}]{
\mathbox{mtr}{\mathbox{mtd}{{\A}}}
\mathbox{mtr}{\mathbox{mtd}{{\B}}}}
$
\end{verbatim}
Alignment
$\def\X{\mathbox{maligngroup}{}}
\def\A{{{\X\mathmn{8.44}\*\X x} \X +{\X \mathmn{55} \*\X y}}\X=\X0}
\def\B{{{\X\mathmn{3.1} \*\X x} \X -{\X \mathmn{0.7}\*\X y}}\X=\X{-\mathmn{1.1}}}
\mathbox{mtable}[groupalign][\char`\{decimalpoint left left decimalpoint left
decimalpoint\char`\}]{
\mathbox{mtr}{\mathbox{mtd}{{\A}}}
\mathbox{mtr}{\mathbox{mtd}{{\B}}}}
$. As explained above, this could be typeset, by aligning the \cmd{X}. the
material between two \cmd{X} commands should be left-aligned, or aligned on
the decimal point. In some cases, the \cmd{X} is a direct child of the cell,
but not always. For this reason, it is nearly impossible to typeset this
correctlty in \TeX.


\fi

\bibliography{tralics}


\tableofcontents

\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End:
 
