Debian Codegraph @

texmf-dist/doc/luatex/minim-math/minim-math.doc

raw
1
2 \input minim-doc.sty
3
4 \manual{minim-math}
5
6 \ifchapter \chapter Mathematics
7
8 \else \startmetadata
9 author {Esger Renkema}
10 title {minim-math}
11 date {2025-02-12}
12 version {2025/1.5}
13 keywords {LuaTeX; Plain TeX; Unicode mathematics}
14 stopmetadata
15 \maketitle \fi
16
17 This package gives a simple and higly-configurable way of using unicode and
18 OpenType mathematics with plain LuaTeX, making use of most of the latter
19 engine’s new capabilities in mathematical typesetting. Also included are proper
20 settings and definitions for nearly all unicode mathematical characters, as
21 well as a few shorthands and helper macros that seemed useful additions.
22
23 Load the package by saying ⟦\input minim-math.tex⟧; this will set up luatex for
24 using opentype mathematical fonts and unicode math input.
25 It will not, however, select mathematical fonts for you. That you will have to
26 do for yourself; see below for instructions.
27
28
29 \section Experimental LaTeX support
30
31 As of version 1.5, an experimental latex package is available as a faster
32 alternative to unicode-math.
33 The unicode-math user interface is not replicated though: it adds nothing to
34 the plain tex version but the ⟦\setfontfam⟧ macro for loading a math font.
35 Use it like this:
36
37 {\leftskip2em
38 ⟦\usepackage {minim-mp}
39 % additional fonts can be loaded with \setfontfam
40 \textfam = 1 % for the \text command; see below
41 \setfontfam \textfam {Latin Modern Roman}
42 % the next line is also the default
43 \setfontfam 0 {Latin Modern Math} ⟧
44 \par}
45
46 Bugs are likely many at this point; reports are welcome.
47
48
49 \section Styles and alphabets
50
51 For some (mostly alphabetical) characters, multiple variants are available,
52 e.g. $\mit A \mup A \mbf A \mbfit A \mbb A \frak A \bffrak A \scr A \bfscr A$.
53 You can (locally) override the default style of these with
54 ⟦*\mathstyle {style}⟧ (equivalent to the old ⟦\bf⟧, ⟦\rm⟧ etc.)
55 or with one of the shorthands that apply the style to their argument only:
56 \smallskip\smallskip\automarktable \halign{\qquad
57 #\unskip\quad\hfil &#\unskip\quad\hfil &#\unskip\hfil\cr
58 Shorthand\quad\strut & Value of ⟦style⟧\quad\strut & Result \cr
59 ⟦*\mup⟧ & ⟦up⟧/⟦rm⟧ & $\mup {ABC}$ \cr
60 ⟦*\mit⟧ & ⟦it⟧ & $\mit {ABC}$ \cr
61 ⟦*\mbf⟧ & ⟦bf⟧ & $\mbf {ABC}$ \cr
62 ⟦*\mbfit⟧ & ⟦bfit⟧ & $\mbfit {ABC}$ \cr
63 ⟦*\mbb⟧ & ⟦bb⟧ & $\mbb {ABC}$ \cr
64 ⟦*\frak⟧ & ⟦frak⟧ & $\frak {ABC}$ \cr
65 ⟦*\bffrak⟧ & ⟦bffrak⟧ & $\bffrak {ABC}$ \cr
66 ⟦*\scr⟧ & ⟦cal⟧/⟦scr⟧ & $\scr {ABC}$ \cr
67 ⟦*\bfscr⟧ & ⟦bfscr⟧ & $\bfscr {ABC}$ \cr
68 }
69 Styles without shorthand are ⟦sans⟧/⟦sf⟧, ⟦sfit⟧, ⟦sfbf⟧, ⟦sfbfit⟧, ⟦tt⟧/⟦mono⟧
70 and finally the special value ⟦*clear⟧ for using the default style.
71 You can use the shorthands directly in sub- and superscripts: ⟦v^\scr F⟧ will
72 result in $v^\scr F$\kern-4pt.
73
74 While math families are not used anymore for switching between styles (see
75 below), you still can use ⟦\fam⟧ with the values 0, 1, 2, 4, 5, 6 or~7 for
76 doing so. This means that plain tex’s ⟦\rm⟧, ⟦\it⟧, ⟦\cal⟧, ⟦\sl⟧, ⟦\bf⟧ and
77 ⟦\tt⟧ can still be used (at least in math mode).
78
79 Please note that ⟦*\mup⟧ is not the right choice for upright multiletter
80 symbols or operators: you should use ⟦*\mord⟧ or ⟦*\mop⟧ instead (see near the
81 end of this chapter).
82 For nonmathematical text, you should use ⟦*\text⟧ instead of ⟦\mup⟧.
83
84 The default properties of characters can be set with one of the following three
85 commands:
86 \startlist
87 \tagattribute List ListNumbering /Unordered
88 \item\ignore. ⟦*\mathmap {character list} {style}⟧
89 \item\ignore. ⟦*\mathclass {character list} {class}⟧
90 \item\ignore. ⟦*\mathfam {character list} nr⟧
91 \stoplist
92 There, ⟦style⟧ is one of the above and ⟦class⟧ is the name of a class as below.
93 Finally, the ⟦character list⟧ should be a comma-separated list with elements of
94 one of the following forms:
95 \startlist
96 \tagattribute List ListNumbering /Decimal
97 {\def\⟦#1{⟦[\uppercase{#1}#1]\kern-1pt}
98 \item1. a list of characters, like ⟦abc⟧ or ⟦\partial⟧ or $ℝ$;
99 \item2. a character range, like ⟦`A-`Z⟧, ⟦65-90⟧ or ⟦"41-"5A⟧;
100 \item3. one of the alphabets \⟦latin⟧, \⟦greek⟧, or ⟦digits⟧;
101 \item4. one of the style groups ⟦bold⟧, ⟦boldgreek⟧, ⟦sans⟧, ⟦sansgreek⟧,
102 ⟦mono⟧, ⟦blackboard⟧, ⟦fraktur⟧ or ⟦script⟧;
103 \item5. the name of a math class:
104 ⟦ord⟧, ⟦op⟧, ⟦bin⟧, ⟦rel⟧, ⟦fence⟧, ⟦open⟧, ⟦close⟧ or ⟦punct⟧.
105 }\stoplist
106
107 Note that unicode is somewhat irregular in its encoding of mathematical
108 letters; this is taken into account when using ranges as under~(2) above. Thus,
109 ⟦`\mscra-`\mscrz⟧ really gives you all lowercase script characters, despite
110 e.g.~$ℯ$ being well outside that range.
111
112 The default style settings are ⟦\mathmap {latin, greek, Latin}{it}⟧.
113 Since the math family setting is not used anymore for selecting different
114 styles, the default family of every symbol is zero.
115 Instead, you can use ⟦\mathfam⟧ for mixing fonts (see below).
116 The ⟦class⟧ option to ⟦\mathclass⟧ should be one of the names under~5.
117
118
119 \section Character variants
120
121 You can change the default appearance of several greek characters with
122 ⟦*\use∥-math∥-variant {chars}⟧ or ⟦*\usemathdefault {chars}⟧, where ⟦chars⟧ is
123 a list of normal greek characters.
124 As in unicode but against tex’s tradition, the variants are
125 $\usemathvariant{εθΘκπρφ}εθΘκπρφ$ and the defaults $εθΘκπρφ$.
126 The macros ⟦*\varepsilon⟧ etc. have been updated to reflect the unicode
127 variants.
128
129 The appearance of root symbols can be set with ⟦*\closedroots⟧ ($\closedroots
130 \smash{√2}$) and ⟦*\normalroots⟧ ($\smash{√2}$, the default).
131
132 Say ⟦*\unicodedots⟧ to use the unicode dots characters ($\unicodedots…⋮⋰⋱$) and
133 ⟦*\traditionaldots⟧ to construct these characters from periods ($\smash{…⋮⋰⋱}$,
134 the default).
135 Both settings affect the meaning of both the actual characters and the ⟦\xdots⟧
136 macros ($\mathstyle{mono}x∈\{l,v,c,a,d\}$).
137 Unlike in traditional plain tex, the traditional dots are available in script
138 sizes, too.
139
140 Say ⟦*\decimalcomma⟧ and have commas appear as $\decimalcomma1,2$ instead
141 of~$1,2$ (⟦*\nodecimalcomma⟧ restores the default).
142 Say ⟦*\smartdecimalcomma⟧ for a comma that only acts as punctuation when not
143 immediately followed by a digit.
144 The explicit ⟦*\comma⟧, like ⟦*\colon⟧, will always be punctuation.
145
146 The behaviour of limits on integral signs can be set by redefining
147 ⟦*\intlimits⟧ (the default is ⟦\let \intlimits = \nolimits⟧).
148
149 If you want to change the meaning (inside math mode) altogether for a single
150 character, you can use the commands ⟦*\mathdef⟧ and ⟦*\mathlet⟧.
151 For example, by default, you can use the letter ħ for the reduced planck
152 constant~$ħ$;
153 this has been made so with ⟦*\mathdef ħ {\hbar}⟧ (you could also have said
154 ⟦\mathlet ħ \hbar⟧).
155
156
157 \section Setting up fonts
158
159 The minimum you need do to set up a mathematical font is this:
160
161 ⟦*\font\tenmath
162 {Latin Modern Math:mode=base;script=math;ssty=0;} at 10pt
163 \font\tenmaths
164 {Latin Modern Math:mode=base;script=math;ssty=1;} at 7pt
165 \font\tenmathss
166 {Latin Modern Math:mode=base;script=math;ssty=2;} at 5pt
167 \textfont 0 = \tenmath
168 \scriptfont 0 = \tenmaths
169 \scriptscriptfont 0 = \tenmathss⟧
170
171 Note that you only have to set up the font for a single family: opentype
172 mathematical fonts typically contain all necessary variants of all mathematical
173 characters.
174 Therefore, the ⟦*\fam⟧ setting has been made a no-op (use ⟦*\setfam⟧ if you
175 really need the old primitive) and the default family of all symbols has been
176 set to zero.
177
178 As mentioned above, you can still change the family number of specific
179 characters and this allows you to mix mathematical fonts. For instance, if you
180 dislike the current blackboard bold characters, just assign a second font to
181 family
182 1 and say ⟦\mathfam {blackboard} 1⟧. Less useful are the parameters
183 ⟦*\accentfam⟧, ⟦*\radicalfam⟧ and ⟦*\extensiblefam⟧ that control the family of
184 all accents, radicals and extensibles.
185
186 Do note that various spacing constants are set according to the \emph{last}
187 math family that is assigned to. Therefore, you should assign your main math
188 font to a family after all others.
189
190 You can use ⟦*\text⟧ for adding nonmathematical text to your equations.
191 It will behave well in sub- and superscripts:
192 ⟦\text{word}^\text{word}⟧ gives $\smash{\text{word}^\text{word}}$.
193 By default, the font used is the normal mathematical font. You can change this
194 by setting the ⟦*\textfam⟧ parameter to some nonzero value and assigning
195 a different font to that family.
196 You probably want this, since most commonly-used mathematical fonts do not
197 include a normal kerning table.
198
199 \section Shorthands and additions
200
201 All the usual arrows can be made extensible by prefacing them with an ⟦x⟧,
202 including ⟦\xmapsto⟧ and ⟦\xmapsfrom⟧. Alternatively, you can use ⟦\→⟧ etc. as
203 shorthands. Additionally, you can use the following:
204
205 {\smallskip\smallskip\automarktable \halign{\qquad
206 \vrule width0pt depth 9pt#\unskip\hfil
207 &&\qquad#\unskip\hfil\cr
208 Shorthand & Result \cr
209 ⟦\bra x, \ket y⟧ & $\bra x, \ket y$ \cr
210 ⟦\braket x y⟧ & $\braket x y$ \cr
211 ⟦\norm x, \Norm x⟧ & $\norm x, \Norm x$ \cr
212 ⟦\floor x, \ceil x⟧ & $\floor x, \ceil x$ \cr
213 ⟦x \stackrel ?= y⟧ & $x \stackrel ?= y$ \cr
214 ⟦x \stackbin a+ y⟧ & $x \stackbin a+ y$ \cr
215 ⟦f\inv⟧ & $f\inv$ \quad (cf. $f^{-1}$) \cr
216 ⟦a \xrightarrow[down]{up} b⟧ & $a \xrightarrow[down]{up} b$ \cr
217 ⟦a \xeq[down]{up} b⟧ & $a \xeq[down]{up} b$ \cr
218 ⟦\frac12, \tfrac12, \dfrac12⟧& $\frac12, \tfrac12, \dfrac12$\cr
219 }\smallskip}
220
221 Also new are the operators
222 ⟦\Tr⟧, ⟦\tr⟧, ⟦\Span⟧, ⟦\GL⟧, ⟦\SL⟧, ⟦\SU⟧, ⟦\U⟧, ⟦\SO⟧, ⟦\O⟧,
223 ⟦\Sp⟧, ⟦\im⟧, ⟦\End⟧, ⟦\Aut⟧, ⟦\Dom⟧ and ⟦\Codom⟧.
224 You can define new operators with ⟦*\newmathop⟧ and ⟦*\newlargemathop⟧:
225 ⟦\newmathop{op}⟧ will define the new operator ⟦\op⟧.
226 For single use of an upright symbol, operator or large operator you can use
227 ⟦*\mord⟧, ⟦*\mop⟧ and ⟦*\mlop⟧.
228 The difference between ⟦\mord⟧ and ⟦\mup⟧ is that ⟦\mord⟧ also applies the
229 correct symbol spacing.
230
231 The accents ⟦\overbrace⟧, ⟦\underbracket⟧ etc. allow a label between square
232 brackets:
233 ⟦$$\underbrace[=1]{(x^2+∥penalty0y^2)}$$⟧ gives
234 $$\underbrace[=1]{(x^2 + y^2)}.$$
235
236 Finally, for plain tex only, the following (entirely optional) alternative to
237 using dollar signs is provided, which also offers slight improvements in the
238 spacing of displayed equations:
239 \stopformulatagging\Ustartdisplaymath
240 \halign{# \hfil&#\quad&#\hfil\cr
241 &⟦\[ ... \]⟧&inline mathematics\cr
242 ⟦\display⟧&⟦\[ ... \]⟧&display mathematics\cr
243 ⟦\displaynr {nr}⟧&⟦\[ ... \]⟧&numbered display mathematics\cr
244 ⟦\displaynr⟧&⟦\[ ... \]⟧&automatically numbered display mathematics\cr
245 }\Ustopdisplaymath\startformulatagging
246
247 The automatic display numbering uses the count ⟦\equationnumber⟧ and the token
248 list ⟦\setequationnumber⟧ internally. All displays created this way can be made
249 left-aligned by saying ⟦\leftdisplaystrue⟧. In that case, the displays are
250 offset from the margin by ⟦\leftdisplayindent⟧ (a muskip, default value~⟦0mu⟧).
251
252 \section Best practices
253
254 The following remarks on mathematical typesetting have no relation to the
255 contents of this package; I have included them because I find them hard to
256 remember.
257
258 \startlist
259 \tagattribute List ListNumbering /Decimal
260 \item1. ⟦*\eqalign⟧ gives a vertically centered box and can occur many times in
261 an equation, while ⟦*\eqalignno⟧ and ⟦*\leqalignno⟧ span whole lines (put the
262 equation numbers in the third column). All assume the relation (or operator)
263 appears at the right hand side of the ampsersand.
264 \item2. The command ⟦*\displaylines⟧ can only have one column that spans the
265 whole line (and you will have to add the equation number by hand).
266 \item3. Further alignment commands are ⟦*\cases⟧, ⟦*\matrix⟧, ⟦*\pmatrix⟧ (with
267 parentheses) and ⟦*\bordermatrix⟧ (includes labels for lines and columns).
268 \item4. Finetuning alignments can be done with ⟦*\smash⟧, ⟦*\phantom⟧,
269 ⟦*\hphantom⟧ and ⟦*\vphantom⟧.
270 \item5. Small matrices like $1\;2\choose3\;4$ can be made by misusing
271 ⟦*\choose⟧ or ⟦*\atop⟧.
272 \item6. If you start a line with a binary operator, put a ⟦*{}⟧ before it: this
273 way, tex recognises it as such.
274 \item7. Thin spaces (⟦*\,⟧) should be inserted: before $\mup dx$, before units,
275 after factorials and after ⟦*\dots⟧ if those are followed by a closing
276 parenthesis.
277 \item8. Whether the differential operator should be set upright or not is as of
278 yet an open question in mathematics.
279 \item9. You should prefer ⟦*\bigr⟧ and ⟦*\bigl⟧ etc. over ⟦\big⟧, ⟦\Big⟧,
280 ⟦\bigg⟧ and ⟦\Bigg⟧.
281 \item10. An overview of mathematical symbols, with control sequences and their
282 availability in different fonts, can be found in ⟦*unimath-symbols.pdf⟧, which
283 is part of the unicode-math package.
284 \stoplist
285
286 \endmanual
287
288