Skip to main content

The PreTeXt Guide

Subsection 4.9.13 Semantic Macros

We have resisted using overly-verbose MathML for mathematics, or worse, inventing our own XML vocabulary for mathematics. syntax generally works great, but to work even better within PreTeXt an author needs to take a few extra steps. Your work will translate better to a variety of formats, and will be easier to maintain, with well-designed macros. A well-designed macro will convey the mathematical meaning of the object to a reader of your source, without them looking at your definition of the macro. In situations where a mathematical object might be written with different notation, it should be trivial to change the macro’s definition and preserve the mathematical meaning. For example, consider two versions of a binomial coefficient:
\begin{align*} &{n\choose r} & &\operatorname{C}(n,r) \end{align*}
which could both equally well be the realization of \binomial{n}{r}.
Here we describe some notation which often carries multiple mathematical meanings and/or may be created with in multiple ways.

Subsubsection 4.9.13.1 Vertical Bars

Vertical bars are used for a variety of mathematical objects. Paired to create functions of expressions: absolute value, \(\left\lvert x-1\right\rvert\text{;}\) norm of a vector, \(\left\lVert \mathbf{v}\right\rVert\text{;}\) cardinality of a set, \(\left\lvert X\right\rvert\text{;}\) and the determinant of a matrix, \(\left\lvert A^k\right\rvert\text{.}\) As relations: division, \(a\mid b\text{;}\) parallel lines \(L_1\parallel L_2\text{.}\) Sets are another use: \(E=\left\{x\in{\mathbb Z}\,\middle\vert\, x\equiv 0\pmod 2\right\}\text{.}\)
\vert, \Vert, \lvert, \rvert, \lVert, \rVert are the delimiters, where l and r refer to left and right, and the capitalized versions are a pair of vertical lines. The qualifiers \left and \right can be used to have the length of the bar grow to match what it encloses. Note that there is a \middle that we have used above with \vert for the set \(E\text{,}\) and we have added space on either side. \mid and \parallel are relations, used above to indicate divisibility and parallel lines, and so automatically get an extra bit of spacing on either side.
When using \left or \right in isolation, \left. or \right. can be used to define a group that only has a bar on one end. For example:
\begin{gather*} \int_0^1\,\sin^{-1}(x)\,dx = \left.\frac{1}{\sqrt{1-x^2}}\right\rvert_{x=0}^{x=1}\text{.} \end{gather*}

Subsubsection 4.9.13.2 Times

The “times” symbol sees many uses that are different: dimensions, multiplication, and more complicated products (such as a Cartesian product of two sets). Macros \product, \times, and by could carry different meanings, even if each one is defined by the \times symbol, \(\times\text{.}\) For example:
Chess is played on an <m>8 \by 8</m> grid, which
contains <m>8 \times 8 = 64</m> little squares.
If <m>G</m> and <m>H</m> are finite groups, then
<m>\card(G \product H) = \card(G) \times \card(H)</m>.