%% This is part of the OpTeX project, see http://petr.olsak.net/optex

% Run  optex optex-math  (two times) to generate this document
% or look at PDF here: http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf

\fontfam[lmfonts]

\font\ttlib=[LiberationMono-Regular]
\def\ttspec{\let\_ttfont=\ttlib}

\report

\def\new #1 {\mnote{\Red$\blacktriangleleft$\,\sans\setfontsize{at9pt}\rm#1}}
\fixmnotes\right
\enquotes
\verbchar`
\catcode`\<=13
\def<#1>{$\langle\hbox{\it#1\/}\rangle$}
\everyintt={\catcode`\<=13 }
\def\ss#1{$\vrule height3pt#1\vrule height3pt$}

\addto\_secfont\Blue  \addto\_seccfont\Blue
\_def\_printsec#1{\_par
   \_abovetitle{\_penalty-400}\_bigskip
   {{\_secfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}\_insertmark{#1}%
   \_nobreak \_belowtitle{\_medskip}%
   \_firstnoindent
}
\_def\_printsecc#1{\_par
   \_abovetitle{\_penalty-200}\_medskip
   {{\_seccfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}%
   \_nobreak \_belowtitle{\_medskip}%
   \_firstnoindent
}

\def\i #1 {\ii .#1 \iis .#1 {{\code{\\#1}}}}
\def\x`{\bgroup\_setverb\xx}
\bgroup \lccode\string`\.=\string`\` \lowercase{\egroup \def\xx #1#2.{\i #2 \egroup `#1#2.}}


\hyperlinks\Green\Green

\insertoutline{MATH}
\outlines{0}



\tit Typesetting Math with \OpTeX/

\hfill Version 03, January 2021

\author Petr Olšák


This document is a brief summary of typesetting math. It describes \TeX/,
Plain \TeX/ and \OpTeX/ features concerned to math.  The first two types of
features are documented in \TeX/book in chapters 16, 17, and 18, but it is
summarized here in short again in order to give a complete guide about math
typesetting for \OpTeX/ users.

\new {}
The \OpTeX/ features which differs from standard \TeX/ or Plain \TeX/ are
documented with the red triangle at the margin (like in this paragraph).
Reader can simply distinguish between \"standard" features (given by
\TeX/ or Plain \TeX/) and new \OpTeX/ features.

There are more types of extensions: e\TeX, lua\TeX/, Unicode math and
\OpTeX/ macros. The appropriate label (e\TeX, Lua\TeX/, Unicode, \OpTeX/)
is appended to the red triangle to inform you about the extension type.
Nevertheless, \OpTeX/ user doesn't have to worry about it, all extensions
are available if Unicode Math font is loaded (e.g., by the command
`\fonfam[lmfonts]`). See section 1.3.3 in \OpTeX/ documentation about
loading Unicode math fonts.

{\iindent=2em
\bigskip
\maketoc }
\vfil\break

\sec Basics structure of math formulas

\secc General rules and terminology

The \ii in-line/math in-line math (in the paragraph) is created by `$<math list>$`. The
\ii display/math display math (a standalone line between paragraphs) is created by `$$<math list>$$`.
More than one line can be here if an appropriate macro is used. In-line math is
processed in a \TeX/ group in \ii in-line/math/mode {\em in-line math mode}. The display math is
processed in a \TeX/ group in \ii display/math/mode {\em display math mode}. Spaces are
ignored in math modes, so `$x+y$` and `$x + y$` gives the same result: $x+y$.

The \ii math/list <math list> is a sequence of \ii math/atom,atom {\em math atoms} and
\ii other/material {\em other material}.
The math atoms are \ii single/math/object {\em single math objects} or
\ii composed/math/atom composed math atoms.

\begitems \hfuzz=.6pt
* The single math object is a single character to be printed in math mode
  like `x`, `+`, `\int`.
* The math atom is constructed in general by `{<math list 1>}^{<math list 2>}_{<math list 3>}`.
  It consists from \ii nucleus {\em nucleus} <math list 1>, \ii exponent exponent <math list 2>
  and \ii subscript subscript <math list 3>. Each part of the atom should be empty.
  If <math list 2> or <math list 3> is empty, we need not to write brackets and
  the prefix `^` or `_`.
  If the <math list 1> or <math list 2> or <math list 3>
  consist only from a single math object then we need not use brackets.
  For example
  `x^2` is a math atom with `x` in the nucleus, `2` in the exponent, and with empty subscript.
  Or `a_{i,j}` is a math atom with `a` in the nucleus, empty exponent, and `i,j` in the subscript.%
  \fnote{In \OpTeX/, the character `_` can be interpreted as a part of
  the control sequence name, not as the subscript constructor. But in common cases,
  constructions of math atoms are interpreted exactly as in plain \TeX. See sections
  2.2.2 and 2.14 of \OpTeX/ documentation for more details. If you want to
  be sure that `_` is just a subscript constructor in \OpTeX/ then you can set \code{\\catcode`\\_=8}
  but after this, you cannot use control sequences with `_` character.}
  The constructors for exponent `^` and subscript `_` can be used in arbitrary order
  after the nucleus, for example, `z_1^{x+y}` is the same math atom as
  `z^{x+y}_1`.  The single math objects not followed by `^` nor `_` are
  considered as math atoms with this object in the nucleus and with empty
  exponent and subscript (this is a very common case).
  \TeX/ assigns the \ii class {\em class} for each math atom, see section~\ref[class].
* Other material can be \TeX/ box or glue (space) or `\kern` or `\vrule` etc.
\enditems

Example: The `Z = \int``_\Omega x^{2y} + z\, dx` generates
$Z = \int_\Omega x^{2y} + z\, dx$ and it is <math list> which consists from:

\begitems
* `Z` is math atom with empty exponent and subscript, class: Ord,
* `=` is math atom with empty exponent and subscript, class: Rel,
* `\int``_\Omega` is math atom with empty exponent and with subscript `\Omega`, class: Op,
* `x^{2y}` is math atom with exponent `2y` and empty subscript, class: Ord,
  \begitems \let\_bullet=\circ
  * `2` is math atom with empty exponent and subscript, class: Ord,
  * `y` is math atom with empty exponent and subscript, class: Ord,
  \enditems
* `+` is math atom with empty exponent and subscript, class: Bin,
* `z` is math atom with empty exponent and subscript, class: Ord,
* `\,` is another material, the glue (space) in this case,
* `d` is math atom with empty exponent and subscript, class: Ord,
* `x` is math atom with empty exponent and subscript, class: Ord.
\enditems

\secc[class] Classes of math atoms

\TeX/ assigns \ii class {\em a class} for each math atom.\fnote
{Using terminology of \TeX/book, each single math object has its {\em class} but the
 math atom has its {\em kind} derived from this class. I use only one word
 for both meanings in this document.}
This data type is used when
\TeX/ decides about \ii horizontal/spacing horizontal spaces between atoms in the output. (Note
that spaces in the input are ignored.) For example,
`$xy$` prints two atoms without space between them but `$x+y$` is printed with
small spaces around the `+` binary operator. Compare: $xy$ and $x+y$.

The class is assigned depending on the nucleus of the atom. If the nucleus is
not a single math object, i.e. it is constructed by `{<math list>}` with braces
then the atom has its class Ord. If the nucleus is a single math object constructed
without braces then the class of the atom depends on this single math
object. Each single math object must be declared in \TeX/ with its default
class. The following table lists the classes with typical examples.
The full set of all math objects used in math typesetting
is listed in section~\ref[objects] with their default classes.

\bigskip
\noindent\hfil\table{llll}{
     & \ii class Class  & Meaning          & Example \crl
   0 & \iid Ord    & ordinary object  & variables, digits, $x, {\bbchar R}, \Gamma, 0, 1$ \cr
   1 & \iid Op     & big opertator    & $\sum, \int, \bigcup$ \cr
   2 & \iid Bin    & binary operator  & $+, \times, -, \pm, \cup$ \cr
   3 & \iid Rel    & reations         & $=, \ne, \leq, \supseteq, \succsim$ \cr
   4 & \iid Open   & opening bracket  & $\{, (, [, \langle$ \cr
   5 & \iid Close  & closing bracket  & $\}, ), ], \rangle$ \cr
   6 & \iid Punct  & punctuation      & comma \cr
     & \iid Inner  & left-right       & \code{\\left...\\right} outputs, see section~\ref[delims]
}
\bigskip

There are \ii horizontal/spacing,spacing three space types used
by the algorithm for horizontal spacing in the math formulas.

\begitems
* \ii thin/space Thin space:   \x`\thinmuskip` primitive register, `\,` macro. Used around Op atoms.
* \ii medium/space Medium space: \x`\medmuskip` primitive register, `\>` macro. Used around Bin atoms.
* \ii thick/space Thick space: \x`\thickmusip` primitive register, `\;` macro. Used around Rel atoms.
\enditems

\puttext 7.8cm -3.7cm {\rotbox{90}{Left atom}}
\puttext 11.5cm  -.5cm  {Right atom}
\puttext 8.2cm -4.4cm {\typosize[9/11]
\thistable{\def\_enspace{ }}%
\table {l|8c|} {
  \omit & Ord & Op & Bin & Rel & Open & Close & Punct & \omit \hfil Inner \crlp{2-9}
  Ord   &  0  &  1 &  2  &  3  &  0   &  0    &  0    &  1  \cr
  Op    &  1  &  1 &     &  3  &  0   &  0    &  0    &  1  \cr
  Bin   &  2  &  2 &     &     &  2   &       &       &  2  \cr
  Rel   &  3  &  3 &     &  0  &  3   &  0    &  0    &  3  \cr
  Open  &  0  &  0 &     &  0  &  0   &  0    &  0    &  0  \cr
  Close &  0  &  1 &  2  &  3  &  0   &  0    &  0    &  1  \cr
  Punct &  1  &  1 &     &  1  &  1   &  1    &  1    &  1  \cr
  Inner &  1  &  1 &  2  &  3  &  1   &  0    &  1    &  1 \crlp{2-9}
}}

\hangindent=-8.7cm \hangafter=0
Ord atoms are printed without spaces between them. The spaces are not
cumulated, so the rule about spaces mentioned above is only a rough idea.
The exact rule for horizontal spaces is given for each pairs of atoms
in the table here. The symbol 0 means no space, 1 thin space, 2 medium space,
and 3 means thick space.

\hangindent=-8.7cm \hangafter-2
The Bin atom is automatically transformed to the
Ord atom if no atom precedes or if Op, Bin, Rel, Open, or Punct atom
precedes. And it is transformed to the Ord atom if Rel, Close or Punct atom
follows. This corresponds to the empty cells in the table.
Why such behavior? Compare \"\hbox{$0-3$}" and \"$-3$". The Bin atom in
the second case behaves like Ord atom because it is \ii unary/minus {\em unary minus}.
There is no space between the unary minus and the following object.

All medium spaces and thick spaces and some thin spaces from this table are
omitted if the <math list> is processed in
\ii script/style,scriptscript/style script or scriptscript styles
(smaller size). See section~\ref[styles] about math styles.

You can overwrite the default class derived from the nucleus of the atom by
\TeX/ primitives \x`\mathord`, \x`\mathop`, \x`\mathbin`, \x`\mathrel`, \x`\mathopen`,
\x`\mathclose`, \x`\mathpunct` and \x`\mathinner`. They can precede a nucleus of
the atom and they set the class of the atom.
For example, `x \mathrel+ y` behaves like `x = y` from a spacing point of view but +
is printed. Another example: `\mathop{\rm lim} z` creates the atom `lim` in
roman font of class Op. So, the thin space is inserted between lim and $z$.

There are more special kinds of math atoms: fractions, math accents,
radicals. They are constructed in a special way (see next sections) but they behave
like Ord atom in the horizontal spacing algorithm.

\secc[styles] Math styles

When a formula (or a sub-formula) is processed by \TeX/ then one from four
\ii math/style,display/style,text/style,script/style,scriptscript/style
styles is active: display style ($D$), text style ($T$), script style ($S$) or
scriptscript style ($SS$).

\ii T/style,D/style,S/style,SS/style The $T$ style is started in in-line math mode `$...$` and the $D$
style is started in display math mode `$$...$$`. The first level of exponents or
subscripts is processed in $S$ style and the second and more levels of
exponents or indexes are processed in $SS$ style.
There are special rules for math styles when fractions are constructed, see
section~\ref[frac].

The $D$ and $T$ styles use basic \ii font/size font size, $S$ uses smaller font size (typically
70~\%) and $SS$ style uses more smaller font size (typically 50~\%). Next
levels of \"more smaller fonts" are not used due to classical typographic rules.

The \ii nucleus nucleus of \iid Op atoms (big operators, $\sum$, $\int$, etc.) have typically bigger versions
of the character shape for $D$ style than for $T$ style.
So, there are four sizes for such math
objects: one size for each math style. All other math objects (with non Op
class) are printed only in three sizes: The sizes for $T$ and $D$ styles are equal.

The \iid Op atom puts its \iid exponent and \iid subscript above and below the nucleus in $D$
style but right to the nucleus in other styles:
$$
  `\sum``_{i=1}^\infty` \quad \hbox{gives}\quad \sum_{i=1}^\infty \hbox{ in $D$ style and}
  \quad \textstyle \sum_{i=1}^\infty \hbox{ in $T$ style}.
$$
This default behavior of the Op atom
can be modified by placing \x`\limits` or \x`\nolimits` or
\x`\displaylimits` \TeX/ primitive just after its nucleus before the constructors
of exponent and/or index. The `\nolimits` puts exponent and subscript right
to the nucleus (regardless of the current style) and `\limits` puts these
objects above and below the nucleus (regardless of the current style). There
can be more such primitives in a queue (due to a macro expansion, for
instance). Then the last primitive in the queue wins.
If the last primitive is \x`\displaylimits` then
the default behavior is processed regardless there are \x`\limits` or \x`\nolimits`
before it.
$$
  `\sum\nolimits``_{i=1}^\infty` \quad \hbox{gives}\quad \sum\nolimits_{i=1}^\infty
  \hbox{ in $D$ style and}\quad \textstyle\sum\nolimits_{i=1}^\infty
  \hbox{ in $T$ style}.
$$
Atoms of all other classes have their exponents and/or subscripts only right
to their nucleus without any exception.

The primitives \x`\displaystyle`, \x`\textstyle`, \x`\scriptstyle` and
\x`\scriptscriptstyle` set the given style regardless the default rules. For
example, you can create a formula in in-line math mode and in $D$ style by
`$\displaystyle <fomula>$` or a formula in display mode and $T$ style can be printed
by `$$\textstyle <fomrula>$$`.

If a subformula is placed below something (below a line from root symbol,
below a fraction line), then the processed style $D, T, S$ or $SS$ is
\ii cramped/style {\em cramped}.
The exponents are positioned slightly lower than in
\ii non-cramped/style non-cramped style. The selectors `\displaystyle`\,\dots
`\scriptscriptstyle` mentioned above select non-cramped style. The
non-cramped style is selected when math mode starts too.
\new \OpTeX/
You can select a cramped style by the macro \x`\cramped` at the start of the
math formula or after the math-style selectors: `\scriptstyle\cramped` for
example.

Several macros need to know what math style is currently processed (for
example they need to draw something in an appropriate size). But it
not possible simply due to the syntax of fractions (section~\ref[frac]).
This syntax requires to process all math lists in two steps: the first step
expands all macros and creates structured data of processed math list. The
second step reads the output of the first step, switches between math
styles and creates definitive output. So, macros (working in the first step)
cannot know the current math
style because it is set only in the second step. \TeX/ supports the primitive
\x`\matchchioce``{<D>}{<T>}{<S>}{<SS>}` which prepares four math lists in the
first step and only one of these four lists are used in the second step. We
can put different macros into each of the four parameters of `\mathchoice`.
Plain \TeX/ supports the macro \x`\mathpalette` which gives a more comfortable
interface of \x`\mathchoice` to the macro programmer.
The cramped/non-cramped variants of the current style are kept when `\mathchioce`
is used.

\new \OpTeX/
We describe another interface for creating macros depending on the current
style. You can use \x`\mathstyles``{<math list>}`. It
behaves like `{<math list>}`, moreover, you can use the following commands inside such
<math list>:
\begitems
* The macro \x`\currstyle`. It expands to
  `\displaystyle`, `\textstyle`,
  `\scriptstyle` or `\scriptscriptstyle` depending on the current math style
  when the `\mathstyles` was opened.
* The \x`\dobystyle``{<D>}{<T>}{<S>}{<SS>}` is expandable macro. It expands its
  parameter `<D>`, `<T>`, `<S>` or `<SS>` depending on the current math style
  when `\mathstyles` was opened.
* The value of the \x`\stylenum` register is 0, 1, 2 or 3
  depending on the current math style when `\mathstyles` was opened.
\enditems
%
Example of usage of \x`\mathstyles`:
\def\mysymbol{\mathbin\mathstyles
   {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}}
\def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}}
\begtt
\def\mysymbol{\mathbin\mathstyles
   {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}}
\def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}}
Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$.
\endtt
This example gives Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$.

The \x`\mathstyles` macro mentioned above uses \TeX/ primitive \x`\mathchoice`, so it
creates four math lists and only one is used. It may take more
computer time in special cases.
\new Lua\TeX/
Lua\TeX/ supports the \x`\mathstyle` primitive
(no \"`s`" at the end of this control sequence) which
expands to values 0 to 7 depending on the current style:
$D, D', T, T', S, S', SS, SS'$
(where $X'$ means cramped variant of the style). This primitive does
not use `\mathchoice` but it simply ignores the fraction syntax, so
`$a\mysymbol b\over c$` cannot work if `\mysymbol` is defined using the `\mathstyle`
primitive. See section 7.3.1 of Lua\TeX/ documentation for more information.


\secc[frac] Fractions

The \iid fraction can be constructed by `{<numerator>`\x`\over``<denominator>}`. If the
fraction is only a single object in the whole math mode (between dollars),
you need not use the outer braces, so you can write `$1\over2$` to get $1\over2$.

The \ii numerator,denominator <numerator> and <denominator> are printed in \"smaller" math style than
current math style. More exactly the following schema is used.
$D$: $T\over T$., $T$: $S\over S$, $S$: $SS\over SS$, $SS$: $SS\over SS$.
For example
$$
  `{a+b \over c}` \quad \hbox{is printed as }
   {a+b\over c} \hbox{ in $D$ style and as }
   \textstyle {a+b\over c} \hbox{ in $T$ style}.
$$

The \LaTeX/ macro \x`\frac``{<numerator>}{<denominator>}` is not supported in
Plain \TeX/ nor in \OpTeX/ but you can define such macro if you want.

The syntax with \x`\over` is more preferred because it is more human-readable
notation. You can write the fraction in the same manner as you can read it.
You can compare: `$1\over2$` (one over two) with `$\frac12$` (frac twelve).

Besides the `\over` primitive, there are analogical \TeX/ primitives which
create \"generalized" fractions. The result is similar to `{<above>\over <below>}`
but there is something extra:

\begitems
* `{<above>`\x`\atop``<below>}` does `{<above>\over<below>}` but
  without the fractional rule.
* `{<above>`\x`\above``<dimen><below>}` creates fractional rule with <dimen> thickness.
* `{<above>`\x`\overwithdelims``<delim-l><delim-r><below>}` adds the <delim-l> left to
  the fraction and the <delim-r> right to the fraction.
* `{<above>`\x`\atopwithdelims``<delim-l><delim-r><below>}` is analogical to
  `\overwithdelims` but without fractional rule.
* `{<above>`\x`\abovewithdelims``<delim-l><delim-r><dimen><below>}` behaves as
  `\overwithdelims` but the fractional rule has <dimen> thickness.
\enditems
%
The `\...withdelims` variants read <delim-l> and <delim-r>, they must be
declared as {\em math delimiter} in \TeX. They are vertically scalable
math objects, typically brackets. See section~\ref[delims] for more
information about math delimiters. Example:
$$
 `{n \atopwithdelims() k}`\quad \hbox{ creates }
  {n \choose k} \hbox{ in $D$ style and }
  \textstyle {n \choose k} \hbox{ in $T$ style}.
$$
The \x`\choose` macro is defined by `\def\choose{\atopwithdelims()}`, so the
user can write `{n\choose k}` in order to get binomial coefficients.


\secc[delims] Vertically scalable objects: math delimiters

The vertically scalable objects are called \ii delimiters {\em delimiters}. For example,
all types of brackets are declared as delimiters.
This means that you can use a bracket in arbitrary
vertical size.\fnote{
This is not exactly true, because traditional typography says that they
cannot be scaled continuously but by visible steps. This means that there is
a sequence of increasing brackets in the font, the reader must see a difference
between every two sizes of brackets.}

The following objects are declared as delimiters (i.e.\ vertically scalable):

\bigskip
{\tt \adef!{\bslash}
\table{l 14c}{
 \rm source: & ( & ) & [ & ] & \code{\\\{} & \code{\\\}} & /
             & !backslash & !langle & !rangle
             & | & \code{\\|} & \cr
 \rm output: &$($&$)$&$[$&$]$& $\{$  & $\}$ & $/$
             & $\backslash$ & $\langle$ & $\rangle$
             & $|$ & $\|$
}
\medskip
\table{l 14c}{
 \rm source: & !lfloor & !rfloor & !lceil & !rceil \cr
 \rm output: &  $\lfloor$  & $\rfloor$ & $\lceil$ & $\rceil$
}
\medskip
\table{l 14c}{
 \rm source: & !uparrow & !Uparrow & !dowarrow & !Downarrow
             & !updownarrow & !Updownarrow \cr
 \rm output: & $\uparrow$ & $\Uparrow$ & $\downarrow$ & $\Downarrow$
             & $\updownarrow$ & $\Updownarrow$
}}
\bigskip
\noindent \new Unicode
If you can produce the characters $\langle$, $\rangle$,\fnote
 {Do not confuse $\string<, >$ and $\langle, \rangle$. The first pair are Rel atoms
  with meaning \"less than" or \"greater than", but the second pair are special
  types of brackets. They are not directly available at computer keyboards without
  using a keyboard macro.}
$\lfloor$, $\rfloor$, ... $\updownarrow$, $\Updownarrow$
directly in your text editor then you can use these Unicode characters in your source instead of control
sequences `\langle`, `\rangle`, `\lfloor`, `\rfloor` ... `\updownarrow`, `\Updownarrow`.
For many users (including me), there is more simple to type `\lfloor` than to find
how to create the $\lfloor$ character in my text editor. Note that there exist
text editors (Emacs, for example)
enabling you to type `\lfloor` and this control sequence is immediately
converted to the $\lfloor$ Unicode character.
Your source text looks pretty and you can use classical \TeX/ sequences.

\new Unicode
There are more \ii delimiters delimiters, but it heavily depends on loaded Unicode Math
font. For example, this document is printed in `latinmodern-math` font and
there are six more delimiters `\lBrack`~$\lBrack$, `\rBrack`~$\rBrack$,
`\lAngle` $\lAngle$, `\rAngle` $\rAngle$, `\lgroup` $\lgroup$, `\rgroup` $\rgroup$.
See section~\ref[objects] for table of all Unicode symbols for math typesetting.

Arbitrary tall formula can be surrounded by a pair of delimiters using
\x`\left` and \x`\right` \TeX/ primitives: `\left<delim> <formula> \right<delim>`.
The delimiters are scaled to the height and depth of the <formula>
and vertically centered to the {\em math axis}.\fnote
{Math axis is a horizontal line passing through the center of symbols $+$
 and $-$. All vertically scalable objects are vertically centered with
 respect to this axis.}
Example:
$$
  `+ \left\{ \sum_{i=1}^\infty x_i \right)` \quad \hbox{ gives }
   + \left\{ \sum_{i=1}^\infty x_i \right).
$$
The pair `\left<delim> <formula> \right<delim>` creates the formula in a
\TeX/ group. Such group can be nested with another groups.
Each `\left` must have its `\right` counterpart at the same group level.
If you don't want to create visible delimiter, use dot instead <delim>.
Example:
$$
  `\left. \int``_0^t e^{x^2}\,dx\, \right|_{t=42}` \quad \hbox{ gives }
   \left. \int_0^t e^{x^2} \,dx\, \right|_{t=42}
$$

\new e\TeX/
You can use \x`\middle``<delim>` inside the <formula> which is surrounded by
`\left...\right`. Then the given <delim> is scaled to the same size like
their `\left` and `\right` counterparts.

When a delimiter is used without `\left` nor `\right` prefix, then it is the
Open, Close, Ord or Bin atom by its natural meaning:
$(, [, \{, \ldots, \lfloor, \lceil$ are Open atoms,
$], ], \}, \ldots, \rfloor, \rceil$ are Close atoms,
$/, \backslash, |, \|$ are Ord atoms and
$\uparrow, \Uparrow, \ldots, \Updownarrow$ are Bin atoms. You can overwrite
this default setting, for example `\mathclose(`. If delimiters are used with
`\left` and `\right` prefixes then `\left<delim>` behaves like Open atom,
`\right<delim>` behaves like Close atom and the math list
`\left<delim><formula>\right<delim>` is encapsulated as a single Inner atom.
The `\middle<delim>` behaves like Open atom at its left side and like Close
atom at its right side.

The sequence of increasing delimiters can be printed by the following
macros:
$$
  `(` \to (,\quad \x`\big``(` \to \big(,\quad \x`\Big``(` \to \Big(,\quad
  \x`\bigg``(` \to \bigg(, \quad \x`\Bigg``(` \to \Bigg(.
$$
The `\Bigg<delim>` is not the maximal size of the bracket. Try
`\left(\vbox to5cm{}\right.`, for example. You can see that the font
\"cheats" from certain sizes, because there are not all infinity number of
sizes of brackets drawn in the font, of course.

The `\big<delim>` creates Ord atom. We need to create Open atom
for opening bracket and Close atom for closing bracket more often.
Then we can use macros
\x`\bigl``<delim>`,
\x`\Bigl``<delim>`,
\x`\biggl``<delim>`,
\x`\Biggl``<delim>` for creating Open atoms and
\x`\bigr``<delim>`,
\x`\Bigr``<delim>`,
\x`\biggr``<delim>`,
\x`\Biggr``<delim>` for creating Close atoms. Unfortunately, the source is not
too attractive when more sizes of brackets are used, but typographic
traditions say that we have to distinguish brackets by the size in math
mode if they are in equal types:
$$
  `\Bigl( f\bigl( 2(x+y) + z\bigr) \Bigr)'` \quad \hbox{gives }
  \Bigl(f\bigl(2(x+y)+z\bigr)\Bigr)'.
$$

\secc Horizontally scalable objects: math accents

Arbitrary wide formula can be covered by \ii math/accent,accent {\em scalable math accent}.
Example:
$$
  \x`\overrightarrow`` {a+b+c+d+e+f}` \quad \hbox{gives } \overrightarrow {a+b+c+d+e+f}.
$$
The usage is: control sequence of selected math accent followed by `{<math list>}`.

Standard scalable math accents are:
\x`\overline` $\overline{abc}$,
\x`\overbrace` $\overbrace{abc}$,
\x`\overrightarrow` $\overrightarrow{abc}$,
\x`\overleftarrow`~$\overleftarrow{abc}$,
\x`\underline` $\underline{abc}$,
\x`\underbrace` $\underbrace{abc}$.

An Op atom is created. The exponents and subscripts are centered above
and below the nucleus of this atom (regardless of the current style). Example:
$$
  `\overbrace {b\cdot b\cdot b \cdots b}^{k\times}` \quad \hbox{gives }
  \overbrace {b\cdot b\cdot b \cdots b}^{k\times}
$$
There are scalable accents with a limited maximum width:
\x`\widehat` $\widehat{abc}$ and \x`\widetilde` $\widetilde{abc}$. If the
formula is wider than the font can cover then the widest variant from the
font is used and it is horizontally centered.

\new Unicode
There are more scalable accents in Unicode math fonts:
\x`\overparen` $\overparen{abc}$, \x`\underparen` $\underparen{abc}$,
\x`\overbracket` $\overbracket{abc}$, \x`\underbracket` $\underbracket{abc}$,
\x`\overleftrightarrow` $\overleftrightarrow{abc}$,
\x`\overleftharpoon` $\overleftharpoon{abc}$,
\x`\overrightharpoon` $\overrightharpoon{abc}$,


\secc Fixed math accents

Fixed \ii math/accent,accent math accents can be applied to single math object or to the `{<math list>}`.
The accent is centered (with respect of slanting axis) and the result is a
nucleus of Ord
atom. For example `\dot x` gives $\dot x$. The list of fixed math accents
follows: \x`\acute`` x` $\acute x$, \x`\bar`` x` $\bar x$,
\x`\breve`` x` $\breve x$, \x`\check`` x` $\check x$,
\x`\dot`` x` $\dot x$, \x`\ddot`` x` $\ddot x$,
\x`\grave`` x` $\grave x$, \x`\hat`` x` $\hat x$,
\x`\vec`` x` $\vec x$, \x`\tilde`` x` $\tilde x$.

\new Unicode
The additional fixed accents depends on used Unicode math font. The
`latinmodern-math` supports:
\x`\ovhook`` x` $\ovhook x$, \x`\ocirc`` x` $\ocirc x$,
\x`\leftharpoonaccent`` x` $\leftharpoonaccent x$, \x`\rightharpoonaccent`` x` $\rightharpoonaccent x$,
\x`\dddot`` x` $\dddot x$, \x`\ddddot`` x` $\ddddot x$,
\x`\widebridgeabove`` x` $\widebridgeabove x$, \x`\asteraccent`` x` $\asteraccent x$.

There exist one special math accent `'` (single quote, ASCII 39)
which can be appended after a symbol like this: `f'`
and it creates $f'$ (typical meaning is the
derivation of the given function). You can put more such accents, for
example `g'''` gives $g'''$.

\secc Roots

There is a macro \x`\sqrt``{<math list>}` to create \ii square/root square root. For example:
$$
  `\sqrt{\sqrt{\sqrt{x+1}+1}+1}` \quad \hbox{gives }
   \sqrt{\sqrt{\sqrt{x+1}+1}+1}
$$
The \ii root $n$-th root is created by the macro \x`\root`` <n>\of{<math list>}`. For
example `\root k+1\of x` gives $\root k+1\of x$.

\secc Math alphabets

Letters \ii math/alphabet $a\dots z$, $A\dots Z$ and $\alpha$\dots$\omega$ are printed in italic
in math mode. This follows the traditional typographic rule.
All other math symbols, digits, and uppercase Greek letters must be
upright.\fnote
{French typographic convention says that uppercase Greek letters have to be
 in italic too. Use `\_itGreek` declaration in this case.}
These rules are independent of the current variant of surrounding text font.

If we want to use the letters or digits
in another than this default shape, then we can use
\ii math/alphabet/selector {\em math alphabet selectors}:
\x`\mit`, \x`\rm`, \x`\it`, \x`\bf`, \x`\cal`.
\new \OpTeX/
\OpTeX/ supports more such selectors \x`\script`, \x`\frak`, \x`\bbchar`, \x`\bi`, see
section 1.3.3 in the \OpTeX/ documentation. The math selectors have local
validity in the group.

The control sequences \x`\rm`, \x`\it`, \x`\bf`, and \x`\bi` act as variant selectors
of fonts in non-math mode (text mode) and they act
as math alphabet selectors in math mode. This \"overlaying" concept
is given by Plain \TeX/. Example: math operators lim, sin, cos,
log, etc.\ must be printed unslanted. We are using `\lim`, `\sin`, `\cos`,
`\log` etc.\ in math mode in order to comply with this typographic convention. For
example `\sin` is defined as:
\begtt
\def\sin {\mathop{\rm sin}\nolimits}
\endtt
The `\rm` is used here as math alphabet selector, no variant selector of
text fonts.

The list of all predefined `\rm`-like math operators follows: \x`\arccos`,
\x`\arcsin`, \x`\arctan`, \x`\arg`, \x`\cos`, \x`\cosh`, \x`\cot`, \x`\coth`, \x`\deg`.
\x`\det`, \x`\dim`, \x`\exp`, \x`\gcd`, \x`\hom`, \x`\inf`, \x`\ker`, \x`\lg`, \x`\lim`,
\x`\liminf`, \x`\limsup`, \x`\ln`, \x`\log`, \x`\max`, \x`\min`, \x`\Pr`, \x`\scs`, \x`\sin`,
\x`\sinh`, \x`\sup`, \x`\tan`, \x`\tanh`, You can define another such operator
analogically.

\new Unicode
Unicode font can include the following math alphabets:
\begtt \typosize[9/11]
\_rmvariables      % upright letters A-Z, a-z
\_bfvariables      % bold letters A-Z, a-z
\_itvariables      % italic letters A-Z, a-z
\_bivariables      % bold italic letters A-Z, a-z
\_calvariables     % calligraphic letters A-Z, a-z
\_bcalvariables    % calligraphic letters A-Z, a-z
\_frakvariables    % fraktur A-Z, a-z
\_bfrakvariables   % bold fraktur A-Z, a-z
\_sansvaraibales   % sans serif letters A-Z, a-z
\_bsansvaraibales  % bold sans serif letters A-Z, a-z
\_isansvaraibales  % slanted sans serif letters A-Z, a-z
\_bisansvaraibales % bold slanted sans serif letters A-Z, a-z
\_ttvariables      % monospace, typewriter letters A-Z, a-z
\_bbvariables      % double struck A-Z, a-z
\_rmdigits         % upright digits 0..9
\_bfdigits         % bold digits 0..9
\_sansdigits       % sans serif digits 0..9
\_bsansdigits      % bold sans serif digits 0..9
\_ttdigits         % monospace typewriter digits 0..9
\_bbdigits         % double-struck digits 0..9
\_rmgreek          % upright Greek letters \alpha-\omega
\_itgreek          % slanted Greek letters \alpha-\omega
\_bfgreek          % bold Greek letters \alpha-\omega
\_bigreek          % bold italic Greek letters \alpha-\omega
\_bsansgreek       % bold sans serif Greek letters \alpha-\omega
\_bisansgreek      % bold slanted snas serif Greek letters \alpha-\omega
\_itGreek          % slanted Greek letters \Alpha-\Omega
\_bfGreek          % bold Greek letters \Alpha-\Omega
\_biGreek          % bold italic Greek letters \Alpha-\Omega
\_bsansGreek       % bold sans serif Greek letters \Alpha-\Omega
\_bisansGreek      % bold slanted snas serif Greek letters \Alpha-\Omega
\endtt
%
Not all Unicode math fonts include all math alphabets listed here. Typically,
the lowercase letters of calligraphic shape and all letters of
bold calligraphic shape are missing.

\new \OpTeX/
\OpTeX/ defines internal math alphabet selectors as mentioned in the
previous listing of math alphabets and sets as default:
\begtt \typosize[10/12]
\_itvariables \_rmdigits \_itgreek \_rmGreek
\endtt
%
Moreover, it defines the alphabet selectors at user level (see section 1.3.3
of the \OpTeX/ manual). For example
\begtt \typosize[10/12]
\def\rm {\_tryload\_tenrm \_inmath{\_rmavariables \_rmdigits}}
\endtt
%
The first part
\new \OpTeX/
`\_tryload\_tenrm` is applicable for text fonts and the
`\_inmath` part is processed only in math mode and sets the math alphabets.
You can see the file `unimath-codes.opm` where all user-level selectors are
defined. You can redefine them. For example, \OpTeX/ defines `\bf` as a math
alphabet selector that selects sans serif bold in math. This is the common
notation for vectors, tensors, and matrices. If you dislike this, then you can define:
\begtt \typosize[10/12]
\def\bf {\_tryloadbf\_tenbf \_inmath{\_bfvariables\_bfdigits\_bfgreek\_bfGreek}}
\endtt


\secc[objects] List of single math objects

\new Unicode
All \ii single/math/object single math objects are listed in the `unimath-table.opm` or
`unicode-math-table.tex` file. You can
look into this file. The codes, \TeX/ sequences, classes, and comments
for all possible math codes are here. Maybe, your Unicode math font which is loaded
does not support all these codes.
\new \OpTeX/
You can try all codes of the currently loaded font by
\begtt
\input print-unimath.opm
\endtt
The `unimath-table` is printed with characters available in the loaded font.
\new \OpTeX/
If the character is unsupported by the font then the slot is empty and only
\TeX/ sequence and the class of the code is printed in the table.
For example, this document loads `latimodern-math.otf` font.
And the result from `\input print-unimath.opm` looks like the following ten
pages.

Unsupported characters can be replaced by characters from other Unicode math
font, see
\ulink[http://petr.olsak.net/optex/optex-tricks.html\#addumathfont]{OpTeX trick 0030}
or section~\ref[newfam].


\label[listA]\wlabel{}

\bigskip
\input print-unimath.opm
\bigskip

\label[listB]\wlabel{}

It isn't very comfortable to find something in the previous table
if you know the shape. You can try the online web tool \ii Detexify
\ulink[https://detexify.kirelabs.org/classify.html]{Detexify}.
You can draw the symbol here and the suggestion of \TeX/ sequence is
printed.

\def\g#1{{\tt\string#1}~$#1$}

The generic \TeX/ sequences for the Greek letters \ii Greek/letters can be used:
\g\alpha, \g\beta, \g\gamma, \g\delta, \g\varepsilon, \g\zeta, \g\eta,
\g\theta, \g\iota, \g\kappa, \g\lambda, \g\mu, \g\nu, \g\xi,
\g\omicron, \g\pi, \g\rho, \g\varsigma, \g\sigma, \g\tau, \g\upsilon,
\g\varphi, \g\chi, \g\psi, \g\omega, \g\vardelta, \g\epsilon, \g\vartheta,
\g\varkappa, \g\phi, \g\varrho, \g\varpi\
and
\g\Alpha, \g\Beta, \g\Gamma, \g\Delta, \g\Epsilon, \g\Zeta, \g\Eta, \g\Theta,
\g\Iota, \g\Kappa, \g\Lambda, \g\Mu, \g\Nu, \g\Xi, \g\Omicron, \g\Pi, \g\Rho,
\g\Sigma, \g\Tau, \g\Upsilon, \g\Phi, \g\Chi, \g\Psi, \g\Omega.

\new \OpTeX/
The variant of Greek letters in the output
(upright, italic, bold, bold sans serif, etc.)
written by the sequences `\alpha`, `\beta` etc. depends on the math alphabet
selected by `\_itgreek`, `\_rmgreek`, etc. selectors. The user-level
selectors `\bf` and `\bi` set `\_bsansgreek` and `\_bisansgreek`, so
`{\bi\delta}` produces $\bi\delta$.

\new Unicode
All characters available in the math font can be accessed by \TeX/ control
sequence or by directly using the Unicode character in the document source.
Example:
\begtt \adef/{}
$$
   \sum/_{k=0}^\infty e^{(\alpha+i\beta/_k)} =
   e^\alpha \sum/_{k=0}^\infty e^{i\beta/_k} =
   e^\alpha \sum/_{k=0}^\infty (\cos\beta/_k + i\sin\beta/_k).
$$
\endtt
or
\begtt \ttspec
$$
   ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k}
                            = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k).
$$
\endtt
both gives the same result:
$$
  ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k}
                           = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k).
$$
\medskip


\sec Other specialities

\secc The `\not` prefix

You can apply \x`\not` before a following math object.
The slash $/$ is overprinted such math object, for example
`$a \not= b$` gives $a \not= b$.

\new \OpTeX/
If there exists a direct Unicode character for the negation of a relation symbol
(for example `\ne` creates $\ne$ directly as a character U+2260)
then `\not<char>` expands to appropriate Unicode character.
For example `\not=` expands to `\ne` or `\not\in` expands to `\notin`.
If such character does not exist then
the centered $/$ is overprinted over the next character.


\secc The `\buildrel` macro: text over the relation

The macro \x`\buildrel`` <text>\over <relation>` creates a new atom Rel with the
<relation> and with the smaller <text> above this <relation>. Example:
`$M \buildrel\rm def\over= X\cup Y$` gives $M\buildrel\rm def\over= X\cup Y$.


\secc Spaces

Spaces between atoms are created automatically as were mentioned in
section~\ref[class]. But sometimes you have to help \TeX/ to create
appropriate space. You can use following macros:

\begitems
* `\,` is \ii thin/space {\em thin space} used around Op atoms, after comma, etc.: \ss\,,
* `\!` is \ii negative/thin/space negative thin space,
* `\>` is \ii medium/space {\em medium space} used around Bin atoms: \ss\>,
* `\;` is \ii thick/space {\em thick space} used around Rel atoms: \ss\;,
* \x`\quad` is \ii em/space {\em em space}: \ss\quad,
* \x`\qquad` is \ii double/em/space {\em double em space}: \ss\qquad.
\enditems
%
Of course, you can use \ii direct/space {\em direct space} {\visiblesp`\ `} which is \TeX/ primitive
and gives interword space: \ss\ \
or you can use \x`\hskip`` <value>` to put arbitrary space.

The space size of `\,`, `\!` resp. `\>`, resp. `\;` is given by
`\thinmuskip`, resp. `\medmuskip`, resp. `\thickmuskip` values. You can see
in the `plain.tex` file that these default values differ very little in their basic
size but there is no stretchability/shrinkability in the `\,` space, there is small
stretchability in the `\>` space, and more stretchability in the `\;` space.

The registers \x`\thinmuskip`, \x`\medmuskip`, and \x`\thickmuskip` store so-called
\ii mu/values {\em mu values} given by math unit `mu`. It is 1/18 em and this unit depends
on the current font size used in the math formula ($S$ or $SS$ styles use
smaller font size, the `mu` unit is smaller here). You can use \x`\mskip`
instead `\hskip` or \x`\mkern` instead `\kern` if you want to use this
special `mu` unit. It is allowed only in math mode.

If \x`\nonscript` precedes `\hskip`, `\mskip`, `\kern`, or `\mkern` then this
space is applied only in $D$ or $T$ style.

The \x`\quad` and \x`\qquad` spaces have fixed width and they can be used in text
mode too. (\OpTeX/ allows to use `\,` in text mode too).
Use `\quad` or `\qquad` if you want to separate more formulas created in
single math mode. Examples of typical usage of spaces:

\begtt \adef/{} \typosize[10/12]
$$ \alpha\,(x+y), \qquad \int/_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma/_{\!i}. $$
\endtt
$$ \alpha\,(x+y), \qquad \int_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma_{\!i}. $$


\secc Texts in math mode

If you write `$Hello world!$` (i.e.\ Hello world in math mode), then you get
$Hello world!$. It is interpreted as the product of variables $H$, and $e$, and
$l^2$, and $o$, etc., followed by the symbol ! used for factorial.
The non-ASCII letters (with accents) don't work at all because they are
never used as symbols for variables. Spaces are ignored.

If you want to write a short text in the math mode, then you can use
`\hbox{<text>}`. The \x`\hbox` primitive initializes text mode regardless of
the \"outer mode". Example:

\begtt  \adef/{} \typosize[10/12]
$$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$
\endtt
$$ \sum_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$
%
Note the space before the word \"converges". The space before `\hbox` is
irrelevant. Second notice: the example shows the text mode inside math mode
and the in-line math mode inside this text mode. The same result can be
produced by:

\begtt  \adef/{} \typosize[10/12]
$$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if } a_n\searrow 0. $$
\endtt
%
The difference can be visible if the formula $a_n\searrow 0$ includes a
fraction, for example ${1\over2}a_n\searrow 0$. The first example prints the
fraction in the text style and the second example prints it in the display style.

The disadvantage of `\hbox` is that it starts in the text mode independently
of the current style, but we want to use smaller font in $S$ or $SS$ styles.
\new \OpTeX/
You can use \x`\mathbox``{<text>}` in such situations. This macro behaves like
`\hbox` but the text is appropriately smaller in $S$ and $SS$ styles.
Example:
$$
  `{\mathbox{cena}\over\mathbox{výkon}}` \quad \hbox{gives }
   {\mathbox{cena}\over\mathbox{výkon}}  \hbox{ in $D$ style and }
   \textstyle {\mathbox{cena}\over\mathbox{výkon}} \hbox{ in $T$ style.}
$$
Note that $\mathbox{cena}\over\mathbox{výkon}$ means $\rm price\over performance$
and you can write `$\rm price\over performance$` when you are using only
words without spaces and accented letters. But phrases with spaces or accented letters
should be printed in text mode using `\hbox` or `\mathbox`.

\secc `\vcenter`

The \x`\vcenter` primitive behaves like `\vbox`, but it can be used only in
math mode and its result is vertically centered to the math axis.
For example, matrices, are created by tables in `\vcenter`.

All big objects in math formula are centered on the math axis and the baseline is
ignored. In the following example, we create a new big math operator by
`\vcenter`:
\begtt
$$
  \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}}
  F(x) = \myop{x(i)}_{i=1}^\infty
$$
\endtt
\vskip-2em
$$
  \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}}
  F(x) = \myop{x(i)}_{i=1}^\infty
$$


\secc Three dots

You can write `$1,2,\dots,n$` to get $1,2,\dots,n$. The \x`\dots` macro puts
thin space between dots and after the last dot, so the five object: comma,
dots, comma are exactly equidistant.

Typographic conventions say that you have to use the repeating symbol
before and after three dots (comma in the previous example) and the three dots
should be at baseline if the repeating symbol is at baseline. Or they should be
at the math axis if the repeating symbol is at the math axis. We have to use \x`\cdots` instead
`\dots` in the second case. Example:
$$
  \addto\_ttfont{\thefontsize[9.5]}
  `a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n` \qquad
   a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n
$$
\vskip-.7em
There are \x`\vdots` $\vdots$, \x`\ddots` $\ddots$ and \x`\adots` $\adots$ which
can be used in matrices.

\new Unicode
Three dots like the output of the `\dots` macro are present as a single
character in fonts too. This character is called ellipsis. Font designers
typically suggest this character with smaller spaces between dots than we
need in math mode. So the rule about equidistant \"comma, three dots, comma"
is not met when this character is used. You can try `$1,2,\unicodeellipsis, n$`
and `$1+2+\unicodecdots + n$`. You get $1,2,\unicodeellipsis, n$ and
$1+2+\unicodecdots + n$. If you feel that this is better, then you can set:
`\let\dots=\unicodeellipsis \let\cdots=\unicodecdots`.

The Unicode fonts includes compact variants `\unicodevdots` $\unicodevdots$,
`\unicodeddots` $\unicodeddots$ and `\unicodeadots` $\unicodeadots$ too.


\secc Phantoms and `\smash`

The \x`\phantom``{<math list>}` macro creates an invisible subformula equal to
the formula generated by <math list>. It has its size, so it can
interfere with surrounding visible subformulas. This macro is very useful for
aligning with special requirements. Examples are shown in
sections~\ref[matrix] and~\ref[elines].

The \x`\vphantom``{<math list>}` has only its vertical size (i.e.\ its height
and depth), the width is zero. The \x`\hphantom``{<math list>}` has only its
width.

The \x`\smash``{<math list>}` is the opposite of `\vphantom`. It creates visible
subformula but it has only its width. Its height and depth are zero.

The result of these macros is the nucleus of an Ord atom. You can use `\mathop`,
`\mathbin`, etc. primitives to change this class. For example
`$a\mathrel{\phantom{=}}b$` creates the same formula as $a=b$ with the same
distance from $a$ to $b$ but without the equal sign:
$a\mathrel{\phantom{=}}b$.

These macros work in the text mode too. Then their argument is
the <horizontal list>.


\sec Structured objects

\secc[matrix] Matrices

The macro \x`\matrix``{<data>}` creates a vertically centered table of items.
The <data> includes <items> separated by `&` and rows are separated by
`\cr`. The number of columns and rows are unlimited. Columns are printed centered
and separated by the `\quad` space. The vertically scalable
brackets around the table are not printed. You can use \x`\pmatrix``{<data>}`
instead `\matrix{<data>}`: the vertically scalable parentheses () are inserted
around the table. Examples:

\begtt
$$
  {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr
                     a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr
                     \vdots  & \vdots  & \ddots & \vdots  \cr
                     a_{m,1} & a_{m,2} & \cdots & a_{m,n} },
$$
\endtt
$$
  {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr
                     a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr
                     \vdots  & \vdots  & \ddots & \vdots  \cr
                     a_{m,1} & a_{m,2} & \cdots & a_{m,n} },
$$
or:

\begtt
\def\qmatrix[#1]{\left[\matrix{#1}\right]}
$$
  \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3]
  = \qmatrix[b_1\cr b_2\cr b_3].
$$
\endtt
$$
  \def\qmatrix[#1]{\left[\matrix{#1}\right]}
  \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3]
  = \qmatrix[b_1\cr b_2\cr b_3].
$$

If you need to align the columns by another way than to center, then you can
use the phantom. Compare:

\begtt
$$
  \pmatrix{ 1 & -1 & 0  \cr
            0 &  2 & 13 \cr
           -3 &  0 & 5 }    \quad \hbox{or} \quad
  \def\0{\phantom0} \def\+{\phantom+}
  \pmatrix { \+1 &  -1 & \00 \cr
             \+0 & \+2 &  13 \cr
              -3 & \+0 & \05 }
$$
\endtt
$$
  \pmatrix{ 1 & -1 & 0  \cr
            0 &  2 & 13 \cr
           -3 &  0 & 5 }    \quad \hbox{or} \quad
  \def\0{\phantom0} \def\+{\phantom+}
  \pmatrix { \+1 &  -1 & \00 \cr
             \+0 & \+2 &  13 \cr
              -3 & \+0 & \05 }
$$

\new\OpTeX/
Another option to set the right aligned matrix is setting the \x`\lmfil`:
Its value is used on the left side in each `\matrix` item. The right side is
set directly to `\hfil`.
\begtt
$$
  \lmfil={\hfill}  % left matrix filler = \hfill
  \pmatrix{ 1 & -1 & 0 \cr 0 & 2 & 13 \cr -3 & 0 & 5 }
$$
\endtt

\new \OpTeX/
If you want to draw a vertical line inside the matrix, you can use `\adef|`
as in the following example:
\begtt
$$
  \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
  \def\+{\phantom+}
  \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim
  \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim
  \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 }
$$
\endtt
$$
  \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
  \def\+{\phantom+}
  \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim
  \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim
  \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 }
$$

If you want to put something before the opening bracket in the matrix, you can
use another `\matrix`. Example:

\begtt
$$
  \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
  \def\+{\phantom+}
  \def\r{{\bf r}}
  \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \
  \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: }
  \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2}
$$
\endtt
$$
  \adef|{\kern-.2em&\strut\vrule&\kern-.2em}
  \def\+{\phantom+}
  \def\r{{\bf r}}
  \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \
  \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: }
  \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2}
$$

Plain \TeX/ defines the \x`\bordermatrix` macro which allows you to create a
top row above the brackets and left column before the opening bracket.
\TeX/book shows the following example:

\begtt
$$
  M = \bordermatrix{ &C&I&C'\cr
                    C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a }
$$
\endtt
$$
  M = \bordermatrix{ &C&I&C'\cr
                    C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a }
$$

The `\matrix` macro used in $D$ style creates all its items in $T$ style.
\new \OpTeX/
If you are using the `\matrix` macro in $T$ style or $S$ style (but not in
fractions nor another matrices) then the resulting table is appropriately
smaller and all its items are processed in $S$ style.
If you are using `\matrix` in $SS$ style then the items are in $SS$ style too.
The following example shows one-column matrix in script style:
$$
  `\sum``_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k}` \ \hbox{ creates: }
   \sum_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k}
$$


\secc Cases

The \x`\cases` macro can be used as in the following example:

\begtt
$$
  f(x) = \cases{        1       & for $x\le 0$, \cr
                 100-x\over 100 & when $0 < x \le 100$, \cr
                        0       & in other cases. }
$$
\endtt
$$
  f(x) = \cases{        1       & for $x\le 0$, \cr
                 100-x\over 100 & when $0\string< x\le 100$, \cr
                        0       & in other cases. }
$$

The `\cases` macro behaves like a special `\matrix` with two left-aligned
columns and with left vertically scaled brace $\{$.
The first column is processed in math mode and $T$ style, the second column
is processed in text mode. We have to use `$...$` in the second column if
there is math material.


\sec Lines in display mode

\secc General principles

The \ii display/math,display/math/mode
`$$<formula>$$` finalizes previous paragraph, prints centered <formula> on
single line with a vertical space above and below and opens next paragraph
with no indentation.

From \TeX/'s point of view, the text above `$$<formula>$$` plus text
below is a single paragraph interrupted by display <formula>. If there is no
text above (i.e. the opening `$$` are in vertical mode), then the internal
`\noindent` is processed first and the empty line above <formula> is created.
Thus, it is definitely a bad idea to open display mode in vertical mode: never
put an empty line before `$$<formula>$$`. On the other hand, the empty line
just after `$$<formula>$$` says that the paragraph is finalized by the
<formula> and the next text (after the empty line) opens the next paragraph with
indentation. Summary:

\begitems
* \"Text above `$$<formula>$$` text below": the <formula> interrupts the
  paragraph with \"Text above" and \"text below". The \"text below" is
  without indentation.
* \"Text above `$$<formula>$$` empty line Text below": the \"Text below"
  opens new paragraph with indentation.
* \"Empty line `$$<formula>$$`" is bad practice.
\enditems

In contrast with the paragraph breaking, there is no built-in algorithm for
breaking display <formula> to more lines. If the <formula> is too wide then
overfull `\hbox` occurs and human must decide about splitting the <formula>
to more lines. The macros `\displaylines` and `\eqalign` are intended to
such task, see sections~\ref[dlines] and~\ref[elines].

On the other hand, the in-line math <formula>, i.e.\ the `$<formula>$` in a
paragraph, can be broken after a Bin atom (with penalty `\binoppenalty`) or
after a Rel atom (with penalty `\relpenalty`). If you don't want to break
such a formula at a specific place then use `\nobreak`, for example
`$a+\nobreak b$`. If you want never to break such formulas then you can set
`\binoppenalty=10000`, `\relpenalty=10000`. (Default values are 700 and 500.)


\secc References to display lines

The `$$<formula>`\x`\eqno``<mark>$$` \ii mark prints centered <formula> and the <mark> at
right margin. The `$$<formula>`\x`\leqno``<mark>$$` prints centered <formula> and
the <mark> at left margin. Examples:

\begtt
$$ a^2 + b^2 = c^2  \eqno (1) $$
\endtt
$$
  a^2 + b^2 = c^2  \eqno (1)
$$
\begtt \aftergroup\nobreak
$$ a^2 + b^2 = c^2  \leqno \rm Py $$
\endtt
$$\predisplaypenalty=10000
  a^2 + b^2 = c^2  \leqno \rm Py
$$
The <mark> \ii mark is processed in math mode and $T$ style. If you want to put a
text here then you have to use `\rm <text>` or `\hbox{<text>}`.

\new \OpTeX/
The auto-generated <mark> can be created by `$$<formula>`\x`\eqmark``$$`. The
<label> can be used previously declared by \x`\label``[<label>]`.
Then it is associated to such
auto-generated <mark> and you can write a reference in the form
`see equation~\ref[<label>]`. You can write `\eqmark[<label>]` instead of
`\label[<label>]...\eqmark`. See the \OpTeX/ manual, section~1.4.3.

\secc[dlines] The `\displaylines` macro

This macro creates more horizontally centered formulas in one display mode.
The syntax is
\begtt \catcode`\<=13
$$ \displaylines{
   <formula> \cr
   <formula> \cr
   ... \cr
   <formula>
} $$
\endtt
Usage of \x`\displaylines` is more
prefered than doing more display modes just behind each other.
Example:
\begtt
$$ \displaylines{
   (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
   = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
} $$
\endtt
$$ \displaylines{
   (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
   = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
} $$

The output from `\displaylines` macro is breakable to more pages because
the lines are not encapsulated in one box. The macro uses a special feature of
`\halign` primitive. The disadvantage is that you cannot use `\eqno` nor
`\leqno` nor `\eqmark`.

\new \OpTeX/
\OpTeX/ provides alternative form: `\displaylines to<dimen> {<data>}`.
Then the centered formulas are encapsulated in a `\vcenter` box of width <dimen> and
usage of `\eqno` or `\leqno` or `\eqmark` is allowed.
The individual lines have the form `\hbox to<dimen>` and formulas are centered using
`\hss` from both sides. This means that you can set arbitrary <dimen>
without visual change of the formulas. Use smaller <dimen> value than
`\hsize` (or `\displaywidth`\fnote
{`\displaywith` = `\hsize` in most cases but it is
real display width when `\parshape` or `\hangindent` is used.})
if you want to center formulas with `\eqno` appended.
The internal \TeX/ rule says: the formula with `\eqno` (or `\leqno`) is centered
if its width is less or equal `\displaywidth-4<mark-width>`. So
\begtt \catcode`\<=13
$$ \displaylines to\hsize-8em {<formula>\cr<formula>}\eqno (1) $$
\endtt
does global centering, because size of `(1)` is less than 2\,em.
You can do more experiments with this example,
for example `\diplaylines to\hsize{...}`
puts the `\eqno` mark to the next line in the display environment. Read
\TeX/book or \TeX/book naruby, where the precise explanation about such
positioning is.

\new \OpTeX/
You can use \"`\displaylines to<dimen>`" for more applications. For example,
you can put more
\"`\displaylines to<dimen>`" in single display mode, one next to second in order
to creating more centered columns with formulas; the width of such columns
are controlled by the <dimen> parameter.
Or, you can give an exception for several lines:

\begtt \catcode`\<=13
$$\displaylines to 10cm {<formula>\hfill \cr
                         <formula>\cr
                         <formula>\cr
                         \hfill <formula>}
$$
\endtt
The example above gives similar result as the \LaTeX/ `multline` environment:
$$\displaylines to \hsize {
  (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \hfill \cr
       = 3x^9 + 3x^5 + 15x^3 + 4x^8 + 4x^4 + 20x^2 + 5x^7 + 5x^3 + 25x
 + 6x^6 + 6x^2 + 30 = \cr
  \hfill = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. }
$$


\secc[elines] The `\eqalign` macro

The \ii .eqalign \iis .eqalign {{\code{\\eqalign}}} usage is:
\begtt \catcode`\<=13
$$ \eqalign { <left-side> & <right-side> \cr
              <left-side> & <right-side> \cr
              ... \cr
              <left-side> & <right-side>
} $$
\endtt
The `\vcenter` box is created with two columns, left column is right aligned
and right column is left aligned. Example:

\vbox{
\begtt
$$ \eqalign{
    x + 2y + 3z &= 600 \cr
   12x + y - 3z &= 7 \cr
    4x - y + 5z &= -5 \cr
} $$
\endtt
\vskip-5.7\baselineskip
{\hsize=1.35\hsize
$$ \eqalign{
    x + 2y + 3z &=  600 \cr
   12x + y - 3z &=  7 \cr
    4x - y + 5z &=   -5 \cr
} $$}}

\bigskip\noindent
The tab \"`&`" should be used just before a relation, i.e. `&=` is right, `=&`
is wrong. All lines are aligned to the used tab.

Maybe you want more precise alignment in the example above. You can use
`\phantom`:

\par\nobreak\vbox{
\begtt
$$ \def\1{\phantom1} \def\+{\phantom+}
   \eqalign{
     x +  2y + 3z &=  600 \cr
   12x + \1y - 3z &= \+7 \cr
    4x - \1y + 5z &=  -5 \cr
} $$
\endtt
\vskip-5.7\baselineskip
{\hsize=1.35\hsize
$$ \def\1{\phantom1} \def\+{\phantom+}
   \eqalign{
     x +  2y + 3z &= 600 \cr
   12x + \1y - 3z &= \+7 \cr
    4x - \1y + 5z &= -5
} $$}}
\bigskip
Another typical usage of the `\eqalign` macro:

\begtt \typosize[10/12]
$$ \eqalign{
  p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
             &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
} $$
\endtt
$$ \eqalign{
  p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr
       &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30.
} $$

In \OpTeX/, \new\OpTeX/
the `\eqalign` macro is more flexible. You can set the
`\baselineskip` value by the \x`\eqlines` parameter and math style
by the \x`\eqstyle` parameter.
For example, you need to put the system of \"equations" as a subscript of a sum
operator:
\begtt \typosize[10/12] \adef/{}
$$
  \sum/_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{
                  i &\in A  \cr
           \quad  j &\in B\cup C  \cr
                  m &\in C }}
   i + j + m
$$
\endtt
$$
  \sum_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{
                  i &\in A  \cr
           \quad  j &\in B\cup C  \cr
                  m &\in C }}
   i + j + m
$$

\indent \new\OpTeX/
You can write more equation systems one next second:
\begtt
$$\eqalign{
     x + y + z &= 1     &&  a + b + c &= -1 \cr
         u + v &= 20    &&      f + g &= -20 \cr
             i &= j
}$$
\endtt
You can use the third column for centered equations
without aligning point. For example:
\begtt \catcode`\<=13
$$ \left( \eqspace=0pt \eqalign{&& <first equation>\cr
                                && <second equation>} \right) $$
\endtt
The \x`\eqspace` is additional space used in the third column to separate
equation systems one next second.

\new \OpTeX/
\OpTeX/ extensions summary:
\begitems
* `\eqlines` and `\eqstyle` set baselineskip and math style of the formulas.
* `\eqalign` allows more than two columns:
   The first column is right-aligned (no space). The second is left-aligned (no space).
   The third column (if used)
   is centered with `\eqspace/2` at the left and right boundary of the column.
   The fourth is the same as the first. The fifth is the same as second etc. The number
   of columns that can be used in `\eqalign` is unlimited.
\enditems

\secc The `\eqalign` macro with references

You can give common mark to whole equation system by
`$$\eqalign{<data>}\eqno <mark>$$`. If you want to give marks to individual
lines of the equation system, then you can use another macro:
\x`\eqalignno`. The usage is similar as `\eqalign` but the
third column (if used) is intended to the equation mark. Example:

\begtt
$$ \eqalignno{
    x + 2y + 3z &= 600 & \rm(A) \cr
   12x + y - 3z &= 7   & \rm(B) \cr
    4x - y + 5z &= -5  & \rm(C) \cr
} $$
\endtt
\vskip-\baselineskip
$$ \eqalignno{
    x + 2y + 3z &= 600 & \rm(A) \cr
   12x + y - 3z &= 7   & \rm(B) \cr
    4x - y + 5z &= -5  & \rm(C) \cr
} $$

The `\leqalignno` macro is similar to `\eqalignno` but the marks are at the left
margin. The \OpTeX/ extensions of `\eqalign` are not available in
`\eqalignno` nor `\leqalignno` macros.

\new \OpTeX/
You can use auto-generated marks by `\eqmark` macro:
`$$\eqalign{<data>}\eqmark$$` or:
\begtt
$$ \eqalignno{
    x + 2y + 3z &= 600 & \eqmark[A] \cr
   12x + y - 3z &= 7   & \eqmark[B] \cr
    4x - y + 5z &= -5  & \eqmark[C] \cr
} $$
\endtt

More examples of alignments in display math mode (including comparison with
\LaTeX/ code) are shown in the document
\ulink[http://petr.olsak.net/ftp/olsak/optex/op-mathalign.pdf]{op-mathalign.pdf}.

\sec Concept of loading math fonts

\secc[fams] Math families

\TeX/ can use more than one math font in math mode. This was a
necessity in the old days when only 128-characters fonts existed.
Each math font used in math mode has its \ii math/family {\em math family} represented by a number.
Math family is a collection of three (almost) equal fonts in three sizes:
first for `\textstyle` and `\displaystyle`, second for `\scriptstyle`
and third for `\scriptscriptstyle`.

\new Unicode
When Unicode math font is loaded then it includes all three optical sizes and
all characters needed for typesetting math formula.
Theoretically, we can use only one math family with this single font. But more math families
(i.e.\ more fonts in math mode) is still possible. You can combine
characters from more fonts (Unicode fonts and old TFM fonts together) in one math formula.

\new \OpTeX/
\OpTeX/ loads the main Unicode math font into math family 1. The math
families 2 and 3 are reserved for specific \TeX/nical reasons, family 4 is
used for `\script` font and families 5, 6, 7, etc. can be used by user for
loading more fonts. The default macro for loading math fonts looks like:

\begtt \typosize[10/12]
\_def\_normalunimath{%
    \_loadumathfamily 1 {\_unimathfont}{} % Main Unicode math font
    \_loadmathfamily  4 rsfs              % \script (old TFM font)
    \_setunimathdimens   % set dimen parameters used in math formulas internally
}%
\let\_normalmath=\_normalunimath % this is done when Unicode math is initialized
\endtt
%
Whenever \OpTeX/ needs to resize math fonts (for example in footnotes or
titles), it calls the `\_normalmath` macro to reload all math
families to the desired size. If you want to add the next font, you can add
`\_loadunimathfamily <family> {<Unicode-font>}{<features>}` or
`\_loadmathfamily <family> <TFM-font>` into the `\_normalmath` macro.
The example in section~\ref[newfam] shows how to do it.

\secc Two variants of math fonts: normal and bold

All math formulas in the whole document need only one Unicode font (or only one collection
of math fonts as mentioned in section~\ref[fams]). But this
is not really true if titles are in bold font. If a math formula is present in
such a bold title then all characters of this formula must be bolder.
For example \"normal" variables must be in bold italic in titles, symbols
like `+` `=` must be bold and \"normal bold" letters
(e.g., indicating vectors in math formula) must be extra bold in titles.
It means that all fonts from the collection of math fonts must be bolder.
We need a second collection of math fonts with bolder
shape. Unfortunately, it is not always available.

\new \OpTeX/
If you  have bold variant of used Unicode math font, then you can use
\ii .loadmath \iis .loadmath {{\code{\\loadmath}}} \x`\loadboldmath` command, for example:
\begtt
\loadmath     {[xitsmath-regular]}
\loadboldmath {[xitsmath-bold]} \to {[xitsmath-regular]}
\endtt
%
\OpTeX/ uses `\_normalmath` macro for loading collection of math fonts in
\"normal" cases and `\_boldmath` macro for bold titles. The font declared by
\x`\loadboldmath` is used in second case. But if the bold variant of the font is
not available (this is unfortunately more typical), then \OpTeX/ uses faked
bold of main Unicode math font (the `embolden` internal font feature is
used). So, the default `\_boldmath` macro defined by \OpTeX/ looks like:

\begtt \typosize[10/12]
\_def\_boldunimath{%
   \_ifx\_unimathboldfont \_undefined
      \_loadumathfamily 1 {\_unimathfont}{embolden=1.7;} % Main faked bold
   \_else
      \_loadumathfamily 1 {\_unimathboldfont}{} % Main real bold font
   \_fi
   \_loadmathfamily 4 rsfs  % rsfs in not in bold, unfortunately
   \_setunimathdimens
}%
\let\_boldmath=\_boldunimath % this is done when Unicode math is initialized
\endtt

\secc[newfam] Example of using additional math font

The font `bbold10.tfm` includes double stroked characters, for example,
double stroked plus, double stroked Greek letters and digits.
Try to run `pdftex testfont`, then answer the question about the name of the
font: `bbold10` and then type command `\table\end`. The `testfont.pdf` is
printed with the table of characters of this font.
Most of these characters cannot be found in Unicode math fonts.

\new \OpTeX/
We show an example of how to add this font to the collection of used math fonts.
We can re-define the `\_normalmath` macro by:
\begtt \typosize[10/12]
\addto\_normalmath {\_loadmathfamily 5 bbold }

\_regtfm bbold 0 bbold5 6 bbold7 8.5 bbold10 * % using all bbold*.pfb
\_normalmath  % reload the math fonts collection
\endtt
%
The string \"`bbold`" is declared by `\_regtfm` as a collection of all
`bbold*.tfm` fonts, the optical sizes are supported.

\addto\_normalmath {\_loadmathfamily 5 bbold }
\_regtfm bbold 0 bbold5 6 bbold7 8.5 bbold10 * % using all bbold*.pfb
\_normalmath
\Umathchardef \bbplus 2 5 "2B
\Umathchardef \bble   3 5 "3C
\Umathchardef \bbge   3 5 "3E

Finally, we must to declare new \TeX/ sequences for accessing the characters
from the new font, for example:

\begtt \typosize[10/12]
\Umathchardef \bbplus 2 5 "2B
\Umathchardef \bble   3 5 "3C
\Umathchardef \bbge   3 5 "3E
\endtt
%
The \x`\Umathchardef` \TeX/ primitive declares new \TeX/ sequence used in math
typesetting. The first parameter is a class number (2 means Bin, 3 means Rel,
see the table in the section~\ref[class]).  The second parameter is a math
family number. It is 5, see the redefinition of the `\_normalmath` macro above.
The third parameter is a slot in the font. Now you can try to use these characters:
$$
   `a \bbplus b \bbge c` \quad \hbox{gives} \quad a \bbplus b \bbge c.
$$
%
Maybe, you want to declare a special math selector which can be used as
`$\bball a+b>c$` in order to get $\bbchar a \bbplus b \bbge c$.
Then you can define:

\begtt \typosize[10/12]
\def\bball {\bbchar \Umathcodenum `+ \bbplus
                    \Umathcodenum `> \bbge
                    \Umathcodenum `< \bble }
\endtt

If you want to add all double stroked Greek letters into `\bball`
selector, then you can do something like this:

\begtt \typosize[10/12]
\def\setbbgreek #1 {\tmpnum=#1\xargs\setbbgreekA}
\def\setbbgreekA #1{\Umathcode \_ea`#1 0 5 \tmpnum \advance\tmpnum by1 }

\addto\bball {%
   \setbbgreek "0B \alpha \beta \gamma \delta \epsilon \zeta \eta
                   \theta \iota \kappa \lambda \mu \nu \xi \pi \rho \sigma
                   \tau \upsilon \phi \chi ;
   \setbbgreek "7F \omega ;
   \setbbgreek "00 \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon
                   \Phi \Psi \Omega ; }
\endtt
%
The \x`\Umathcode`` <input-code> <class> <family> <font-slot>` primitive is used
here. The control sequences `\alpha`, `\beta`, `\gamma` etc. are macros which expand
to the Unicode character of appropriate (non-math) Greek letter. We set the
Umathcode to such character, for example
\code{\\Umathcode `}$\_rmgreek\alpha$` 0 5 "0B` is processed.

The bold variant of the font `bbold*.tfm` is not available, unfortunately.
We have to settle for normal version of the font in the `\_boldmath` macro:

\begtt \typosize[10/12]
   \addto \_boldmath {\_loadmathfamily 5 bbold }
\endtt

Another approach of using more Unicode math fonts in a single formula is
shown in
\ulink[http://petr.olsak.net/optex/optex-tricks.html\#addumathfont]{OpTeX trick 0030}.

\sec Index

Control sequences listed at pages \pgref[listA]--\pgref[listB] are not
mentioned here again.

\begmulti 3
\makeindex
\endmulti

\bye
