French title: Produire du MathML avec Tralics
Author: José Grimm
Location: Sophia Antipolis
Inria Research Theme: THnum
Inria Research Report Number: 6181
Revision: 2
Team: Apics
Date: May 2007
Revised Date: 29 November 2007
Keywords: Tralics, XML, MathML, mathematics, LaTeX, HTML, Pdf.
French keywords: Tralics, XML, MathML, mathématiques, LaTeX, HTML, Pdf.
Note: The software and the documentation is available at http://www-sop.inria.fr/apics/tralics.
Author's email address: Jose.Grimm[at]sophia.inria.fr.
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 TeXbook, 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 xmltex (a package by D. Carlisle that makes TeX an XML interpreter), and a great number of modifications to the file 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 experimantal version 2.10.8, in which examples in section 4.1 should work fine.
Le but de ce papier est de démontrer qu´il est possible de traduire presque toutes les formules de mathématiques de la syntaxe LaTeX vers le langage XML. Le document que vous lisez contient un grand nombre de formules extraites du TeXbook, 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ématiques inchangées; pour la lire, il vous faut un navigateur ou un plugin qui sache interpréter le MathML et les fontes associées pour les symboles et les opérateurs. La version Pdf a été obtenue grâce au package xmltex de D. Carlisle (qui fait de TeX un interprète XML), et un grand nombre de modifications dans le fichier mathml2.xmt, qui contient le code d´interprétation des mathématiques. Tous les fichiers nécessaires pour obtenir ce document sont distribués avec le package Tralics à partir de la version 2.10.
1. Introduction
2. Examples from the TEXbook
3. Higher Mathematics, TLC2
4. Other Examples
5. Font tests
6. Examples from the MathML recommendation
Bibliography
Table of Contents
The technical reports [6] and [7] 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 ([10], [3], [2]). 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émiques de mathématiques, http://www.cedram.org/) has decided to convert the metadata of some collections (including the Annales de l´institut Fourier) from LaTeX to HTML, [1]. 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 , and the alternate version contains $L^1(\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 \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 [9], but also those of the TeXbook [8], or the MathML recommendation [4], 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 \newpage \null \vskip-2cm is impossible to express in XSL/FO (said otherwise, all my attempts failed), and I had to add a new element <vspace> for this purpose.
The source file testmath.tex is part of the Tralics distribution; translating it requires Tralics version 2.10, and some packages, like amsmath (do not try to include the file amsmath.sty, this is not possible; you must use 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 TeXbook. Examples of the LaTeX companion [9] 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 FL means Firefox on Linux (unless specified, it is Firefox 2.0, on Fedora Core 3) and FM means Firefox on MacIntosh (unless specified, it is Firefox 2.0 on a PowerBook G4, MacOS 10.4). We also tested Amaya, bot AM (version 9.55 on Mac) and 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.
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 \clearpage commands; in this document, we used the \xbox command in order to produce an empty <clearpage> element in the XML document, and we adapted the style sheets.
There is a \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 3 and 4, that occupy a full page, and inserting smaller tables after that. Moreover, table 4 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 raweb-cfg.sty file. However, the color attribute is honored for the <mstyle> element (all symbols appearing in the LaTeX companion for which no Unicode element has been found are replaced by a red using this method). For the text case, the <inline> element is translated into <span> element in the HTML and a <fo:inline> element in the Pdf, all attributes are copied; in the previous sentence we have used
\xbox{inline}{\XMLaddatt{color}{#F00000}\XMLaddatt{style}{color:#E00000}red} $\mathbox{mstyle}[color][\#D00000]{X}$ \def\UnimplementedOperator{\mathbox{mstyle}[color][red]{X}}
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.
These are the options you can use when compiling the file testmath.tex
-noentnames -trivialmath=7 -leftquote=2018 -rightquote=2019 -nozerowidthspace
The first option says that you prefer ⇚ to ⇚ (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 \mathbb should add a mathvariant attribute; these two options set initial values to some counters, they are not needed, because the associated file 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 -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:
a configuration file, that behaves like the default one; namely one that defines the root element to be <std> and the dtd file to be classes.dtd;
the source file testmath.tex, and the associated testmath.ult file;
the class file report.clt (and the auxiliary file std.clt);
the standard math packages amsmath.plt, amscd.plt, delarray.plt, amsxtra.plt, amsgen.plt, amsbsy.plt, amsopn.plt;
the file fancyvrb.plt for the special verbatim mode; and
the file RR.plt for the meta data.
When converting the document to HTML, we use the `xsltproc´ program. The style sheet is testmathhtml.xsl; this is a short style sheet; but it needs cls.xsl and RR.xsl. Conversion to XSL/FO uses RRfo.xsl as style sheet, it needs clsfo.xsl, that includes raweb3-param.xsl, rrrafo3.xsl, clspages.xsl, RRfosimple.xsl, 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 xml or 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 wtestmath.tex containing the following lines
1 \def\xmlfile{testmath.fo} 2 \def\LastDeclaredEncoding{T1} 3 \input{xmltex.tex} 4 \end{document}
It requires 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 fotex.xmt, fotex.sty as distributed in the xml directory. Additional required files are fotex-add.sty, raweb-uni.sty, and fotex.cfg. Finally the file wtestmath.cfg should be a symbolic link to raweb-cfg.sty.
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, \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 \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 \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 \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 $L^1(\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 <mrow> elements; translation of the hat character is non-obvious, because MathML provides <msub> and <mover> as possible translations; a command like \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 \cfrac is always text style) or the presence of style change commands. Some commands depend on the style (for instance \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: ^^1 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 \par, this is illegal. Characters that are neither letters nor digits generally translate to a <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 \sqrt\frac{1}{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 \frac, are prefix commands (they come before their arguments), a few commands, like \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 <mi> element; Tralics tries to converts LL or TT into a single element, according to the following rule. Assume that \T is defined to be \mathbb{T} and \TT is defined to be \mathbb{TT}. Then \TT produces a single element with two characters, while \T\T produces two elements with a single character. On the other hand, a strange rule of MathML says that the font used for a <mi> element (that lacks font attributes) depends on the number of characters in it; for this reason, in a formula like , the translation is a sequence of two <mi> elements, without attributes, containing a single character (implicit product). In a case like , a single <mn> element is constructed, because this represents a number (in a case like , an implicit comma could be added in the case where the expression refers to row 1 column 2 of the matrix ; however, do not expect such a behavior in a near future). The source code of the expression above is $x_{12}$. Without the braces, the translation is (if you do not see the difference, there is a bug somewhere).
If the internal counter \@nomathml is negative, the tree is converted to a character string in a trivial manner; in a case like \cfrac12, you will see \cfrac{1}{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 , you will see two font changes as explained above. If you want to see the characters \mathbb there are two solutions: the easy one works only since version 2.10: Tralics inserts in the tree all commands that behave like \relax; these commands are ignored when converting the tree into a MathML expression, but the name is used otherwise; thus \let \mathbb \relax does the job. Otherwise, it suffices to redefine \mathbb in order to expand to the desired string (using \string for instance). Note: since version 2.10, a font change command that takes an argument defines a semi-simple group, by inserting \begingroup and \endgroup commands.
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.
1 `$x$', `$2$', `$ x$', `$ 2 $', 2 `$(x + y)/(x - y)$', `$(x+y) / (x-y)$'
Easy formulas: `´, `´, `´, `´, `´, `´.
We show here some Greek letters, and some other symbols:
3 $\Gamma, \nu,\kappa$, 4 $\phi,\emptyset, \epsilon,\in,\approx,\mapsto$ 5 $(\phi,\theta,\epsilon,\rho)$, 6 $(\varphi,\vartheta,\varepsilon,\varrho)$, 7 $$\alpha, \beta, \gamma, \delta.$$
Greek letters , and other symbols: ; standard Greek(note: ➳) letters, , and variants , a display math formula:
8 \begingroup 9 \catcode`\*=3 10 *x^2*, \( x_2\), \begin{math}\Sigma\end{math} 11 **A** \[ B\] \begin{displaymath} C \end{displaymath} 12 \endgroup
We show here that any character of category code 3 can be used as math delimiter: , as well as two alternative ways introduced by LaTeX: , . We show that display math can be entered by doubling the character of category 3 (actual rules are more complicated, see the TeXBook), 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.
Exercise 16.1: .
Exercise 16.2: \le,\ge,\ne, \leq,\geq, and \neq: , .
Complex formulas with superscripts(up high) and subscripts (down low).
13 $x^2$, $x_2$, $2^x$, $x^2y^2$, $x ^ 2y ^ 2$, $x_2y_2$, $_2F_3$, 14 $x^{2y}$, $2^{2^x}$, $2^{2^{2^x}}$, $y_{x_2}$, $y_{x^2}$.
Translation , , , , , , , , , , , .
Consider now the following two formulas:
15 $((x^2)^3)^4$, ${({(x^2)}^3)}^4$.
Translation of the first formula
16 <formula type='inline'> 17 <math xmlns='http://www.w3.org/1998/Math/MathML'> 18 <mrow> 19 <mo>(</mo> 20 <mo>(</mo> 21 <msup><mi>x</mi> <mn>2</mn> </msup> 22 <msup><mo>)</mo> <mn>3</mn> </msup> 23 <msup><mo>)</mo> <mn>4</mn> </msup> 24 </mrow> 25 </math> 26 </formula>
Translation of the second formula
27 <formula type='inline'> 28 <math xmlns='http://www.w3.org/1998/Math/MathML'> 29 <msup> 30 <mrow><mo>(</mo> 31 <msup> 32 <mrow> 33 <mo>(</mo> 34 <msup><mi>x</mi> <mn>2</mn> </msup> 35 <mo>)</mo> 36 </mrow> 37 <mn>3</mn> 38 </msup> 39 <mo>)</mo> 40 </mrow> 41 <mn>4</mn> 42 </msup> 43 </math> 44 </formula>
The current Tralics uses some hacks, so that the translation is actually different. You will get first , second , third , and fourth . Here the first two formulas correspond to the XML fragment shown above (they were produced by prefixing each parenthesis with \mathord, and after that we have the actual translation. The MathML recommendation says that some operators are 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 \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 All parentheses have the same size in the pdf version, the same is true for the HTML version in the first formula. Now, the <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.”
45 `${}_2F_3$', `${_2}F_3$', `${_2F_3}$'
Exercise 16.3: Three ways to have an empty kernel: `´, `´, `´. 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 <mrow> element, unless the list has one element (in the second example, there are two tokens between the braces, converted to a single <msub> element, the math list has a single element, braces are useless). In these two cases, the main math list has two <msub> elements, and a <mrow> is added. In the last case, the main math list has a single element, a <mrow>, thus, no <mrow> is added and braces are useless.
46 `$x+_2F_3$' and `$x+{}_2F_3$'.
Effect of braces after plus sign: `´ and `´. 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 (AM shows both formulas with index attached to F).
47 ${x_2}_3$, $\displaystyle {\sum}'$
Note that an <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 , you will get an error if braces are omitted; in the same fashion, an error is signaled (when converting to Pdf) if <mrow> is missing. Reason two, in a case like , the apostrophe is not placed above the sum if there is a <mrow> (the sum operator has type Op, but not the group, unless there is a \mathop before it).
Exercise 16.4: Double superscript, , .
48 $x^2_3$, $x_3^2$, $x^{31415}_{92}+\pi$, $x_{y^a_b}^{z_c^d}$. 49 $P_2^2$ and $P{}_2^2$.
Simultaneous superscripts and subscripts , , , .
Vertical alignment: and . 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).
50 `$\prime$', $y_1^\prime$, $y_2^{\prime\prime}$, $y_3^{\prime\prime\prime}$, 51 $f'[g(x)]g'(x)$, $y_1'+y_2''$, $y'_1+y''_2$, $y'''_3+g'^2$
Primes and shorthand: `´, , , , , , , . 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: `´, , , , , , , . 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.
52 $x\varprime y^\varprime, x\Prime y^\Prime, 53 x\tprime y^\tprime,x\bprime y^\bprime,x\qprime y^\qprime$
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: . Note that \qprime is unkown to Amaya, and the prime subscript in the following exercice is hard to see.
Exercise 16.5: and .
54 \let\none\mmlnone 55 $R_i{}^{jk}{}_l$ versus $\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$
Exercise 16.6: versus (MathML example, section 3.4.7.2, only second index raised).
56 $\sqrt 2$, $\sqrt{x+2}$, $\underline4$, $\overline{x+y}$, 57 $\overline x+ \overline y$, $x^{\underline n}$, $x^{\overline{m+n}}$, 58 $\sqrt{x^3+\sqrt\alpha}$
Translation , , , , , , , . There are problems with underline and overline on 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: , Tfoo, , Tfoo, , Tfoo.
59 $\root 3 \of 2$, $\root n \of {x^n + y^n}$, $\root n+1 \of a$, 60 $\sqrt[3]{2}$, $\sqrt[n]{x^n + y^n}$, $\sqrt[n+1]a$, `$\sqrt[3]{~~}$'.
Translation , , , , , , `´.
61 $\sqrt{\mathstrut a} + \sqrt{\mathstrut d} + \sqrt{\mathstrut y}$, 62 $\sqrt{a} + \sqrt{d} + \sqrt{y}$, 63 $\overline{a} + \overline{d} + \overline{y}$, 64 $\overline{\mathstrut a} + \overline{\mathstrut d} + \overline{\mathstrut y}$.
Translation , , , .
Exercise 16.7: , , , , , , , .
Exercise 16.8: If,then is equal to (this exercise says what you should not do).
Exercise 16.9: Deleting an element from an -tuple leaves an -tuple.
Exercise 16.10: Letters with descenders are Qfgjpqy.
65 $x+y-z$, $x+y*z$, $x*y/z$
Basic binary operators: , , .
66 $x\times y\cdot z$, $x\circ y\bullet z$, $x\cup y\cap z$, 67 $x\sqcup y\sqcap z$, $x\vee y\wedge z$, $x\pm y \mp z$. 68 Aliases $x\land y\lor z$.
Many more binary operators , , , , , . Aliases .
69 $x=+1$, $3.142-$, $(D*)$ 70 $x=\mathmo[form][prefix]{+}1$ 71 $3.142\mathmo[form][prefix]{-}$ 72 $(D\mathmi[mathvariant][normal]{*})$ 73 $(D\mathmo[lspace][0][rspace][0]{*})$
Binary as ordinary symbols: , , . The HTML version is slightly different from the TeX version. You can declare the plus sign as prefix operator, this gives , you can define the minus sign as prefix operator, this gives . Removing the space around the star is more complicated, a solution consists of using an identifier in upright variant like this , or by setting the lspace and rspace attributes to zero: .
74 $K_n^+,K_n^-$, $z^*_{ij}$, $g^\circ\mapsto g^\bullet$, $f^*(x)\cap f_*(y)$
Binary operators in superscripts , , , .
Exercise 16.11: and .
75 $x=y>z$, $x:=y$, $x\le y\ne z$, $x\sim y\simeq z$, $x\equiv y\not\equiv z$, 76 $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 \coloneq that behaves like colon-eq in normal TeX, or Tralics could be modified in order to recognise sequences like this. Translation of \not is problematic: in this document we consider it as an undefined operator, and you see a red X. We should add rules like: \not= should give \ne.
77 $f(x,y;z)$, $f:A\to B$, $f\colon A\to B$ 78 %\def\colon{\mathmo[lspace][0]{:}}
Punctuation , , . Note that \colon is a colon with lspace = `0pt´, but the attribute is ignored in the Pdf version. It seems that Amaya uses a zero lspace by default.
79 $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.
Exercise 16.12: , but \mathmn{3^^b71416} gives (less space in the HTML version).
80 $\hat a$, $\check a$, $\tilde a$, $\acute a$, $\grave a$, $\dot a$, 81 $\ddot a$, $\breve a$, $\bar a$, $\vec a$ 82 \def\ihat{{\hat \imath}} \def\jhat{{\hat\jmath}} $\ihat$, $\jhat$
, , , , , , , , , , , . Character \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.
83 $\hat{I+M}$, $\bar z+ \overline z$, $\widehat x, \widetilde x$, 84 $\widehat{xy}, \widetilde{xy}$ 85 $\widehat{xy}, \widetilde{xy}$ 86 $\widehat{xyz}, \widetilde{xyz}$ 87 % $\ghat\in{(H^{\pi_1^{-1}})}' -> Ex16.13 below
Large accents , , , , , . 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.
Exercise 16.13: , , , (braces added), (without braces). In Tralics 2.11, there shuld be no difference between the version with and without braces.
88 $$ {1\over 2}\qquad {\rm and}\qquad {n+1 \over 3} \qquad {\rm and}\qquad {n+1 89 \choose 3}\qquad {\rm and}\qquad \sum_{n=1}^3Z_n^2. \label{eq17.1}$$ 90 \[ \frac{1}{2}\qquad \text{and}\qquad \frac{n+1}{3} \qquad \text{and}\qquad 91 \binom{n+1}{3}\qquad \text{and}\qquad \sum_{n=1}^3Z_n^2.\label{eq17.2}\]
Example of vertical alignment. Translation of the first three expressions is a <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 <munderover> element for the sum (it is an operator with limits in display style) and a <msubsup> element for the Z (that is not an operator).
(1) |
The same, using LaTeX syntax
(2) |
92 \[{x+y^2\over k+1},\qquad {x+y^2\over k}+1,\qquad 93 x+{y^2\over k}+1,\qquad x+{y^2\over k+1},\qquad x+y^{2\over k+1}\] 94 \[\frac{x+y^2}{k+1},\qquad \frac{x+y^2}{k}+1,\qquad 95 x+\frac{y^2}{k}+1,\qquad x+\frac{y^2}{k+1},\qquad x+y^{\frac{2}{k+1}}\]
Single over. The only difference in these expressions is the placement of the braces.
(3) |
LaTeX style: this uses a command with two arguments, that behaves without surprise.
(4) |
96 \[{ {a \over b}\over 2} \qquad \text{and}\qquad { a\over {b\over 2}} 97 \qquad \text{and}\qquad { a/ b\over 2} \qquad \text{and}\qquad { a\over b/2} 98 \] 99 \[ \frac{\frac{a}{b}}{2} \qquad \text{and}\qquad \frac{a}{\frac{b}{2}} 100 \qquad \text{and}\qquad \frac{a/b}{2} \qquad \text{and}\qquad \frac{a}{b/2} \]
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.
(5) |
LaTeX style (nothing special here).
(6) |
Exercise 17.1: Compare with . 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.
Exercise 17.2: Compare with .
Exercise 17.3: Wrong use of \over in .
Exercise 17.4: , using the \textcent command.
Exercise 17.5: Same as in the TeXbook, but not cramped.
101 \[n+\scriptstyle n + \scriptscriptstyle n\] 102 \[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 <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(note: ➳).
103 \[a_0+{1\over\displaystyle a_1 + 104 {\strut 1\over\displaystyle a_2+ 105 {\strut 1\over\displaystyle a_3+ 106 {\strut 1\over a_4}}}}\]
Translation
Without \displaystyle
Without \strut. Since a \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.(note: ➳)
Without both
Until version 2.9.4, commands of the form \hfill were illegal in math mode. Since then, they are allowed as first or last element in arguments of commands like \overline. They are ignored, unless the result is a fraction; we demonstrate here that \hfill placed at the end of the list produces a left alignment, in the case of \over, \genfrac, or \frac. Note that the \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.(note: ➳).
107 \[ {x\atop y+2}, {n \choose k}, \text{latex}, 108 \genfrac{}{}{0pt}{}{x}{y+2},\binom{n}{k} \]
The \atop construction is like \over, without fraction rule; you should not use it in LaTeX, you should use \genfrac instead. The command \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 \genfrac with A and B as arguments (third argument is line thickness, fourth argument is style). The \choose command is nothing else than \atopwithdelims(). You should not use it.
109 \[{ {n\choose k}\over 2} \text{ or } { n\choose{k\over2} } 110 \text{ or } { n\choose k/2} \text{ or } {n\choose{1\over2}k}\]
As mentioned above, a construction like A over B over C needs braces, where over is a generic name for \over and variants, including \choose. Nothing special is required for \frac or \binom, so that LaTeX variant is omitted.
111 %%$${1\over2}{n\choose k}$$; $$\displaystyle{n\choose k}\over2}$$ : TeXbook 112 $\displaystyle \frac{1}{2}\binom{n}{k}$, 113 $\displaystyle{n\choose k}\over \displaystyle 2$, 114 $\dfrac{\dbinom{n}{k}}2$. 115 {\def\P{\mathchoice{D}{T}{S}{SS}} 116 $\displaystyle{\P\choose \P}\P\over \displaystyle \P$, 117 $\dfrac{\dbinom{\P}{\P}\P}\P$.}
Exercise 17.6: and ; LaTeX version ; version with \P: , . Note that the `d´ in \dfrac or \dbinom means that the expression is in display style, hence numerator and denominator are in text style; as a consequence the \choose is same as the \dbinom; on the other hand, the \over produces a fraction in text style, with numerator and denominator in display style, while the \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.
Exercise 17.7: . Fine space added for legibility.
118 \[{\displaystyle{a\over b}\above3pt\displaystyle{c\over d}} 119 \text{~~and~~} \genfrac{}{}{3pt}{}{\dfrac{a}{b}}{\dfrac{c}{d}}\]
There are six operators that behave alike: \over, \atop and \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 \parskip, you must use \genfrac).
120 ${\displaystyle \sum x_n}, {\textstyle \sum x_n}, 121 {\scriptstyle \sum x_n}, {\scriptscriptstyle \sum x_n}$
Different sums . The position of the index is unaffected by the style.
122 \[ {\displaystyle \int_{-\infty}^{\infty} \sum_{n=1}^m}, 123 {\textstyle \int_{-\infty}^{\infty} \sum_{n=1}^m}, 124 {\displaystyle\int\limits_0^{\frac{\pi}{2}} \sum\nolimits_{n=1}^m} \]
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 \msubsup element; in this case, there is an implicit \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 <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 \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(note: ➳).
125 \[\lim_ax+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_ax\] 126 \[\textstyle \lim_lx+\lim\nolimits_l x+\lim\limits_ax+\lim\displaylimits_lx\] 127 \[\sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_ax\] 128 \[\textstyle \sin_lx+\sin\nolimits_l x+\sin\limits_lx+\sin\displaylimits_lx\]
More about limits. Knuth says that \nolimits\limits produces limits; so that \sin\limits produces limits; a special feature of amsmath is that the token that follows the \sin is ignored if it is a \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.
129 \[\operatorname*{sin}_a \operatornamewithlimits{sin}_a \qopname\relax{n}{sin}_a 130 \operatorname{sin}_l \qopname\relax{o}{sin}_l 131 \mathop{\rm sin}_a\mathop{\rm sin}\limits_a\] 132 \[\textstyle\operatorname*{sin}_l \operatornamewithlimits{sin}_l 133 \qopname\relax{n}{sin}_l\operatorname{sin}_l \qopname\relax{o}{sin}_l 134 \mathop{\rm sin}_l\mathop{\rm sin}\limits_a\]
These are LaTeX commands that can define operators like sin or lim:
135 \[\sum_{\scriptstyle0\le i\le m\atop\scriptstyle0<j<n}P(i,j)\qquad 136 \sum_{\stackrel{0\le i\le m}{0<j<n}}P(i,j)\]
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).
Exercise 17.8: .
Exercise 17.9: or .
137 \[\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+x}}}}}}}\]
138 \[ \left(\left[\left\lbrack a\left\{\left\lbrace\left\lfloor b 139 \left\lceil\left\langle\left/ c\left|\left\|\left\uparrow d 140 \left\downarrow\left\updownarrow\frac 12 \right\Updownarrow 141 \right\downarrow t 142 \right\Uparrow\right\Vert\right\vert x\right\backslash\right\rangle 143 \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 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 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: . The first character is Unicode U+2016 (entity ‖ in the file mmlalias.ent), obtained by \Vert in Tralics 2.9.4, accessible as \@Vert in following versions, it is not shwon by Amaya; the second character is Unicode U+2225 (entity ∥, ∥ and ∥ in the file mmlalias.ent), obtained by \parallel in Tralics 2.9.4, and also by \Vert in following versions. We changed this because the first character has fixed size as the following demonstrates (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 \char`\^^5c. Example: old is , new is , note the different spacing.
Example of \bigl and \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).
Example of big
144 \[ \big(\big[\big\lbrack \big\{\big\lbrace\big\lfloor 145 \big\lceil\big\langle\big/ \big|\big\|\big\uparrow 146 \big\downarrow\big\updownarrow\frac 12 \big\Updownarrow 147 \big\downarrow \big\Uparrow\big\Vert\big\vert \big\backslash\big\rangle 148 \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.
149 \[ \big(\bigl[\Big\lbrack \Bigl\{\bigg\lbrace\biggl\lfloor 150 \Bigg\lceil\Biggl\langle /|\|\uparrow \downarrow\updownarrow\frac 12 151 \Updownarrow\downarrow\Uparrow\Vert\vert\backslash 152 \Biggr\rangle\Bigg\rceil\biggr\rfloor\bigg\rbrace\Bigr\}\Big\rbrack\bigr]\big)\]
A formula with all variants
Up to version 2.9.4, there was a bug in handling these big things. Currently, Tralics inserts \left and \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 \vert.
Exercise 17.10: .
153 Phi is $\phi,^^^^03c6$, ^^^^03c6 and varphi is $\varphi,^^^^03d5$, ^^^^03d5,
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 , φ and varphi is , ϕ, epsilon is , varepsilon is . 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).
154 $\bigl (x\in A(n)\bigm|x\in B(n)\bigr)$, 155 $\bigcup_n X_n\bigm\|\bigcap_n Y_n$, 156 $\displaystyle{ {a+1\over b}\bigg/{c+1\over d}}$
Other big and and .
Exercise 17.12: .
157 \[1+\left(\frac{1}{1-x^2}\right)^3,\qquad \pi(n)=\sum_{k=2}^n 158 \left\lfloor\frac{\phi(k)}{k-1}\right\rfloor, \qquad 159 \left|\left|x\right|-|\left|y\right|\right|, \qquad 160 \left(\sum_{k=1}^n A_k\right),\qquad \biggl(\sum_{k=1}^n A_k\biggr)\]
Exercise 17.13: Comparison between \left and \bigl; translation is the same in Tralics.
Exercise 17.14: was wrong in Tralics 2.9.4.
TeX sets \nulldelimiterspace, unused by Tralics.
The \vcenter command is not implemented. Any box can be put into a formula by simply saying \hbox or \vbox or \vtop or \box or \copy; this is not implemented in Tralics, you can insert text in math mode via \text or \hbox.
Exercise 17.15: This shows the use of \mathchoice.
161 \def\puzzle{\mathchoice{D}{T}{S}{SS}} 162 \[\puzzle{\puzzle \over\puzzle^{\puzzle^\puzzle}} \qquad 163 \frac{\puzzle}{\puzzle^{\puzzle^\puzzle}} \]
Exercise 17.16: The \square command is built-in: .
The \mathpalette command is introduced in Tralics 2.9.5, not tested yet.
164 \def\legendre{\overwithdelims()}\def\Legendre{\genfrac(){}{}} 165 \def\euler{\atopwithdelims<>}\def\Euler{\genfrac<>{0pt}{}} 166 \def\grimm{\abovewithdelims][4pt}\def\Grimm{\genfrac][{4pt}{}} 167 \[{a\legendre b}, \Legendre{a}{b}, {n \euler k}, \Euler{n}{k}, 168 {\dfrac ab \grimm \dfrac cd}\Grimm{x}{y} \]
Exercise 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:
If is the value of \delimiterfactor and the value of \delimitershortfall, and we have a formula that extents units above the axis, and units below, if , then the delimiter size is at least , and at least . 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 \textfont, \scriptfont and \scriptscriptfont take a small number as argument, and provide a reference to a font. The following code
169 \font\tenrm=somefont at 12pt 170 \font\Helvetica=someotherfont scaled 1013 171 \textfont0=\tenrm 172 \scriptscriptfont2=\scriptfont3 173 \the\fontdimen3\scriptscriptfont15 174 $\textfont0=\tenrm 9\hbox{$9\textfont0=\Helvetica$}$% 175 ${\textfont0=\Helvetica 9}$ % exercise 17.18
gives: 0.0pt. 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 \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 \tt in a math formula. First of all, in a formula, this evaluates to \mathtt, and the real command is \@mathtt. This is a self-modifying command; after first use it is equivalent to \fam9 (this means that normal characters in text size use the \textfont9). The first use allocates the number 9, and defines the font, moreover the font information is remembered (the font \textfont9 will be defined for all subsequent math formulas). Note that the value of \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 raweb-uni.sty).
Exercise 17.19: Math code are not implemented in Tralics, \oplus is character U+2295 and \bullet is character U+2022.
176 \mathcode`<="2203 \mathcode`*="313C 177 \mathcode`a="8000 {\catcode`a=13 \gdef a{A}} 178 $a<b*c$ 179 %\mathchardef\@M=10000
In TeX, the previous code is equivalent to , in Tralics, it gives: . 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 \@M as the constant 10000, not as control-P in family 7 (binary operation).
Following code is unlikely to work
180 \def\sum\{\mathchar"1350} 181 \mathchardef\sum"1350 182 \def\n@space{\nulldelimiterspace\z@ \m@th} 183 \newdimen\p@ \p@=1pt 184 \def\bigl#{\mathopen{\hbox{$\left#1\vbox to8.5\p@{}\right.\n@space$}}} 185 \delcode `x="123456 186 \def\langle{\delimiter"426830A } 187 \bigl\delimiter"426830A 188 \def\sqrt{\radical"270370 } 189 \def\idehat{\mathaccent"362 }
Say: If , we have shown that
Do not say: for , or , but: for , , , or use a tie: or .
Exercise 18.1: , as . Adding braces improves the Html version: .
TeX has 32 predefined operators, some of them behave like sums according to the placement of limits.
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).
Exercise 18.2:
Example of formulas using \rm: , , , , and .
Some formulas using \hbox for roman font: , , , and .
The same formulas using \text for roman font: , , , and .
190 \def\Varliminf{\mathop{\underline{\mathmo{lim}}}} 191 \def\Varlimsup{\mathop{\overline{\mathmo{lim}}}} 192 \[\lim_{n\to\infty}x_n\text{ exists}\iff 193 \Varlimsup_{n\to\infty}x_n=\Varliminf_{n\to\infty}x_n.\]
Exercise 18.3:
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 movablelimits = `false´ to the operator.
194 $\gcd(m,n)=\gcd(n,m\bmod n)$, or $x\equiv y+1\pmod{m^2}$ 195 $x\equiv0(\pmod y^n)$.
Modulo: , or
Exercise 18.4: B.L. User got the unexpected formula .
Exercise 18.5: In this example, there are braces around n/p, but not k/p; this can affect the size of the slash operator (HTML version only).
Example of bold face ; 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 \cal are robust, so that $\cal Ab\Phi$ produces ; command \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.
Exercise 18.6: If you want 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.
196 $\bf\bar x^{\mathmo{T}}Mx={\rm0}\iff x=\mathmn[mathvariant][bold]{0}$ 197 Compare $This\ is\ math\ italics$ with {\it This is text italics}. 198 Compare $different$ and $\it different$. We have also 199 $\it last\mathmo{:=}first$, $\it x\_coord(point\_2)$
Compare with This is text italics. Compare and . We have also , .
Exercise 18.8: We use \mathit instead of \it here.
Exercise 18.9: The following code was obtaining by taking the answer from the TeXbook, with the following modifications: the \sfcode of the semi colon not changed; math formulas put outside scope of \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 <br> as separator (inter-paragraph width too big), and a huge left margin (for fun). We show here the start of the code:
200 \begin{xmlelement+}{pseudocode}\XMLaddatt{leftskip}{5cm} 201 \obeylines 202 \def\coleq{\mathmo{:=}} 203 \textbf{for} $j\coleq 2$ \textbf{step} $1$ \textbf{until} $n$ \textbf{do} 204 ... 205 \end{xmlelement+}
for step until do
begin ; ; ;
while do
begin ; ;
end;
;
end.
Compare
with (lot of white space in the formula)
and (no unnecessary white space in the formula)
Normally, the spacing should be the same in the last two formulas. In fact, Knuth says that \quad is the same as \hskip 1em\relax. The translation of a \quad in math mode is <mspace width="1.em">, but the \hskip command reads a dimension, and converts one em into ten points(note: ➳).
Exercise 18.10: Three versions:
Let be a Hilbert space, a closed bounded convex subset of , a non-expansive self map of . Suppose that as , for each , and . Then for each in , converges weakly to a fixed point of .
Let be a Hilbert space, a closed bounded convex subset of , a non-expansive self map of . Suppose that as , for each , and . Then for each in , converges weakly to a fixed point of .
Let be a closed, bounded, convex subset of a Hilbert space , and let be a non-expansive self map of . Suppose that as , we have for each , and . Then for each in , the infinite sum converges weakly to a fixed point of .
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.
206 $a\,b\>c\;d\!e\quad f\qquad g\ h$~j 207 %\the\thinmuskip\the\medmuskip\the\thickmuskip
The math spacing commands: . In TeX, the value of the glue inserted depends on three registers: \thinmuskip (3mu), \medmuskip (4mu plus 2mu minus 4mu) and \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, \mskip 18mu is equivalent to \hskip1em, and, as said above, this is the same as \hskip10pt. The same is true for \mkern18mu; the translation is an empty <mspace> element, with attribute 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 \text command).
208 $\int_0^\infty f(x)\,dx$, $y\,dx-x\,dy$, $dx\,dy=r\,dr\,d\theta$, $x\,dy/dx$
Translation , , , .
Exercise 18.11:
209 $55\,\mathrm{mi/hr}$, $g=9.8\,\mathrm{m/sec}^2$, 210 $1\mathrm{ml}=1.000028\,\mathrm{cc}$
Units: , , . Note that digits are outside the scope of \mathrm.
Exercise 18.12: Inline math, displaystyle:
211 $(2n)!/\bigl(n!\,(n+1)!\bigr)$, $\sqrt2\,x$, 212 $\sqrt{\,\log x}$, $O\bigl(1/\sqrt n\,\bigr)$, 213 $[\,0,1)$, $\log n\,(\log\log n)^2$, $x^2\!/2$, $n/\!\log n$, 214 $\Gamma_{\!2}+\Delta^{\!2}$, $R_i{}^j{}_{\!kl}$, $\int_0^x\!\int_0^y dF(u,v)$ 215 \[\frac{52!}{13!\,13!\,26!}\qquad \int\!\!\!\int_D dx\,dy\]
Test: , , , , , , , , , ,
Same formulas, without thin spaces
Test: , , , , , , , , , ,
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.
Exercise 18.14: intervals with left/right: ; with mathopen, mathclose ; with nothing . And with left/right: ; with mathopen, mathclose ; with nothing .
Exercise 18.15: The spacing in differs between TeX and MathML.
216 $x_1+\cdots+x_n$, $x_1=\cdots=x_n=0$, $A_1\times\cdots\times A_n$, 217 $f(x_1,\ldots,x_n)$, $x_1x_2\ldots x_n$, $(1-x)(1-x^2)\ldots(1-x^n)$, 218 $n(n-1)\ldots(1)$.
Translation of these formulas , , , , , , .
Exercise 18.16: Answer , . Prove that . Clearly , for , 2, , . The coefficients , , ..., are positive. With braces surrounding the LHS: .
Exercise 18.17: Clearly , for . Note that the `2´ here is a math digit, while it is text digit in the sentence above.
Exercise 18.18: Knuth used \dots.
The TeX book explains how TeX can break a math formula. This does not apply to Tralics. Commands \nobreak and \allowbreak do nothing in math mode.
You should use braces only for grouping. You can use a brace character via \{ in text or math mode. This character is a delimiter (it can be preceded by \left or \big).
219 $\{a,b,c\}$, $\{1,2,\ldots,n\}$, $\{\mathrm{red,white,blue}\}$ 220 $\{\,x\mid x>5\,\}$, $\{\,x:x>5\,\}$, 221 $\bigl\{\,\bigl(x,f(x)\bigr)\bigm|x\in D\,\big\}$ 222 $\bigl\{\,\bigl(x,f(x)\bigr)\bigm\mid x \in D\,\big\}$ 223 $\bigl\{\,\bigl(x,f(x)\bigr)\mid x\in D\,\big\}$
Translation , , , , , . Note that \mid gives better spacing than a single bar , .
Exercise 18.21:
Exercise 18.22: and 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.
Exercise 18.23: The \cases command is not implemented, but there is a environment. You cannot use \noalign. After a double backslash you can put a dimension in brackets, but this is currently ignored.
224 \[\overbrace{x+\cdots+x}^{k\; \textrm{times}} \qquad \underbrace{x+y+z}_{>\,0}\]
We show here braces can stretch horizontally, when used as over-accent or under-accent.
The plain TeX command \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.
225 \[A=\begin{pmatrix}x-\lambda&1&0\\0&x-\lambda&1\\0&0&x-\lambda\end{pmatrix}\] 226 \[\begin{pmatrix}a&b&c\\d&e&f\end{pmatrix} 227 \begin{pmatrix}u&x\\v&y\\w&z\end{pmatrix}\]
Exercise 18.24: This looks bad in the HTML version, but it OK is Pdf. Delimiters are \lgroup and \rgroup.
Exercise 18.25:
Border matrix(note: ➳)
Small matrices and . Note that horizontal alignment is only approximative.
228 \def\Limsup{\mathop{\smash\limsup\vphantom\liminf}} 229 $\Limsup\limits_3=\limsup\limits_3$
Compare: ! The second index should be lower than the first.
Commands \raise and \lower not yet implemented. Commands \llap and \rlap not yet implemented.(note: ➳)
230 \def\undertext#1{$\underline{\hbox{#1}}$} 231 \undertext{This} \undertext{does} \undertext{not} \undertext{always} 232 \undertext{work} \undertext{right}. 233 \def\undertext#1{$\underline{\smash{\hbox{#1}}}$} 234 \undertext{This} \undertext{does} \undertext{not} \undertext{always} 235 \undertext{work} \undertext{right}.
Exercise 18.26: A sentence where each word is an underlined math formula (text only): . The same, where the \smash is used to hide the depth of the text (all lines vertically aligned): .
236 $\rm Fe_2^{+2}Cr_2^{\vphantom{+2}}O_4^{\vphantom{+2}}$
Use of phantoms:
Commands \nonscript, \everymath and \everydisplay are OK.
237 {\everydisplay{a}\everymath{b} \def\X{x\nonscript\qquad y} 238 \[u = \text{ v $w$ }\frac{\X}{\textstyle\X} \]}
Exercise 18.27: from the TeXbook, is LaTeX, and th is textsuperscript.
Exercise 18.28: , uses \mathnormal, no bf lambda?
Exercise 18.29: .
Exercise 18.30: .
Exercise 18.31: .
Exercise 18.32: .
Exercise 18.33: .
Exercise 18.34: . Note: Firefox shows small integral signs, and larger ones in the previous exercise.
Exercise 18.35: Using cases environment
Exercise 18.36: with a \frac
Exercise 18.37:
Exercise 18.38: Using \frac and \binom
Exercise 18.39: Using \genfrac
Exercise 18.40:
239 \def\X{\char`'} 240 \[{ 241 \{\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a\X\mathrm{s}}, 242 \overbrace{\mathstrut 243 b,\ldots,b}^{l\;b\X\mathrm{s}}}_{k+l\;\mathrm{elements}}\} 244 }\quad\text{vs}\qquad { 245 {\{\,}\underbrace{\overbrace{\mathstrut a,\ldots,a}^{k\;a'\mathrm{s}}, 246 \overbrace{\mathstrut 247 b,\ldots,b}^{l\;b'\mathrm{s}}}_{k+l\;\mathrm{elements}}{\}\,}.}\]
Exercise 18.41: In this formula, we want the denote the plural of the token 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.
Exercise 18.42:
A non trivial question: what is the distance between two lines in a matrix like these? or said otherwise, what is the vertical glue added between two lines? Let be the value of \baselineskip, the value of \lineskiplimit and the value of \lineskip. Then, the quantity is computed so that , unless this gives , case where is used instead. Typically, for a normal paragraph, , , , and for a `align´ environment, we have , , . 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 is at least 12pt.
This has as consequence that, in the big matrix above, parentheses do touch. We changed, in the file raweb-cfg.sty, the code of the \@array command: , and 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 \display mode; this is the case for all environments like `gather´ or `align´ that are translated by Tralics as an array).
Exercise 18.43: Note: entries are left aligned because of explicit \hfil.
Exercise 18.44:
Exercise 18.45: This is not so nice
Exercise 18.46: Vertical arrow centered via the use of phantom on the left; command \hidewidth not used (the purpose of the command is to make \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).
Example of a display, containing only text
Another one, with text and math
Compare the following two examples: the translation is the same, but you cannot put arbitrary text in a math formula!
248 $$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q \qquad\hbox{for all }n\ge 0.$$ 249 $$Y_n=X_n\bmod p \quad\hbox{and}\quad Z_n=X_n\bmod q\qquad\hbox{for all $n\ge0$}.$$
Exercise 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.
250 $$\sum_{n=0}^\infty a_nz^n\qquad \hbox{converges if}\qquad |z| < 251 \Bigl(\limsup_{n\to\infty}\root n\!\of{|a_n|}\,\Bigr)^{-1}.$$ 252 \[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| < 253 (\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}{\,)}^{-1}. \] 254 \[\sum_{n=0}^\infty a_nz^n\qquad \text{converges if} \qquad |z| < 255 (\limsup_{n\to\infty}\sqrt[n\!]{|a_n|}\,)^{-1}. \]
Next two formulas.
256 $${f(x+\Delta x)-f(x)\over\Delta x}\to f'(x)\qquad \hbox{as $\Delta\to0$.}$$ 257 \[\frac{f(x+\Delta x)-f(x)}{\Delta x}\to f'(x)\qquad \text{as }\Delta\to0.\] 258 $$\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\hbox{if $i\ne j$.}$$ 259 \[\|u_i\|=1,\qquad u_i\cdot u_j=0\quad\text{if } i\ne j.\]
Last formula; you cannot use the \matrix command defined by plain TeX, but you have to use the matrix environment.
260 \[\it\text{The confluent image of}\quad 261 \begin{Bmatrix}\text{an arc}\hfill\\\text{a circle}\hfill\\\text{a fan}\hfill 262 \end{Bmatrix} 263 \quad\text{is}\quad 264 \begin{Bmatrix}\text{an arc}\hfill\\\text{an arc or a circle}\hfill\\ 265 \text{a fan or an arc}\hfill\end{Bmatrix}.\]
Since version 2.9.5, you can use font changes in \text commands and friends (the previous formula is in italics). This is a more elaborate example
266 $\hbox{upright} \it \text{Italic\bf Boldface} {\tt \text{x = y$^2$}}$
Translation: .
Exercise 19.2: Compare B. L. User´s solution, Knuth´s solutions and \tfrac:
Exercise 19.3: We demonstrate in this example that using $$\hbox{$formula$}$$ is non-trivial.
267 \everymath={A} 268 \everyhbox={B} 269 \def\X{\ifhmode H\else \ifvmode V \else \ifmmode M \else U\fi\fi\fi} 270 \def\Y{\X\ensuremath{\beta}} 271 $$ \Y\hbox{\X$\Y $\X}\Y \text{\X}$$
Guess what happens if \X were replaced by \Y? the problem might be solved in a future version. Note that \text does not insert the every-hbox token list.
Exercise 19.4: Look at these four identical formulas.
(14) |
(14) |
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.
Note on Equation Numbering For a very long time, I have used the \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 \label{eq+12}, you can get its number via \ref{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 \label command is the addition of an id (for instance `id12´ to the equation(note: ➳)), and translation of the \ref is a <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 <ref> is converted. In the case of XML to XSL/FO, a number is computed only for <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 \eqno and \tag; that´s a bit tricky, let´s explain some difficulties.
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 <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.
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 <xsl:number level=´any´ count=´formula[@id]´ />.
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 \tag{x}, this gives as equation number, and \eqref gives this value back. On the other hand, \eqno(x) is equivalent to \tag*{(x)}.
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 or as tag. In LaTeX, tags are typeset in text mode, and math shift characters are sometimes used. These are removed by Tralics.
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).
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.
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 \tag, described below. Finally, you can use the TeX command \eqno. This command reads everything up to the end of the formula, expanding tokens when needed; if this yields foo, then \y@tag{foo} is evaluated again; this the same as if you said \tag*{foo}. Its effect by default is to convert the tag as an attribute to the formula. Moreover, the attribute eqnpos is added to the formula, with a value of left and right, depending on whether \leqno or \eqno has been used. The equals signs should be aligned for the five next formulas.
(15R) |
(15L) |
Equation number of (7) is on the left, of (8) on the right, and (9) depends on the class option.
(7) |
(8) |
(9) |
Exercise 19.5:
(16´) |
Exercise 19.6: In TeX, you can put an en-dash in an equation number by using \hbox. This is not allowed in Tralics: the equation 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 \apostrophe.
The example below illustrates one complexity. The end of the tag (via \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 \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 \char command reads a character, and pushes back a character token, with the same value, but category code 12. We explained above that \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 \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 gives a double superscript error, guess why). Note how we insert an en-dash (of course \textendash is a non-math command, we had to modify some files in order to allow this character in the Pdf).
272 \[1=1\eqno\hbox{(3--1)} \] 273 \[0=0\eqno(*,{**},{***},16'\char`\'\char`\^,3^^^^20131)\] 274 \[\def\apostrophe{'} 2=2\eqno(16'\char`\')\] 275 \[\def\apostrophe{'} 3=3\eqno(16')\]
(*,**,***,16´´^,3–1) |
Exercise 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.
Exercise 19.8: Knuth says: if \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.
276 \[\quad x=y\hskip10000pt minus 1fill\eqno(5)\]
(5) |
Exercise 19.9: The \eqalign feature of plain TeX is not implemented; you can use the align environment like here:
Using aligned, you can get
Exercise 19.10:
(10) |
Currently, the following code does not work.
277 \begin{eqalignno} 278 (x+y)(x-y)&=x^2-xy+yx-y^2\\ 279 &=x^2-y^2;&(4)\\ 280 (x+y)^2&=x^2+2xy+y^2 ; 281 \end{eqalignno} 282 \begin{leqalignno} 283 (x+y)(x-y)&=x^2-xy+yx-y^2\\ 284 &=x^2-y^2;&(4)\\ 285 (x+y)^2&=x^2+2xy+y^2 . 286 \end{leqalignno}
The best we can do is using phantoms:
287 \def\xcenter#1#2#3{\phantom{#3}{#1#2#3}\phantom{#1}} 288 \[\xcenter{(x+y)(x-y)}{=}{x^2-xy+yx-y^2} \] 289 \[\xcenter{{}}{=}{x^2-y^2;}\label{192-0}\] 290 \[\xcenter{{(x+y)^2}}{=}{x^2+2xy+y^2 .}\label{192-5}\]
(11) |
(12) |
Exercise 19.12: First two equations use \leqno, Equations (13) and (14) have a label.
(9) |
(10) |
(13) |
(14) |
Exercise 19.13: Note: Knuth has a small space before the first dx, this seems unnecessary. Some operators are big by default in MathML, so that no \big is required. However, there is a rule in Tralics that says that small parentheses are used in , even when the integral has limits. In this cases, this mechanism produces small parentheses. The remedy is to put f(x) in a group; the size of the parentheses depend only on what is in the group. In a case like , large parentheses are used. If you want small ones, you must use the \smash command, and you get . In the pdf version, the vertical bar is too small.
291 \[\xcenter{\left(\int_{-\infty}^{\infty}e^{-x^2}dx\right)^2}{=} 292 {\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-(\smash{x^2+y^2})}dx\,dy}\] 293 \[\xcenter{}{=}{\int_0^{2\pi}\int_0^\infty e^{-r^2}r\,dr\,d\theta}\] 294 \[\xcenter{}{=}{\int_0^{2\pi}{\left(-\frac{e^{-r^2}}{2}| 295 _{r=0}^{r=\infty}\right)}\,d\theta}\] 296 \[\xcenter{}{=}{\pi.}\label{e19.13}\]
(15) |
Exercise 19.14: Knuth explains that eqalign and eqalignno environments are based on \halign, so that \noalign can be used. In environments like gather, you can try \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 \eqalign.
Exercise 19.16: This uses \gather. There are no equation numbers, because \hfil, \hfill or \hfilneg are not allowed.
The long formula is
It can be split as
Exercise 19.17:
(16) |
Attempt to use multline for the long formula.
Exercise 19.18:
(17) |
Exercise 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 \\ command. The \Paren command puts parentheses around the argument., the \Slash command produces a slash.
297 { 298 \def\\#1;{\noexpand\Paren{#1;q^2}_\infty} 299 \xdef\formA{q^{\frac 12 n(n+1)}\\ea;\\eq\noexpand\Slash a;} 300 \xdef\formB{\\caq\noexpand\Slash e;\\cq^2\!\noexpand\Slash ae;} 301 \xdef\formC{(e;q)_\infty(cq/e;q)_\infty} 302 }
The question is: What is the size of the parentheses? In the case of 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 or 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 and . In the second case, we have added an empty group. In this case, we have a group with followed by followed by a group with followed by . 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 \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 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 , this group cannot contain both parentheses. Expressions can be split after binary operators or relations, in the case of , only the equals sign is considered. Understanding exactly where the expression is split is not easy. Obviously, in the case when there are two 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 . 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 (x)^2, will be converted into (x){}^2, that can be converted into (x){}^2, and after removal of the dummy group into (x)^2.
303 \def\Paren#1{(#1)} 304 \def\Paren#1{(#1){}} 305 \def\Paren#1{{(#1)}} 306 \def\Paren#1{{(\smash{#1})}} 307 \def\Slash{/} 308 \[ \frac{\formA\formB}{\formC} \] 309 \[ \frac{\textstyle\formA\qquad \atop\hfill\textstyle\formB}{\formC} \]
The whole formula version 1
Version two
Version 3
Version 4
The split formula
One trick in order to get a smaller slash: define \Slash to be a group consisting of a slash (and something else, here a \kern of width minus 1pt). The whole formula version two
Version 4
The split formula, version 4
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 \begin{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.
The following packages are defined for use with Tralics:
amsmath is the main package, it loads amstext, amsbsy, amsopn; Options are sumlimits, nosumlimits, namelimits, nonamelimits, centertags, tbtags, cmex10, and fleqn.
amsgen contains some useful commands (currently unused).
amstext defines the \text command, which is built-in in Tralics.
amsbsy loads amsgen. It provides \boldsymbol and \bm, which do nothing in Tralics.
amsopn, no options. The package defines commands like \lim, that are built-in in Tralics.
amscd, implementes commutative diagrams.
amsthm, not yet implemented (theorems are built-in in Tralics).
amsxtra, not yet implemented.
upref, not yet implemented.
amsfonts, not yet implemented; this package and the following recognize options psamsfonts.
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: \vartriangle, \doublebarwedge, \varpropto, \smallsmile, \smallfrown, \lvertneqq \gvertneqq, \npreceq, \nsucceq, \varsubsetneq(q) \varsupsetneq(q), \nsubseteqq, \nsupseteqq, \(n)shortmid, \(n)shortparallel.
eufrak. The package defines family \Eufrak (this command is \mathfrak in Tralics), this is assumed to use the font family `euf´. The eufrak package is redundant if the amsfonts package is used.
eucal. The package defines family \Euscript (this command is \mathcal in Tralics), this is assumed to use the font family `eus´. Accepts options `mathcal´ and `mathscr´ (this make \mathscr equivalent to \mathcal.
All undefined math symbols are defined to be \ams@unimp, a command that expands to an undefined command, the one defined here to produce a red X.
310 \def\UnimplementedOperator{\mathbox{mstyle}[color][red]{X}}
Source code for some formulas used below:
311 \begin{equation} (a+b)^2 = a^2+2ab+b^2\end{equation} 312 \[ \sin^2\eta+\cos^2\eta = 1 \] 313 \begin{equation} x^2 + y^2 = z^2 \end{equation} 314 \begin{align} x^2 + y^2 &= z^2 \\ x^3 + y^3 &< z^3 \end{align} 315 \begin{eqnarray} x^2 + y^2 &=& z^2 \\ x^3 + y^3 &<& z^3 \end{eqnarray} 316 \begin{equation*} n^2 + m^2 = k^2 \end{equation*} 317 \begin{equation} n^p +m^p \neq k^p \qquad p > 2 \end{equation} 318 \begin{multline} \tag{2} 319 \sum_{t \in \mathbf{T}} \int_a^t 320 \biggl\lbrace \int_a^t f(t - x)^2 \, 321 g(y)^2 \,dx \biggr\rbrace \,dy \\ 322 = \sum_{t \notin \mathbf{T}} \int_t^a 323 \biggl\lbrace g(y)^2 \int_t^a 324 f(x)^2 \,dx \biggr\rbrace \,dy 325 \end{multline}
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 equation-number = `left´ of the document element.
In Tralics, if a formula has no \label, no number is associated to it. Here we have a formula using the equation environment, or a displaymath formula enclosed in a \[, \] pair.
Example 8-2-2. This uses options `reqno´ option of the amsmath package (equations to the right), it puts equation-number = `left´ on the document element. It uses also `fleqn´, that sets flushed-equation = `true´; in LaTeX, you must define \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.
(18) |
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 equation:
(19) |
Second environment is align:
(20) |
Third environment is eqnarray:
(21) |
Note: amsmath adds a new complexity to how spaces are handled: spaces after \\ 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 equation*, (22) as well as equation, (23).
(22) |
(23) |
Example 8-2-5. Translation of \multline is a table, elements are centered, except first, last, and lines using \shoveleft or \shoveright. No & should be given; last line should not be terminated with \\.
Example 8-2-6. This is the default behavior for tags.
Same formulas, with \multlinegap set to zero. This has no effect in Tralics
From now on, we redefine the \tag command via \tagasattribute; the second equation with a tag gives:
(3) |
The magic is that this uses \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 \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 \mathattribute cannot be used (it adds an attribute to the last element created). It is not possible to use \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 \par, then \noindent is inserted, thus, if this token is \XMLaddatt, the current element is an empty paragraph). Example
326 \begin{align} 327 \formulaattribute{tag}{8-2-3} 328 \thismathattribute{background}{white} 329 \rowattribute{mathvariant}{bold} x^2 + y^2+100 &= z^2 \\ 330 \cellattribute{columnalign}{left} x^3 + y^3+1 &< z^3 331 \end{align}
Translation (bold attribute ignored in the Pdf version):
8-2-3 |
332 \begin{equation} \begin{split} % 8-2-7 333 (a + b)^4 334 &= (a + b)^2 (a + b)^2 \\ 335 &= (a^2 + 2ab + b^2) (a^2 + 2ab + b^2) \\ 336 &= a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4 337 \end{split}\end{equation} 338 \begin{equation} \begin{split} % 8-2-8 339 (a + b)^3 &= (a + b) (a + b)^2 \\ 340 &= (a + b)(a^2 + 2ab + b^2) \\ 341 &= a^3 + 3a^2b + 3ab^2 + b^3 342 \end{split}\end{equation}
Example 8.2.7 Single equation on several lines with alignment
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 split-tags = `tb´ on the root element.
343 \newcommand\relphantom[1]{\mathrel{\phantom{#1}}} 344 \newcommand\ve{\varepsilon} \newcommand\tve{t_{\varepsilon}} 345 \newcommand\vf{\varphi} \newcommand\yvf{y_{\varphi}} 346 \newcommand\bfE{\mathbf{E}} 347 348 \begin{equation} \begin{split} 349 f_{h, \ve}(x, y) 350 &= \ve \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve u)} \vf(x) \,du \\ 351 &= h \int L_{x, z} \vf(x) \rho_x(dz) \\ 352 &\relphantom{=} {} + h \biggl[ 353 \frac{1}{\tve} 354 \biggl( \bfE_{y} \int_0^{\tve} L_{x, y^x(s)} \vf(x) \,ds 355 - \tve \int L_{x, z} \vf(x) \rho_x(dz) \biggr) + \\ 356 &\relphantom{=} \phantom{{} + h \biggl[ } 357 \frac{1}{\tve} 358 \biggl( \bfE_{y} \int_0^{\tve} L_{x, y^x(s)} \vf(x) \,ds 359 - \bfE_{x, y} \int_0^{\tve} L_{x, \yvf(\ve s)} 360 \vf(x) \,ds \biggr) \biggr] 361 \end{split} \end{equation}
Example 8-2-9
(24) |
362 \begin{gather} 363 (a + b)^2 = a^2 + 2ab + b^2 \\ 364 (a + b) \cdot (a - b) = a^2 - b^2 365 \end{gather}
Example 8-2-10, equation groups without alignment.
366 \begin{gather} 367 D(a,r) \equiv \{ z \in \mathbf{C} \colon |z - a| < r \} \notag \\ 368 \operatorname{seg} (a, r) \equiv \{ z \in \mathbf{C} \colon 369 \Im z < \Im a, \ |z - a| < r \} \\ 370 C (E, \theta, r) \equiv \bigcup_{e \in E} c (e, \theta, r) 371 \end{gather}
Example 8-2-11
372 \begin{align} 373 (a + b)^3 &= (a + b) (a + b)^2 \\ 374 &= (a + b)(a^2 + 2ab + b^2) \\ 375 &= a^3 + 3a^2b + 3ab^2 + b^3 376 \end{align} 377 \begin{align} x^2 + y^2 & = 1 \\ x & = \sqrt{1-y^2}\end{align}
Example 8-2-12
and
378 \begin{align} 379 \text{Compare } x^2 + y^2 &= 1 & x^3 + y^3 &= 1 \\ 380 x &= \sqrt {1-y^2} & x &= \sqrt[3]{1-y^3} 381 \end{align} 382 \begin{align} 383 x&= y & X &= Y &a &= b+c \\ 384 x' &= y'& X' &= Y' &a' &= b\\ 385 x + x' &= y + y' & X + X' &= Y + Y' & a'b &= c'b 386 \end{align}
Example 8-2-13. This example has two column-pairs.
This example has three column-pairs.
387 \begin{flalign} \text{Compare } 388 x^2 + y^2 &= 1 & x^3 + y^3 &= 1 \\ 389 x &= \sqrt {1-y^2} & x &= \sqrt[3]{1-y^3} 390 \end{flalign} 391 \begin{flalign} 392 x &= y & X &= Y & a &= b+c \\ 393 x' &= y' & X' &= Y' & a' &= b \\ 394 x + x' &= y + y' & X + X' &= Y + Y' & a'b &= c'b 395 \end{flalign}
Example 8-2-14 This example has two column-pairs.
This example has three column-pairs.
396 \renewcommand\minalignsep{0pt} 397 \begin{align} \text{Compare } 398 x^2 + y^2 &= 1 & x^3 + y^3 &= 1 \\ 399 x &= \sqrt {1-y^2} & x &= \sqrt[3]{1-y^3} 400 \end{align} 401 \renewcommand\minalignsep{15pt} 402 \begin{flalign} 403 x &= y & X &= Y & a &= b+c \\ 404 x' &= y' & X' &= Y' & a' &= b \\ 405 x + x' &= y + y' & X + X' &= Y + Y' & a'b &= c'b 406 \end{flalign}
Example 8-2-15 This example has two column-pairs.
This example has three column-pairs.
407 \renewcommand\minalignsep{2em} 408 \begin{align} 409 x &= y && \text{by hypothesis} \\ 410 x' &= y' && \text{by definition} \\ 411 x + x' &= y + y' && \text{by Axiom 1} 412 \end{align}
Example 8-2-16
413 \begin{equation} 414 \begin{aligned} 415 x^2 + y^2 &= 1 \\ x &= \sqrt{1-y^2} \\ \text{and also }y &= \sqrt{1-x^2} 416 \end{aligned} \qquad 417 \begin{gathered} 418 (a + b)^2 = a^2 + 2ab + b^2 \\ (a + b) \cdot (a - b) = a^2 - b^2 419 \end{gathered} \end{equation}
Example 8-2-17
420 \begin{equation} 421 \begin{aligned}[b] 422 x^2 + y^2 &= 1\\ x &= \sqrt{1-y^2} \\ \text{and also }y &= \sqrt{1-x^2} 423 \end{aligned} \qquad 424 \begin{gathered}[t] 425 (a + b)^2 = a^2 + 2ab + b^2 \\ (a + b) \cdot (a - b) = a^2 - b^2 426 \end{gathered}\end{equation}
Example 8-2-18 (note: ➳)
427 \newenvironment{rcase}{\left.\begin{aligned}} {\end{aligned}\right\rbrace} 428 \begin{equation*} 429 \begin{rcase} 430 B' &= -\partial\times E \\ E' &= \partial\times B - 4\pi j \, 431 \end{rcase} 432 \quad \text {Maxwell's equations} 433 \end{equation*} 434
Example 8-2-19(note: ➳)
435 \renewcommand\minalignsep{5pt} 436 \begin{equation} \begin{aligned} 437 V_j &= v_j & X_i &= x_i - q_i x_j & &= u_j + \sum_{i\ne j} q_i \\ 438 V_i &= v_i - q_i v_j & X_j &= x_j & U_i &= u_i 439 \end{aligned} \end{equation}
Example 8-2-20
440 \begin{align} 441 A_1 &= N_0 (\lambda ; \Omega') - \phi ( \lambda ; \Omega') \\ 442 A_2 &= \phi (\lambda ; \Omega') \phi (\lambda ; \Omega) \\ 443 \intertext{and finally} 444 A_3 &= \mathcal{N} (\lambda ; \omega) 445 \end{align}
Example 8-2-21
Example 8-2-22, 8-2-23, 8-2-24 explain that spacing around equations can be wrong; we omit them.
446 \begin{align} 447 x^2+y^2 &= z^2 \label{eq:A} \\ 448 x^3+y^3 &= z^3 \notag \\ 449 x^4+y^4 &= r^4 \tag{$*$} \\ 450 x^5+y^5 &= r^5 \tag*{$*$} \\ 451 x^6+y^6 &= r^6 \tag{\ref{eq:A}$'$} \\ 452 A_1 &= N_0 (\lambda ; \Omega') 453 - \phi ( \lambda ; \Omega') \\ 454 A_2 &= \phi (\lambda ; \Omega') 455 \, \phi (\lambda ; \Omega) 456 \tag*{ALSO (\theequation)} \\ 457 A_3 &= \mathcal{N} (\lambda ; \omega) 458 \end{align}
Example 8-2-25. In the Companion, first equation is numbered (1), second equation has no number, third is (*), then come *, (1´), (2), ALSO (2) and (3). Since Tralics does not compute equation numbers, you will not see (1), (2), (3). Since (1´) is obtained by a reference to the first equation, the whole set of equations is numbered, namely (25). It is currently impossible to use a reference, we locally change \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 *,*,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.
Note: the style sheet that converts XML to HTML attributes a number to each equation that has a label, and \ref uses this number. If the equation has a tag, no number should be attributed, and \ref should use the tag. This might change.
Note: LaTeX uses \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.
(25) |
Same example, with default behavior of \tag. Note that the equation number is still the same. The equation has an another label, it is now equation (17), but \ref is still defined to be 17.
(26) |
459 \begin{equation} \begin{split} \label{e-8-2-26} 460 \lvert I_2 \rvert &= \left\lvert \int_{0}^T \psi(t) 461 \left\{ u(a, t) - \int_{\gamma(t)}^a \frac{d\theta}{k} 462 (\theta, t) \int_{a}^\theta c (\xi) u_t (\xi, t) \,d\xi 463 \right\} dt \right\rvert \\ 464 &\le C_6 \Biggl\lvert 465 \left\lvert f \int_\Omega \left\lvert 466 \widetilde{S}^{-1,0}_{a,-} W_2(\Omega, \Gamma_l) 467 \right\rvert \ \right\rvert 468 \left\lvert \lvert u \rvert 469 \overset{\circ}{\to} W_2^{\widetilde{A}} (\Omega; \Gamma_r,T) 470 \right\rvert \Biggr\rvert 471 \end{split} \end{equation}
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.
(27) |
Example 8-2-27. Equation (28) should be the same as (27); but in order to test our algorithm we have replaced some \lvert and \rvert by \lVert and \rVert, that are the same as \Vert, but declared as mathopen and mathclose symbols
(28) |
472 \begin{gather} \raisetag{-40pt} 473 \text{The sign function: \ } \mathcal{S}(x) = 474 \begin{cases}-1 & x < 0 \\ 0 & x = 0 \\ 1 & x > 0\end{cases} 475 \end{gather}
Example 8-2-28, showing the command \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
476 \def\raisetag#1{% 477 \dimen0=#1\relax 478 \ifdim\dimen0<0pt 479 \dimen0=-\dimen0 480 \formulaattribute{tag-down}{\the\dimen0}% 481 \else 482 \formulaattribute{tag-up}{\the\dimen0}\fi}
Thus \raisetag with a value of -10pt will add tag-down = `10pt´ to the formula element. In this case, the style sheet adds 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.
(29) |
483 begin{subequations} \label{eq:1} 484 \begin{align} f &= g \label{eq:1A} \\ 485 f' &= g' \label{eq:1B} \\ 486 \mathcal{L}f &= \mathcal{L}g \label{eq:1C} 487 \end{align} 488 \end{subequations} 489 \begin{subequations} \label{eq:2} 490 \renewcommand\theequation{\theparentequation\roman{equation}} 491 \begin{align} f &= g \label{eq:2A} \\ 492 f' &= g' \label{eq:2B} \\ 493 \mathcal{L}f &= \mathcal{L}g + K \label{eq:2C} 494 \end{align} 495 \end{subequations} 496 Note the relationship between~\eqref{eq:1} 497 and~\eqref{eq:2}: only~\ref{eq:1C} and~\ref{eq:2C} differ.
Example 8-2-29: the amsmath package provides a 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 parentequation and equation. First group, with only labels eq:1 and eq1:C
(30) |
The Tralics implementation is trivial: the environment does nothing. Thus, the \label command in the subequations corresponds to the current section. Second group, with only labels eq:2 and eq2:C
(31) |
We have removed two \labels from the align, because it produces a single equation number and accepts a single label. Thus, the text after the equations reads: Note the relationship between (3.2) and (3.2): only 30 and 31 differ.
498 \begin{equation} P_{r - j} = 499 \begin{cases} 500 0 & \text{if $r - j$ is odd,} \\ 501 r! \, (-1)^{(r - j)/2} 502 & \text{if $r - j$ is even.} 503 \end{cases} \end{equation}
Example 8-3-1
504 \begin{gather*} 505 \begin{matrix} 0 & 1 \\ 1 & 0 \end{matrix} \quad 506 \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix} \\ 507 \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \quad 508 \begin{Bmatrix} 1 & 0 \\ 0 & -1 \end{Bmatrix} \\ 509 \begin{vmatrix} a & b \\ c & d \end{vmatrix} \quad 510 \begin{Vmatrix} i & 0 \\ 0 & -i \end{Vmatrix} 511 \end{gather*}
Example 8-3-2, using a single equation(note: ➳)
512 \newcommand\hdotsfor[2][x]{\multicolumn{5}{c}{.\ .\ .\ .\ .\ .\ .\ .\ .}} 513 \setcounter{MaxMatrixCols}{20} 514 \[ 515 \begin{Vmatrix} 516 \,a&b&c&d&e&f&g&h&i&j &\cdots\,{} \\ 517 &a&b&c&d&e&f&g&h&i &\cdots\,{} \\ 518 & &a&b&c&d&e&f&g&h &\cdots\,{} \\ 519 & & &a&b&c&d&e&f&g &\cdots\,{} \\ 520 & & & &\ddots&\ddots&\hdotsfor[2]{5}%\,{} 521 \end{Vmatrix} \]
Example 8-3-3. The example uses \hdotsfor, a command equivalent to \multicolumn{5}{c}{leaders}. Leaders cannot be implemented in MathML, so that the command is redefined in this case.
In the example above, there was a \,{} at the end of each line. We had to remove it on the last line, because Tralics complains if a cell contains \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 \,{} in the LaTeX case?
522 $\begin{array}{ccc} 523 111&222&333\\ 524 \hdotsfor{2}x&t\\ 525 \end{array}$
Example 8-3-4. This example uses the environment smallmatrix, which is defined by Tralics to be the same as matrix, i.e., a matrix without delimiters, the same with \left and \right parentheses . 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.
526 \begin{gather} 527 \sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i, j) \\ 528 \sum_{\begin{subarray}{l} i \in \Lambda \\ 529 0 \le i \le m \\ 530 0 < j < n 531 \end{subarray}} P(i, j) 532 \end{gather}
Example 8-3-5. The style of the subarray should be smaller
533 \DeclareMathOperator\add{add} 534 \DeclareMathOperator\cf {cf} 535 \DeclareMathOperator\cov{cov} 536 \DeclareMathOperator\non{non} 537 \DeclareMathOperator\End{End} 538 \[ \begin{CD} 539 \cov (L) @>>> \non (K) @>>> \cf (K) \\ 540 @VVV @AAA @AAA \\ 541 \add (L) @>>> \add (K) @>>> \cov (K) \\ 542 \end{CD} \]
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.
543 \[ \begin{CD} 544 S^{W_\Lambda}\otimes T @>j>> T \\ 545 @VVV @VV{\End P}V \\ 546 (S \otimes T)/I @= (Z\otimes T)/J 547 \end{CD} \]
Example 8-3-7
Example 8-3-8. This uses \longrightarrow, that produces character U+27F9, unknown to FM.
548 \[ \mathcal{Q} = 549 \begin{delarray}[t] ( {cc} ) X & Y \end{delarray} 550 \begin{delarray}[t] [ {cc} ] A & B \\ C & D \end{delarray} 551 \begin{delarray}[b] \lgroup{cc}\rgroup L \\ M \end{delarray} 552 \]
Example 8-3-9. This example uses the delarray package that changes the meaning of the array environment. In the current version of Tralics, there is no \array command, hence no possibility to redefine it. The delarray.plt file defines a delarray environment that is used here.
553 \[ 0 \xleftarrow [\zeta]{} F \times \Delta (n - 1) 554 \xrightarrow {\partial_0 \alpha(b)} E^{\partial_0 b}\]
Example 8-4-1
555 \begin{equation*} 556 \cfrac {1}{\sqrt{2} + 557 \cfrac {1}{\sqrt{3} + 558 \cfrac {1}{\sqrt{4} + 559 \cfrac[r] {1}{\sqrt{5} + 560 \cfrac[l] {1}{\sqrt{6} + \dotsb } 561 }}}} 562 \end{equation*}
Example 8-4-2
563 \begin{equation} \boxed { W_t - F \subseteq V(P_i) \subseteq W_t }\end{equation}
Example 8-4-3
564 \[ \sum_{i=1}^n \qquad \int_0^\infty \qquad \lim_{n \to 0} \] 565 Text: $\sum_{i=1}^n$, $\int_0^\infty$, $\lim_{n \to 0}$.
Example 8-4-4
Text: , , .
566 \[ 567 \sum\nolimits_{i=1}^n \qquad \int\limits_0^\infty 568 \qquad \lim\displaylimits_{n \to 0} 569 \] 570 Text: $\sum\nolimits_{i=1}^n$, $\int\limits_0^\infty$, 571 $\lim\displaylimits_{n \to 0}$.
Example 8-4-5 (limits placement is wrong in the Pdf version, text style).
Text: , , .
572 \begin{gather*} 573 \xiint \limits _V \mu(v,w) \,du \,dv \quad 574 \xiiint \limits _V \mu(u,v,w) \,du \,dv \,dw \quad 575 \xiiiint \limits _V \mu(t,u,v,w) \,dt \,du \,dv \,dw \\ 576 \idotsint \limits _V \mu(z_1, \dots, z_k) \,\mathbf{dz}\\ 577 \iint \limits _V \mu(v,w) \,du \,dv \qquad 578 \iiint \limits _V \mu(u,v,w) \,du \,dv \,dw \qquad 579 \iiiint \limits _V \mu(t,u,v,w) \,dt \,du \,dv \,dw \\ \textstyle 580 \iint \limits _V \mu(v,w) \,du \,dv \qquad 581 \iiint \limits _V \mu(u,v,w) \,du \,dv \,dw \qquad 582 \iiiint \limits _V \mu(t,u,v,w) \,dt \,du \,dv \,dw 583 \end{gather*}
Example 8-4-6. Modified, using \xiint, \xiiint, \xiiiint command that produce Unicode character U+222c, U+222D and U+2A0C, or simple integrals.
584 \begin{align*} 585 u & \equiv v + 1 \mod{n^2} \\ 586 u & \equiv v + 1 \bmod{n^2} \\ 587 u & = v + 1 \pmod{n^2} \\ 588 u & = v + 1 \pod{n^2} 589 \end{align*} 590 The in-text layout: $ u = v + 1 \pmod{n^2} $ 591 \begin{gather*} 592 (m \bmod n) = k^2 \, ; \quad 593 x \equiv y \pmod b \, ; \\ 594 x \equiv y \mod c \, ; \quad 595 x \equiv y \pod d\, . 596 \end{gather*}
Example 8-4-7
The in-text layout:
597 \begin{equation} \frac{1}{k} \log_2 c(f) 598 \quad \tfrac{1}{k} \log_2 c(f) \end{equation} 599 Text: $ \sqrt{ \frac{1}{k} \log_2 c(f) } \quad 600 \sqrt{ \dfrac{1}{k} \log_2 c(f) }\, $.
Example 8-4-8
Text: .
601 \begin{equation} \binom{k}{2} 2^{k - 1} 602 + \tbinom{k - 1}{2} 2^{k - 2} \end{equation} 603 Text: $ \binom{k}{2} 2^{k - 1} + \dbinom{k - 1}{2} 2^{k - 2} $. 604 $ \dot{S} \quad \ddot{P} \quad \dddot{Q} \quad \ddddot{R} $
Example 8-4-9
Text: .
Example 8-4-10: Four dots above: character unknown by FM.
605 \[ \accentset{\ast}{X} \quad 606 \hat{\accentset{\star}{\hat h}} \quad 607 \underaccent{\diamond}{\mathcal{M}} \quad 608 \undertilde{C}\quad\undertilde{M}\quad\undertilde{ABC} \]
Example 8-4-11. Commands \accentset and \underaccent are defined in the amsmath.plt file, they produce a <munder> or <mover> element, with attribute accent or mathaccent set to true. Note that accents might be too big.
609 $(xyz)\spdddot$ \quad $(xyz)\spddot$ \quad $(xyz)\spdot$ 610 $(xyz)\spbreve$ \quad $(xyz)\spcheck$ 611 $(xyz)\sphat$ \quad $(xyz)\sptilde$
Example 8-4-12. (breve and hat are invisible on Firefox, too high on Amaya).
612 \[ \overset{*}{X} > \underset{*}{X} 613 \iff \sideset{}{'}\sum_{a,b \in \mathbf{R^*}} 614 \overset{a}{\underset{b}{X}} = X \]
Example 8-4-13. Commands \overset and \underset are defined in the amsmath.plt file, they produce a <munder> or <mover> element.
615 \[ \sideset{_{i = 1}^n}{_{j = 2}^m}\prod_{k > 1} \mathcal{T}_{i, j}^k \]
Example 8-4-14.
616 A series $H_1, H_2, \dots, H_n$, a sum 617 $H_1 + H_2 + \dots + H_n$, an orthogonal product 618 $H_1 \times H_2 \times \dots \times H_n$. 619 A series $H_1, H_2, \dotsc\,$, a sum 620 $H_1 + H_2 + \dotsb\,$, an orthogonal product 621 $H_1 \times H_2 \times \dotsm\,$, and an infinite 622 integral: \[ \int_{H_1} \int_{H_2} \dotsi \; {-\Gamma}\, d\Theta \]
Example 8-5-1. A series , a sum , an orthogonal product .
Example 8-5-2. A series , a sum , an orthogonal product , and an infinite integral:
623 \begin{align*} 624 \widehat {\psi_\delta(t) E_t h} &= \widetilde {\psi_\delta(t) E_t h} \\ 625 \overline {\psi_\delta(t) E_t h}&= \underline {\psi_\delta(t) E_t h} \\ 626 \overbrace {\psi_\delta(t) E_t h}&= \underbrace {\psi_\delta(t) E_t h} 627 & & \text{Do not change style} \\ 628 \overrightarrow {\psi_\delta(t) E_t h}&= \overleftarrow {\psi_\delta(t) E_t h} 629 & & \text{Do not change style} \\[-3pt] 630 & & & \text{without \textsf{amsmath}} \\ 631 \underrightarrow {\psi_\delta(t) E_t h} 632 &= \underleftarrow {\psi_\delta(t) E_t h} 633 & & \text{Do need \textsf{amsmath}} \\ 634 \overleftrightarrow {\psi_\delta(t) E_t h} 635 &=\underleftrightarrow{\psi_\delta(t) E_t h} 636 & & \text{Do need \textsf{amsmath}} 637 \end{align*}
Example 8-5-3
638 \[ \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 + 639 \sqrtsign{1 + \sqrtsign{1 + \sqrtsign{1 + x}}}}}} \]
Example 8-5-4
( ) | \{\} | \lVert\rVert | |||
\langle\rangle | \lbrace\rbrace | \lvert\rvert | |||
\lgroup\rgroup | [ ] | | | |||
\lmoustache\rmoustache | \lbrack\rbrack | \vert | |||
\Downarrow | \lceil\rceil | \arrowvert | |||
\Uparrow | \lfloor\rfloor | \bracevert | |||
\Updownarrow | \llbracket\rrbracket | \Arrowvert | |||
\downarrow | / | \| | |||
\uparrow | \backslash | \Vert | |||
\updownarrow | . | \sqrtsign |
\arccos | v | \arcsin | \arctan | \arg | ||||
\cos | \cosh | \cot | \coth | |||||
\csc | \deg | \det | \dim | |||||
\exp | \gcd | \hom | \inf | |||||
\injlim | \ker | \lg | \lim | |||||
\liminf | \limsup | \ln | \log | |||||
\max | \min | \Pr | \projlim | |||||
\sec | \sin | \sinh | \sup | |||||
\tan | \tanh | \varinjlim | \varliminf | |||||
\varlimsup | \varprojlim |
640 \begin{gather} 641 \text{Also, if } \Delta_{\text{max up}} 642 = \Delta_{\text{min down}} \notag \\ 643 \text{(for all ups and downs) then} \notag \\ 644 \Delta_{\text{sum of ups}} 645 = \Delta_{\text{sum of downs}} 646 \end{gather}
Example 8-6-1
647 \newcommand\abs[1]{\lvert#1\rvert} 648 \setlength\mathindent{0pt} 649 \begin{gather*} 650 \lim_{x \rightarrow 0} \frac{ \sin^2(x) }{ x^2 } = 1 \\ 651 \varliminf_{n \rightarrow \infty} 652 \abs{a_{n+1}} / \abs{a_n} = 0 \\ 653 %{ JG 654 \varinjlim (m_i^\lambda \cdot M)^* 655 %} JG 656 \le \varprojlim_{A/p \rightarrow \lambda(A)}A_p \le 0 657 \end{gather*}
Example 8-6-2. Braces uncommented out for the last equation.
658 \let\abs\relax 659 \DeclareMathOperator \meas {meas} 660 \DeclareMathOperator*\esssup {ess \, sup} 661 \DeclareMathOperator*\supminus{sup - minus*} 662 \newcommand\abs [1]{\lvert#1\rvert} 663 \newcommand\norm[1]{\lVert#1\rVert} 664 \begin{gather*} 665 \norm{f}_\infty = \esssup_{x \in R^n} \abs{f(x)} \\ 666 \norm{f}_\infty = \smash{\esssup_{x \in R^n}} \abs{f(x)} \\ 667 \meas_1 \{ u \in R_+^1 \colon f^*(u)>\alpha \} = 668 \esssup_{x \in R^i} \; \meas_i 669 \{ u \in R^n \colon \abs{f(u)} \geq \alpha \} \\ 670 \quad (\forall \alpha \in \supminus_{f^*} R_{*+}) 671 \end{gather*}
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 \smash command:
672 \[\varlimsup_{n\to\infty}\calQ (u_n, u_n - u^{\#}) \ge \csc (\calQ' (u^{\#})) \]
Example 8-6-4
673 \let\LB\relax\let\RB\relax\let\DS\relax 674 \def\Test{ 675 b %% D 676 ^0 %% S 677 + %% D 678 \frac{\LB(k + p) %% T 679 _{j'}\RB %% S' 680 \DS% \displaystyle 681 \pm %% T [D] 682 \frac{(f + q) %% S [T] 683 ^{(pk) %% SS [S] 684 ^y %% SS 685 _{j'}}} %% SS' 686 {(h + y)}} %% S' [T'] 687 {(l + q) %% T' 688 ^{(pk)}} %% S' 689 } 690 \[\Test\qquad \let\LB={ \let \RB=} \Test \]
Example 8-7-1. Original LaTeX version, plus version with braces added.
Example 8-7-2. Same, with \DS replaced by \displaystyle
691 \[ \biggl( \mathbf{E}_{y} \int_0^{t_\varepsilon} 692 L_{x, y^x(s)} \varphi(x)\, ds \biggr) \]
Example 8-7-3. This demonstrates that commands like \Large do affect the size delimiters as \biggl. In Tralics, translation of math formulas is unaffected by font size commands. Thus, second part of example omitted.
693 \[ 694 \sqrt[\beta]{k} \qquad 695 \sqrt[\leftroot{2}\uproot{4} \beta]{k} \qquad 696 \sqrt[\leftroot{1}\uproot{3} \beta]{k} 697 \]
Example 8-7-4 Commands \leftroot and \uproot implemented as no-op.
698 $\sqrt{x} + \sqrt{y} + \sqrt{z}$, 699 $\sqrt{x} + \sqrt{\mathstrut y} + \sqrt{z}$, 700 $\sqrt{x} + \sqrt{\smash{y}} + \sqrt{z}$, 701 $\sqrt{x} + \sqrt{\smash[b]{y}} + \sqrt{z}$
Example 8-7-5, explaining smash. , , ,
More uses of smash (top, bottom, all):
702 \[ 703 f_p (x) = 704 \begin{cases} 705 \frac{1}{\smash[b]{p}} & x = p \\ 706 \frac{\strut 707 \smash[t]{\frac{(1 - x)^{\frac{1}{2}} } 708 { x - \sin (x - p) } } } 709 {\sqrt{1 - p} \, \cos (x - p)} & x \neq p 710 \end{cases} 711 \]
Example 8-7-6. The \strut above needed by amsmath, see TLC2.
712 \[ 713 \sqrt{ \frac{a+b}{x_j} } \quad 714 \sqrt{ \frac{a+b}{\smash{x_j}} } \quad 715 \sqrt{ \frac{a+b}{{}\smash{x_j}} } \quad 716 \sqrt{ \frac{a+b}{\smash{x_j+b}} } 717 \]
Example 8-7-7. The empty group above needed by amsmath, see TLC2.
718 $ \forall n \in \mathbb{N} : \mathfrak{M}_n \leq \mathfrak{A} $ 719 \DeclareMathAlphabet\mathbb{U}{fplmbb}{m}{n} 720 $ \lbrace n,m \in \mathbb{N} \mid \mathfrak{N}_{n,m} \rbrace $ 721 \DeclareMathAlphabet\mathscr{T1}{hlcw}{m}{it} 722 $A_B \neq \mathscr{A}_\mathscr{B} \neq \mathcal{A}_\mathcal{B}$
Example 8-8-1
Example 8-8-2
Example 8-8-3 The \DeclareMathAlphabet command takes five arguments and defines the first one to be \relax.
723 \newcommand\bfB{\mathbf{B}} \newcommand\bfx{\mathbf{x}} 724 \bmdefine\bpi{\pi} \bmdefine\binfty{\infty} 725 \section{The bold equivalence 726 $\sum_{j < B} \prod_\lambda : \bm{\sum_{x_j} \prod_\lambda}$} 727 \begin{gather} 728 B_\infty + \pi B_1 \sim \bfB_{\binfty} \bm{+}\bpi \bfB_{\bm{1}} 729 \bm {\sim B_\infty + \pi B_1} \\ 730 B_\binfty + \bpi B_{\bm{1}} \bm{\in} \bm{\biggl\lbrace} 731 (\bfB, \bfx) : \frac {\partial \bfB}{\partial \bfx} 732 \bm{\lnapprox} \bm{1} \bm{\biggr\rbrace} 733 \end{gather}
Example 8-8-4. Currently \bndefine is \def and \bm is \mathbf.
Example 8-8-5: same code different packages
734 $\bm{\Biggl\lbrace\biggl\lbrace\Bigl\lbrace\bigl\lbrace \lbrace 735 \mathcal{Q} 736 \rangle \bigr\rangle\Bigr\rangle\biggr\rangle\Biggr\rangle}$
Example 8-8-6
Example 8-8-7: same code different packages.
737 $ \bm{\sqrt[2]{x \times \alpha}} $ but 738 $\let\unboldmath\relax 739 \bm{\sqrt[2]{x \mathbin{\mbox{\unboldmath$\times$}} \alpha}} $ 740 or the similar 741 \def\sqrtsign{\sqrt{}} 742 $ \bm{\sqrtsign}{\bm{x} \times \bm{\alpha}} $ 743 %% $\bf \sqrt \it {\bf x \IT \times \bf \alpha \IT } $ see below A 744 %% $\bf {\sqrt} \it {\bf {x} \IT \times \bf {\alpha} \IT } $ see below B
Example 8-8-8. Second formula modified: you cannot use \unboldmath. Third formula: the command \sqrtsign is identical to \sqrt; you may wonder what the argument is. Currently \bm is the same as \mathbf, it takes one argument and typesets it in bold face font. Hence, Tralics executes the line shown above, marked `see below A´. Here \bf and \it are the tokens inserted by the \bm command corresponding to the new and old font (in reality, these tokens have complicated names). Thus, the argument of \sqrt is the \it command. Note that the \sqrt command uses a local group (is this good idea?), so that the \it command changes font locally; said otherwise, current font remains bold, and \IT is \bf. It is a wonder that this works. We noticed that LaTeX font change commands like \mathbf typeset their arguments in a group, and modified the Tralics code; thus the equivalent of line marked `see below B´ is executed. Suddenly \sqrt looses its argument. For this reason, we changed the command \sqrtsign to \sqrt{}. The example is but or the similar
745 \bmdefine\bhat{\hat} 746 % This does not work 747 %$\hat a \neq \bm{\hat a} \neq \bm{\hat a} = \bhat a \neq \bm{\widehat a}$ 748 $\hat a \neq \bm{\hat a} \neq \bm\hat a = \bhat a \neq \bm\widehat a$
Example 8-8-9 modified
749 \section{Sample page of mathematical typesetting} 750 751 First some large operators 752 both in text: \( \iiint\limits_{\mathcal{Q}} 753 f(x,y,z)\,dx\,dy\,dz \) and 754 \(\prod_{\gamma\in\Gamma_{\widetilde{C}}} 755 \partial(\widetilde{X}_\gamma)\); and also on display: 756 757 \begin{equation} 758 \begin{split} 759 %% This line is deliberately long so as to show 760 %% differences in widths; it is a little over the measure 761 %% in article/cmr. 762 \iiiint\limits_{\mathbf{Q}} f(w,x,y,z)\,dw\,dx\,dy\,dz &\leq 763 \oint_{\bm{\partial Q}} f' \left( \max \left\lbrace 764 \frac{\lVert w \rVert}{\lvert w^2 + x^2 \rvert} ; 765 \frac{\lVert z \rVert}{\lvert y^2 + z^2 \rvert} ; 766 \frac{\lVert w \oplus z \rVert}{\lVert x \oplus y \rVert} 767 \right\rbrace\right) 768 \\ 769 &\precapprox \biguplus_{\mathbb{Q} \Subset \bar{\mathbf{Q}}} 770 \left[ f^{\ast} \left( 771 \frac{\left\lmoustache\mathbb{Q}(t)\right\rmoustache} 772 {\sqrt {1 - t^2}} 773 \right)\right]_{t=\alpha}^{t=\vartheta} 774 \\ 775 \end{split} 776 \end{equation} 777 778 For $x$ in the open interval \( \left] -1, 1 \right[ \) 779 the infinite sum in Equation~\eqref{eq:binom1} is convergent; 780 however, this does not hold 781 throughout the closed interval \( \left[ -1, 1 \right] \). 782 \begin{align} 783 (1 - x)^{-k} &= 784 1 + \sum_{j=1}^{\infty} (-1)^j \ibinom{k}{j} x^j 785 \quad \text{ for } k \in \mathbb{N}; k \neq 0. 786 \label{eq:binom1} 787 \end{align}
Example 8-8-10. Changed a little bit: it is currently not possible to put a \quad in a \text in math mode. Thus, the \text contains only the word `for´.
First some large operators both in text: and ; and also on display:
For in the open interval the infinite sum in Equation (32) is convergent; however, this does not hold throughout the closed interval .
(32) |
Other examples here omitted.
788 \[ a \# \top _x^\alpha x^\alpha_b \] 789 \[ a \mathrel{\#} \mathop{\top}_x^\alpha x^\alpha_b \] 790 \thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu 791 \[ a - b = -\max \{ x , y \}\]
Example 8-9-1. In this example, \# and \top are changed into a Rel and a Op operator, so that <msub> or <mover> is used in the translation, but in the current version of Tralics, no information is attached to the symbol.
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.
Example 8-9-3. This demonstrates that different spacing is used for \bigl/\bigr or \left/\right. Tralics tries very hard to convert big open/close pairs to left-right ones.
792 \thinmuskip=10mu \medmuskip=17mu \thickmuskip=30mu 793 \[ a \Bigl( \sum x \Bigr) \neq a \left( \sum x \right) \]
794 \DeclareMathSymbol\bneg {\mathbin}{symbols}{"3A} 795 \DeclareMathSymbol\rsquare{\mathrel}{AMSa}{"03} 796 \[ a \neg b \qquad x \square y + z \] 797 \[ a \mathbin{\neg} b \qquad x \mathrel{\square} y + z \] 798 \[ a \bneg b \qquad x \rsquare y + z \]
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 \mathrel or \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.
799 \[ a = b \text{ but } a \tilde{=} b 800 \text{ which is not } a \mathrel{\tilde{=}} b \]
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.
801 $ u \not< v$ or $a \not\in \mathbf{A} $, 802 {\makeatletter\let\not\@@not $ u \not< v$ or $a \not\in \mathbf{A} $} 803 $ \not\leq \ \not\succeq \ \not\sim $ $ \nleq \ \nsucceq \ \nsim $
Example 8-9-6. By default \not< is translated at \neg<; this is wrong, so that we redefined it. The only trouble is that \not\in does not work. We show here both behaviors:
or , or
Example 8-9-7. This is not really good. and
804 $\Longarrownot\longleftrightarrow \qquad \arrownot\hookleftarrow$
Example 8-9-8, demonstrating how to negate an arrow , this is not implemented in Tralics.
* | + | - | |||
\amalg | \ast | \baro | |||
\barwedge | \bbslash | \bigtriangledown | |||
\bigtriangleup | \Cap | \cap | |||
\Cup | \cup | \curlyvee | |||
\curlywedge | \dag | \dagger | |||
\ddag | \ddagger | \diamond | |||
\divideontimes | \div | \dotplus | |||
\doublecap | \doublecup | \fatbslash | |||
\fatsemi | \fatslash | \gtrdot | |||
\intercal | \interleave | \land | |||
\lbag | \leftslice | \leftthreetimes | |||
\lessdot | \lor | \ltimes | |||
\merge | \minuso | \moo | |||
\mp | \nplus | \pm | |||
\rbag | \rightslice | \rightthreetimes | |||
\rtimes | \setminus | \smallsetminus | |||
\sqcap | \sqcup | \sslash | |||
\star | \talloblong | \times | |||
\triangleleft | \triangleright | \uplus | |||
\varbigtriangledown | \varbigtriangleup | \varcurlyvee | |||
\varcurlywedge | \vartimes | \veebar | |||
\vee | \wedge | \wr | |||
\Ydown | \Yleft | \Yright | |||
\Yup |
\circlearrowleft | \circlearrowright | \curvearrowleft | |||
\curvearrowright | \dasharrow | \dashleftarrow | |||
\dashrightarrow | \Downarrow | \downarrow | |||
\downdownarrows | \downharpoonright | \gets | |||
\hookleftarrow | \hookleftarrow | \hookrightarrow | |||
\Leftarrow | \leftarrow | \leftarrowtail | |||
\leftarrowtriangle | \leftrightarrowtriangle | \leftharpoondown | |||
\leftharpoonup | \leftleftarrows | \Leftrightarrow | |||
\leftrightarrows | \leftrightarrow | \leftrightharpoons | |||
\leftrightsquigarrow | \Lleftarrow | \Longleftarrow | |||
\longleftarrow | \Longleftarrow | \longleftrightarrow | |||
\Longmapsfrom | \longmapsfrom | \Longmapsto | |||
\longmapsto | \Longrightarrow | \longrightarrow | |||
\looparrowleft | \looparrowright | \Lsh | |||
\Mapsfrom | \mapsfrom | \Mapsto | |||
\mapsto | \multimap | \nearrow | |||
\nwarrow | \restriction | \rightarrowtail | |||
\rightarrowtriangle | \Rightarrow | \rightarrow | |||
\rightharpoondown | \rightharpoonup | \rightleftarrows | |||
\rightleftharpoons | \rightrightarrows | \rightsquigarrow | |||
\Rrightarrow | \Rsh | \searrow | |||
\shortdownarrow | \shortleftarrow | \shortrightarrow | |||
\shortuparrow | \swarrow | \to | |||
\twoheadleftarrow | \twoheadrightarrow | \Uparrow | |||
\uparrow | \upharpoonleft | \upharpoonright | |||
\Updownarrow | \updownarrow | \upuparrows |
\curlyveedownarrow | \curlyveeuparrow | \curlywedgedownarrow | |||
\curlywedgeuparrow | \nnearrow | \nnwarrow | |||
\ssearrow | \sswarrow |
\Delta | \Gamma | \Lambda | \Omega | \Phi | |||||
\Pi | \Psi | \Sigma | \Theta | \Upsilon | |||||
\Xi | \alpha | \beta | \chi | \delta | |||||
\digamma | \epsilon | \eta | \gamma | \iota | |||||
\kappa | \lambda | \mu | \nu | \omega | |||||
\phi | \pi | \psi | \rho | \sigma | |||||
\tau | \theta | \upsilon | \varepsilon | \varkappa | |||||
\varphi | \varpi | \varrho | \varsigma | \vartheta | |||||
\xi | \zeta |
\$ | \Im | \Re | \aleph | |||||
\Bbbk | \beth | \circledS | \complement | |||||
\daleth | \ell | \eth | \Finv | |||||
\Game | \gimel | \hbar | \hslash | |||||
\imath | \jmath | \mathdollar | \mathparagraph | |||||
\mathsection | \mathsterling | \mho | \P | |||||
\partial | \pounds | \S | \wp |
! | . | / | ? | ||||
@ | | | \# | \% | ||||
\& | \_ | \| | \angle | ||||
\Arrowvert | \arrowvert | \backprime | \backslash | ||||
\bracevert | \bigstar | \blacklozenge | \blacksquare | ||||
\blacktriangledown | \blacktriangle | \bot | \clubsuit | ||||
\copyright | \diagdown | \diagup | \diamondsuit | ||||
\emptyset | \exists | \flat | \forall | ||||
\heartsuit | \infty | \lightning | \lnot | ||||
\lozenge | \measuredangle | \nabla | \natural | ||||
\neg | \nexists | \prime | \sharp | ||||
\spadesuit | \sphericalangle | \square | \surd | ||||
\top | \triangledown | \triangle | \varcopyright | ||||
\varnothing | \Vert | \vert |
\acute{x} | \bar{x} | \breve{x} | \check{x} | ||||
\ddddot{x} | \dddot{x} | \ddot{x} | \dot{x} | ||||
\grave{x} | \hat{x} | \mathring{x} | \tilde{x} | ||||
\vec{x} | \widehat{xyz} | \widetilde{xyz} |
\boxast | \boxbar | \boxbox | \boxbslash | \boxcircle | \boxdot | ||||||
\boxempty | \boxminus | \boxplus | \boxslash | \boxtimes | \oblong |
\bullet | \cdot | \centerdot | \bigcirc | ||||
\circledast | \circledcirc | \circleddash | \circ | ||||
\oast | \obar | \ocircle | \obar | ||||
\odot | \ogreaterthan | \olessthan | \ominus | ||||
\oplus | \oslash | \otimes | \ovee | ||||
\owedge | \varobslash | \varocircle | \varodot | ||||
\varogreaterthan | \varolessthan | \varominus | \varoplus | ||||
\varoslash | \varotimes | \varovee | \varowedge |
< | = | > | \approxeq | ||||
\approx | \asymp | \backsimeq | \backsim | ||||
\Bumpeq | \bumpeq | \circeq | \cong | ||||
\curlyeqprec | \curlyeqsucc | \Doteq | \doteqdot | ||||
\doteq | \eqcirc | \eqsim | \eqslantgtr | ||||
\eqslantless | \equiv | \fallingdotseq | \geqq | ||||
\geqslant | \geq | \ge | \gggtr | ||||
\ggg | \gg | \gtrapprox | \gtreqless | ||||
\gtreqqless | \gtrless | \gtrsim | \leftrightarroweq | ||||
\leqq | \leqslant | \leq | \lessapprox | ||||
\lesseqgtr | \lesseqqgtr | \lessgtr | \lesssim | ||||
\le | \llless | \lll | \ll | ||||
\precapprox | \preccurlyeq | \preceq | \prec | ||||
\risingdotseq | \simeq | \sim | \succapprox | ||||
\succcurlyeq | \succeq | \succsim | \succ | ||||
\thickapprox | \thicksim | \triangleq |
\gnapprox | \gneqq | \gneq | \gnsim | ||||
\gvertneqq | \lnapprox | \lneqq | \lneq | ||||
\lnsim | \lvertneqq | \ncong | \neq | ||||
\ne | \ngeqq | \ngeqslant | \ngeq | ||||
\ngtr | \nleqq | \nleqslant | \nleq | ||||
\nless | \npreceq | \nprec | \nsim | ||||
\nsucceq | \nsucc | \precnapprox | \precneqq | ||||
\precnsim | \precsim | \succnapprox | \succneqq | ||||
\succnsim |
\blacktriangleleft | \blacktriangleright | \inplus | |||
\in | \niplus | \ni | |||
\ntriangleleftsqslant | \ntrianglerightsqslant | \owns | |||
\sqsubseteq | \sqsubset | \sqsupseteq | |||
\sqsupset | \Subset | \Supset | |||
\subseteqq | \subseteq | \subsetpluseq | |||
\subsetplus | \subset | \supseteqq | |||
\supseteq | \supsetpluseq | \supsetplus | |||
\supset | \trianglelefteq | \trianglerighteq | |||
\trianglerighteqslant | \trianglelefteqslant | \vartriangleleft | |||
\vartriangleright | \vartriangle |
, | \cdots | \hdots | \ldots | \mathellipsis | |||||
; | \colon | \ddots | \vdots |
\notin | \nsubseteqq | \nsubseteq | \nsupseteqq | ||||
\nsupseteq | \ntrianglelefteq | \ntriangleleft | \ntrianglerighteq | ||||
\ntriangleright | \subsetneqq | \subsetneq | \supsetneqq | ||||
\supsetneq | |||||||
\varsubsetneqq | \varsubsetneq | \varsupsetneqq | \varsupsetneq |
\nLeftarrow | \nLeftrightarrow | \nRightarrow | |||
\nleftarrow | \nleftrightarrow | \nrightarrow |
\Arrownot | \Longarrownot | \Mapsfromchar | \Mapstochar | ||||
\arrownot | \longarrownot | \mapsfromchar | \mapstochar | ||||
\lhook | \not | \rhook |
: | \backepsilon | \because | \between | ||||
\bowtie | \dashv | \frown | \Join | ||||
\mid | \models | \nmid | \nparallel | ||||
\nshortmid | \nshortparallel | \nVDash | \nvDash | ||||
\nVdash | \nvdash | \parallel | \perp | ||||
\pitchfork | \propto | \shortmid | \shortparallel | ||||
\smallfrown | \smallsmile | \smile | \therefore | ||||
\varpropto | \Vdash | \vDash | \vdash | ||||
\Vvdash |
\int | \oint | \bigbox | |||
\bigcap | \bigcup | \bigcurlyvee | |||
\bigcurlywedge | \biginterleave | \bignplus | |||
\bigodot | \bigoplus | \bigotimes | |||
\bigparallel | \bigsqcap | \bigsqcup | |||
\bigtriangledown | \bigtriangleup | \biguplus | |||
\bigvee | \bigwedge | \coprod | |||
\prod | \smallint | \sum |
[] | \{\} | \lVert\rVert | ||||
\lbrack\rbrack | \lbrace\rbrace | \lvert\rvert | ||||
\lceil\rceil | () | \lgroup\rgroup | ||||
\lfloor\rfloor | \langle\rangle | \lmoustache\rmoustache | ||||
\llbracket\rrbracket |
\llceil\rrceil | \binampersand\bindnasrepma | \Lbag\Rbag | |||
\llfloor\rrfloor | \llparenthesis\rrparenthesis |
805 \def\EXP{\frac{x^1_2}3Foo} 806 \[\dfrac {\EXP1}{\phantom{\EXP}1}=\dfrac {\EXP1}{\hphantom{\EXP}1}=\dfrac21= 807 \dfrac{\EXP1}{\EXP1}= 808 \dfrac{\EXP1}{\vphantom{\EXP}1}\]
Example of a \phantom, a \hphantom and a \vphantom. In the case of a \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 \vphantom, it should be centered otherwise flushed right (aligned with the numerator).
Test of multiscripts: , , ,
809 \[\sideset{}{_d^c}\sum _xy \qquad \sideset{^a_b}{}\sum _xy \qquad 810 \sideset{'^a}{^c}\sum_xy\qquad \sideset{_b}{_d}\sum_xy \qquad 811 \sideset{^{aA}_{bB}}{^{cC}_{dD}}\sum_xy 812 \]
More examples of sideset
Differences between \uplus and \biguplus. Consider the following input lines.
813 \[{\uplus a}, {\uplus _ab}, {\mathop \uplus_ab}, {\mathop \uplus\limits_ab} \] 814 \[{x\uplus a}, {x\uplus _ab}, {x\mathop \uplus_ab}, {x\mathop \uplus\limits_ab} \]
Initial code
(33) |
(34) |
Unicode character U+2A04 used instead of \uplus.
(35) |
(36) |
In Tralics 2.9.4, translation of \uplus was a character ⊎, translation of \biguplus was ⨄, characters U+22E8 (multiset union) and U+2A04 (n-ary union operator with plus). Thus lines 33 and 34 correspond to \uplus, while lines 35 and 36 correspond to \biguplus. On FL, I see a big operator on line 33, a smaller one on line 34 (the version without index being smaller than the other ones), and small operators on lines 35 and 36. On FM, I see a very big operator on line 33, a small one on line 34, question marks on lines 35 and 36, and Amaya gives the same for35 and 36. Thus, translation of \biguplus seems to be wrong. Thus, we changed it: in Tralics 2.9.5, \biguplus is the same character as \uplus. Same formulas as above, with command \biguplus used instead of \uplus
(37) |
(38) |
Same, with \textstyle
(39) |
(40) |
815 \[ A\xleftarrow{u}B\xleftarrow[d]{}C\xleftarrow[d]{u} 816 D\xrightarrow{u}E\xrightarrow[d]{}F\xrightarrow[d]{u}G \]
This example shows the use of \xleftarrow and \xrightarrow. Optional argument below the arrow, mandatory argument below.
817 \[\begin{CD} 818 @. 0 @. 0\\ 819 @. @VVV @VVV\\ 820 0 @>>> D^{1 \times q} @>.R>> D^{1 \times p} @>\pi>> M @>>> 0\\ 821 @. @| @VV.UV\\ 822 0 @>>> D^{1 \times q} @>.J>> D^{1 \times p} @>\kappa>> D^{1 \times (p-q)} @>>>0\\ 823 @. @VVV @VVV\\ 824 @. 0 @. 0\\ 825 \end{CD}\]
This example shows how to produce a commutative diagram (adapted from [5])
826 \[\begin{CD} 827 @. 0 @. 0\\ 828 @. @VLLVV @VVDV\\ 829 0 @<\mathrm{above}<< D @))\mathrm{below}) D @>\mathrm{above}>\mathrm{below}> 0\\ 830 @. @\vert @VLLVDV\\ 831 @. 0 @. 0\\ 832 \end{CD}\]
A variant that shows how to put data above and below the arrows.
Some formulas that were badly rendered:
More formulas: formula A: , formula B: , formula C: , formula D: , and finally . Using display style
These are example where Tralics 2.10.5 produces the wrong size for closing delimiters.
Example 1: and
Example 2: .
Example 3: .
Example 4: .
Example 5: and
Example 6: .
Example 7: .
Example 8: smaller parens versus larger parens .
Example 9:
(41) |
833 $\bra{X}=\bra{x^2}=\ket{Y}=\ket{y^2} = \braket{X|Y}=\braket{x^2| y^2}$ 834 $\Bra{X}=\Bra{x^2}=\Ket{Y}=\Ket{y^2} = \Braket{X|Y}=\Braket{x^2| y^2}$ 835 $\Braket{x|y||z}$, $\Braket{x\|y|z}$ 836 $\Braket{x+x_2|y+y^3||z+z^4+-5}$, $\Braket{x+x_2\|y+y^2|z+z^4_5}$ 837 $ \Braket{ \phi | \frac{\partial^2}{\partial t^2} | \psi } $ 838 $ \Set{ x\in\mathbf{R}^2 | 0<{|x|}<5 }$
Formula one
Formula two
Formula three ,
Formula four ,
Formula five .
These are from the style file and .
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 \mml@font@italic.
839 \def\F#1{\mbox{#1: }\csname mml@font@#1\endcsname} 840 \def\La{AB=c+1+23} 841 \def\Lb{ABCDEFGHIJKLMNOPQRSTUVWXYZ} 842 \def\Lc{$\Lx abcde$ $\Lx fghijklm$ $\Lx nopqrs$ $\Lx tuvwxyz$} 843 \def\Ld{0123456789} 844 \def\Test#1{\par Test of #1: \def\Lx{\csname mml@font@#1\endcsname} 845 $\Lx\La$, $\Lx\Lb$, \Lc, $\Lx\Ld$.} 846 847 \Test{normal} 848 \Test{upright} 849 \Test{bold} 850 \Test{italic} 851 \Test{bolditalic} 852 \Test{script} 853 \Test{boldscript} 854 \Test{fraktur} 855 \Test{doublestruck} 856 \Test{boldfraktur} 857 \Test{sansserif} 858 \Test{boldsansserif} 859 \Test{sansserifitalic} 860 \Test{sansserifbolditalic} 861 \Test{monospace}
Test of normal: , , , .
Test of upright: , , , .
Test of bold: , , , .
Test of italic: , , , .
Test of bolditalic: , , , .
Test of script: , , , .
Test of boldscript: , , , .
Test of fraktur: , , , .
Test of doublestruck: , , , .
Test of boldfraktur: , , , .
Test of sansserif: , , , .
Test of boldsansserif: , , , .
Test of sansserifitalic: , , , .
Test of sansserifbolditalic: , , , .
Test of 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.
862 \mathfontproperty0=0 863 \mathfontproperty1=0 864 \mathfontproperty2=0 865 \mathfontproperty3=0 866 \mathfontproperty4=0 867 \mathfontproperty5=0 868 \mathfontproperty6=0 869 \mathfontproperty7=0 870 \mathfontproperty8=0 871 \mathfontproperty9=0 872 \mathfontproperty10=0 873 \mathfontproperty11=0 874 \mathfontproperty12=0 875 \mathfontproperty13=0 876 \mathfontproperty14=0
Test of normal: , , , .
Test of upright: , , , .
Test of bold: , , , .
Test of italic: , , , .
Test of bolditalic: , , , .
Test of script: , , , .
Test of boldscript: , , , .
Test of fraktur: , , , .
Test of doublestruck: , , , .
Test of boldfraktur: , , , .
Test of sansserif: , , , .
Test of boldsansserif: , , , .
Test of sansserifitalic: , , , .
Test of sansserifbolditalic: , , , .
Test of 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.
877 \def\entity#1{\xmllatex{\&\#x#1;}{}} 878 \makeatletter 879 \mathfontproperty2=3 $\mathbf{x}$ 880 Font property:\the\mathfontproperty\mml@font@bold, 881 Character propery:\the\setmathchar\mathbf`x.\\ 882 \mathfontproperty\mathbf=0 883 Bold x: \setmathchar\mathbf`x={\entity{1d431}}$\mathbf{x}$ 884 ComplexC: \setmathchar\mathbf`c={\entity{2102}}$\mathbf{c}$ 885 \setmathchar 5 6 7 ok
Font property:1, Character property:𝐱. Bold x: ComplexC: ok
Examples and italic text taken from [4] (Mathematical Markup Language (MathML) Version 2.0, W3C recommendation 21 October 2003.
886 \newcommand\Apply[2]{\mathbox{apply}{\mathbox{#1}{}#2}} 887 $\mathbox{mfenced}{{a+b}}^2$ % F1 888 $\Apply{power}{\Apply{plus}{\mathci{a}\mathci{b}} \mathcn{2}}$ %F2 889 ${(a+b)}^2$ % F3
The four lines above show a command and three math formulas, representing the square of the sum of and . 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 <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 , it is impossible to tell if this means the square of the variable , or the second component of the vector .
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 <mi> obtained by \mathmi, instead of a <ci> obtained by \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 (<msup> for a construction base plus exponent), or a token element (a <mo> element for a sum). In the case of content markup, special element can be used (for instance <list>, or empty elements, like <plus/>.
In content markup, the sum of two objects is specified by a <apply> element, whose children are the operator <plus/> followed by the objects, and a list of three objects is represented by a <list> element whose children are the objects. In presentation markup, a sum is a sequence (an explicit or implicit <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 <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 can be obtained by the juxtaposition of and a <mfenced> element containing , and . In the case of formula F1, the content of <mfenced> element is the translation of {a+b}; because of the braces this is a <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 .
The second formula renders as . My Web browser knows only some of the operators; hence it is possible that you see the same as . In the Pdf version, we implement the <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 such that satisfies some condition, for instance, and is a square. Since Tralics does not generate content markup, this is not implemented at all.
890 ${\mathbox{apply}{\mathbox{minus}{}\mathci{a}\mathci{b}}}$ %2.1.3
Simple example of presentation markup: . Note that the minus operator takes one or two arguments.
891 ${x^2+{4\*x}+4}=0$
Rendering: . 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. The ⁢ 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 \* command whose meaning is: do not consider any special spacing rule, but allow a break here. We decide to translate \* 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.
892 $x=\frac{{-b}\pm\sqrt{b^2-{4\* a\* c}}}{2\* a}$
Second example, . Notice that the `plus or minus´ sign is given by the entity name ± this is equivalent to using the character reference �B1;. 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).
893 $z\mathbox{mfenced}{{x+y}}$ 894 $A=\begin{bmatrix}x&y\\z&w\end{bmatrix}$
Example three: . The MathML recommendation says that there is some ambiguity: what is the relation between and the expression that follows? implicit product or function application? A translator like Tralics cannot guess.
Example four . Most elements have a number of attributes that control the details of their screen and print rendering. The attributes for operator elements given using <mo> are set to default values determined by a dictionary. Translation of the environment is a <mfenced> element, with two attributes; all other attributes are ignored in the XML to Pdf conversion. No dictionary is currently used; translation of a <mo> is complicated: the difference between and 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 \sum, that expands to whatever is defined by the style files.
895 \def\Cx{\mathci{x}} \def\Dz{\mathcn{0}} 896 \def\Dt{\mathcn{2}} \def\Df{\mathcn{4}} 897 $\Apply{eq}{ 898 \Apply{plus}{ \Apply{power}{\Cx\Dt} \Apply{times}{\Df\Cx}\Df} 899 \Dz}$
Example 2.3.2, content markup. This example shows that content markup is sometimes easier.
900 \def\Ca{\mathci{a}}\def\Cb{\mathci{b}} \def\Cc{\mathci{c}} 901 \def\Cpm{\mathcsymbol{^^b1}} 902 $\Apply{eq}{ 903 \Cx 904 \Apply{divide}{ 905 \mathbox{apply}{ 906 \Cpm 907 \Apply{minus}{\Cb} 908 \Apply{root}{\mathbox{degree}{\Dt} 909 \Apply{minus}{ 910 \Apply{power}{\Cb\Dt} 911 \Apply{times}{\Df\Ca\Cc}}}} 912 \Apply{times}{\Dt\Ca}}}$
Next example . 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 <apply> can be any function; in this example, it is a <csymbol> element (equivalent of <mo>), whose value is the character (that has to be entered as a character, not a command). Other content markup examples omitted.
913 $\mathbox{mrow}{\mathbox{apply}{\mathbox{eq}{}\mathci{A} 914 \mathbox{matrix}{\mathbox{matrixrow}{\mathci{x}\mathci{y}} 915 \mathbox{matrixrow}{\mathci{z}\mathci{w}}}}}$
Next example . This example is badly rendered in the Pdf (matrix operators not implemented), and my favorite HTML browser shows the same result!
916 \def\X#1#2{\mathbox{#1}{\mathcnothing{\char32#2\char32}}} 917 $\X{mi}{x}\X{mo}{+}{\X{mi}{a}\X{mo}{/}\X{mi}{b}}$ 918 $x+{a/b}$
Compare `´ with `´. 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.
919 $\mathmi[fontweight][bold][mathvariant][normal]{a}$ 920 $\mathmi[fontweight][bold][mathvariant][sans-serif]{a}$ 921 $\mathmi[fontweight][bold][mathvariant][fraktur]{a1}$ 922 $\mathbox{mstyle}[fontstyle][italic]{\mathbf{a}b}$
Deprecated styles: `´ should be a normal a, `´ should be a sans-serif a, and `´ should be fraktur. In the case of `´, 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 \mstyle are currently ignored.
923 $x$ $\mathmi{\char32x\char32}$ 924 $D$ $\mathmi{\char32sin\char32}$ $\mathmi[mathvariant][script]{L}$ 925 $\mathmi{}$
Examples for 3.2.3: `´ (an x without spaces), `´ (an x with spaces), `´, `´, ´´ and `´ (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.
926 $\sin(x)$ $\mathmi{sin}\ApplyFunction x$ $1+x+\mathmo{...}+n$ 927 $1+x+\mathmi{...}+n$ $\pi, \ImaginaryI,\ExponentialE$
This is , using ⁡, Unicode character U+2061: `´. Ellipses using <mo>: `´ and <mi>: `´, constants (these are somehow unusual in Pdf).
928 $2, \mathmn{0.123}, \mathmn{1,000,000}, \mathmn{2.1e10}, 929 \mathmn{0xFFEF}, \mathmn{MCMLXIX}, \mathmn{twenty one}$. 930 $2+{3\*\ImaginaryI},\frac12, \pi, \ExponentialE$.
A <mathmn> element represents a number, typeset with an upright font, for instance , , , , , , . Numbers, that could be <mathcn> (content markup numbers), but are not <mathmn> (presentation markup numbers): .
931 $+, <,\le, \mathmo{<=}, \mathmo{++}, \sum,\mathmo{.NOT}, \mathmo{and}, 932 \*,\mathmo[mathvariant][bold]{+}$ 933 $({a+b})$, $[{0,1})$, $f\ApplyFunction {({x,y})}$ 934 $x\* y$, $f\ApplyFunction{(x)}$, $\sin\ApplyFunction x$ 935 and $m_{1\InvisibleComma2}$.
Example of <mathmo> (operators): . 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: , , .
Invisible operators: , , and .
936 $\frac{\DifferentialD}{\DifferentialD x}$
Embellishment . The MathML recommendation says that the spacing around an embellished operator like should be the same as that of the operator at its core. An expression like 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.
937 $\underline{(}\frac ab \overline)$. 938 $\mathmo[maxsize][1]{(} \frac ab\mathmo[maxsize][1]{)}$, 939 $(\frac ab)$ 940 $x\mathop\rightarrow\limits_{\mtext{ maps to }}y$
Stretching: . With maxsize , and without . 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: . In the Pdf version, we have a normal arrow.
941 $\mtext{ Theorem 1: }$ 942 $X\mathbox{mtext}{\mathcnothing{^^^^2009}}X$ 943 $X\mathbox{mtext}{\mathcnothing{^^^^2009^^^^200a^^^^200a^^^^2009% 944 ^^^^200a^^^^200a}}X$' 945 $X\mkern10muX$ 946 $X\mtext{ /* a comment */ }X$' 947 $\mathmo{ there exists }{{\delta>0}\mathmo{ such that 948 }{{f\ApplyFunction{(x)}}<1}}$
Text: `´, `´ `´ (expression obtained by inserting twice three characters: thickspace, thinspace and verythinspace, should be the same as `´, `´. Other example: . 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 <mtext> or <mo>. This is not done in the Pdf version, and you will see the following: normally <mtext> is typeset via \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 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 <mtext> elements or between a <mtext> and a comma.
949 ${x\mathbox{malignmark}[edge][right]{}}^2$
Alignment: . 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 <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 <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.
950 $\mathbox{ms}{\mathcnothing{\&}}$ 951 $\mathbox{ms}{\mathcnothing{\&}}$ 952 $\mathbox{ms}{\mathcnothing{double quote is "}}$ 953 $\mathbox{ms}[lquote][aa][rquote][bb]{\mathcnothing{test}}$
Literals , , , . 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.
954 ${2\* x}+y-z$, $({x,y})$
Example of <mrow>: , .
955 \[\frac{(\frac ab\mathattribute{linethickness}{0})\qquad 956 \frac ab}{\frac cd}\mathattribute{linethickness}{2}\qquad 957 \frac{1}{x^3+\frac x3} = \frac{1}{x^3+\frac x3} 958 \mathattribute{bevelled}{true}\qquad \frac{1+\sqrt 5}{2} 959 \]
Example of <mfrac>; if the bevelled attribute is true, a diagonal line should separate numerator and denoninator (not implemented in Pdf).
960 $\mathbox{mstyle}[maxsize][1]{(\frac ab)}$
Example of <mstyle>: . 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.
961 $\mathbox{merror}{ 962 \mtext{ Unrecognised element: mfraction; arguments were: } 963 {1+\sqrt5}\mtext{ and } 2}$
Error: .
964 \def\test{C\mathbox{mpadded}[width][0em]{\kern-0.3em\text{|}}} 965 $\test$, $\mathbox{semantics} 966 {\test\mathbox{annotation-xml}[encoding][MathML-Presentation]{\mathbb{C}}}$ 967 $\mathbb{C}$ 968 $\mathbox{mpadded}[width][0em]{C}\kern0.3em\text{|}$
Padding: , . 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 <semantics> element is not implemented. The formula should mimic . Positive padding is better in my browser.
969 $\frac{x+y+z}{x\phantom{\mathmo[form][infix]{+}y}+z}$ 970 $\frac{x+y+z}{x\phantom{+}\phantom{y}+z}$
Phantom: and . 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.
971 \def\mfence{\mathbox{mfenced}} 972 Fences: $\mfence{x}$, $(x)$, $\mfence{xy}$, $f\ApplyFunction\mfence{xy}$, 973 $(x,y)$, $\mfence{{a+b}}$, $\mfence[open][[]{0\relax1}$. 974 Wrong $\mfence{a+b}$, $\mfence{01}, \bf\mfence{xy}$, 975 right: $\bf\mfence{x y}$, $\bf\mfence{{x}{y}}$.
Fences: , , , , , , . Wrong , , right: , . 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 <mrow> is necessary so that the <mfenced> has just one argument; a pair of braces should be added, this gives the \mrow. Examples that follow are wrong because `01´ or `xy´ produce a single <mn> or <mi> element; in the case of an identifier this may depend on the font. You can use a separator (space or \relax) or uses braces (no <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.
976 \[ 977 \def\mtr{\mathbox{mtr}} 978 \def\mtdr{\mathbox{mtd}[columnalign][right]} 979 \def\ralign{\cellattribute{columnalign}{right}} 980 \def\X#1#2{\mathbox{menclose}[notation][#1]{#2}} 981 \mathbox{mtable}[columspacing][0pt][rowspacing][0pt]{ 982 \mtr{\mathbox{mtd}{}\mtdr{10}} 983 \mtr{\mtdr{131}\mtdr{\X{longdiv}{1413}}} 984 \mtr{\mathbox{mtd}{}\mtdr{{\underline{131}\phantom{3}}}} 985 \mtr{\mathbox{mtd}{}\mtdr{103}}} 986 \qquad 987 a_{\X{actuarial}{n}\*i} 988 \qquad 989 \begin{array}{cc} 990 &\ralign10\\ 991 \ralign131&\ralign\X{longdiv}{1413}\\ 992 &\ralign \underline{131}\phantom{3}\\ 993 &\ralign 103 994 \end{array}\mathattribute{columspacing}{0pt}\mathattribute{rowspacing}{0pt} 995 \]
Examples of menclose (Does not work in the Pdf or with Firefox; works with Amaya).
996 $(x+y)^2$ ${(x+y)}^2$ $\int_0^1{\ExponentialE^x\*{\DifferentialD x}}$
Scripts: Compare (without braces) with (recommended),
997 $\underbrace{x+y+z}\mathattribute{accentunder}{true} \text{~versus~} 998 \underbrace{x+y+z}\mathattribute{accentunder}{false} 999 $, $\hat x \text{~versus~}\hat x\mathattribute{accent}{false}$, 1000 $\overbrace{x+y+z}\mathattribute{accent}{true} \text{~versus~} 1001 \overbrace{x+y+z}\mathattribute{accent}{false}$, 1002 $\mathop{\int\limits_0}\limits^\infty \text{~versus~} \int\limits_0^\infty$
Underscript, overscripts: , , . 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 there is no difference between an operator with underscript to which an overscript is added, and an operator with two scripts.
1003 $\mathbox{mmultiscripts}{F1\none\mathbox{mprescripts}{}0\none} 1004 \ApplyFunction{({;a;z})}$ 1005 $\mathbox{mmultiscripts}{Ri\none\none jk \none l\none}$
Multiscripts: and .
1006 $(\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\end{array})$, 1007 $\mathbox{mtable}{\mathbox{mlabeledtr}[id][e-is=m-c-square]{ 1008 \mathbox{mtd}{\text{(2.1)}} 1009 \mathbox{mtd}{{E={m\*c^2}}}}}$.
Tables: a matrix , and an numbered equation: .
1010 $\def\X{\mathbox{maligngroup}{}} 1011 \def\A{{{\X\mathmn{8.44}\*\X x} \X +{\X \mathmn{55} \*\X y}}\X=\X0} 1012 \def\B{{{\X\mathmn{3.1} \*\X x} \X -{\X \mathmn{0.7}\*\X y}}\X=\X{-\mathmn{1.1}}} 1013 \mathbox{mtable}[groupalign][\char`\{decimalpoint left left decimalpoint left 1014 decimalpoint\char`\}]{ 1015 \mathbox{mtr}{\mathbox{mtd}{{\A}}} 1016 \mathbox{mtr}{\mathbox{mtd}{{\B}}}} 1017 $
Alignment . As explained above, this could be typeset, by aligning the \X. the material between two \X commands should be left-aligned, or aligned on the decimal point. In some cases, the \X is a direct child of the cell, but not always. For this reason, it is nearly impossible to typeset this correctlty in TeX.
[1] Thierry Bouche. A pdflatex-based automated journal production system. in « TUGboat », number 1, volume 27, 2006.
[2] David Carlisle. XMLTEX: A non validating (and not 100% conforming) namespace aware XML parser implemented in TeX. in « TUGboat », number 3, volume 21, 2000, pages 193-199.
[3] David Carlisle, Michel Goossens, Sebastian Rahtz. De XML à PDF avec xmltex et PassiveTeX. in « Cahiers Gutenberg », number 35-36, pages 79-114, 2000.
[4] David Carlisle, Patrick Ion, Robert Miner, Nico Poppelier (editors). Mathematical Markup Language (MathML) Version 2.0. 2001, http://www.w3.org/TR/MathML2/
[5] Anna Fabiańska, Alban Quadrat. Applications of the Quillen-Suslin theorem to multidimensional systems theory. Rapport de recherche INRIA, number RR-6126, 2007, http://hal.inria.fr/inria-00131035/en/
[6] José Grimm. Tralics, a LaTeX to XML translator, Part I. Rapport Technique, number 309, Inria, 2006, http://hal.inria.fr/inria-00000198
[7] José Grimm. Tralics, a LaTeX to XML translator, Part II. Rapport Technique, number 310, Inria, 2006, http://hal.inria.fr/inria-00069870
[8] Donald E. Knuth. The TeXbook. Addison Wesley, 1984.
[9] Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle, Chris Rowley. The LaTeX companion, second edition. Addison Wesley, 2004.
[10] Sebastian Rahtz. Passive TeX. http://www.tei-c.org.uk/Software/passivetex/, 2003.
1. Introduction
1.1. Special features
1.2. Compiling the example file
1.3. Overview of math mode
2. Examples from the TEXbook
2.1. Typing math formulas, TB 16
2.2. More about Math, TB 17
2.3. Fine points of Mathematics Typing, TB 18
2.3.1. Punctuation
2.3.2. Non-italics letters in formulas
2.3.3. Spacing between formulas
2.3.4. Spacing within formulas
2.3.5. Ellipses
2.3.6. Line breaking
2.3.7. Braces
2.3.8. Matrices
2.3.9. Vertical Spacing
2.3.10. Special features for math hackers
2.3.11. Summary
2.4. Displayed Equations, TB19
2.4.1. One-line displays
2.4.2. Multi-line displays
2.4.3. Long formulas
3. Higher Mathematics, TLC2
3.1. Introduction to amslatex
3.2. Display and alignment structures for equations
3.3. Matrix-like environments
3.4. Compound structures and decorations
3.5. Variable symbol commands
3.6. Words in mathematics
3.7. Fine tuning the mathematical layout
3.8. Fonts in formulas
3.9. The bold equivalence
∑ j<B ∏ λ :∑ x j ∏ λ
3.10. Sample page of mathematical typesetting
3.11. Symbols in formulas
4. Other Examples
4.1. The connexion examples
4.2. Test of brackets
4.3. Recursion test
5. Font tests
6. Examples from the MathML recommendation
6.1. Introduction
6.2. More complicated examples
6.3. Presentation Markup
Bibliography
Note 1. AM does not show the epsilon
Note 2. Amaya seems to ignore the style attribute
Note 3. 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
Note 4. As previously, the struts induce unwanted space in Amaya
Note 5. Amaya places the too low
Note 6. Maybe, one day, Tralics will have an em that depends on the context
Note 7. Command \bordermatrix not yet implemented
Note 8. Fixme
Note 9. The label name provided by the user cannot be used since it is an invalid XML id in this case
Note 10. We should do something with the optional argument
Note 11. Translation/rendering of apostrophe not always correct
Note 12. The delimiter for Vmatrix is badly rendered by Amaya