Debian Codegraph @

texmf-dist/doc/optex/base/optex-math.tex

raw
1 %% This is part of the OpTeX project, see http://petr.olsak.net/optex
2
3 % Run optex optex-math (two times) to generate this document
4 % or look at PDF here: http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf
5
6 \fontfam[lmfonts]
7
8 \font\ttlib=[LiberationMono-Regular]
9 \def\ttspec{\let\_ttfont=\ttlib}
10
11 \report
12
13 \def\new #1 {\mnote{\Red$\blacktriangleleft$\,\sans\setfontsize{at9pt}\rm#1}}
14 \fixmnotes\right
15 \enquotes
16 \verbchar`
17 \catcode`\<=13
18 \def<#1>{$\langle\hbox{\it#1\/}\rangle$}
19 \everyintt={\catcode`\<=13 }
20 \def\ss#1{$\vrule height3pt#1\vrule height3pt$}
21
22 \addto\_secfont\Blue \addto\_seccfont\Blue
23 \_def\_printsec#1{\_par
24 \_abovetitle{\_penalty-400}\_bigskip
25 {{\_secfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}\_insertmark{#1}%
26 \_nobreak \_belowtitle{\_medskip}%
27 \_firstnoindent
28 }
29 \_def\_printsecc#1{\_par
30 \_abovetitle{\_penalty-200}\_medskip
31 {{\_seccfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}%
32 \_nobreak \_belowtitle{\_medskip}%
33 \_firstnoindent
34 }
35
36 \def\i #1 {\ii .#1 \iis .#1 {{\code{\\#1}}}}
37 \def\x`{\bgroup\_setverb\xx}
38 \bgroup \lccode\string`\.=\string`\` \lowercase{\egroup \def\xx #1#2.{\i #2 \egroup `#1#2.}}
39
40 \bgroup
41 \globaldefs=-1
42 \def\refs{} \tmpnum=0
43 \def\_Xtoc#1#2#3{\incr\tmpnum
44 \ea\addto \ea\refs \expanded{{\noexpand\sdef{r:#3}{\the\tmpnum}}}
45 \scantoeol\ignoreit
46 }
47 \isfile{optex-doc.ref}\iftrue \input{optex-doc.ref}\fi
48 \ea
49 \egroup
50 \refs
51
52 \def\urloptexdoc{https://petr.olsak.net/ftp/olsak/optex/optex-doc.pdf}
53 \def\optexdoc[#1]{\ea\ulink\expanded{[\urloptexdoc\#toc:\trycs{r:#1}{}]}}
54
55 \hyperlinks\Green\Green
56
57 \insertoutline{MATH}
58 \outlines{0}
59
60
61
62 \tit Typesetting Math with \OpTeX/
63
64 \hfill Version 03, January 2021
65
66 \author Petr Olšák
67
68
69 This document is a brief summary of typesetting math. It describes \TeX/,
70 Plain \TeX/ and \OpTeX/ features concerned to math. The first two types of
71 features are documented in \TeX/book in chapters 16, 17, and 18, but it is
72 summarized here in short again in order to give a complete guide about math
73 typesetting for \OpTeX/ users.
74
75 \new {}
76 The \OpTeX/ features which differs from standard \TeX/ or Plain \TeX/ are
77 documented with the red triangle at the margin (like in this paragraph).
78 Reader can simply distinguish between \"standard" features (given by
79 \TeX/ or Plain \TeX/) and new \OpTeX/ features.
80
81 There are more types of extensions: e\TeX, lua\TeX/, Unicode math and
82 \OpTeX/ macros. The appropriate label (e\TeX, Lua\TeX/, Unicode, \OpTeX/)
83 is appended to the red triangle to inform you about the extension type.
84 Nevertheless, \OpTeX/ user doesn't have to worry about it, all extensions
85 are available if Unicode Math font is loaded (e.g., by the command
86 `\fonfam[lmfonts]`). See \optexdoc[1.3.3]{section 1.3.3} in \OpTeX/
87 documentation about loading Unicode math fonts.
88
89 {\iindent=2em
90 \bigskip
91 \maketoc }
92 \vfil\break
93
94 \sec Basics structure of math formulas
95
96 \secc General rules and terminology
97
98 The \ii in-line/math in-line math (in the paragraph) is created by `$<math list>$`. The
99 \ii display/math display math (a standalone line between paragraphs) is created by `$$<math list>$$`.
100 More than one line can be here if an appropriate macro is used. In-line math is
101 processed in a \TeX/ group in \ii in-line/math/mode {\em in-line math mode}. The display math is
102 processed in a \TeX/ group in \ii display/math/mode {\em display math mode}. Spaces are
103 ignored in math modes, so `$x+y$` and `$x + y$` gives the same result: $x+y$.
104
105 The \ii math/list <math list> is a sequence of \ii math/atom,atom {\em math atoms} and
106 \ii other/material {\em other material}.
107 The math atoms are \ii single/math/object {\em single math objects} or
108 \ii composed/math/atom composed math atoms.
109
110 \begitems \hfuzz=.6pt
111 * The single math object is a single character to be printed in math mode
112 like `x`, `+`, `\int`.
113 * The math atom is constructed in general by `{<math list 1>}^{<math list 2>}_{<math list 3>}`.
114 It consists from \ii nucleus {\em nucleus} <math list 1>, \ii exponent exponent <math list 2>
115 and \ii subscript subscript <math list 3>. Each part of the atom should be empty.
116 If <math list 2> or <math list 3> is empty, we need not to write brackets and
117 the prefix `^` or `_`.
118 If the <math list 1> or <math list 2> or <math list 3>
119 consist only from a single math object then we need not use brackets.
120 For example
121 `x^2` is a math atom with `x` in the nucleus, `2` in the exponent, and with empty subscript.
122 Or `a_{i,j}` is a math atom with `a` in the nucleus, empty exponent, and `i,j` in the subscript.%
123 \fnote{In \OpTeX/, the character `_` can be interpreted as a part of
124 the control sequence name, not as the subscript constructor. But in common cases,
125 constructions of math atoms are interpreted exactly as in plain \TeX. See sections
126 \optexdoc[2.2.2]{2.2.2} and \optexdoc[2.15]{2.15}
127 of \OpTeX/ documentation for more details. If you want to
128 be sure that `_` is just a subscript constructor in \OpTeX/ then you can set \code{\\catcode`\\_=8}
129 but after this, you cannot use control sequences with `_` character.}
130 The constructors for exponent `^` and subscript `_` can be used in arbitrary order
131 after the nucleus, for example, `z_1^{x+y}` is the same math atom as
132 `z^{x+y}_1`. The single math objects not followed by `^` nor `_` are
133 considered as math atoms with this object in the nucleus and with empty
134 exponent and subscript (this is a very common case).
135 \TeX/ assigns the \ii class {\em class} for each math atom, see section~\ref[class].
136 * Other material can be \TeX/ box or glue (space) or `\kern` or `\vrule` etc.
137 \enditems
138
139 Example: The `Z = \int``_\Omega x^{2y} + z\, dx` generates
140 $Z = \int_\Omega x^{2y} + z\, dx$ and it is <math list> which consists from:
141
142 \begitems
143 * `Z` is math atom with empty exponent and subscript, class: Ord,
144 * `=` is math atom with empty exponent and subscript, class: Rel,
145 * `\int``_\Omega` is math atom with empty exponent and with subscript `\Omega`, class: Op,
146 * `x^{2y}` is math atom with exponent `2y` and empty subscript, class: Ord,
147 \begitems \let\_bullet=\circ
148 * `2` is math atom with empty exponent and subscript, class: Ord,
149 * `y` is math atom with empty exponent and subscript, class: Ord,
150 \enditems
151 * `+` is math atom with empty exponent and subscript, class: Bin,
152 * `z` is math atom with empty exponent and subscript, class: Ord,
153 * `\,` is another material, the glue (space) in this case,
154 * `d` is math atom with empty exponent and subscript, class: Ord,
155 * `x` is math atom with empty exponent and subscript, class: Ord.
156 \enditems
157
158 \secc[class] Classes of math atoms
159
160 \TeX/ assigns \ii class {\em a class} for each math atom.\fnote
161 {Using terminology of \TeX/book, each single math object has its {\em class} but the
162 math atom has its {\em kind} derived from this class. I use only one word
163 for both meanings in this document.}
164 This data type is used when
165 \TeX/ decides about \ii horizontal/spacing horizontal spaces between atoms in the output. (Note
166 that spaces in the input are ignored.) For example,
167 `$xy$` prints two atoms without space between them but `$x+y$` is printed with
168 small spaces around the `+` binary operator. Compare: $xy$ and $x+y$.
169
170 The class is assigned depending on the nucleus of the atom. If the nucleus is
171 not a single math object, i.e. it is constructed by `{<math list>}` with braces
172 then the atom has its class Ord. If the nucleus is a single math object constructed
173 without braces then the class of the atom depends on this single math
174 object. Each single math object must be declared in \TeX/ with its default
175 class. The following table lists the classes with typical examples.
176 The full set of all math objects used in math typesetting
177 is listed in section~\ref[objects] with their default classes.
178
179 \bigskip
180 \noindent\hfil\table{llll}{
181 & \ii class Class & Meaning & Example \crl
182 0 & \iid Ord & ordinary object & variables, digits, $x, {\bbchar R}, \Gamma, 0, 1$ \cr
183 1 & \iid Op & big opertator & $\sum, \int, \bigcup$ \cr
184 2 & \iid Bin & binary operator & $+, \times, -, \pm, \cup$ \cr
185 3 & \iid Rel & reations & $=, \ne, \leq, \supseteq, \succsim$ \cr
186 4 & \iid Open & opening bracket & $\{, (, [, \langle$ \cr
187 5 & \iid Close & closing bracket & $\}, ), ], \rangle$ \cr
188 6 & \iid Punct & punctuation & comma \cr
189 & \iid Inner & left-right & \code{\\left...\\right} outputs, see section~\ref[delims]
190 }
191 \bigskip
192
193 There are \ii horizontal/spacing,spacing three space types used
194 by the algorithm for horizontal spacing in the math formulas.
195
196 \begitems
197 * \ii thin/space Thin space: \x`\thinmuskip` primitive register, `\,` macro. Used around Op atoms.
198 * \ii medium/space Medium space: \x`\medmuskip` primitive register, `\>` macro. Used around Bin atoms.
199 * \ii thick/space Thick space: \x`\thickmusip` primitive register, `\;` macro. Used around Rel atoms.
200 \enditems
201
202 \puttext 7.8cm -3.7cm {\rotbox{90}{Left atom}}
203 \puttext 11.5cm -.5cm {Right atom}
204 \puttext 8.2cm -4.4cm {\typosize[9/11]
205 \thistable{\def\_enspace{ }}%
206 \table {l|8c|} {
207 \omit & Ord & Op & Bin & Rel & Open & Close & Punct & \omit \hfil Inner \crlp{2-9}
208 Ord & 0 & 1 & 2 & 3 & 0 & 0 & 0 & 1 \cr
209 Op & 1 & 1 & & 3 & 0 & 0 & 0 & 1 \cr
210 Bin & 2 & 2 & & & 2 & & & 2 \cr
211 Rel & 3 & 3 & & 0 & 3 & 0 & 0 & 3 \cr
212 Open & 0 & 0 & & 0 & 0 & 0 & 0 & 0 \cr
213 Close & 0 & 1 & 2 & 3 & 0 & 0 & 0 & 1 \cr
214 Punct & 1 & 1 & & 1 & 1 & 1 & 1 & 1 \cr
215 Inner & 1 & 1 & 2 & 3 & 1 & 0 & 1 & 1 \crlp{2-9}
216 }}
217
218 \hangindent=-8.7cm \hangafter=0
219 Ord atoms are printed without spaces between them. The spaces are not
220 cumulated, so the rule about spaces mentioned above is only a rough idea.
221 The exact rule for horizontal spaces is given for each pairs of atoms
222 in the table here. The symbol 0 means no space, 1 thin space, 2 medium space,
223 and 3 means thick space.\fnote
224 {The table presented here is built into \TeX. On the other hand,
225 \LuaTeX/ allows to set arbitrary spaces between arbitrary pairs,
226 see section 7.5.2 in the \LuaTeX/ manual.}
227
228 \hangindent=-8.7cm \hangafter-2
229 The Bin atom is automatically transformed to the
230 Ord atom if no atom precedes or if Op, Bin, Rel, Open, or Punct atom
231 precedes. And it is transformed to the Ord atom if Rel, Close or Punct atom
232 follows. This corresponds to the empty cells in the table.
233 Why such behavior? Compare \"\hbox{$0-3$}" and \"$-3$". The Bin atom in
234 the second case behaves like Ord atom because it is \ii unary/minus {\em unary minus}.
235 There is no space between the unary minus and the following object.
236
237 All medium spaces and thick spaces and some thin spaces from this table are
238 omitted if the <math list> is processed in
239 \ii script/style,scriptscript/style script or scriptscript styles
240 (smaller size). See section~\ref[styles] about math styles.
241
242 You can overwrite the default class derived from the nucleus of the atom by
243 \TeX/ primitives \x`\mathord`, \x`\mathop`, \x`\mathbin`, \x`\mathrel`, \x`\mathopen`,
244 \x`\mathclose`, \x`\mathpunct` and \x`\mathinner`. They can precede a nucleus of
245 the atom and they set the class of the atom.
246 For example, `x \mathrel+ y` behaves like `x = y` from a spacing point of view but +
247 is printed. Another example: `\mathop{\rm lim} z` creates the atom `lim` in
248 roman font of class Op. So, the thin space is inserted between lim and $z$.
249
250 There are more special kinds of math atoms: fractions, math accents,
251 radicals. They are constructed in a special way (see next sections) but they behave
252 like Ord atom in the horizontal spacing algorithm.
253
254 \secc[styles] Math styles
255
256 When a formula (or a sub-formula) is processed by \TeX/ then one from four
257 \ii math/style,display/style,text/style,script/style,scriptscript/style
258 styles is active: display style ($D$), text style ($T$), script style ($S$) or
259 scriptscript style ($SS$).
260
261 \ii T/style,D/style,S/style,SS/style The $T$ style is started in in-line math mode `$...$` and the $D$
262 style is started in display math mode `$$...$$`. The first level of exponents or
263 subscripts is processed in $S$ style and the second and more levels of
264 exponents or indexes are processed in $SS$ style.
265 There are special rules for math styles when fractions are constructed, see
266 section~\ref[frac].
267
268 The $D$ and $T$ styles use basic \ii font/size font size, $S$ uses smaller font size (typically
269 70~\%) and $SS$ style uses more smaller font size (typically 50~\%). Next
270 levels of \"more smaller fonts" are not used due to classical typographic rules.
271
272 The \ii nucleus nucleus of \iid Op atoms (big operators, $\sum$, $\int$, etc.) have typically bigger versions
273 of the character shape for $D$ style than for $T$ style.
274 So, there are four sizes for such math
275 objects: one size for each math style. All other math objects (with non Op
276 class) are printed only in three sizes: The sizes for $T$ and $D$ styles are equal.
277
278 The \iid Op atom puts its \iid exponent and \iid subscript above and below the nucleus in $D$
279 style but right to the nucleus in other styles:
280 $$
281 `\sum``_{i=1}^\infty` \quad \hbox{gives}\quad \sum_{i=1}^\infty \hbox{ in $D$ style and}
282 \quad \textstyle \sum_{i=1}^\infty \hbox{ in $T$ style}.
283 $$
284 This default behavior of the Op atom
285 can be modified by placing \x`\limits` or \x`\nolimits` or
286 \x`\displaylimits` \TeX/ primitive just after its nucleus before the constructors
287 of exponent and/or index. The `\nolimits` puts exponent and subscript right
288 to the nucleus (regardless of the current style) and `\limits` puts these
289 objects above and below the nucleus (regardless of the current style). There
290 can be more such primitives in a queue (due to a macro expansion, for
291 instance). Then the last primitive in the queue wins.
292 If the last primitive is \x`\displaylimits` then
293 the default behavior is processed regardless there are \x`\limits` or \x`\nolimits`
294 before it.
295 $$
296 `\sum\nolimits``_{i=1}^\infty` \quad \hbox{gives}\quad \sum\nolimits_{i=1}^\infty
297 \hbox{ in $D$ style and}\quad \textstyle\sum\nolimits_{i=1}^\infty
298 \hbox{ in $T$ style}.
299 $$
300 Atoms of all other classes have their exponents and/or subscripts only right
301 to their nucleus without any exception.
302
303 The primitives \x`\displaystyle`, \x`\textstyle`, \x`\scriptstyle` and
304 \x`\scriptscriptstyle` set the given style regardless the default rules. For
305 example, you can create a formula in in-line math mode and in $D$ style by
306 `$\displaystyle <formula>$` or a formula in display mode and $T$ style can be printed
307 by `$$\textstyle <formula>$$`.
308
309 If a subformula is placed below something (below a line from root symbol,
310 below a fraction line), then the processed style $D, T, S$ or $SS$ is
311 \ii cramped/style {\em cramped}.
312 The exponents are positioned slightly lower than in
313 \ii non-cramped/style non-cramped style. The selectors `\displaystyle`\,\dots
314 `\scriptscriptstyle` mentioned above select non-cramped style. The
315 non-cramped style is selected when math mode starts too.
316 \new \OpTeX/
317 You can select a cramped style by the macro \x`\cramped` at the start of the
318 math formula or after the math-style selectors: `\scriptstyle\cramped` for
319 example.
320
321 Several macros need to know what math style is currently processed (for
322 example they need to draw something in an appropriate size). But it
323 not possible simply due to the syntax of fractions (section~\ref[frac]).
324 This syntax requires to process all math lists in two steps: the first step
325 expands all macros and creates structured data of processed math list. The
326 second step reads the output of the first step, switches between math
327 styles and creates definitive output. Macros are working only in the first step
328 and they cannot know the current math
329 style because it is set in the second step. \TeX/ supports the primitive
330 \x`\mathchoice``{<D>}{<T>}{<S>}{<SS>}` which prepares four math lists in the
331 first step and only one of these four lists are used in the second step. We
332 can put different macros into each of the four parameters of `\mathchoice`.
333 Plain \TeX/ supports the macro \x`\mathpalette` which gives a more comfortable
334 interface of \x`\mathchoice` to the macro programmer.
335 The cramped/non-cramped variants of the current style are kept when `\mathchioce`
336 is used.
337
338 \new \OpTeX/
339 We describe another interface for creating macros depending on the current
340 style. You can use \x`\mathstyles``{<math list>}`. It
341 behaves like `{<math list>}`, moreover, you can use the following commands inside such
342 <math list>:
343 \begitems
344 * The macro \x`\currstyle`. It expands to
345 `\displaystyle`, `\textstyle`,
346 `\scriptstyle` or `\scriptscriptstyle` depending on the current math style
347 when the `\mathstyles` was opened.
348 * The \x`\dobystyle``{<D>}{<T>}{<S>}{<SS>}` is expandable macro. It expands its
349 parameter `<D>`, `<T>`, `<S>` or `<SS>` depending on the current math style
350 when `\mathstyles` was opened.
351 * The value of the \x`\stylenum` register is 0, 1, 2 or 3
352 depending on the current math style when `\mathstyles` was opened.
353 \enditems
354 %
355 Example of usage of \x`\mathstyles`:
356 \def\mysymbol{\mathbin\mathstyles
357 {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}}
358 \def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}}
359 \begtt
360 \def\mysymbol{\mathbin\mathstyles
361 {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}}
362 \def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}}
363 Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$.
364 \endtt
365 This example gives Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$.
366
367 The \x`\mathstyles` macro mentioned above uses \TeX/ primitive \x`\mathchoice`, so it
368 creates four math lists and only one is used. It may take more
369 computer time in special cases.
370 \new Lua\TeX/
371 Lua\TeX/ supports the \x`\mathstyle` primitive
372 (no \"`s`" at the end of this control sequence) which
373 expands to values 0 to 7 depending on the current style:
374 $D, D', T, T', S, S', SS, SS'$
375 (where $X'$ means cramped variant of the style). This primitive does
376 not use `\mathchoice` but it simply ignores the fraction syntax, so
377 `$a\mysymbol b\over c$` cannot work if `\mysymbol` is defined using the `\mathstyle`
378 primitive. See section 7.3.1 of Lua\TeX/ documentation for more information.
379
380
381 \secc[frac] Fractions
382
383 The \iid fraction can be constructed by `{<numerator>`\x`\over``<denominator>}`. If the
384 fraction is only a single object in the whole math mode (between dollars),
385 you need not use the outer braces, so you can write `$1\over2$` to get $1\over2$.
386
387 The \ii numerator,denominator <numerator> and <denominator> are printed in \"smaller" math style than
388 current math style. More exactly the following schema is used.
389 $D$: $T\over T$., $T$: $S\over S$, $S$: $SS\over SS$, $SS$: $SS\over SS$.
390 For example
391 $$
392 `{a+b \over c}` \quad \hbox{is printed as }
393 {a+b\over c} \hbox{ in $D$ style and as }
394 \textstyle {a+b\over c} \hbox{ in $T$ style}.
395 $$
396
397 The \LaTeX/ macro \x`\frac``{<numerator>}{<denominator>}` is not supported in
398 Plain \TeX/ nor in \OpTeX/ but you can define such macro if you want.
399
400 The syntax with \x`\over` is more preferred because it is more human-readable
401 notation. You can write the fraction in the same manner as you can read it.
402 You can compare: `$1\over2$` (one over two) with `$\frac12$` (frac twelve).
403
404 Besides the `\over` primitive, there are analogical \TeX/ primitives which
405 create \"generalized" fractions. The result is similar to `{<above>\over <below>}`
406 but there is something extra:
407
408 \begitems
409 * `{<above>`\x`\atop``<below>}` does `{<above>\over<below>}` but
410 without the fractional rule.
411 * `{<above>`\x`\above``<dimen><below>}` creates fractional rule with <dimen> thickness.
412 * `{<above>`\x`\overwithdelims``<delim-l><delim-r><below>}` adds the <delim-l> left to
413 the fraction and the <delim-r> right to the fraction.
414 * `{<above>`\x`\atopwithdelims``<delim-l><delim-r><below>}` is analogical to
415 `\overwithdelims` but without fractional rule.
416 * `{<above>`\x`\abovewithdelims``<delim-l><delim-r><dimen><below>}` behaves as
417 `\overwithdelims` but the fractional rule has <dimen> thickness.
418 \enditems
419 %
420 The `\...withdelims` variants read <delim-l> and <delim-r>, they must be
421 declared as {\em math delimiter} in \TeX. They are vertically scalable
422 math objects, typically brackets. See section~\ref[delims] for more
423 information about math delimiters. Example:
424 $$
425 `{n \atopwithdelims() k}`\quad \hbox{ creates }
426 {n \choose k} \hbox{ in $D$ style and }
427 \textstyle {n \choose k} \hbox{ in $T$ style}.
428 $$
429 The \x`\choose` macro is defined by `\def\choose{\atopwithdelims()}`, so the
430 user can write `{n\choose k}` in order to get binomial coefficients.
431
432
433 \secc[delims] Vertically scalable objects: math delimiters
434
435 The vertically scalable objects are called \ii delimiters {\em delimiters}. For example,
436 all types of brackets are declared as delimiters.
437 This means that you can use a bracket in arbitrary
438 vertical size.\fnote{
439 This is not exactly true, because traditional typography says that they
440 cannot be scaled continuously but by visible steps. This means that there is
441 a sequence of increasing brackets in the font, the reader must see a difference
442 between every two sizes of brackets.}
443
444 The following objects are declared as delimiters (i.e.\ vertically scalable):
445
446 \bigskip
447 {\tt \adef!{\bslash}
448 \table{l 14c}{
449 \rm source: & ( & ) & [ & ] & \code{\\\{} & \code{\\\}} & /
450 & !backslash & !langle & !rangle
451 & | & \code{\\|} & \cr
452 \rm output: &$($&$)$&$[$&$]$& $\{$ & $\}$ & $/$
453 & $\backslash$ & $\langle$ & $\rangle$
454 & $|$ & $\|$
455 }
456 \medskip
457 \table{l 14c}{
458 \rm source: & !lfloor & !rfloor & !lceil & !rceil \cr
459 \rm output: & $\lfloor$ & $\rfloor$ & $\lceil$ & $\rceil$
460 }
461 \medskip
462 \table{l 14c}{
463 \rm source: & !uparrow & !Uparrow & !dowarrow & !Downarrow
464 & !updownarrow & !Updownarrow \cr
465 \rm output: & $\uparrow$ & $\Uparrow$ & $\downarrow$ & $\Downarrow$
466 & $\updownarrow$ & $\Updownarrow$
467 }}
468 \bigskip
469 \noindent \new Unicode
470 If you can produce the characters $\langle$, $\rangle$,\fnote
471 {Do not confuse $\string<, >$ and $\langle, \rangle$. The first pair are Rel atoms
472 with meaning \"less than" or \"greater than", but the second pair are special
473 types of brackets. They are not directly available at computer keyboards without
474 using a keyboard macro.}
475 $\lfloor$, $\rfloor$, ... $\updownarrow$, $\Updownarrow$
476 directly in your text editor then you can use these Unicode characters in your source instead of control
477 sequences `\langle`, `\rangle`, `\lfloor`, `\rfloor` ... `\updownarrow`, `\Updownarrow`.
478 For many users (including me), there is more simple to type `\lfloor` than to find
479 how to create the $\lfloor$ character in my text editor. Note that there exist
480 text editors (Emacs, for example)
481 enabling you to type `\lfloor` and this control sequence is immediately
482 converted to the $\lfloor$ Unicode character.
483 Your source text looks pretty and you can use classical \TeX/ sequences.
484
485 \new Unicode
486 There are more \ii delimiters delimiters, but it heavily depends on loaded Unicode Math
487 font. For example, this document is printed in `latinmodern-math` font and
488 there are six more delimiters `\lBrack`~$\lBrack$, `\rBrack`~$\rBrack$,
489 `\lAngle` $\lAngle$, `\rAngle` $\rAngle$, `\lgroup` $\lgroup$, `\rgroup` $\rgroup$.
490 See section~\ref[objects] for table of all Unicode symbols for math typesetting.
491
492 Arbitrary tall formula can be surrounded by a pair of delimiters using
493 \x`\left` and \x`\right` \TeX/ primitives: `\left<delim> <formula> \right<delim>`.
494 The delimiters are scaled to the height and depth of the <formula>
495 and vertically centered to the {\em math axis}.\fnote
496 {Math axis is a horizontal line passing through the center of symbols $+$
497 and $-$. All vertically scalable objects are vertically centered with
498 respect to this axis.}
499 Example:
500 $$
501 `+ \left\{ \sum_{i=1}^\infty x_i \right)` \quad \hbox{ gives }
502 + \left\{ \sum_{i=1}^\infty x_i \right).
503 $$
504 The pair `\left<delim> <formula> \right<delim>` creates the formula in a
505 \TeX/ group. Such group can be nested with another groups.
506 Each `\left` must have its `\right` counterpart at the same group level.
507 If you don't want to create visible delimiter, use dot instead <delim>.
508 Example:
509 $$
510 `\left. \int``_0^t e^{x^2}\,dx\, \right|_{t=42}` \quad \hbox{ gives }
511 \left. \int_0^t e^{x^2} \,dx\, \right|_{t=42}
512 $$
513
514 \new e\TeX/
515 You can use \x`\middle``<delim>` inside the <formula> which is surrounded by
516 `\left...\right`. Then the given <delim> is scaled to the same size like
517 their `\left` and `\right` counterparts.
518
519 When a delimiter is used without `\left` nor `\right` prefix, then it is the
520 Open, Close, Ord or Bin atom by its natural meaning:
521 $(, [, \{, \ldots, \lfloor, \lceil$ are Open atoms,
522 $], ], \}, \ldots, \rfloor, \rceil$ are Close atoms,
523 $/, \backslash, |, \|$ are Ord atoms and
524 $\uparrow, \Uparrow, \ldots, \Updownarrow$ are Bin atoms. You can overwrite
525 this default setting, for example `\mathclose(`. If delimiters are used with
526 `\left` and `\right` prefixes then `\left<delim>` behaves like Open atom,
527 `\right<delim>` behaves like Close atom and the math list
528 `\left<delim><formula>\right<delim>` is encapsulated as a single Inner atom.
529 The `\middle<delim>` behaves like Open atom at its left side and like Close
530 atom at its right side.
531
532 The sequence of increasing delimiters can be printed by the following
533 macros:
534 $$
535 (\quad \x`\big``(`\quad \x`\bbig``(`\fnotemark1\quad \x`\Big``(`\quad
536 \x`\bBig``(`\fnotemark1\quad \x`\bigg``(`\quad \x`\Bigg``(` \quad \to \quad
537 ( \big( \bbig( \Big( \bBig( \bigg( \Bigg(
538 \fnotetext{Provided only in \OpTeX/.}
539 $$
540 The `\Bigg<delim>` is not the maximal size of the bracket. Try
541 `\left(\vbox to5cm{}\right.`, for example. You can see that the font
542 \"cheats" from certain sizes, because there are not all infinity number of
543 sizes of brackets drawn in the font, of course.
544
545 The `\big<delim>` creates Ord atom. We need to create Open atom
546 for opening bracket and Close atom for closing bracket more often.
547 Then we can use macros
548 \x`\bigl``<delim>`,
549 \x`\bbigl``<delim>`,
550 \x`\Bigl``<delim>`,
551 \x`\bBigl``<delim>`,
552 \x`\biggl``<delim>`,
553 \x`\Biggl``<delim>` \ for creating Open atoms and
554 \x`\bigr``<delim>`,
555 \x`\bbigr``<delim>`,
556 \x`\Bigr``<delim>`,
557 \x`\bBigr``<delim>`,
558 \x`\biggr``<delim>`,
559 \x`\Biggr``<delim>` for creating Close atoms. Unfortunately, the source is not
560 too attractive when more sizes of brackets are used, but typographic
561 traditions say that we have to distinguish brackets by the size in math
562 mode if they are in equal types:
563 $$
564 `\bbigl( f\bigl( 2(x+y) + z\bigr) \bbigr)'` \quad \hbox{gives }
565 \bbigl(f\bigl(2(x+y)+z\bigr)\bbigr)'.
566 $$
567 The `math.opm` package from \OpTeX/ provides doing this more comfortable.
568
569
570 \secc Horizontally scalable objects: math accents
571
572 Arbitrary wide formula can be covered by \ii math/accent,accent {\em scalable math accent}.
573 Example:
574 $$
575 \x`\overrightarrow`` {a+b+c+d+e+f}` \quad \hbox{gives } \overrightarrow {a+b+c+d+e+f}.
576 $$
577 The usage is: control sequence of selected math accent followed by `{<math list>}`.
578
579 Standard scalable math accents are:
580 \x`\overline` $\overline{abc}$,
581 \x`\overbrace` $\overbrace{abc}$,
582 \x`\overrightarrow` $\overrightarrow{abc}$,
583 \x`\overleftarrow`~$\overleftarrow{abc}$,
584 \x`\underline` $\underline{abc}$,
585 \x`\underbrace` $\underbrace{abc}$.
586
587 An Op atom is created. The exponents and subscripts are centered above
588 and below the nucleus of this atom (regardless of the current style). Example:
589 $$
590 `\overbrace {b\cdot b\cdot b \cdots b}^{k\times}` \quad \hbox{gives }
591 \overbrace {b\cdot b\cdot b \cdots b}^{k\times}
592 $$
593 There are scalable accents with a limited maximum width:
594 \x`\widehat` $\widehat{abc}$ and \x`\widetilde` $\widetilde{abc}$. If the
595 formula is wider than the font can cover then the widest variant from the
596 font is used and it is horizontally centered.
597
598 \new Unicode
599 There are more scalable accents in Unicode math fonts:
600 \x`\overparen` $\overparen{abc}$, \x`\underparen` $\underparen{abc}$,
601 \x`\overbracket` $\overbracket{abc}$, \x`\underbracket` $\underbracket{abc}$,
602 \x`\overleftrightarrow` $\overleftrightarrow{abc}$,
603 \x`\overleftharpoon` $\overleftharpoon{abc}$,
604 \x`\overrightharpoon` $\overrightharpoon{abc}$,
605 \x`\wideoverbar` $\wideoverbar{abc}$,
606 \x`\widebreve` $\widebreve{abc}$,
607 \x`\widecheck` $\widecheck{abc}$,\nl
608 \x`\wideutilde` $\wideutilde{abc}$,
609 \x`\mathunderbar` $\mathunderbar{abc}$,
610 \x`\underleftrightarrow` $\underleftrightarrow{abc}$,
611 \x`\widebridgeabove` $\widebridgeabove{abc}$,\nl
612 \x`\underrightharpoondown` $\underrightharpoondown{abc}$,
613 \x`\underleftharpoondown` $\underleftharpoondown{abc}$,
614 \x`\underleftarrow` $\underleftarrow{abc}$,\nl
615 \x`\underrightarrow` $\underrightarrow{abc}$.
616
617
618 \secc Fixed math accents
619
620 Fixed \ii math/accent,accent math accents can be applied to single math object or to the `{<math list>}`.
621 The accent is centered (with respect of slanting axis) and the result is a
622 nucleus of Ord
623 atom. For example `\dot x` gives $\dot x$. The list of fixed math accents
624 follows: \x`\acute`` x` $\acute x$, \x`\bar`` x` $\bar x$,
625 \x`\breve`` x` $\breve x$, \x`\check`` x` $\check x$,
626 \x`\dot`` x` $\dot x$, \x`\ddot`` x` $\ddot x$,
627 \x`\grave`` x` $\grave x$, \x`\hat`` x` $\hat x$,
628 \x`\vec`` x` $\vec x$, \x`\tilde`` x` $\tilde x$.
629
630 \new Unicode
631 The additional fixed accents depends on used Unicode math font. The
632 `latinmodern-math` supports:
633 \x`\ovhook`` x` $\ovhook x$, \x`\ocirc`` x` $\ocirc x$,
634 \x`\leftharpoonaccent`` x` $\leftharpoonaccent x$, \x`\rightharpoonaccent`` x` $\rightharpoonaccent x$,
635 \x`\dddot`` x` $\dddot x$, \x`\ddddot`` x` $\ddddot x$,
636 \x`\widebridgeabove`` x` $\widebridgeabove x$, \x`\asteraccent`` x` $\asteraccent x$.
637
638 There exist one special math accent `'` (single quote, ASCII 39)
639 which can be appended after a symbol like this: `f'`
640 and it creates $f'$ (typical meaning is the
641 derivation of the given function). You can put more such accents, for
642 example `g'''` gives $g'''$.
643
644 \secc Roots
645
646 There is a macro \x`\sqrt``{<math list>}` to create \ii square/root square root. For example:
647 $$
648 `\sqrt{\sqrt{\sqrt{x+1}+1}+1}` \quad \hbox{gives }
649 \sqrt{\sqrt{\sqrt{x+1}+1}+1}
650 $$
651 The \ii root $n$-th root is created by the macro \x`\root`` <n>\of{<math list>}`. For
652 example `\root k+1\of x` gives $\root k+1\of x$.
653
654 \secc Math alphabets
655
656 Letters \ii math/alphabet $a\dots z$, $A\dots Z$ and $\alpha$\dots$\omega$ are printed in italic
657 in math mode. This follows the traditional typographic rule.
658 All other math symbols, digits, and uppercase Greek letters must be
659 upright.\fnote
660 {French typographic convention says that uppercase Greek letters have to be
661 in italic too. Use `\_itGreek` declaration in this case.}
662 These rules are independent of the current variant of surrounding text font.
663
664 If we want to use the letters or digits
665 in another than this default shape, then we can use
666 \ii math/alphabet/selector {\em math alphabet selectors}:
667 \x`\mit`, \x`\rm`, \x`\it`, \x`\bf`, \x`\cal`.
668 \new \OpTeX/
669 \OpTeX/ supports more such selectors \x`\script`, \x`\frak`, \x`\bbchar`, \x`\bi`, see
670 \optexdoc[1.3.3]{section 1.3.3} in the \OpTeX/ documentation.
671 The math selectors have local validity in the group.
672
673 The control sequences \x`\rm`, \x`\it`, \x`\bf`, and \x`\bi` act as variant selectors
674 of fonts in non-math mode (text mode) and they act
675 as math alphabet selectors in math mode. This \"overlaying" concept
676 is given by Plain \TeX/. Example: math operators lim, sin, cos,
677 log, etc.\ must be printed unslanted. We are using `\lim`, `\sin`, `\cos`,
678 `\log` etc.\ in math mode in order to comply with this typographic convention. For
679 example `\sin` is defined as:
680 \begtt
681 \def\sin {\mathop{\rm sin}\nolimits}
682 \endtt
683 The `\rm` is used here as math alphabet selector, no variant selector of
684 text fonts.
685
686 The list of all predefined `\rm`-like math operators follows: \x`\arccos`,
687 \x`\arcsin`, \x`\arctan`, \x`\arg`, \x`\cos`, \x`\cosh`, \x`\cot`, \x`\coth`, \x`\deg`.
688 \x`\det`, \x`\dim`, \x`\exp`, \x`\gcd`, \x`\hom`, \x`\inf`, \x`\ker`, \x`\lg`, \x`\lim`,
689 \x`\liminf`, \x`\limsup`, \x`\ln`, \x`\log`, \x`\max`, \x`\min`, \x`\Pr`, \x`\scs`, \x`\sin`,
690 \x`\sinh`, \x`\sup`, \x`\tan`, \x`\tanh`, You can define another such operator
691 analogically.
692
693 \new Unicode
694 Unicode font can include the following math alphabets:
695 \begtt \typosize[9/11]
696 \_rmvariables % upright letters A-Z, a-z
697 \_bfvariables % bold letters A-Z, a-z
698 \_itvariables % italic letters A-Z, a-z
699 \_bivariables % bold italic letters A-Z, a-z
700 \_calvariables % calligraphic letters A-Z, a-z
701 \_bcalvariables % calligraphic letters A-Z, a-z
702 \_frakvariables % fraktur A-Z, a-z
703 \_bfrakvariables % bold fraktur A-Z, a-z
704 \_sansvaraibales % sans serif letters A-Z, a-z
705 \_bsansvaraibales % bold sans serif letters A-Z, a-z
706 \_isansvaraibales % slanted sans serif letters A-Z, a-z
707 \_bisansvaraibales % bold slanted sans serif letters A-Z, a-z
708 \_ttvariables % monospace, typewriter letters A-Z, a-z
709 \_bbvariables % double struck A-Z, a-z
710 \_rmdigits % upright digits 0..9
711 \_bfdigits % bold digits 0..9
712 \_sansdigits % sans serif digits 0..9
713 \_bsansdigits % bold sans serif digits 0..9
714 \_ttdigits % monospace typewriter digits 0..9
715 \_bbdigits % double-struck digits 0..9
716 \_rmgreek % upright Greek letters \alpha-\omega
717 \_itgreek % slanted Greek letters \alpha-\omega
718 \_bfgreek % bold Greek letters \alpha-\omega
719 \_bigreek % bold italic Greek letters \alpha-\omega
720 \_bsansgreek % bold sans serif Greek letters \alpha-\omega
721 \_bisansgreek % bold slanted snas serif Greek letters \alpha-\omega
722 \_itGreek % slanted Greek letters \Alpha-\Omega
723 \_bfGreek % bold Greek letters \Alpha-\Omega
724 \_biGreek % bold italic Greek letters \Alpha-\Omega
725 \_bsansGreek % bold sans serif Greek letters \Alpha-\Omega
726 \_bisansGreek % bold slanted snas serif Greek letters \Alpha-\Omega
727 \endtt
728 %
729 Not all Unicode math fonts include all math alphabets listed here. Typically,
730 the lowercase letters of calligraphic shape and all letters of
731 bold calligraphic shape are missing.
732
733 \new \OpTeX/
734 \OpTeX/ defines internal math alphabet selectors as mentioned in the
735 previous listing of math alphabets and sets as default:
736 \begtt \typosize[10/12]
737 \_itvariables \_rmdigits \_itgreek \_rmGreek
738 \endtt
739 %
740 Moreover, it defines the alphabet selectors at user level (see section 1.3.3
741 of the \OpTeX/ manual). For example
742 \begtt \typosize[10/12]
743 \_def\_marm {\_inmath{\_rmavariables \_rmdigits}} % \_marm is used in \rm
744 \endtt
745 %
746 `\_inmath` runs its parameter only in math mode and sets the math alphabets.
747 You can see the file `unimath-codes.opm` where all these selectors are
748 defined. You can redefine them. For example, \OpTeX/ defines `\bf` as a math
749 alphabet selector that selects sans serif bold in math. This is the common
750 notation for vectors, tensors, and matrices. If you dislike this (maybe
751 because plain \TeX/ has different defaults), then you can define:
752 \begtt \typosize[10/12]
753 \_def\_mabf {\_inmath{\_bfvariables\_bfdigits\_bfgreek\_bfGreek}} % used in \bf
754 \endtt
755
756
757 \secc[objects] List of single math objects
758
759 \new Unicode
760 All \ii single/math/object single math objects are listed in the `unimath-table.opm` or
761 `unicode-math-table.tex` file. You can
762 look into this file. The codes, \TeX/ sequences, classes, and comments
763 for all possible math codes are here. Maybe, your Unicode math font which is loaded
764 does not support all these codes.
765 \new \OpTeX/
766 You can try all codes of the currently loaded font by
767 \begtt
768 \input print-unimath.opm
769 \endtt
770 The `unimath-table` is printed with characters available in the loaded font.
771 \new \OpTeX/
772 If the character is unsupported by the font then the slot is empty and only
773 \TeX/ sequence and the class of the code is printed in the table.
774 For example, this document loads `latimodern-math.otf` font.
775 And the result from `\input print-unimath.opm` looks like the following ten
776 pages.
777
778 Unsupported characters can be replaced by characters from other Unicode math
779 font, see section~\ref[newfam].
780
781
782 \label[listA]\wlabel{}
783
784 \bigskip
785 \input print-unimath.opm
786 \bigskip
787
788 \label[listB]\wlabel{}
789
790 See also \ulink[https://texdoc.org/serve/unimath-symbols.pdf/0]{Unimath-symbols}
791 which summarizes these symbols by their type and shows their existence in
792 typical Unicode-math fonts.
793
794 It isn't very comfortable to find something in the table of symbols
795 if you know the shape. You can try the online web tool \ii Detexify
796 \ulink[https://detexify.kirelabs.org/classify.html]{Detexify}.
797 You can draw the symbol here and the suggestion of \TeX/ sequence is
798 printed.
799
800 \def\g#1{{\tt\string#1}~$#1$}
801
802 The generic \TeX/ sequences for the Greek letters \ii Greek/letters can be used:
803 \g\alpha, \g\beta, \g\gamma, \g\delta, \g\varepsilon, \g\zeta, \g\eta,
804 \g\theta, \g\iota, \g\kappa, \g\lambda, \g\mu, \g\nu, \g\xi,
805 \g\omicron, \g\pi, \g\rho, \g\varsigma, \g\sigma, \g\tau, \g\upsilon,
806 \g\varphi, \g\chi, \g\psi, \g\omega, \g\vardelta, \g\epsilon, \g\vartheta,
807 \g\varkappa, \g\phi, \g\varrho, \g\varpi\
808 and
809 \g\Alpha, \g\Beta, \g\Gamma, \g\Delta, \g\Epsilon, \g\Zeta, \g\Eta, \g\Theta,
810 \g\Iota, \g\Kappa, \g\Lambda, \g\Mu, \g\Nu, \g\Xi, \g\Omicron, \g\Pi, \g\Rho,
811 \g\Sigma, \g\Tau, \g\Upsilon, \g\Phi, \g\Chi, \g\Psi, \g\Omega.
812
813 \new \OpTeX/
814 The variant of Greek letters in the output
815 (upright, italic, bold, bold sans serif, etc.)
816 written by the sequences `\alpha`, `\beta` etc. depends on the math alphabet
817 selected by `\_itgreek`, `\_rmgreek`, etc. selectors. The user-level
818 selectors `\bf` and `\bi` set `\_bsansgreek` and `\_bisansgreek`, so
819 `{\bi\delta}` produces $\bi\delta$.
820
821 \new Unicode
822 All characters available in the math font can be accessed by \TeX/ control
823 sequence or by directly using the Unicode character in the document source.
824 Example:
825 \begtt \adef/{}
826 $$
827 \sum/_{k=0}^\infty e^{(\alpha+i\beta/_k)} =
828 e^\alpha \sum/_{k=0}^\infty e^{i\beta/_k} =
829 e^\alpha \sum/_{k=0}^\infty (\cos\beta/_k + i\sin\beta/_k).
830 $$
831 \endtt
832 or
833 \begtt \ttspec
834 $$
835 ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k}
836 = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k).
837 $$
838 \endtt
839 both gives the same result:
840 $$
841 ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k}
842 = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k).
843 $$
844 \medskip
845
846
847 \sec Other specialities
848
849 \secc The `\not` prefix
850
851 You can apply \x`\not` before a following math object.
852 The slash $/$ is overprinted such math object, for example
853 `$a \not= b$` gives $a \not= b$.
854
855 \new \OpTeX/
856 If there exists a direct Unicode character for the negation of a relation symbol
857 (for example `\ne` creates $\ne$ directly as a character U+2260)
858 then `\not<char>` expands to appropriate Unicode character.
859 For example `\not=` expands to `\ne` or `\not\in` expands to `\notin`.
860 If such character does not exist then
861 the centered $/$ is overprinted over the next character.
862
863
864 \secc The `\buildrel` macro: text over the relation
865
866 The macro \x`\buildrel`` <text>\over <relation>` creates a new atom Rel with the
867 <relation> and with the smaller <text> above this <relation>. Example:
868 `$M \buildrel\rm def\over= X\cup Y$` gives $M\buildrel\rm def\over= X\cup Y$.
869
870
871 \secc Spaces
872
873 Spaces between atoms are created automatically as were mentioned in
874 section~\ref[class]. But sometimes you have to help \TeX/ to create
875 appropriate space. You can use following macros:
876
877 \begitems
878 * `\,` is \ii thin/space {\em thin space} used around Op atoms, after comma, etc.: \ss\,,
879 * `\!` is \ii negative/thin/space negative thin space,
880 * `\>` is \ii medium/space {\em medium space} used around Bin atoms: \ss\>,
881 * `\;` is \ii thick/space {\em thick space} used around Rel atoms: \ss\;,
882 * \x`\quad` is \ii em/space {\em em space}: \ss\quad,
883 * \x`\qquad` is \ii double/em/space {\em double em space}: \ss\qquad.
884 \enditems
885 %
886 Of course, you can use \ii direct/space {\em direct space} {\visiblesp`\ `} which is \TeX/ primitive
887 and gives interword space: \ss\ \
888 or you can use \x`\hskip`` <value>` to put arbitrary space.
889
890 The space size of `\,`, `\!` resp. `\>`, resp. `\;` is given by
891 `\thinmuskip`, resp. `\medmuskip`, resp. `\thickmuskip` values. You can see
892 in the `plain.tex` file that these default values differ very little in their basic
893 size but there is no stretchability/shrinkability in the `\,` space, there is small
894 stretchability in the `\>` space, and more stretchability in the `\;` space.
895
896 The registers \x`\thinmuskip`, \x`\medmuskip`, and \x`\thickmuskip` store so-called
897 \ii mu/values {\em mu values} given by math unit `mu`. It is 1/18 em and this unit depends
898 on the current font size used in the math formula ($S$ or $SS$ styles use
899 smaller font size, the `mu` unit is smaller here). You can use \x`\mskip`
900 instead `\hskip` or \x`\mkern` instead `\kern` if you want to use this
901 special `mu` unit. It is allowed only in math mode.
902
903 If \x`\nonscript` precedes `\hskip`, `\mskip`, `\kern`, or `\mkern` then this
904 space is applied only in $D$ or $T$ style.
905
906 The \x`\quad` and \x`\qquad` spaces have fixed width and they can be used in text
907 mode too. (\OpTeX/ allows to use `\,` in text mode too).
908 Use `\quad` or `\qquad` if you want to separate more formulas created in
909 single math mode. Examples of typical usage of spaces:
910
911 \begtt \adef/{} \typosize[10/12]
912 $$ \alpha\,(x+y), \qquad \int/_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma/_{\!i}. $$
913 \endtt
914 $$ \alpha\,(x+y), \qquad \int_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma_{\!i}. $$
915
916
917 \secc Texts in math mode
918
919 If you write `$Hello world!$` (i.e.\ Hello world in math mode), then you get
920 $Hello world!$. It is interpreted as the product of variables $H$, and $e$, and
921 $l^2$, and $o$, etc., followed by the symbol ! used for factorial.
922 The non-ASCII letters (with accents) don't work at all because they are
923 never used as symbols for variables. Spaces are ignored.
924
925 If you want to write a short text in the math mode, then you can use
926 `\hbox{<text>}`. The \x`\hbox` primitive initializes text mode regardless of
927 the \"outer mode". Example:
928
929 \begtt \adef/{} \typosize[10/12]
930 $$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$
931 \endtt
932 $$ \sum_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$
933 %
934 Note the space before the word \"converges". The space before `\hbox` is
935 irrelevant. Second notice: the example shows the text mode inside math mode
936 and the in-line math mode inside this text mode. The same result can be
937 produced by:
938
939 \begtt \adef/{} \typosize[10/12]
940 $$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if } a_n\searrow 0. $$
941 \endtt
942 %
943 The difference can be visible if the formula $a_n\searrow 0$ includes a
944 fraction, for example ${1\over2}a_n\searrow 0$. The first example prints the
945 fraction in the text style and the second example prints it in the display style.
946
947 The disadvantage of `\hbox` is that it starts in the text mode independently
948 of the current style, but we want to use smaller font in $S$ or $SS$ styles.
949 \new \OpTeX/
950 You can use \x`\mathbox``{<text>}` in such situations. This macro behaves like
951 `\hbox` but the text is appropriately smaller in $S$ and $SS$ styles.
952 Example:
953 $$
954 `{\mathbox{cena}\over\mathbox{výkon}}` \quad \hbox{gives }
955 {\mathbox{cena}\over\mathbox{výkon}} \hbox{ in $D$ style and }
956 \textstyle {\mathbox{cena}\over\mathbox{výkon}} \hbox{ in $T$ style.}
957 $$
958 Note that $\mathbox{cena}\over\mathbox{výkon}$ means $\rm price\over performance$
959 and you can write `$\rm price\over performance$` when you are using only
960 words without spaces and accented letters. But phrases with spaces or accented letters
961 should be printed in text mode using `\hbox` or `\mathbox`.
962
963 \secc `\vcenter`
964
965 The \x`\vcenter` primitive behaves like `\vbox`, but it can be used only in
966 math mode and its result is vertically centered to the math axis.
967 For example, matrices, are created by tables in `\vcenter`.
968
969 All big objects in math formula are centered on the math axis and the baseline is
970 ignored. In the following example, we create a new big math operator by
971 `\vcenter`:
972 \begtt
973 $$
974 \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}}
975 F(x) = \myop{x(i)}_{i=1}^\infty
976 $$
977 \endtt
978 \vskip-2em
979 $$
980 \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}}
981 F(x) = \myop{x(i)}_{i=1}^\infty
982 $$
983
984
985 \secc Three dots
986
987 You can write `$1,2,\dots,n$` to get $1,2,\dots,n$. The \x`\dots` macro puts
988 thin space between dots and after the last dot, so the five object: comma,
989 dots, comma are exactly equidistant.
990
991 Typographic conventions say that you have to use the repeating symbol
992 before and after three dots (comma in the previous example) and the three dots
993 should be at baseline if the repeating symbol is at baseline. Or they should be
994 at the math axis if the repeating symbol is at the math axis. We have to use \x`\cdots` instead
995 `\dots` in the second case. Example:
996 $$
997 \addto\_ttfont{\thefontsize[9.5]}
998 `a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n` \qquad
999 a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n
1000 $$
1001 \vskip-.7em
1002 There are \x`\vdots` $\vdots$, \x`\ddots` $\ddots$ and \x`\adots` $\adots$ which
1003 can be used in matrices.
1004
1005 \new Unicode
1006 Three dots like the output of the `\dots` macro are present as a single
1007 character in fonts too. This character is called ellipsis. Font designers
1008 typically suggest this character with smaller spaces between dots than we
1009 need in math mode. So the rule about equidistant \"comma, three dots, comma"
1010 is not met when this character is used. You can try `$1,2,\unicodeellipsis, n$`
1011 and `$1+2+\unicodecdots + n$`. You get $1,2,\unicodeellipsis, n$ and
1012 $1+2+\unicodecdots + n$. If you feel that this is better, then you can set:
1013 `\let\dots=\unicodeellipsis \let\cdots=\unicodecdots`.
1014
1015 The Unicode fonts include compact variants `\unicodevdots` $\unicodevdots$,
1016 `\unicodeddots` $\unicodeddots$ and `\unicodeadots` $\unicodeadots$ too.
1017
1018
1019 \secc Phantoms and `\smash`
1020
1021 The \x`\phantom``{<math list>}` macro creates an invisible subformula equal to
1022 the formula generated by <math list>. It has its size, so it can
1023 interfere with surrounding visible subformulas. This macro is very useful for
1024 aligning with special requirements. Examples are shown in
1025 sections~\ref[matrix] and~\ref[elines].
1026
1027 The \x`\vphantom``{<math list>}` has only its vertical size (i.e.\ its height
1028 and depth), the width is zero. The \x`\hphantom``{<math list>}` has only its
1029 width.
1030
1031 The \x`\smash``{<math list>}` is the opposite of `\vphantom`. It creates visible
1032 subformula but it has only its width. Its height and depth are zero.
1033
1034 The result of these macros is the nucleus of an Ord atom. You can use `\mathop`,
1035 `\mathbin`, etc. primitives to change this class. For example
1036 `$a\mathrel{\phantom{=}}b$` creates the same formula as $a=b$ with the same
1037 distance from $a$ to $b$ but without the equal sign:
1038 $a\mathrel{\phantom{=}}b$.
1039
1040 These macros work in the text mode too. Then their argument is
1041 the <horizontal list>.
1042
1043
1044 \sec Structured objects
1045
1046 \secc[matrix] Matrices
1047
1048 The macro \x`\matrix``{<data>}` creates a vertically centered table of items.
1049 The <data> includes <items> separated by `&` and rows are separated by
1050 `\cr`. The number of columns and rows are unlimited. Columns are printed centered
1051 and separated by the `\quad` space. The vertically scalable
1052 brackets around the table are not printed. You can use \x`\pmatrix``{<data>}`
1053 instead `\matrix{<data>}`: the vertically scalable parentheses () are inserted
1054 around the table. Examples:
1055
1056 \begtt
1057 $$
1058 {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr
1059 a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr
1060 \vdots & \vdots & \ddots & \vdots \cr
1061 a_{m,1} & a_{m,2} & \cdots & a_{m,n} },
1062 $$
1063 \endtt
1064 $$
1065 {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr
1066 a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr
1067 \vdots & \vdots & \ddots & \vdots \cr
1068 a_{m,1} & a_{m,2} & \cdots & a_{m,n} },
1069 $$
1070 or:
1071
1072 \begtt
1073 \def\qmatrix[#1]{\left[\matrix{#1}\right]}
1074 $$
1075 \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3]
1076 = \qmatrix[b_1\cr b_2\cr b_3].
1077 $$
1078 \endtt
1079 $$
1080 \def\qmatrix[#1]{\left[\matrix{#1}\right]}
1081 \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3]
1082 = \qmatrix[b_1\cr b_2\cr b_3].
1083 $$
1084
1085 If you need to align the columns by another way than to center, then you can
1086 use the phantom. Compare:
1087
1088 \begtt
1089 $$
1090 \pmatrix{ 1 & -1 & 0 \cr
1091 0 & 2 & 13 \cr
1092 -3 & 0 & 5 } \quad \hbox{or} \quad
1093 \def\0{\phantom0} \def\+{\phantom+}
1094 \pmatrix { \+1 & -1 & \00 \cr
1095 \+0 & \+2 & 13 \cr
1096 -3 & \+0 & \05 }
1097 $$
1098 \endtt
1099 $$
1100 \pmatrix{ 1 & -1 & 0 \cr
1101 0 & 2 & 13 \cr
1102 -3 & 0 & 5 } \quad \hbox{or} \quad
1103 \def\0{\phantom0} \def\+{\phantom+}
1104 \pmatrix { \+1 & -1 & \00 \cr
1105 \+0 & \+2 & 13 \cr
1106 -3 & \+0 & \05 }
1107 $$
1108
1109 \new\OpTeX/
1110 Another option to set the right aligned matrix is setting the \x`\lmfil`:
1111 Its value is used on the left side in each `\matrix` item. The right side is
1112 set directly to `\hfil`.
1113 \begtt
1114 $$
1115 \lmfil={\hfill} % left matrix filler = \hfill
1116 \pmatrix{ 1 & -1 & 0 \cr 0 & 2 & 13 \cr -3 & 0 & 5 }
1117 $$
1118 \endtt
1119
1120 \new \OpTeX/
1121 If you want to draw a vertical line inside the matrix, you can use `\adef|`
1122 as in the following example:
1123 \begtt
1124 $$
1125 \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
1126 \def\+{\phantom+}
1127 \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim
1128 \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim
1129 \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 }
1130 $$
1131 \endtt
1132 $$
1133 \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
1134 \def\+{\phantom+}
1135 \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim
1136 \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim
1137 \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 }
1138 $$
1139
1140 If you want to put something before the opening bracket in the matrix, you can
1141 use another `\matrix`. Example:
1142
1143 \begtt
1144 $$
1145 \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
1146 \def\+{\phantom+}
1147 \def\r{{\bf r}}
1148 \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \
1149 \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: }
1150 \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2}
1151 $$
1152 \endtt
1153 $$
1154 \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
1155 \def\+{\phantom+}
1156 \def\r{{\bf r}}
1157 \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \
1158 \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: }
1159 \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2}
1160 $$
1161
1162 Plain \TeX/ defines the \x`\bordermatrix` macro which allows you to create a
1163 top row above the brackets and left column before the opening bracket.
1164 \TeX/book shows the following example:
1165
1166 \begtt
1167 $$
1168 M = \bordermatrix{ &C&I&C'\cr
1169 C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a }
1170 $$
1171 \endtt
1172 $$
1173 M = \bordermatrix{ &C&I&C'\cr
1174 C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a }
1175 $$
1176
1177 The `\matrix` macro used in $D$ style creates all its items in $T$ style.
1178 \new \OpTeX/
1179 If you are using the `\matrix` macro in $T$ style or $S$ style (but not in
1180 fractions nor another matrices) then the resulting table is appropriately
1181 smaller and all its items are processed in $S$ style.
1182 If you are using `\matrix` in $SS$ style then the items are in $SS$ style too.
1183 The following example shows one-column matrix in script style:
1184 $$
1185 `\sum``_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k}` \ \hbox{ creates: }
1186 \sum_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k}
1187 $$
1188
1189
1190 \secc Cases
1191
1192 The \x`\cases` macro can be used as in the following example:
1193
1194 \begtt
1195 $$
1196 f(x) = \cases{ 1 & for $x\le 0$, \cr
1197 100-x\over 100 & when $0 < x \le 100$, \cr
1198 0 & in other cases. }
1199 $$
1200 \endtt
1201 $$
1202 f(x) = \cases{ 1 & for $x\le 0$, \cr
1203 100-x\over 100 & when $0\string< x\le 100$, \cr
1204 0 & in other cases. }
1205 $$
1206
1207 The `\cases` macro behaves like a special `\matrix` with two left-aligned
1208 columns and with left vertically scaled brace $\{$.
1209 The first column is processed in math mode and $T$ style, the second column
1210 is processed in text mode. We have to use `$...$` in the second column if
1211 there is math material.
1212
1213
1214 \sec Lines in display mode
1215
1216 \secc General principles
1217
1218 The \ii display/math,display/math/mode
1219 `$$<formula>$$` finalizes previous paragraph, prints centered <formula> on
1220 single line with a vertical space above and below and opens next paragraph
1221 with no indentation.
1222
1223 From \TeX/'s point of view, the text above `$$<formula>$$` plus text
1224 below is a single paragraph interrupted by display <formula>. If there is no
1225 text above (i.e. the opening `$$` are in vertical mode), then the internal
1226 `\noindent` is processed first and the empty line above <formula> is created.
1227 Thus, it is definitely a bad idea to open display mode in vertical mode: never
1228 put an empty line before `$$<formula>$$`. On the other hand, the empty line
1229 just after `$$<formula>$$` says that the paragraph is finalized by the
1230 <formula> and the next text (after the empty line) opens the next paragraph with
1231 indentation. Summary:
1232
1233 \begitems
1234 * \"Text above `$$<formula>$$` text below": the <formula> interrupts the
1235 paragraph with \"Text above" and \"text below". The \"text below" is
1236 without indentation.
1237 * \"Text above `$$<formula>$$` empty line Text below": the \"Text below"
1238 opens new paragraph with indentation.
1239 * \"Empty line `$$<formula>$$`" is bad practice.
1240 \enditems
1241
1242 In contrast with the paragraph breaking, there is no built-in algorithm for
1243 breaking display <formula> to more lines. If the <formula> is too wide then
1244 overfull `\hbox` occurs and human must decide about splitting the <formula>
1245 to more lines. The macros `\displaylines` and `\eqalign` are intended to
1246 such task, see sections~\ref[dlines] and~\ref[elines].
1247
1248 On the other hand, the in-line math <formula>, i.e.\ the `$<formula>$` in a
1249 paragraph, can be broken after a Bin atom (with penalty `\binoppenalty`) or
1250 after a Rel atom (with penalty `\relpenalty`). If you don't want to break
1251 such a formula at a specific place then use `\nobreak`, for example
1252 `$a+\nobreak b$`. If you want never to break such formulas then you can set
1253 `\binoppenalty=10000`, `\relpenalty=10000`. (Default values are 700 and 500.)
1254
1255
1256 \secc References to display lines
1257
1258 The `$$<formula>`\x`\eqno``<mark>$$` \ii mark prints centered <formula> and the <mark> at
1259 right margin. The `$$<formula>`\x`\leqno``<mark>$$` prints centered <formula> and
1260 the <mark> at left margin. Examples:
1261
1262 \begtt
1263 $$ a^2 + b^2 = c^2 \eqno (1) $$
1264 \endtt
1265 $$
1266 a^2 + b^2 = c^2 \eqno (1)
1267 $$
1268 \begtt \aftergroup\nobreak
1269 $$ a^2 + b^2 = c^2 \leqno \rm Py $$
1270 \endtt
1271 $$\predisplaypenalty=10000
1272 a^2 + b^2 = c^2 \leqno \rm Py
1273 $$
1274 The <mark> \ii mark is processed in math mode and $T$ style. If you want to put a
1275 text here then you have to use `\rm <text>` or `\hbox{<text>}`.
1276
1277 \new \OpTeX/
1278 The auto-generated <mark> can be created by `$$<formula>`\x`\eqmark``$$`. The
1279 <label> can be used previously declared by \x`\label``[<label>]`.
1280 Then it is associated to such
1281 auto-generated <mark> and you can write a reference in the form
1282 `see equation~\ref[<label>]`. You can write `\eqmark[<label>]` instead of
1283 `\label[<label>]...\eqmark`. See the \OpTeX/ manual, section~1.4.3.
1284
1285 \secc[dlines] The `\displaylines` macro
1286
1287 This macro creates more horizontally centered formulas in one display mode.
1288 The syntax is
1289 \begtt \catcode`\<=13
1290 $$ \displaylines{
1291 <formula> \cr
1292 <formula> \cr
1293 ... \cr
1294 <formula>
1295 } $$
1296 \endtt
1297 Usage of \x`\displaylines` is more
1298 preferred than doing more display modes just behind each other.
1299 Example:
1300 \begtt
1301 $$ \displaylines{
1302 (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
1303 = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
1304 } $$
1305 \endtt
1306 $$ \displaylines{
1307 (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
1308 = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
1309 } $$
1310
1311 The output from `\displaylines` macro is breakable to more pages because
1312 the lines are not encapsulated in one box. The macro uses a special feature of
1313 `\halign` primitive. The disadvantage is that you cannot use `\eqno` nor
1314 `\leqno` nor `\eqmark`.
1315
1316 \new \OpTeX/
1317 \OpTeX/ provides alternative form: `\displaylines to<dimen> {<data>}`.
1318 Then the centered formulas are encapsulated in a `\vcenter` box of width <dimen> and
1319 usage of `\eqno` or `\leqno` or `\eqmark` is allowed.
1320 The individual lines have the form `\hbox to<dimen>` and formulas are centered using
1321 `\hss` from both sides. This means that you can set arbitrary <dimen>
1322 without visual change of the formulas. Use smaller <dimen> value than
1323 `\hsize` (or `\displaywidth`\fnote
1324 {`\displaywith` = `\hsize` in most cases but it is
1325 real display width when `\parshape` or `\hangindent` is used.})
1326 if you want to center formulas with `\eqno` appended.
1327 The internal \TeX/ rule says: the formula with `\eqno` (or `\leqno`) is centered
1328 if its width is less or equal `\displaywidth-4<mark-width>`. So
1329 \begtt \catcode`\<=13
1330 $$ \displaylines to\hsize-8em {<formula>\cr<formula>}\eqno (1) $$
1331 \endtt
1332 does global centering, because size of `(1)` is less than 2\,em.
1333 You can do more experiments with this example,
1334 for example `\diplaylines to\hsize{...}`
1335 puts the `\eqno` mark to the next line in the display environment. Read
1336 \TeX/book or \TeX/book naruby, where the precise explanation about such
1337 positioning is.
1338
1339 \new \OpTeX/
1340 You can use \"`\displaylines to<dimen>`" for more applications. For example,
1341 you can put more
1342 \"`\displaylines to<dimen>`" in single display mode, one next to second in order
1343 to creating more centered columns with formulas; the width of such columns
1344 are controlled by the <dimen> parameter.
1345 Or, you can give an exception for several lines:
1346
1347 \begtt \catcode`\<=13
1348 $$\displaylines to 10cm {<formula>\hfill \cr
1349 <formula>\cr
1350 <formula>\cr
1351 \hfill <formula>}
1352 $$
1353 \endtt
1354 The example above gives similar result as the \LaTeX/ `multline` environment:
1355 $$\displaylines to \hsize {
1356 (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \hfill \cr
1357 = 3x^9 + 3x^5 + 15x^3 + 4x^8 + 4x^4 + 20x^2 + 5x^7 + 5x^3 + 25x
1358 + 6x^6 + 6x^2 + 30 = \cr
1359 \hfill = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. }
1360 $$
1361
1362
1363 \secc[elines] The `\eqalign` macro
1364
1365 The \ii .eqalign \iis .eqalign {{\code{\\eqalign}}} usage is:
1366 \begtt \catcode`\<=13
1367 $$ \eqalign { <left-side> & <right-side> \cr
1368 <left-side> & <right-side> \cr
1369 ... \cr
1370 <left-side> & <right-side>
1371 } $$
1372 \endtt
1373 The `\vcenter` box is created with two columns, left column is right aligned
1374 and right column is left aligned. Example:
1375
1376 \vbox{
1377 \begtt
1378 $$ \eqalign{
1379 x + 2y + 3z &= 600 \cr
1380 12x + y - 3z &= 7 \cr
1381 4x - y + 5z &= -5 \cr
1382 } $$
1383 \endtt
1384 \vskip-5.7\baselineskip
1385 {\hsize=1.35\hsize
1386 $$ \eqalign{
1387 x + 2y + 3z &= 600 \cr
1388 12x + y - 3z &= 7 \cr
1389 4x - y + 5z &= -5 \cr
1390 } $$}}
1391
1392 \bigskip\noindent
1393 The tab \"`&`" should be used just before a relation, i.e. `&=` is right, `=&`
1394 is wrong. All lines are aligned to the used tab.
1395
1396 Maybe you want more precise alignment in the example above. You can use
1397 `\phantom`:
1398
1399 \par\nobreak\vbox{
1400 \begtt
1401 $$ \def\1{\phantom1} \def\+{\phantom+}
1402 \eqalign{
1403 x + 2y + 3z &= 600 \cr
1404 12x + \1y - 3z &= \+7 \cr
1405 4x - \1y + 5z &= -5 \cr
1406 } $$
1407 \endtt
1408 \vskip-5.7\baselineskip
1409 {\hsize=1.35\hsize
1410 $$ \def\1{\phantom1} \def\+{\phantom+}
1411 \eqalign{
1412 x + 2y + 3z &= 600 \cr
1413 12x + \1y - 3z &= \+7 \cr
1414 4x - \1y + 5z &= -5
1415 } $$}}
1416 \bigskip
1417 Another typical usage of the `\eqalign` macro:
1418
1419 \begtt \typosize[10/12]
1420 $$ \eqalign{
1421 p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
1422 &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
1423 } $$
1424 \endtt
1425 $$ \eqalign{
1426 p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
1427 &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
1428 } $$
1429
1430 In \OpTeX/, \new\OpTeX/
1431 the `\eqalign` macro is more flexible. You can set the
1432 `\baselineskip` value by the \x`\eqlines` parameter and math style
1433 by the \x`\eqstyle` parameter.
1434 For example, you need to put the system of \"equations" as a subscript of a sum
1435 operator:
1436 \begtt \typosize[10/12] \adef/{}
1437 $$
1438 \sum/_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{
1439 i &\in A \cr
1440 j &\in B\cup C \cr
1441 m &\in C }}
1442 i + j + m
1443 $$
1444 \endtt
1445 $$
1446 \sum_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{
1447 i &\in A \cr
1448 j &\in B\cup C \cr
1449 m &\in C }}
1450 i + j + m
1451 $$
1452
1453 \indent \new\OpTeX/
1454 You can write more equation systems one next second:
1455 \begtt
1456 $$\eqalign{
1457 x + y + z &= 1 && a + b + c &= -1 \cr
1458 u + v &= 20 && f + g &= -20 \cr
1459 i &= j
1460 }$$
1461 \endtt
1462 You can use the third column for centered equations
1463 without aligning point. For example:
1464 \begtt \catcode`\<=13
1465 $$ \left( \eqspace=0pt \eqalign{&& <first equation>\cr
1466 && <second equation>} \right) $$
1467 \endtt
1468 The \x`\eqspace` is additional space used in the third column to separate
1469 equation systems one next second.
1470
1471 \new \OpTeX/
1472 \OpTeX/ extensions summary:
1473 \begitems
1474 * `\eqlines` and `\eqstyle` set baselineskip and math style of the formulas.
1475 * `\eqalign` allows more than two columns:
1476 The first column is right-aligned (no space). The second is left-aligned (no space).
1477 The third column (if used)
1478 is centered with `\eqspace/2` at the left and right boundary of the column.
1479 The fourth is the same as the first. The fifth is the same as second etc. The number
1480 of columns that can be used in `\eqalign` is unlimited.
1481 \enditems
1482
1483 \secc The `\eqalign` macro with references
1484
1485 You can give common mark to whole equation system by
1486 `$$\eqalign{<data>}\eqno <mark>$$`. If you want to give marks to individual
1487 lines of the equation system, then you can use another macro:
1488 \x`\eqalignno`. The usage is similar as `\eqalign` but the
1489 third column (if used) is intended to the equation mark. Example:
1490
1491 \begtt
1492 $$ \eqalignno{
1493 x + 2y + 3z &= 600 & \rm(A) \cr
1494 12x + y - 3z &= 7 & \rm(B) \cr
1495 4x - y + 5z &= -5 & \rm(C) \cr
1496 } $$
1497 \endtt
1498 \vskip-\baselineskip
1499 $$ \eqalignno{
1500 x + 2y + 3z &= 600 & \rm(A) \cr
1501 12x + y - 3z &= 7 & \rm(B) \cr
1502 4x - y + 5z &= -5 & \rm(C) \cr
1503 } $$
1504
1505 The `\leqalignno` macro is similar to `\eqalignno` but the marks are at the left
1506 margin. The \OpTeX/ extensions of `\eqalign` are not available in
1507 `\eqalignno` nor `\leqalignno` macros.
1508
1509 \new \OpTeX/
1510 You can use auto-generated marks by `\eqmark` macro:
1511 `$$\eqalign{<data>}\eqmark$$` or:
1512 \begtt
1513 $$ \eqalignno{
1514 x + 2y + 3z &= 600 & \eqmark[A] \cr
1515 12x + y - 3z &= 7 & \eqmark[B] \cr
1516 4x - y + 5z &= -5 & \eqmark[C] \cr
1517 } $$
1518 \endtt
1519
1520 More examples of alignments in display math mode (including comparison with
1521 \LaTeX/ code) are shown in the document
1522 \ulink[http://petr.olsak.net/ftp/olsak/optex/op-mathalign.pdf]{op-mathalign.pdf}.
1523
1524 \sec Concept of loading math fonts
1525
1526 \secc[fams] Math families
1527
1528 \TeX/ can use more than one math font in math mode. This was a
1529 necessity in the old days when only 128-characters fonts existed.
1530 Each math font used in math mode has its \ii math/family {\em math family} represented by a number.
1531 Math family is a collection of three (almost) equal fonts in three sizes:
1532 first for `\textstyle` and `\displaystyle`, second for `\scriptstyle`
1533 and third for `\scriptscriptstyle`.
1534
1535 \new Unicode
1536 When Unicode math font is loaded then it includes all three optical sizes and
1537 all characters needed for typesetting math formula.
1538 Theoretically, we can use only one math family with this single font. But more math families
1539 (i.e.\ more fonts in math mode) is still possible. You can combine
1540 characters from more fonts (Unicode fonts and old TFM fonts together) in one math formula.
1541
1542 \new \OpTeX/
1543 \OpTeX/ loads the main Unicode math font into math family 1. The math
1544 families 2 and 3 are reserved for specific \TeX/nical reasons, family 4 is
1545 used for `\script` font and families 5, 6, 7, etc. can be used by user for
1546 loading more fonts. The default macro for loading math fonts looks like:
1547
1548 \begtt \typosize[10/12]
1549 \_def\_normalunimath{%
1550 \_loadumathfamily 1 {\_unimathfont}{} % Main Unicode math font
1551 \_loadmathfamily 4 rsfs % \script (old TFM font)
1552 \_setunimathdimens % set dimen parameters used in math formulas internally
1553 }%
1554 \let\_normalmath=\_normalunimath % this is done when Unicode math is initialized
1555 \endtt
1556 %
1557 Whenever \OpTeX/ needs to resize math fonts (for example in footnotes or
1558 titles), it calls the `\_normalmath` macro to reload all math
1559 families to the desired size. If you want to add the next font, you can add
1560 `\_loadunimathfamily <family> {<Unicode-font>}{<features>}` or
1561 `\_loadmathfamily <family> <TFM-font>` into the `\_normalmath` macro.
1562 The example in section~\ref[newfam] shows how to do it.
1563
1564 \secc Two variants of math fonts: normal and bold
1565
1566 All math formulas in the whole document need only one Unicode font (or only one collection
1567 of math fonts as mentioned in section~\ref[fams]). But this
1568 is not really true if titles are in bold font. If a math formula is present in
1569 such a bold title then all characters of this formula must be bolder.
1570 For example \"normal" variables must be in bold italic in titles, symbols
1571 like `+` `=` must be bold and \"normal bold" letters
1572 (e.g., indicating vectors in math formula) must be extra bold in titles.
1573 It means that all fonts from the collection of math fonts must be bolder.
1574 We need a second collection of math fonts with bolder
1575 shape. Unfortunately, it is not always available.
1576
1577 \new \OpTeX/
1578 If you have bold variant of used Unicode math font, then you can use
1579 \ii .loadmath \iis .loadmath {{\code{\\loadmath}}} \x`\loadboldmath` command, for example:
1580 \begtt
1581 \loadmath {[xitsmath-regular]}
1582 \loadboldmath {[xitsmath-bold]} \to {[xitsmath-regular]}
1583 \endtt
1584 %
1585 \OpTeX/ uses `\_normalmath` macro for loading collection of math fonts in
1586 \"normal" cases and `\_boldmath` macro for bold titles. The font declared by
1587 \x`\loadboldmath` is used in second case. But if the bold variant of the font is
1588 not available (this is unfortunately more typical), then \OpTeX/ uses faked
1589 bold of main Unicode math font (the `embolden` internal font feature is
1590 used). So, the default `\_boldmath` macro defined by \OpTeX/ looks like:
1591
1592 \begtt \typosize[10/12]
1593 \_def\_boldunimath{%
1594 \_ifx\_unimathboldfont \_undefined
1595 \_loadumathfamily 1 {\_unimathfont}{embolden=1.7;} % Main faked bold
1596 \_else
1597 \_loadumathfamily 1 {\_unimathboldfont}{} % Main real bold font
1598 \_fi
1599 \_loadmathfamily 4 rsfs % rsfs in not in bold, unfortunately
1600 \_setunimathdimens
1601 }%
1602 \let\_boldmath=\_boldunimath % this is done when Unicode math is initialized
1603 \endtt
1604
1605 \secc[newfam] Using additional math fonts
1606
1607 \new \OpTeX/
1608 The main Unicode math font is loaded by `\loadmath` and `\loadboldmath`
1609 (typically processed when `\fontfam[<family-name>]` is declared). Moreover,
1610 you can load {\em additional Unicode math fonts} and you can combine
1611 characters from main math font and these additional fonts. This can be
1612 usable if the main math font doesn't include all desired characters or you
1613 dislike some character shapes from main font. \OpTeX/ enables to load
1614 additional math fonts by `\addUmathfont` and characters from additional
1615 fonts can be declared by `\mathchars`. See the \optexdoc[2.16]{section 2.16}
1616 of \OpTeX/ documentation for more details about this.
1617
1618 The rest of this section includes an example which shows another task: how
1619 to combine main Unicode math font with old 8-bit math font `bbold10.tfm`.
1620 This font includes double stroked characters, for example, double stroked
1621 plus, double stroked Greek letters and digits. Try to run `pdftex testfont`,
1622 then answer the question about the name of the font: `bbold10` and then type
1623 command `\table\end`. The `testfont.pdf` is printed with the table of
1624 characters of this font. Most of these characters cannot be found in Unicode
1625 math fonts.
1626
1627 We can re-define the `\_normalmath` macro by:
1628 \begtt \typosize[10/12]
1629 \addto\_normalmath {\_loadmathfamily 5 bbold }
1630
1631 \_regtfm bbold 0 bbold5 6 bbold7 8.5 bbold10 * % using all bbold*.pfb
1632 \_normalmath % reload the math fonts collection
1633 \endtt
1634 %
1635 The string \"`bbold`" is declared by `\_regtfm` as a collection of all
1636 `bbold*.tfm` fonts, the optical sizes are supported.
1637
1638 \addto\_normalmath {\_loadmathfamily 5 bbold }
1639 \_regtfm bbold 0 bbold5 6 bbold7 8.5 bbold10 * % using all bbold*.pfb
1640 \_normalmath
1641 \Umathchardef \bbplus 2 5 "2B
1642 \Umathchardef \bble 3 5 "3C
1643 \Umathchardef \bbge 3 5 "3E
1644
1645 Finally, we must to declare new \TeX/ sequences for accessing the characters
1646 from the new font, for example:
1647
1648 \begtt \typosize[10/12]
1649 \Umathchardef \bbplus 2 5 "2B
1650 \Umathchardef \bble 3 5 "3C
1651 \Umathchardef \bbge 3 5 "3E
1652 \endtt
1653 %
1654 The \x`\Umathchardef` \TeX/ primitive declares new \TeX/ sequence used in math
1655 typesetting. The first parameter is a class number (2 means Bin, 3 means Rel,
1656 see the table in the section~\ref[class]). The second parameter is a math
1657 family number. It is 5, see the redefinition of the `\_normalmath` macro above.
1658 The third parameter is a slot in the font. Now you can try to use these characters:
1659 $$
1660 `a \bbplus b \bbge c` \quad \hbox{gives} \quad a \bbplus b \bbge c.
1661 $$
1662 %
1663 Maybe, you want to declare a special math selector which can be used as
1664 `$\bball a+b>c$` in order to get $\bbchar a \bbplus b \bbge c$.
1665 Then you can define:
1666
1667 \begtt \typosize[10/12]
1668 \def\bball {\bbchar \Umathcodenum `+ \bbplus
1669 \Umathcodenum `> \bbge
1670 \Umathcodenum `< \bble }
1671 \endtt
1672
1673 If you want to add all double stroked Greek letters into `\bball`
1674 selector, then you can do something like this:
1675
1676 \begtt \typosize[10/12]
1677 \def\setbbgreek #1 {\tmpnum=#1\xargs\setbbgreekA}
1678 \def\setbbgreekA #1{\Umathcode \_ea`#1 0 5 \tmpnum \advance\tmpnum by1 }
1679 \addto\bball {%
1680 \setbbgreek "0B \alpha \beta \gamma \delta \epsilon \zeta \eta
1681 \theta \iota \kappa \lambda \mu \nu \xi \pi \rho \sigma
1682 \tau \upsilon \phi \chi ;
1683 \setbbgreek "7F \omega ;
1684 \setbbgreek "00 \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon
1685 \Phi \Psi \Omega ; }
1686 \endtt
1687 %
1688 The \x`\Umathcode`` <input-code> <class> <family> <font-slot>` primitive is used
1689 here. The control sequences `\alpha`, `\beta`, `\gamma` etc. are macros which expand
1690 to the Unicode character of appropriate (non-math) Greek letter. We set the
1691 Umathcode to such character, for example
1692 \code{\\Umathcode `}$\_rmgreek\alpha$` 0 5 "0B` is processed.
1693
1694 The bold variant of the font `bbold*.tfm` is not available, unfortunately.
1695 We have to settle for normal version of the font in the `\_boldmath` macro:
1696
1697 \begtt \typosize[10/12]
1698 \addto \_boldmath {\_loadmathfamily 5 bbold }
1699 \endtt
1700
1701 \sec Index
1702
1703 Control sequences listed at pages \pgref[listA]--\pgref[listB] are not
1704 mentioned here again.
1705
1706 \begmulti 3
1707 \makeindex
1708 \endmulti
1709
1710 \bye