Debian Codegraph @

texmf-dist/doc/latex/semantex/semantex.tex

raw
1 \documentclass[a4paper,oneside,english,10pt]{memoir}
2
3 \makeatletter
4
5 \usepackage[utf8]{inputenc}
6 \usepackage[T1]{fontenc}
7 \usepackage{babel}
8 \usepackage[noDcommand,slantedGreeks]{kpfonts}
9
10 \frenchspacing
11
12 \usepackage{mathtools,etoolbox, microtype,color}
13
14 \usepackage[shortlabels]{enumitem}%control lists
15
16 \usepackage[draft]{fixme}
17
18 %Setup of memoir:
19 \pagestyle{plain} %change to heading for running headings
20 \nouppercaseheads %running heads should not be capitalized
21 \captionnamefont{\small} %captions with small font
22 \captiontitlefont{\small}
23 \makeevenhead{headings}{\thepage}{}{\itshape\leftmark} %make headings italic instead of slanted (though we do not use headings right now)
24 \makeoddhead{headings}{\itshape\rightmark}{}{\thepage}
25
26 \setlrmarginsandblock{4cm}{*}{*}
27 \setulmarginsandblock{4cm}{*}{*}
28 \checkandfixthelayout
29
30 \raggedbottomsectiontrue%less harse than \raggedbottom
31 %\allowdisplaybreaks %long equations may break
32
33 \g@addto@macro\bfseries{\boldmath} %make math in bold text automatically bold
34
35 \usepackage[english=american]{csquotes}
36
37 \usepackage[hidelinks]{hyperref}
38 %\newcommand\hypersetup[1]{}
39 %\newcommand\href[2]{\texttt{#2}}
40 %\newcommand\url[1]{\texttt{#1}}
41 %\newcommand\texorpdfstring[2]{#1}
42
43 \usepackage[nameinlink]{cleveref}
44
45 \usepackage{showexpl}
46
47 \lstset{%
48 language=[LaTeX]TeX,
49 basicstyle=\ttfamily\small,
50 commentstyle=\itshape\ttfamily\small,
51 alsoletter={\\},
52 escapechar=@,
53 breaklines=true,
54 breakindent={0pt},
55 captionpos=t,
56 pos=r,
57 tabsize=2,
58 %inputencoding=utf8,
59 explpreset={numbers=none,},
60 texcl=false,
61 wide=false,
62 width=.45\textwidth,
63 }
64
65 \newcommand\mylst{\lstinline[mathescape]}
66
67 \let\at=@
68
69 \def\<#1\>{\textrm{\textlangle\textit{#1}\textrangle}}
70
71 \def\usercommand\<#1\>{\textrm{\textbackslash\textlangle\textit{#1}\textrangle}}
72
73 \def\values\<#1\>{\textrm{\textlangle\textup{#1}\textrangle}}
74
75 \def\num#1{\textsubscript{\textup{#1}}}
76
77 \newcommand\default[1]{\smash{\underline{\smash{#1}}}}
78
79 \newcommand\commandname[1]{\textbackslash\texttt{#1}}
80
81 \let\pack=\texttt
82
83 \newcommand\semantex{Seman\!\TeX}
84
85 \newcommand\stripsemantex{\texttt{stripsemantex}}
86
87 \usepackage{hologo}
88
89 % Setting up SemanTeX:
90
91 \usepackage{semantex}
92
93 \title{Seman\!\TeX: semantic, keyval-based mathematics (v\SemantexVersion)}
94 \date{\today}
95 \author{Sebastian Ørsted (\href{mailto:[email protected]}{[email protected]})}
96
97 \hypersetup{
98 pdfauthor={Sebastian Ørsted},
99 pdftitle={SemanTeX: semantic, keyval-based mathematics (v\SemantexVersion)},
100 %pdfsubject={},
101 %pdfkeywords={},
102 %pdfproducer={Latex with hyperref, or other system},
103 %pdfcreator={pdflatex, or other tool},
104 }
105
106 \SemantexSetup{
107 semtex file=true,
108 }
109
110 \usepackage{expkv}
111
112 \NewVariableClass\MyVar[
113 output=\MyVar,
114 ]
115
116 \NewObject\MyVar\va{a}
117 \NewObject\MyVar\vb{b}
118 \NewObject\MyVar\vc{c}
119 \NewObject\MyVar\vd{d}
120 \NewObject\MyVar\ve{e}
121 \NewObject\MyVar\vf{f}
122 \NewObject\MyVar\vg{g}
123 \NewObject\MyVar\vh{h}
124 \NewObject\MyVar\vi{i}
125 \NewObject\MyVar\vj{j}
126 \NewObject\MyVar\vk{k}
127 \NewObject\MyVar\vl{l}
128 \NewObject\MyVar\vm{m}
129 \NewObject\MyVar\vn{n}
130 \NewObject\MyVar\vo{o}
131 \NewObject\MyVar\vp{p}
132 \NewObject\MyVar\vq{q}
133 \NewObject\MyVar\vr{r}
134 \NewObject\MyVar\vs{s}
135 \NewObject\MyVar\vt{t}
136 \NewObject\MyVar\vu{u}
137 \NewObject\MyVar\vv{v}
138 \NewObject\MyVar\vw{w}
139 \NewObject\MyVar\vx{x}
140 \NewObject\MyVar\vy{y}
141 \NewObject\MyVar\vz{z}
142
143 \NewObject\MyVar\vA{A}
144 \NewObject\MyVar\vB{B}
145 \NewObject\MyVar\vC{C}
146 \NewObject\MyVar\vD{D}
147 \NewObject\MyVar\vE{E}
148 \NewObject\MyVar\vF{F}
149 \NewObject\MyVar\vG{G}
150 \NewObject\MyVar\vH{H}
151 \NewObject\MyVar\vI{I}
152 \NewObject\MyVar\vJ{J}
153 \NewObject\MyVar\vK{K}
154 \NewObject\MyVar\vL{L}
155 \NewObject\MyVar\vM{M}
156 \NewObject\MyVar\vN{N}
157 \NewObject\MyVar\vO{O}
158 \NewObject\MyVar\vP{P}
159 \NewObject\MyVar\vQ{Q}
160 \NewObject\MyVar\vR{R}
161 \NewObject\MyVar\vS{S}
162 \NewObject\MyVar\vT{T}
163 \NewObject\MyVar\vU{U}
164 \NewObject\MyVar\vV{V}
165 \NewObject\MyVar\vW{W}
166 \NewObject\MyVar\vX{X}
167 \NewObject\MyVar\vY{Y}
168 \NewObject\MyVar\vZ{Z}
169
170 \NewObject\MyVar\valpha{\alpha}
171 \NewObject\MyVar\vvaralpha{\varalpha}
172 \NewObject\MyVar\vbeta{\beta}
173 \NewObject\MyVar\vgamma{\gamma}
174 \NewObject\MyVar\vdelta{\delta}
175 \NewObject\MyVar\vepsilon{\epsilon}
176 \NewObject\MyVar\vvarepsilon{\varepsilon}
177 \NewObject\MyVar\vzeta{\zeta}
178 \NewObject\MyVar\veta{\eta}
179 \NewObject\MyVar\vtheta{\theta}
180 \NewObject\MyVar\viota{\iota}
181 \NewObject\MyVar\vkappa{\kappa}
182 \NewObject\MyVar\vlambda{\lambda}
183 \NewObject\MyVar\vmu{\mu}
184 \NewObject\MyVar\vnu{\nu}
185 \NewObject\MyVar\vxi{\xi}
186 \NewObject\MyVar\vpi{\pi}
187 \NewObject\MyVar\vvarpi{\varpi}
188 \NewObject\MyVar\vrho{\rho}
189 \NewObject\MyVar\vsigma{\sigma}
190 \NewObject\MyVar\vtau{\tau}
191 \NewObject\MyVar\vupsilon{\upsilon}
192 \NewObject\MyVar\vphi{\phi}
193 \NewObject\MyVar\vvarphi{\varphi}
194 \NewObject\MyVar\vchi{\chi}
195 \NewObject\MyVar\vpsi{\psi}
196 \NewObject\MyVar\vomega{\omega}
197
198 \NewObject\MyVar\vGamma{\Gamma}
199 \NewObject\MyVar\vDelta{\Delta}
200 \NewObject\MyVar\vTheta{\Theta}
201 \NewObject\MyVar\vLambda{\Lambda}
202 \NewObject\MyVar\vXi{\Xi}
203 \NewObject\MyVar\vPi{\Pi}
204 \NewObject\MyVar\vSigma{\Sigma}
205 \NewObject\MyVar\vUpsilon{\Upsilon}
206 \NewObject\MyVar\vPhi{\Phi}
207 \NewObject\MyVar\vPsi{\Psi}
208 \NewObject\MyVar\vOmega{\Omega}
209
210 \NewObject\MyVar\sheafF{\mathcal{F}}
211 \NewObject\MyVar\sheafG{\mathcal{G}}
212 \NewObject\MyVar\sheafreg{\mathcal{O}}
213 \NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}}
214
215 \NewObject\MyVar\Hom{\operatorname{Hom}}
216
217 \NewObject\MyVar\co{H}[grading position=upper]
218
219 \NewObject\MyVar\ho{H}[grading position=lower]
220
221 \makeatother
222
223 \begin{document}
224
225 \maketitle
226
227 \noindent
228 The \semantex{} package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the classical math syntax in~\LaTeX.
229 The system uses keyval syntax, and the user can define their own keys and customize the system down to the last detail. At the same time, care has been taken to make the syntax as simple, natural, practical, and lightweight as possible.
230
231 Furthermore, the package has a companion package,
232 called \stripsemantex, which allows you to completely strip
233 your documents of \semantex{} markup to prepare them e.g.~for publication.
234
235 The package is still in beta, but is considered feature-complete
236 and more or less stable, so using it at this point should be safe.
237 Still, suggestions, ideas, and bug reports are more than welcome!
238
239 \setlength\cftsectionnumwidth{3em}
240
241 \pagebreak
242
243 \tableofcontents*
244
245 \pagebreak
246
247 \chapter{Introduction}
248
249 \begingroup
250 \SetupClass\MyVar{
251 define keys={
252 {conj}{command=\overline},
253 {inv}{upper={-1}},
254 {inverse image}{upper={-1},no par},
255 },
256 define keys[1]={
257 {der}{upper={ (#1) } },
258 {res}{ right return, symbol put right={|}, lower={#1} },
259 {stalk}{sep lower={#1}},
260 % "sep lower" means "separator + lower", i.e. lower index
261 % separated from any previous lower index by a separator,
262 % which by default is a comma
263 },
264 }
265
266
267 Let us take an example from elementary analysis
268 to demonstrate the idea of the package:
269 Suppose we want to take the complex conjugate of a function~\( \vf \)
270 and then derive it \( \vn \)~times, i.e.~take~\( \smash{ \vf[conj,der=\vn] } \).
271 \semantex{} allows you to typeset this something like this:
272 \begin{LTXexample}
273 $ \vf[conj,der=\vn] $
274 \end{LTXexample}
275 I shall explain the syntax in detail below, but some immediate comments are in order: First and foremost, the~\lstinline!v!
276 in the command names \lstinline!\vf! and~\lstinline!\vn! stands for~\enquote{variable}, so these commands are the
277 variables \( \vf \) and~\( \vn \).
278 In \semantex, it is usually best to create
279 commands \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!, \ldots
280 for each variable you are using, upper- and lowercase.
281 However, it is completely up to the user how to do that and what to call them.
282 Note also that all of the keys
283 \lstinline!inv!,~\lstinline!res!,~etc.\ are defined by the
284 \emph{user}, and they can be modified and adjusted for all sorts of situations in any kinds of mathematics.
285 In other words, for the most part, you get to choose your own syntax.
286
287 Next, suppose we want to invert a function~\( \vg \) and restrict it to a subset~\( \vU \), and then apply it to~\( \vx \),
288 i.e.~take~\( \vg[inv,res=\vU]{\vx} \). This can be done by writing
289 \begin{LTXexample}
290 $ \vg[inv,res=\vU]{\vx} $
291 \end{LTXexample}
292
293 Next, let us take an example from algebraic geometry:
294 Suppose \( \sheafF \)~is a sheaf and \( \vh \)~a~map,
295 and that we want to typeset the
296 equation~\( \smash{
297 \vh[inverse image]{\sheafF}[spar,
298 stalk=\vp]
299 =
300 \sheafF[stalk=\vh{\vp}]
301 } \),
302 saying that the stalk of the inverse image~\( \vh[inverse image]{\sheafF} \)
303 at the point~\( \vp \) is~\( \smash{ \sheafF[stalk=\vh{\vp}] } \).
304 This can be accomplished by typing
305 \begin{LTXexample}
306 $ \vh[inverse image]{\sheafF}[spar,stalk=\vp]
307 =
308 \sheafF[stalk=\vh{\vp}] $
309 \end{LTXexample}
310 Here, \lstinline!spar! (an abbreviation for~\enquote{symbol parentheses})
311 is the key that adds the parentheses around~\( \vh[inverse image]{\sheafF} \).
312
313 Let us see how you could set up all the above notation:
314
315 \newpage
316
317 \begin{lstlisting}
318 \documentclass{article}
319
320 \usepackage{amsmath,semantex}
321
322 \NewVariableClass\MyVar % creates a new class of variables,
323 % called "\MyVar"
324
325 % Now we create a couple of variables of the class \MyVar:
326 \NewObject\MyVar\vf{f}
327 \NewObject\MyVar\vg{g}
328 \NewObject\MyVar\vh{h}
329 \NewObject\MyVar\vn{n}
330 \NewObject\MyVar\vp{p}
331 \NewObject\MyVar\vU{U}
332 \NewObject\MyVar\vx{x}
333 \NewObject\MyVar\sheafF{\mathcal{F}}
334
335 % Now we set up the class \MyVar:
336 \SetupClass\MyVar{
337 output=\MyVar, % This means that the output of an object
338 % of class \MyVar is also of class \MyVar
339 % We add a few keys for use with the class \MyVar:
340 define keys={ % we define a few keys
341 {inv}{upper={-1}},
342 {conj}{command=\overline}, % Applies \overline to the symbol
343 {inverse image}{upper={-1},no par},
344 },
345 define keys[1]={ % we define keys taking 1 value
346 {der}{upper={(#1)}},
347 {stalk}{sep lower={#1}},
348 % "sep lower" means "separator + lower", i.e. lower index
349 % separated from any previous lower index by a separator,
350 % which by default is a comma
351 {res}{ right return, symbol put right={|}, lower={#1} },
352 },
353 }
354
355 \begin{document}
356
357 $ \vf[conj,der=\vn] $
358
359 $ \vg[inv,res=\vU]{\vx} $
360
361 $ \vh[inverse image]{\sheafF}[spar,stalk=\vp]
362 = \sheafF[stalk=\vh{\vp}] $
363
364 \end{document}
365 \end{lstlisting}
366 \endgroup
367
368 \chapter{Getting started}
369
370 To get started using \semantex, load down the package
371 with
372 \begin{lstlisting}
373 \usepackage{semantex}
374 \end{lstlisting}
375 The \semantex{} system is object-oriented; all entities are objects of some class. When you load the package, there
376 is only one class by default, which is simply called \lstinline!\SemantexBaseObject!.
377 You should think of this as a low-level class, the parent of all other classes. Therefore, I highly advice against using it directly or modifying it.
378 Instead, we create a new, more high-level variable class.
379 We choose to call it \lstinline!\MyVar!.
380 It is best to always start class names with uppercase letters to separate them from objects.
381 We could create this class by writing \lstinline!\NewVariableClass\MyVar!, but we choose to
382 pass some options to it in~\lstinline![...]!:
383 \begin{lstlisting}
384 \NewVariableClass\MyVar[output=\MyVar]
385 \end{lstlisting}
386 This \lstinline!output=\MyVar! option will be explained better below.
387 Roughly speaking, it tells \semantex{} that everything
388 a variable \emph{outputs} will also be a variable.
389 For instance, if the function~\lstinline!\vf! (i.e.~\( \vf \)) is of class~\lstinline!\MyVar!,
390 then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also be of class~\lstinline!\MyVar!.
391
392 Now we have a class, but we do not have any objects.
393 To create the object~\lstinline!\vf! of class~\lstinline!\MyVar! with symbol~\( f \),
394 we write~\lstinline!\NewObject\MyVar\vf{f}!.
395 In general, when you have class~\usercommand\<Class\>, you
396 can create objects of that class wtih the syntax
397 \begin{lstlisting}
398 \NewObject@\usercommand\<Class\>\usercommand\<object\>@{@\<object symbol\>@}[@\<options\>@]
399 \end{lstlisting}
400 To distinguish objects from classes, it is a good idea to denote
401 objects by lowercase letters.\footnote{We shall not follow this convention strictly, as we shall later create objects with names like~\commandname{Hom}; using lowercase letters for these would just look weird.}
402 So after writing,
403 \begin{lstlisting}
404 \NewObject\MyVar\vf{f}
405 \NewObject\MyVar\vx{x}
406 \end{lstlisting}
407 we get two variables \lstinline!\vf! and~\lstinline!\vx! with symbols \( f \) resp.~\( x \).
408 Let us perform a stupid test to see if the variables work:
409 \begin{LTXexample}
410 $\vf$, $\vx$
411 \end{LTXexample}
412 Th general syntax of a variable-type object is
413 \begin{lstlisting}
414 @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@}
415 \end{lstlisting}
416 Both \<options\> and \<argument\> are optional
417 arguments (they can be left out if you do not need them).
418 The \<options\> should consist of a list of options separated by commas, using keyval syntax. Naturally, \<argument\> is the actual argument of the function.
419
420 By a design choice, \semantex{} does not distinguish between variables and functions, so all variables can take arguments.
421 This makes the system easier to use; after all, it is fairly common in mathematics that something is first a variable and then a moment later takes an argument.
422 So we may write:
423 \begin{LTXexample}
424 $\vf{1}$, $\vf{\vx}$,
425 $\vx{\vx}$
426 \end{LTXexample}
427
428 So far, we do not have very many options to write in the
429 \<options\> position, since we have not added any keys yet. However, we do have access
430 to the most important of all options: the \emph{index}.
431 There is a simple shortcut for writing an index: You simply write the index itself in the options tag:
432 \begin{LTXexample}
433 $\vf[1]$, $\vf[\vf]$,
434 $\vf[1,2,\vf]{2}$
435 \end{LTXexample}
436 As long as what you write in the options tag is not recognized as a defined key, it will be printed as the index.
437 Other than that, there are two important predefined keys: \lstinline!upper! and \lstinline!lower! which simply add something to the upper and lower index:
438 \begin{LTXexample}
439 $\vf[upper=2]$,
440 $\vf[lower=3]$
441 \end{LTXexample}
442
443 In fact, there are quite a few keys for manipulating upper and lower indices.
444 Right now, apart from \lstinline!upper! and~\lstinline!lower!,
445 we shall only need a couple more:
446 \lstinline!sep upper! and~\lstinline!sep lower! mean
447 \enquote{separator~+~upper} and \enquote{separator~+~lower}.
448 These are like \lstinline!upper! and~\lstinline!lower!,
449 but if there already was an upper or lower index,
450 the new index will be separated from the old one by a separator.
451 By default, this separator is a comma.
452 There are also two more commands,
453 \lstinline!comma upper! and~\lstinline!comma lower!.
454 These will use a comma as separator, even if you have changed the
455 default separator.
456
457 \newpage
458
459 \section{Next step: Defining more variables}
460
461 We are soon going to need more variables
462 than just \( \vf \) and~\( \vx \).
463 In fact, I advise you to create a variable for each letter in the Latin and Greek alphabets, both uppercase and lowercase.
464 This is pretty time-consuming, so I did it for you already:
465 \begin{lstlisting}
466 \NewObject\MyVar\va{a}
467 \NewObject\MyVar\vb{b}
468 \NewObject\MyVar\vc{c}
469 \NewObject\MyVar\vd{d}
470 \NewObject\MyVar\ve{e}
471 \NewObject\MyVar\vf{f}
472 \NewObject\MyVar\vg{g}
473 \NewObject\MyVar\vh{h}
474 \NewObject\MyVar\vi{i}
475 \NewObject\MyVar\vj{j}
476 \NewObject\MyVar\vk{k}
477 \NewObject\MyVar\vl{l}
478 \NewObject\MyVar\vm{m}
479 \NewObject\MyVar\vn{n}
480 \NewObject\MyVar\vo{o}
481 \NewObject\MyVar\vp{p}
482 \NewObject\MyVar\vq{q}
483 \NewObject\MyVar\vr{r}
484 \NewObject\MyVar\vs{s}
485 \NewObject\MyVar\vt{t}
486 \NewObject\MyVar\vu{u}
487 \NewObject\MyVar\vv{v}
488 \NewObject\MyVar\vw{w}
489 \NewObject\MyVar\vx{x}
490 \NewObject\MyVar\vy{y}
491 \NewObject\MyVar\vz{z}
492
493 \NewObject\MyVar\vA{A}
494 \NewObject\MyVar\vB{B}
495 \NewObject\MyVar\vC{C}
496 \NewObject\MyVar\vD{D}
497 \NewObject\MyVar\vE{E}
498 \NewObject\MyVar\vF{F}
499 \NewObject\MyVar\vG{G}
500 \NewObject\MyVar\vH{H}
501 \NewObject\MyVar\vI{I}
502 \NewObject\MyVar\vJ{J}
503 \NewObject\MyVar\vK{K}
504 \NewObject\MyVar\vL{L}
505 \NewObject\MyVar\vM{M}
506 \NewObject\MyVar\vN{N}
507 \NewObject\MyVar\vO{O}
508 \NewObject\MyVar\vP{P}
509 \NewObject\MyVar\vQ{Q}
510 \NewObject\MyVar\vR{R}
511 \NewObject\MyVar\vS{S}
512 \NewObject\MyVar\vT{T}
513 \NewObject\MyVar\vU{U}
514 \NewObject\MyVar\vV{V}
515 \NewObject\MyVar\vW{W}
516 \NewObject\MyVar\vX{X}
517 \NewObject\MyVar\vY{Y}
518 \NewObject\MyVar\vZ{Z}
519
520 \NewObject\MyVar\valpha{\alpha}
521 \NewObject\MyVar\vvaralpha{\varalpha}
522 \NewObject\MyVar\vbeta{\beta}
523 \NewObject\MyVar\vgamma{\gamma}
524 \NewObject\MyVar\vdelta{\delta}
525 \NewObject\MyVar\vepsilon{\epsilon}
526 \NewObject\MyVar\vvarepsilon{\varepsilon}
527 \NewObject\MyVar\vzeta{\zeta}
528 \NewObject\MyVar\veta{\eta}
529 \NewObject\MyVar\vtheta{\theta}
530 \NewObject\MyVar\viota{\iota}
531 \NewObject\MyVar\vkappa{\kappa}
532 \NewObject\MyVar\vlambda{\lambda}
533 \NewObject\MyVar\vmu{\mu}
534 \NewObject\MyVar\vnu{\nu}
535 \NewObject\MyVar\vxi{\xi}
536 \NewObject\MyVar\vpi{\pi}
537 \NewObject\MyVar\vvarpi{\varpi}
538 \NewObject\MyVar\vrho{\rho}
539 \NewObject\MyVar\vsigma{\sigma}
540 \NewObject\MyVar\vtau{\tau}
541 \NewObject\MyVar\vupsilon{\upsilon}
542 \NewObject\MyVar\vphi{\phi}
543 \NewObject\MyVar\vvarphi{\varphi}
544 \NewObject\MyVar\vchi{\chi}
545 \NewObject\MyVar\vpsi{\psi}
546 \NewObject\MyVar\vomega{\omega}
547
548 \NewObject\MyVar\vGamma{\Gamma}
549 \NewObject\MyVar\vDelta{\Delta}
550 \NewObject\MyVar\vTheta{\Theta}
551 \NewObject\MyVar\vLambda{\Lambda}
552 \NewObject\MyVar\vXi{\Xi}
553 \NewObject\MyVar\vPi{\Pi}
554 \NewObject\MyVar\vSigma{\Sigma}
555 \NewObject\MyVar\vUpsilon{\Upsilon}
556 \NewObject\MyVar\vPhi{\Phi}
557 \NewObject\MyVar\vPsi{\Psi}
558 \NewObject\MyVar\vOmega{\Omega}
559 \end{lstlisting}
560
561 Just like~\lstinline!\vf!, these can all be regarded as functions, so~\lstinline!\va{\vb}!~produces~\( \va{\vb} \).
562 Importantly,
563 \textbf{parentheses can be scaled}.
564 To make parentheses bigger, use the following keys:
565 \begin{LTXexample}
566 $\vf{\vx}$,
567 $\vf[par=\big]{\vx}$,
568 $\vf[par=\Big]{\vx}$,
569 $\vf[par=\bigg]{\vx}$,
570 $\vf[par=\Bigg]{\vx}$,
571 $\vf[par=auto]{\frac{1}{2}}$
572 \end{LTXexample}
573 Using \lstinline!par=auto! corresponds to using \lstinline!\left ...\right!. Just as for ordinary math, I advice you to use manual scaling rather than automatic scaling, as \TeX\ has a tendency to scale things wrong. If you do not want parentheses at all, you can pass the key~\mbox{\lstinline!no par!} (it will still print parentheses if there is more than one argument, though; to exclude this behaviour, run~\lstinline!never par! instead):
574 \begin{LTXexample}
575 $\vf[no par]{\vx}$,
576 $\vf[no par]{\vx,\vy}$,
577 $\vf[never par]{\vx}$,
578 $\vf[never par]{\vx,\vy}$
579 \end{LTXexample}
580 Primes are added via the key~\lstinline!prime!
581 or the keys~\lstinline!'!,~\lstinline!''! and~\lstinline!'''!:
582 \begin{LTXexample}
583 $\vf['] = \vf[prime]$,
584 $\vf[''] = \vf[prime,prime]$,
585 $\vf['''] = \vf[prime,prime,prime]$
586 \end{LTXexample}
587
588 \begingroup\color{red}%
589 For the rest of the manual, we assume that you have already defined a class~\lstinline!\MyVar! and the variables~\lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!, \ldots, as above.
590 \endgroup
591
592 \section{Defining keys}
593
594 So far, so good, but our variables cannot really do anything yet. For this, we need to assign \emph{keys} to them. The more pieces of math notation you need, the more keys you will have to define.
595 To define keys, we use the command~\lstinline!\SetupClass!
596 (or~\lstinline!\SetupObject! if you want to define it for an individual object)
597 and the key~\lstinline!define keys!.
598 The syntax is as follows:
599 \begin{lstlisting}
600 \SetupClass\MyVar{
601 define keys={
602 {@\<key name\num{1}\>@}{ @\<keys to run\>@ },
603 {@\<key name\num{2}\>@}{ @\<keys to run\>@ },
604 {@\<key name\num{3}\>@}{ @\<keys to run\>@ },
605 @\ldots,@
606 },
607 }
608 \end{lstlisting}
609 For instance, you can do
610 \begin{lstlisting}
611 \SetupClass\MyVar{
612 define keys={
613 {key1}{ upper=3, lower=7 },
614 {key2}{ lower=6, upper=4 },
615 },
616 }
617 \end{lstlisting}
618
619 Quite often, we shall also need to define
620 keys that can \emph{take a value}.
621 A key can take up to~\( 8 \)~values (for technical reasons, \( 9 \)~values are not allowed).
622 To define a key taking \( n \)~values,
623 use~\mylst!define keys[$n$]!
624 for~\( n = 0 , 1 , 2 , \ldots , 8 \).
625 The syntax is similar to~\lstinline!define keys!,
626 except the values can be accessed
627 by writing~\lstinline!#1!, \lstinline!#2!, \ldots, \lstinline!#8!.
628 Except for a few special cases, you will probably only
629 ever need~\lstinline!define keys[1]!. So you can do
630 \begin{lstlisting}
631 \SetupClass\MyVar{
632 define keys[1]={
633 {key3}{ upper=\{#1\} },
634 {key4}{ lower=(#1) },
635 },
636 define keys[2]={
637 {key5}{ upper=3+#1, lower=7-#2 },
638 {key6}{ lower=6\cdot#1, upper=4/#2 },
639 },
640 }
641 \end{lstlisting}
642 \begingroup
643 \SetupClass\MyVar{
644 define keys={
645 {key1}{ upper=3, sep lower=7 },
646 {key2}{ lower=6, sep upper=4 },
647 },
648 define keys[1]={
649 {key3}{ sep upper=\{#1\} },
650 {key4}{ sep lower=(#1) },
651 },
652 define keys[2]={
653 {key5}{ sep upper=3+#1, sep lower=7-#2 },
654 {key6}{ sep lower=6\cdot#1, sep upper=4/#2 },
655 },
656 }
657 Let us see these rather ridiculous keys in action:
658
659 \begin{LTXexample}
660 $ \vP[key1,key3=0,key5={3}{4}] $
661 \end{LTXexample}
662
663 \endgroup
664
665 \chapter{Some examples}
666
667 \section{Example: Elementary calculus}
668
669 One thing we might want to do to a variable
670 is \emph{invert} it. We therefore add a key~\lstinline!inv!
671 that adds an upper index~\lstinline!-1! to the symbol.
672 We add this key using the key \lstinline!define keys!
673 since there is no reason for this key to take a value:
674 \begin{lstlisting}
675 \SetupClass\MyVar{
676 define keys={
677 {inv}{ upper={-1} },
678 },
679 }
680 \end{lstlisting}
681 \SetupClass\MyVar{
682 define keys={
683 {inv}{ upper={-1} },
684 },
685 }
686 Now the key \lstinline!inv!
687 has been defined to be equivalent to \lstinline!upper={-1}!.
688 Now we can do the following:
689 \begin{LTXexample}
690 $\va[inv]$, $\vf[inv]$,
691 $\vg[1,2,inv]$,
692 $\vh[\va,\vb,inv]$
693 \end{LTXexample}
694
695 Other keys might need to take one value.
696 For defining these, we use a different key, \lstinline!define keys[1]!.
697 For instance, suppose we want a command for deriving a function \( n \)~times.
698 For this, we add the key~\lstinline!der!:
699 \begin{lstlisting}
700 \SetupClass\MyVar{
701 define keys={
702 {inv}{ upper={-1} },
703 },
704 define keys[1]={
705 {der}{ upper={(#1)} },
706 },
707 }
708 \end{lstlisting}
709 \SetupClass\MyVar{
710 define keys[1]={
711 {der}{ upper={(#1)} },
712 },
713 }
714 The~\lstinline!#1! will contain whatever the
715 user wrote as the value of the key.
716 Now we can write:
717 \begin{LTXexample}
718 $\vf[der=\vn]{\vx}$
719 \end{LTXexample}
720 Maybe we also want a more elementary key~\lstinline!power! for raising a variable to a power:
721 \begin{lstlisting}
722 \SetupClass\MyVar{
723 define keys={
724 {inv}{ upper={-1} },
725 },
726 define keys[1]={
727 {der}{ upper={(#1)} },
728 {power}{ upper={#1} },
729 },
730 }
731 \end{lstlisting}
732 \SetupClass\MyVar{
733 define keys[1]={
734 {power}{ upper={#1} },
735 },
736 }
737 This allows us to write
738 \begin{LTXexample}
739 $\vx[power=2]$,
740 $\vy[1,power=2] + \vy[2,power=2]$
741 \end{LTXexample}
742
743 Let us try doing something a bit more complicated: adding a key for restricting a function to a smaller subset.
744 For this, we do the following:
745 \begin{lstlisting}
746 \SetupClass\MyVar{
747 define keys={
748 {inv}{ upper={-1} },
749 },
750 define keys[1]={
751 {der}{ upper={(#1)} },
752 {power}{ upper={#1} },
753 {res}{ right return,symbol put right={|}, lower={#1} },
754 },
755 }
756 \end{lstlisting}
757 \SetupClass\MyVar{
758 define keys[1]={
759 {res}{ right return,symbol put right={|}, lower={#1} },
760 },
761 }
762 This adds a horizonal line~\enquote{$|$}
763 to the right of the symbol followed by
764 a lower index containing whatever you passed to the key
765 (contained in the \mbox{command~\lstinline!#1!)}.
766 (There is also an extra key, \lstinline!right return!, which is a bit more advanced and should be taken for granted for now. Roughly speaking, it is there to make sure that the restriction symbol is printed \emph{after} all indices that you might have added before. More details in \cref{ch:return}.)
767 Now we may write the following:
768 \begin{LTXexample}
769 $\vf[res=\vU]{\vx}$,
770 $\vg[1,res=\vY]{\vy}$,
771 $\vh[inv,res=\vT]{\vz}$
772 \end{LTXexample}
773
774 If the reader starts playing around with the \semantex{} functions, they will discover that whenever you apply a function to something, the result becomes a new function that can take an argument itself (this is why we wrote~\lstinline!output=\MyVar! in the definition of the class~\lstinline!\MyVar!). This behaviour is both useful and extremely necessary in order for the package to be useful in practice. For instance, you may write
775 \begin{LTXexample}
776 $\vf[der=\vn]{\vx}{\vy}{\vz}
777 =\vg{\vu,\vv,\vw}[3]{
778 \vx[1],\vx[2]}[8,1,der=2]{
779 \vt}$
780 \end{LTXexample}
781 Some people prefer to be able to scale the vertical line in the restriction notation. I rarely do that, but for this purpose, we could do the following:
782 \begin{lstlisting}
783 \SetupClass\MyVar{
784 define keys[1]={
785 {big res}{ right return, symbol put right=\big|, lower={#1} },
786 {Big res}{ right return, symbol put right=\Big|, lower={#1} },
787 {bigg res}{ right return, symbol put right=\bigg|, lower={#1} },
788 {Bigg res}{ right return, symbol put right=\Bigg|, lower={#1} },
789 {auto res}{
790 left return,
791 symbol put left=\kern-\nulldelimiterspace,
792 Other spar={.}{|}{auto}, symbol put left=\bgroup,
793 symbol put right=\egroup, lower={#1},
794 },
795 % The last key auto-scales the vertical bar. See @\textit{\cref{sec:spar}}@
796 % for information about Other spar.
797 % Note that Other spar automatically invokes right return,
798 % so no need to run that key twice.
799 },
800 }
801 \end{lstlisting}
802
803 So to sum up, we first defined a class~\lstinline!\MyVar!
804 via \lstinline!\NewVariableClass! and then used \lstinline!\SetupClass! to add keys to it. In fact, we could have done it all at once by passing these options directly to \lstinline!\NewVariableClass!:
805 \begin{lstlisting}
806 \NewVariableClass\MyVar[
807 output=\MyVar, % This means that the output of an object
808 % of class \MyVar is also of class \MyVar
809 define keys={
810 {inv}{ upper={-1} },
811 },
812 define keys[1]={
813 {der}{ upper={(#1)} },
814 {power}{ upper={#1} },
815 {res}{ right return, symbol put right={|}, lower={#1} },
816 },
817 ]
818 \end{lstlisting}
819 As we proceed in this guide, we shall use \lstinline!\SetupClass!
820 to add more and more keys to~\lstinline!\MyVar!. However, when you set up your own system, you may as well just add all of the keys at once like this when you create the class and then be done with it.
821
822 Let me add that it is possible to create subclasses of existing classes. You just write \mylst!parent=$\usercommand\<Class\>$! in the class declaration to tell that \usercommand\<Class\> is the parent class. \textbf{But a word of warning:} It is a natural idea to create different classes for different mathematical entities, each with their own keyval syntax that fits whatever class you are in; for instance, you could have one class for algebraic structures like rings and modules with keys for opposite rings and algebraic closure, and you could have another class for topological spaces with keys for closure and interior. However, as the reader can probably imagine, this becomes extremely cumbersome to work with in practice since an algebraic structure might very well also carry a topology. So at the end of the day, I advice you to use a single superclass \lstinline!\MyVar! that has all the keyval syntax and mainly use subclasses for further customization. We shall see examples of this below.
823
824 \section{Example: Elementary algebra}\label{sec:algebra}
825
826 \SetupClass\MyVar{
827 define keys={
828 {poly}{
829 par, % This tells semantex to use parentheses around
830 % the argument in the first place, in case this
831 % had been turned off
832 left par=[,right par=],
833 },
834 },
835 }
836
837 Let us try to use \semantex{} to build some commands
838 for doing algebra.
839 As an algebraist, one of the first things you might want to do is to create polynomial rings~\( \vk[poly]{\vx,\vy,\vz} \). Since all variables can already be used as functions (this is a design choice we discussed earlier), all we need to do is find a way to change from using parentheses to square brackets. This can be done the following way:
840 \begin{lstlisting}
841 \SetupClass\MyVar{
842 define keys={
843 {poly}{
844 par, % This tells semantex to use parentheses around
845 % the argument in the first place, in case this
846 % had been turned off
847 left par=[,right par=],
848 },
849 },
850 }
851 \end{lstlisting}
852 Now we may write
853 \begin{LTXexample}
854 $\vk[poly]{\vx,\vy,\vz}$
855 \end{LTXexample}
856 It is straightforward how to do adjust this to instead write the \emph{field} generated by the variables~\( x, y, z \):
857 \begin{lstlisting}
858 \SetupClass\MyVar{
859 define keys={
860 {poly}{
861 par, % This tells semantex to use parentheses around
862 % the argument in the first place, in case this
863 % had been turned off
864 left par=[,right par=],
865 },
866 {field}{
867 par,
868 left par=(,right par=),
869 },
870 },
871 }
872 \end{lstlisting}
873 \SetupClass\MyVar{
874 define keys={
875 {field}{
876 par,
877 left par=(,right par=),
878 },
879 },
880 }
881 Now \lstinline!\vk[field]{\vx,\vy,\vz}! produces~\( \vk[field]{\vx,\vy,\vz} \). Of course, leaving out the \lstinline!field!
882 key would produce the same result with the current configuration of the class~\lstinline!\MyVar!. However, it is still best to use a key for this, both because this makes the semantics more clear, but also because you might later change some settings that would cause the default behaviour to be different.
883
884 Adding support for free algebras, power series, and Laurent series is almost as easy, but there is a catch:
885 \begin{lstlisting}
886 \SetupClass\MyVar{
887 define keys={
888 {poly}{
889 par, % This tells semantex to use parentheses around
890 % the argument in the first place, in case this
891 % had been turned off
892 left par=[,right par=],
893 },
894 {field}{
895 par,
896 left par=(,right par=),
897 },
898 {free alg}{
899 par,
900 left par=\langle,
901 right par=\rangle,
902 },
903 {power series}{
904 par,
905 left par=\llbracket,
906 right par=\rrbracket,
907 },
908 {laurent}{
909 par,
910 left par=(, right par=),
911 pre arg={\!\mathopen{}\SemantexDelimiterSize(},
912 post arg={\SemantexDelimiterSize)\mathclose{}\!},
913 % The "pre arg" and "post arg" are printed before after
914 % the argument, if the argument is non-empty.
915 % The command "\SemantexDelimiterSize" is substituted
916 % by \big, \Big, ..., or whatever size the
917 % argument delimiters have
918 },
919 },
920 }
921 \end{lstlisting}
922 \SetupClass\MyVar{
923 define keys={
924 {free alg}{
925 par,
926 left par=\langle,
927 right par=\rangle,
928 },
929 {power series}{
930 par,
931 left par=\llbracket,
932 right par=\rrbracket,
933 },
934 {laurent}{
935 par,
936 left par=(, right par=),
937 pre arg={\!\mathopen{}\SemantexDelimiterSize(},
938 post arg={\SemantexDelimiterSize)\mathclose{}\!},
939 % These are printed before and after the argument.
940 % The command "\SemantexDelimiterSize" is substituted
941 % by \big, \Big, ..., or whatever size the
942 % argument delimiters have
943 },
944 },
945 }
946 See for yourself:
947 \begin{LTXexample}
948 $\vk[free alg]{\vx}$,
949 $\vk[power series]{\vy}$,
950 $\vk[laurent]{\vz}$
951 \end{LTXexample}
952
953
954 Let us look at some other algebraic operations that we can control via \semantex:
955 \begin{lstlisting}
956 \SetupClass\MyVar{
957 define keys={
958 {op}{upper={\mathrm{op}}},
959 % opposite groups, rings, categories, etc.
960 {alg closure}{command=\overline},
961 % algebraic closure
962 {conj}{command=\overline},
963 % complex conjugation
964 {dual}{upper=*},
965 % dual vector space
966 {perp}{upper=\perp},
967 % orthogonal complement
968 },
969 define keys[1]={
970 {mod}{right return,symbol put right={/#1}},
971 % for modulo notation like R/I
972 {dom}{left return,symbol put left={#1\backslash}},
973 % for left modulo notation like I\R
974 % "dom" is "mod" spelled backwards
975 {oplus}{upper={\oplus#1}},
976 % for notation like R^{\oplus n}
977 {tens}{upper={\otimes#1}},
978 % for notation like R^{\otimes n}
979 {localize}{symbol put right={ \lbrack #1^{-1} \rbrack }},
980 % localization at a multiplicative subset;
981 % we use \lbrack and \rbrack rather than [ and ] since in some
982 % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@),
983 % the [...] might be interpreted as an optional argument.
984 {localize prime}{sep lower={#1}},
985 % for localization at a prime ideal
986 },
987 }
988 \end{lstlisting}
989 \SetupClass\MyVar{
990 define keys={
991 {op}{upper={\mathrm{op}}},
992 % opposite groups, rings, categories, etc.
993 {alg closure}{command=\overline},
994 % algebraic closure
995 {conj}{command=\overline},
996 % complex conjugation
997 {dual}{upper=*},
998 % dual vector space
999 {perp}{upper=\perp},
1000 % orthogonal complement
1001 },
1002 define keys[1]={
1003 {mod}{symbol put right={/#1}},
1004 % for modulo notation like R/I
1005 {dom}{symbol put left={#1\backslash}},
1006 % for left modulo notation like I\R
1007 % "dom" is "mod" spelled backwards
1008 {oplus}{upper={\oplus#1}},
1009 % for notatoin like R^{\oplus n}
1010 {tens}{upper={\otimes#1}},
1011 % for notation like R^{\otimes n}
1012 {localize}{symbol put right={ \lbrack #1^{-1} \rbrack }},
1013 % localization at a multiplicative subset
1014 {localize prime}{sep lower={#1}},
1015 % for localization at a prime ideal
1016 },
1017 }
1018 Let us see it in practice:
1019 \begin{LTXexample}
1020 $\vR[op]$, $\vk[alg closure]$,
1021 $\vz[conj]$, $\vV[dual]$,
1022 $\vR[mod=\vI]$,$\vR[dom=\vJ]$,
1023 $\vR[oplus=\vn]$,
1024 $\vV[tens=\vm]$,
1025 $\vR[localize=\vS]$,
1026 $\vR[localize prime=\vI]$,
1027 $\vk[free alg]{\vS}[op]$,
1028 $\vV[perp]$
1029 \end{LTXexample}
1030
1031 \section{GIT quotients}
1032
1033 \SetupClass\MyVar{
1034 define keys[2]={
1035 {proj quotient}{ symbol put right={ /\!\!/ _ { #1 } #2 } },
1036 }
1037 }
1038
1039 We include a slightly more advanced example
1040 to show the use of keys with more than one value.
1041 Sometimes, a key with one value is simply not enough. For instance, if you
1042 work in geometric invariant theory~(GIT), you will eventually have to take the proj
1043 quotient~\( \vX[proj quotient={\vchi}{\vG}] \) of~\( \vX \) with respect to the action of the group~\( \vG \) and the character~\( \vchi \). In other words, the proj quotient depends on two parameters, \( \vchi \) and~\( \vG \). For this purpose, we the the key~\lstinline!define keys[2]!:
1044 \begin{lstlisting}
1045 \SetupClass\MyVar{
1046 define keys[2]={
1047 {proj quotient}{ symbol put right={ /\!\!/_{#1} #2 } },
1048 }
1049 }
1050 \end{lstlisting}
1051
1052 \begin{LTXexample}
1053 $ \vX[proj quotient={\vchi}{\vG}] $
1054 \end{LTXexample}
1055
1056
1057 \chapter{Some more techniques}
1058
1059 \section{The \texttt{spar} key}\label{sec:spar}
1060
1061 The \lstinline!spar! key is one of the most important commands in \semantex{} at all. To understand why we need it, imagine you want to derive a function \( \vn \)~times and then invert it. Writing something like
1062 \begin{LTXexample}
1063 $\vf[der=\vn,inv]$
1064 \end{LTXexample}
1065 does not yield a satisfactory result. However, the \lstinline!spar! key saves the day:
1066 \begin{LTXexample}
1067 $\vf[der=\vn,spar,inv]$
1068 \end{LTXexample}
1069 So \lstinline!spar! simply adds a pair of parentheses around the current symbol, complete with all indices that you may have added to it so far. The name \lstinline!spar! stands for \enquote{symbol parentheses}. You can add as many as you like:
1070 \begin{LTXexample}
1071 $ \vf[1,res=\vV,spar,conj,op,spar,0,inv,spar,mod=\vI,spar,dual]{\vx} $
1072 \end{LTXexample}
1073 If it becomes too messy, you can scale the parentheses, too. Simply use the syntax
1074 \lstinline!spar=\big!, \lstinline!spar=\Big!, etc.
1075 You can also get auto-scaled parentheses base on \lstinline!\left ...\right!,
1076 using the key \lstinline!spar=auto!:
1077 \begin{LTXexample}
1078 $\vf[spar]$,
1079 $\vf[spar=\big]$,
1080 $\vf[spar=\Big]$,
1081 $\vf[spar=\bigg]$,
1082 $\vf[spar=\Bigg]$,
1083 $\vf[spar=auto]$
1084 \end{LTXexample}
1085 So returning to the above example, we can write
1086 \begin{LTXexample}
1087 $\vf[1,res=\vV,spar,conj,op,spar=\big,0,inv,spar=\Big,mod=\vI,spar=\bigg,dual]{\vx}$
1088 \end{LTXexample}
1089 To adjust the type of brackets, use the \lstinline!left spar! and \lstinline!right spar! keys:
1090 \begin{LTXexample}
1091 $\vf[left spar={[},right spar={\}},spar,spar=\Bigg]$
1092 \end{LTXexample}
1093 Occassionally, it is useful to be able to input a particular kind of brackets just once,
1094 without adjusting any settings. For this purpose, we have the
1095 \lstinline!other spar! and~\lstinline!Other spar! keys. They use the syntax
1096 \begin{lstlisting}
1097 other spar={@\<opening bracket\>@}{@\<closing bracket\>@}
1098 Other spar={@\<opening bracket\>@}{@\<closing bracket\>@}{@\values\<normal|auto|*|{\textit{other}}\>@}
1099 \end{lstlisting}
1100 The last argument in \lstinline!Other spar! sets the size of the
1101 parentheses.
1102 Let us see them in action:
1103 \begin{LTXexample}
1104 $\vf[other spar={[}{)},
1105 other spar={\{}{\rangle},
1106 Other spar={\langle}{\rangle}{\Bigg},spar]$
1107 \end{LTXexample}
1108
1109 \section{The \texorpdfstring{\texttt{$\backslash$\<Class\>}}{Class} command}\label{ch:the_class_command}
1110
1111 So far, we have learned that every mathematical entity should be treated
1112 as an object of some class. However, then we run into issues the moment we
1113 want to write expressions like
1114 \[
1115 \MyVar{\vf\circ\vg}[spar,der=\vn]{\vx}.
1116 \]
1117 We do not want to have to define a new variable
1118 with symbol~\( \vf\circ\vg \) just to write something like this.
1119 Fortunately, once you have created the class~\lstinline!\MyVar!,
1120 you can actually use~\lstinline!\MyVar! as a command to create a quick instance of the class.
1121 More precisely \mylst!\MyVar{$\<symbol\>$}!~creates a variable on the spot with symbol~\mylst!$\<symbol\>$!.
1122 So the above equation can be written
1123 \begin{LTXexample}
1124 $\MyVar{\vf\circ\vg}[spar,
1125 der=\vn]{\vx}$
1126 \end{LTXexample}
1127 More generally, when you crate the class~\usercommand\<Class\>,
1128 you can use it as a command with the following syntax:
1129 \begin{lstlisting}
1130 @\usercommand\<Class\>@{@\<symbol\>@}[@\<options\>@]@\<usual syntax of class\>@
1131 \end{lstlisting}
1132
1133 \section{The \texttt{command} key}
1134
1135 \begingroup
1136
1137 Above, we used the key~\lstinline!command! a couple of times:
1138 \begin{LTXexample}
1139 $\va[command=\overline]$,
1140 $\vH[command=\widetilde]$
1141 \end{LTXexample}
1142 This key applies the given command to the symbol.
1143 Sometimes, it is useful to put these commands into
1144 keys instead. So you can do stuff like
1145 \begin{lstlisting}
1146 \SetupClass\MyVar{
1147 define keys={
1148 {tilde}{command=\tilde},
1149 {widetilde}{command=\widetilde},
1150 {bar}{command=\bar},
1151 {bold}{command=\mathbf},
1152 {roman}{command=\mathrm},
1153 },
1154 }
1155 \end{lstlisting}
1156 \SetupClass\MyVar{
1157 define keys={
1158 {tilde}{command=\tilde},
1159 {widetilde}{command=\widetilde},
1160 {bar}{command=\bar},
1161 {bold}{command=\mathbf},
1162 {roman}{command=\mathrm},
1163 },
1164 }
1165 Let us test:
1166 \begin{LTXexample}
1167 $\va[widetilde]$,
1168 $\va[bold]$,
1169 $\va[roman]$,
1170 $\va[bar]$
1171 \end{LTXexample}
1172 Note that there is a predefined key,~\lstinline!smash!,
1173 which is equivalent to~\lstinline!return, command=\smash!.
1174
1175 \endgroup
1176
1177 \section{The \texttt{return} keys}\label{ch:return}
1178
1179 Let us suppose in this section that we have
1180 defined the key~\lstinline!conj! for complex conjugation,
1181 like in the introduction.
1182 Suppose you want to take the complex conjugate of the variable~\( \vz[1] \). Then you might write something like
1183 \begin{LTXexample}
1184 $\vz[1,conj]$
1185 \end{LTXexample}
1186 Notice that the bar has only been added over the~\( \vz \), as is standard mathematical typography; you normally do not write~\( \vz[1,return,conj] \).
1187 This reveals a design choice that has been made in \semantex:
1188 When you add an index or a command via the \lstinline!command! key,
1189 it is not immediately applied to the symbol.
1190 Rather, both commands and indices are added to a register and are then applied at the very last, right before the symbol is printed.
1191 This allows us to respect standard mathematical typography, as shown above.
1192
1193 However, there are other times when this behaviour is not what you want.
1194 For instance, if you want to comjugate the inverse of a function, the following looks wrong:
1195 \begin{LTXexample}
1196 $\vf[inv,conj]$
1197 \end{LTXexample}
1198 Therefore, there is a key, called \lstinline!return!, that can be applied at any point to invoke the routine of adding all current commands, indices, and arguments to the symbol. Let us try it out:
1199 \begin{LTXexample}
1200 $\vf[inv,return,conj]$
1201 \end{LTXexample}
1202 Before we invoked~\lstinline!return!, the symbol was~\lstinline!f!, and the~\lstinline!-1! was stored as an upper index.
1203 But after the \lstinline!return! routine, the symbol is~\lstinline!f^{-1}!, and consequently, when we apply the~\lstinline!conj! key, you add a line above the whole thing.
1204
1205 There are some cases when you do not want to add all commands, indices, and arguments to the symbol at the same time.
1206 Therefore, there exist a few extra, partial \lstinline!return! keys that only add some of them to the symbol and save the rest of later.
1207 We list the most important ones here and refer to~\cref{sec:fundamental_keys} for the remaining ones.
1208 Most users will probably only ever need the keys \lstinline!return! and~\lstinline!right return!.
1209 \begin{itemize}
1210 \item
1211 \mylst!return!
1212
1213 Invokes the return routine, i.e.\ adds all commands, indices, and arguments to the symbol, if any such exist.
1214
1215 \item
1216 \mylst!inner return!
1217
1218 Invokes the inner return routine, i.e.\ adds all commands to the symbol, if any such exist.
1219
1220 \item
1221 \mylst!right return!
1222
1223 Invokes the right return routine, i.e.\ adds all commands, right indices, and right arguments to the symbol, if any such exist.
1224
1225 \item
1226 \mylst!left return!
1227
1228 Invokes the left return routine, i.e.\ adds all commands, left indices, and left arguments to the symbol, if any such exist.
1229 \end{itemize}
1230
1231
1232 \section{Keyval syntax conflicts}
1233
1234 You can pass anything you want as key values, including other objects.
1235 But you quickly run into the following problem:
1236 Imagine you try setting~\lstinline!\vx[1,power=2]! as the lower
1237 index of a the object~\lstinline!\va!. If you try
1238 \begin{lstlisting}
1239 $ \va[lower=\vx[1,power=2]] $
1240 \end{lstlisting}
1241 then the system will break. Indeed, the system will see the object~\lstinline!\va!
1242 to which you have passed the two keys
1243 \begin{center}
1244 \lstinline!lower=\vx[1!
1245 \qquad\text{and}\qquad
1246 \lstinline!power=2]!.
1247 \end{center}
1248 To avoid this behaviour, you will have to enclose the key
1249 value in braces:
1250 \begin{LTXexample}
1251 $ \va[lower={\vx[1,power=2]}] $
1252 \end{LTXexample}
1253
1254 So far so good, but if you use our favourite shorthand notation
1255 for lower indices (simply writing the index in the options, like~\lstinline!\va[1]!),
1256 then it still goes wrong:
1257 \begin{lstlisting}
1258 $ \va[{\vx[1,power=2]}] $
1259 \end{lstlisting}
1260 The reason is that in \LaTeX\ (really, the \pack{xparse} package from \LaTeX3)
1261 interprets \lstinline![{...}]! more or less like~\lstinline![...]!
1262 in this case.
1263 To make up for this, you can use either of the following strategies:
1264 \begin{LTXexample}
1265 $ \va[ {\vx[1,power=2]} ] $,
1266 $ \va[\vx[{1,power=2}]] $
1267 \end{LTXexample}
1268 There is a similar problem in the arguments,
1269 since arguments also allow a kind of keyval syntax
1270 (the keys that need equality signs are turned off by default, though;
1271 more on that in \cref{ch:arg_keyval}).
1272 But it will still react on commas and keys like~\lstinline!...!.
1273 Therefore, in order to ensure the correct output, you will also have to enclose any argument containing commas with braces:
1274 \begin{LTXexample}
1275 $ \vf{ \vg[{upper=3,lower=2}] } $,
1276 $ \vf{ {\vg[upper=3,lower=2]} } $
1277 \end{LTXexample}
1278 As mentioned in \cref{ch:arg_keyval}, you \emph{can}
1279 also turn keyval syntax in arguments completely off,
1280 avoiding such issues. This can be done by setting
1281 \begin{lstlisting}
1282 \SetupClass\MyVar{
1283 arg keyval=false,
1284 }
1285 \end{lstlisting}
1286
1287 \subsection{Cheating your way around keyval syntax conflicts}
1288
1289 \begingroup
1290 If you grow tired of having to deal with such issues all the time, there
1291 are solutions to either partly or completely avoid this.
1292 The first solution we present does not solve
1293 the problem with~\lstinline!\va[\vx[1,power=2}]!, but
1294 it does solve problems like
1295 \begin{lstlisting}
1296 $ \va[lower=\vx[lower=3]] $
1297 \end{lstlisting}
1298 Normally, this will not work, as the underlying keyval machinery
1299 of \LaTeX3 does not allow key values to contain equality signs.
1300 However, there is another keyval package that does:
1301 the excellent package \pack{expkv}.
1302 To switch to the keyval parser of this package, we do
1303
1304 \begin{lstlisting}
1305 \usepackage{expkv}
1306 \SemantexSetup{
1307 keyval parser=\ekvparse,
1308 }
1309 \end{lstlisting}
1310 \SemantexSetup{
1311 keyval parser=\ekvparse,
1312 }
1313 Now you can do
1314 \begin{LTXexample}
1315 $ \va[lower=\vx[lower=3]] $
1316 \end{LTXexample}
1317
1318 In general,
1319 using the key
1320 \mylst!keyval parser={$\<command\>$}!
1321 sets the keyval parser function to be the command~\<command\>.
1322 The \<command\> must take three arguments:
1323 \mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!.
1324 The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two.
1325 For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values,
1326 while \<function\num{2}\>~will be applied to keys taking a value. By default, this key has been set to the command \lstinline!\keyval_parse:NNn! from~\LaTeX3.
1327 Changing this key will only affect keys for objects and classes,
1328 \emph{not} keys for use inside~\lstinline!\SemantexSetup!.
1329
1330 \endgroup
1331
1332 A more drastic solution is to use the package~\pack{stricttex},
1333 which has been developed mainly as a companion package to~\semantex.
1334 Unfortunately, it only works in~\hologo{LuaTeX}.
1335 If you don't know what \hologo{LuaTeX} is, that means that you are not
1336 using \hologo{LuaTeX}, and you should note that switching is a rather drastic affair
1337 since your existing font settings might very well not work
1338 with \hologo{LuaTeX}. Also, \semantex{} does not exactly make your document faster,
1339 and \hologo{LuaTeX} makes it even slower, so think carefully before you make the switch just for this.
1340
1341 In any case, with \pack{stricttex}, you will be able to make brackets \enquote{strict}, which means that any \lstinline![! will be replaced
1342 by a~\lstinline![{!, and that any~\lstinline!]! will be replaced
1343 by a~\lstinline!}]!. This will make all of the above work just fine:
1344 \begin{lstlisting}
1345 \StrictBracketsOn
1346 $ \va[lower=\vx[lower=3]] $
1347 $ \va[\vx[1,power=2]] $
1348 $ \vf{ \vg[upper=3,lower=2] } $
1349 \StrictBracketsOff
1350 \end{lstlisting}
1351 There is no demonstration on the right since this manual
1352 has not been typeset using \hologo{LuaTeX}, so it would not work.
1353
1354 \chapter{Example: Algebraic geometry}
1355
1356 Let us discuss how to typeset sheaves and operations on morphisms in algebraic geometry.
1357 First of all, adding commands for sheaves is not a big deal:
1358 \begin{lstlisting}
1359 \NewObject\MyVar\sheafF{\mathcal{F}}
1360 \NewObject\MyVar\sheafG{\mathcal{G}}
1361 \NewObject\MyVar\sheafH{\mathcal{H}}
1362 \NewObject\MyVar\sheafreg{\mathcal{O}}
1363 % sheaf of regular functions
1364 \NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}}
1365 \end{lstlisting}
1366 You can of course add as many sheaf commands as you need.
1367
1368 Next, for morphisms of schemes~\( \vf \colon \vX \to \vY \),
1369 we need to be able to typeset comorphisms as well as the one hundred thousand different pullback and pushforward operations. For this, we add some keys to the \lstinline!\MyVar! key:
1370 \begin{lstlisting}
1371 \SetupClass\MyVar{
1372 define keys={
1373 {comorphism}{upper=\#},
1374 % comorphisms, i.e. f^{\#}
1375 {inverse image}{upper={-1},no par},
1376 % inverse image of sheaves
1377 {sheaf pull}{upper=*,no par},
1378 % sheaf *-pullback
1379 {sheaf push}{lower=*,no par},
1380 % sheaf *-pushforward
1381 {sheaf !pull}{upper=!,no par},
1382 % sheaf !-pullback
1383 {sheaf !push}{lower=!,no par},
1384 % sheaf !-pushforward
1385 },
1386 }
1387 \end{lstlisting}
1388 \SetupClass\MyVar{
1389 define keys={
1390 {comorphism}{upper=\#},
1391 % comorphisms, i.e. f^{\#}
1392 {inverse image}{upper={-1},no par},
1393 % inverse image of sheaves
1394 {sheaf pull}{upper=*,no par},
1395 % sheaf *-pullback
1396 {sheaf push}{lower=*,no par},
1397 % sheaf *-pushforward
1398 {sheaf !pull}{upper=!,no par},
1399 % sheaf !-pullback
1400 {sheaf !push}{lower=!,no par},
1401 % sheaf !-pushforward
1402 },
1403 }
1404 We have added the command \lstinline!no par! to all pullback and pushforward commands since it is custom to write, say,~\( \vf[sheaf pull]{\sheafF} \) rather than~\( \vf[sheaf pull,par]{\sheafF} \). Of course, you can decide that for yourself, and in any case, you can write~\lstinline!\vf[sheaf pull,par]{\sheafF}! if you want to force it to use parentheses in a particular case. Of course, since all \semantex{} variables can be used as functions, so can whatever these pullback and pushforward operations output. So we may write:
1405 \begin{LTXexample}
1406 For a morphism~$ \vf \colon
1407 \vX \to \vY $ with
1408 comorphism~$ \vf[comorphism]
1409 \colon \sheafreg[\vY] \to
1410 \vf[sheaf push]{\sheafreg[\vX]} $,
1411 and for a sheaf~$ \sheafF $ on~$ \vY $, we can define the
1412 pullback~$ \vf[sheaf pull]{
1413 \sheafF} $ by letting~$
1414 \vf[sheaf pull]{\sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$
1415 \vf[sheaf !pull]{\sheafF}{\vU} = \cdots $.
1416 \end{LTXexample}
1417 Maybe some people would write \lstinline!pull!, \lstinline!push!, etc.~instead, but there are many different kinds of pullbacks in mathematics, so I prefer to use the \lstinline!sheaf!~prefix to show that this is for sheaves.
1418 Probably, in the long run, an algebraic geometer might also want
1419 to abbreviate~\lstinline!inverse image! to~\lstinline!invim!.
1420
1421 There are a number of other operations we might want to do for sheaves. We already defined the key~\lstinline!res! for restriction, so there is no need to define this again.
1422 However, we might need to stalk, sheafify, take dual sheaves, and twist sheaves. Let us define keys for this:
1423 \begin{lstlisting}
1424 \SetupClass\MyVar{
1425 define keys[1]={
1426 {stalk}{sep lower={#1}},
1427 % "sep lower" means "separator + lower", i.e. lower index
1428 % separated from any previous lower index by a separator,
1429 % which by default is a comma
1430 {sheaf twist}{return,symbol put right={(#1)}},
1431 },
1432 define keys={
1433 {sheafify}{upper=+},
1434 {sheaf dual}{upper=\vee},
1435 },
1436 }
1437 \end{lstlisting}
1438 \SetupClass\MyVar{
1439 define keys[1]={
1440 {stalk}{sep lower={#1}},
1441 % "sep lower" means "separator + lower", i.e. lower index
1442 % separated from any previous lower index by a separator,
1443 % which by default is a comma
1444 {sheaf twist}{return,symbol put right={(#1)}},
1445 },
1446 define keys={
1447 {sheafify}{upper=+},
1448 {sheaf dual}{upper=\vee},
1449 },
1450 }
1451 \begin{LTXexample}
1452 $\sheafF[res=\vU,stalk=\vp]$,
1453 $\sheafF[res=\vU,spar,stalk=
1454 \vp]$,
1455 $\sheafreg[\vX,stalk=\vp]$,
1456 $\sheafG[sheafify]$,
1457 $\vf[inverse image]{\sheafreg[
1458 \vY]}[spar,stalk=\vx]$,
1459 $\sheafG[sheaf dual]$,
1460 $\sheafreg[\vX][sheaf twist=-1]$,
1461 $\sheafreg[sheaf twist=1,sheaf dual]$
1462 \end{LTXexample}
1463
1464 \chapter{Example: Homological algebra}
1465
1466 Before you venture into homological algebra, you should probably
1467 define some keys for the standard constructions:
1468
1469 \begin{lstlisting}
1470 \NewObject\MyVar\Hom{\operatorname{Hom}}
1471 \NewObject\MyVar\Ext{\operatorname{Ext}}
1472 \NewObject\MyVar\Tor{\operatorname{Tor}}
1473 \end{lstlisting}
1474 \NewObject\MyVar\Ext{\operatorname{Ext}}
1475 \NewObject\MyVar\Tor{\operatorname{Tor}}
1476 Now the ability to easily print indices via the options key will come in handy:
1477 \begin{LTXexample}
1478 $\Hom[\vA]{\vM,\vN}$,
1479 $\Ext[\vA]{\vM,\vN}$
1480 \end{LTXexample}
1481 \SetupClass\MyVar{
1482 define keys[1]={
1483 {shift}{ right return,symbol put right={ \relax [ {#1} ] } },
1484 % we use \lbrack and \rbrack rather than [ and ] since in some
1485 % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@),
1486 % the [...] might be interpreted as an optional argument.
1487 },
1488 }
1489 You will probably need several keyval interfaces, some of which will be covered below. But right now, we shall implement a shift operation~\( \vX\mapsto\vX[shift=\vn] \):
1490 \begin{lstlisting}
1491 \SetupClass\MyVar{
1492 define keys[1]={
1493 {shift}{ right return,symbol put right={ \lbrack #1 \rbrack } },
1494 % we use \lbrack and \rbrack rather than [ and ] since in some
1495 % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@),
1496 % the [...] might be interpreted as an optional argument.
1497 },
1498 }
1499 \end{lstlisting}
1500 Let us see that it works:
1501 \begin{LTXexample}
1502 $\vX \mapsto \vX[shift=\vn]$
1503 \end{LTXexample}
1504 Finally, let us define a command for the differential (in the homolgoical algebra sense):
1505 \begin{lstlisting}
1506 \NewObject\MyVar\dif{d}[no par]
1507 \end{lstlisting}%
1508 \NewObject\MyVar\dif{d}[no par]%
1509 \begin{LTXexample}
1510 $\dif{\vx} = 0$
1511 \end{LTXexample}
1512
1513 \section{The \texttt{d}-index and the \texttt{i}-index}
1514
1515 In branches of mathematics such as homological algebra,
1516 people have very different opinions about the positions of the gradings.
1517 As an algebraist, I am used to \emph{upper} gradings (\enquote{cohomological} grading), whereas many topologists prefer \emph{lower} gradings (\enquote{homological} grading). The \semantex{} system
1518 supports both, but the default is upper gradings.
1519 You can adjust this by writing
1520 \lstinline!grading position=upper! or~\lstinline!grading position=lower!.
1521
1522
1523 We already learned about the keys \lstinline!upper! and~\lstinline!lower!,
1524 as well as their friends \lstinline!sep upper!, \lstinline!sep lower!, \lstinline!comma upper!, \lstinline!comma lower!, etc.
1525 There also exist \enquote{relative} versions of these keys that print the index either as an upper index or as a lower index, depending on your preference for cohomological or homological grading. They are called
1526 \begin{center}
1527 \lstinline!d!,
1528 \lstinline!sep d!,
1529 \lstinline!comma d!
1530 \qquad\qquad and\qquad\qquad
1531 \lstinline!i!,
1532 \lstinline!sep i!,
1533 \lstinline!comma i!,
1534 \end{center}
1535 and consequently, we shall refer to the indices
1536 they correspond to as the \enquote{\lstinline!d!-index} and the \enquote{\lstinline!i!-index}.
1537 The \lstinline!d! stands for \enquote{degree} and corresponds to
1538 the grading. The~\lstinline!i! stands for \enquote{index}
1539 and corresponds to the \enquote{other} index where you may store
1540 additional information.\footnote{These names are not perfect; you might object that the degree is also an index, but feel free to come up with a more satisfactory naming principle, and I shall be happy to consider it.}
1541
1542 To understand the difference,
1543 keep the following two examples
1544 in mind: the hom complex~\( \Hom[*,i=\vA] \) and the simplicial homology~\( \ho[*,i=\vDelta] \):
1545 \begin{lstlisting}
1546 \NewObject\MyVar\Hom{\operatorname{Hom}}
1547 \NewObject\MyVar\ho{H}[grading position=lower] % homology
1548 \end{lstlisting}
1549 \begin{LTXexample}
1550 $\Hom[i=\vA,d=0]$,
1551 $\ho[i=\vDelta,d=1]$
1552 \end{LTXexample}
1553 Let us see them in action:
1554 \begingroup\begin{LTXexample}
1555 $ \vX[d=3,i=\vk] $
1556
1557 \SetupObject\vX{
1558 grading position=lower
1559 }
1560
1561 $ \vX[d=3,i=\vk] $
1562 \end{LTXexample}\endgroup
1563 \noindent
1564 If you want to print a bullet as the degree, there is the predefined key~\lstinline!*! for this:
1565 \begingroup\begin{LTXexample}
1566 $ \vX[*] $
1567
1568 \SetupObject\vX{
1569 grading position=lower
1570 }
1571
1572 $ \vX[*] $
1573 \end{LTXexample}\endgroup
1574
1575 I guess it is also time to reveal that the previously mentioned shorthand notation~\lstinline!\vx[1]! for indices always prints the~\lstinline!1! in the \lstinline!i!-index. So changing the grading position changes the position of the index:
1576 \begingroup\begin{LTXexample}
1577 $ \vX[1] $
1578
1579 \SetupObject\vX{
1580 grading position=lower
1581 }
1582
1583 $ \vX[1] $
1584 \end{LTXexample}\endgroup
1585 \noindent In other words, in the first example above, we could have written
1586 \begin{LTXexample}
1587 $\Hom[\vA,d=0]$,
1588 $\ho[\vDelta,d=1]$
1589 \end{LTXexample}
1590
1591
1592 Note that the use of the short notations \lstinline!d! and~\lstinline!i! does not prevent you from writing \lstinline!\vx[d]! and~\lstinline!\vx[i]!.
1593 This still works fine:
1594 \begin{LTXexample}
1595 $\vf[i]$, $\vf[i=]$,
1596 $\vf[d]$, $\vf[d=]$
1597 \end{LTXexample}
1598 As we see, it is only when a \lstinline!d! or~\lstinline!i! key is followed by an equality sign~\lstinline!=!
1599 that the actions of these keys are invoked.
1600 In fact, \semantex{} carefully separates keys taking
1601 a value from keys taking no values.
1602
1603 We can similarly define a command for cohomology:
1604 \begin{lstlisting}
1605 \NewObject\MyVar\co{H}[grading position=upper]
1606 % this is actually unnecessary, as
1607 % upper grading is the default
1608 \end{lstlisting}
1609 Let us see \lstinline!\ho! and~\lstinline!\co! in practise:
1610 \begin{LTXexample}
1611 $\co[d=0]$, $\co[*]$,
1612 $\co[d=\vi]{\vX}$,
1613 $\co[\vG,d=0]$,
1614 $\co[\vH,*]$,
1615 $\co[\vDelta,d=\vi]{\vX}$
1616 \end{LTXexample}
1617
1618 \begin{LTXexample}
1619 $\ho[d=0]$, $\co[*]$,
1620 $\ho[d=\vi]{\vX}$,
1621 $\ho[\vG,d=0]$,
1622 $\ho[\vH,*]$,
1623 $\ho[\vDelta,d=\vi]{\vX}$
1624 \end{LTXexample}
1625 Of course, you can define similar commands for cocycles, coboundaries, and all sorts of other entities that show up in homological algebra.
1626
1627 You might also want to implement feature like reduced cohomology, \v{C}ech cohomology,
1628 and hypercohomology. This is quite easy with the \lstinline!command! key:
1629 \begin{lstlisting}
1630 \SetupClass\MyVar{
1631 define keys={
1632 {reduced}{command=\widetilde},
1633 {cech}{command=\check},
1634 {hyper}{command=\mathbb},
1635 },
1636 }
1637 \end{lstlisting}
1638 \SetupClass\MyVar{
1639 define keys={
1640 {reduced}{command=\widetilde},
1641 {cech}{command=\check},
1642 {hyper}{command=\mathbb},
1643 },
1644 }
1645
1646 \begin{LTXexample}
1647 $\co[reduced,d=\vi]$,
1648 $\co[cech][*]$,
1649 $\co[hyper,cech,d=0]{\vX}$
1650 \end{LTXexample}
1651
1652 You can use a similar approach to define commands for derived functors:
1653 \begin{lstlisting}
1654 \NewObject\MyVar\Lder{\mathbb{L}}[no par]
1655 \NewObject\MyVar\Rder{\mathbb{R}}[no par]
1656 \end{lstlisting}
1657 \NewObject\MyVar\Lder{\mathbb{L}}[no par]
1658 \NewObject\MyVar\Rder{\mathbb{R}}[no par]
1659 For instance, we can write
1660 \begin{LTXexample}
1661 $\Lder[d=\vi]{\vf}$,
1662 $\Rder[d=0]{\vf}$
1663 \end{LTXexample}
1664
1665 Alternatively, the user might prefer to use keyval syntax
1666 on the level of the function itself (\( \vf \)~in this case).
1667 This can be done the following way:
1668 \begin{lstlisting}
1669 \SetupClass\MyVar{
1670 define keys[1]={
1671 {Lder} {
1672 left return, symbol put left=\mathbb{L}^{#1},
1673 },
1674 {Rder} {
1675 left return, symbol put left=\mathbb{R}^{#1},
1676 },
1677 },
1678 define keys={
1679 {Lder} {
1680 left return, symbol put left=\mathbb{L},
1681 },
1682 {Rder} {
1683 left return, symbol put left=\mathbb{R},
1684 },
1685 },
1686 }
1687 \end{lstlisting}
1688 \SetupClass\MyVar{
1689 define keys[1]={
1690 {Lder} {
1691 left return, symbol put left=\mathbb{L}^{#1},
1692 },
1693 {Rder} {
1694 left return, symbol put left=\mathbb{R}^{#1},
1695 },
1696 },
1697 define keys={
1698 {Lder} {
1699 left return, symbol put left=\mathbb{L},
1700 },
1701 {Rder} {
1702 left return, symbol put left=\mathbb{R},
1703 },
1704 },
1705 }
1706 Then the syntax becomes:
1707 \begin{LTXexample}
1708 $\vF[Lder=\vi]$,
1709 $\vF[Lder]{\vX[*]}$,
1710 $\vF[Rder]{\vX[*]}$,
1711 $\Hom[Rder]{\vX,\vY}$
1712 \end{LTXexample}
1713 If you get tired of having to write \lstinline!\Hom[Rder]! all
1714 the time, you can create a shortcut:
1715 \begin{lstlisting}
1716 \NewObject\MyVar\RHom[copy=\Hom,Rder]
1717 \end{lstlisting}
1718 \NewObject\MyVar\RHom[copy=\Hom,Rder]
1719 The \lstinline!copy! key is like the \lstinline!parent! key,
1720 except it allows you to inherit the settings from an \emph{object} rather than a \emph{class}. Notice that we did not specify a symbol; the symbol argument is optional, and in this case, it was unnecessary, as the symbol was inherited from~\lstinline!\Hom!. Let us see it in action:
1721 \begin{LTXexample}
1722 $\RHom{\vX,\vY}$
1723 \end{LTXexample}
1724
1725 \chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)}\label{ch:arg_keyval}
1726
1727 \SetupClass\MyVar{
1728 define arg keys[1]={
1729 {coef}{ other sep={;}{#1} },
1730 },
1731 }
1732
1733 \SetupObject\co{
1734 arg keyval=true,
1735 }
1736
1737 Imagine we want to do cohomology with coefficients in some ring~\( \vR \).
1738 It is common to write this as~\( \co[*]{\vX,coef=\vR} \)
1739 with a semicolon instead of a comma. This can be implemented, too, with the syntax
1740 \begin{LTXexample}
1741 $\co[*]{\vX,coef=\vR}$
1742 \end{LTXexample}
1743 This shows that arguments of functions also support keyval syntax.
1744 To define argument keys,
1745 we use the key~\lstinline!define arg keys!,
1746 or~\mylst!define arg keys[$n$]! if you want it to be
1747 able to take $n$~values for~$n=0,1,2,\ldots,9$. The syntax for these is
1748 just like the syntax for the keys~\lstinline!define keys!
1749 and~\mbox{\mylst!define keys[$n$]!}.
1750 However, for reasons we shall see in a moment, argument
1751 keys (at least those taking values) are actually turned off
1752 by default, so we shall have to turn them on first:
1753 \begin{lstlisting}
1754 \SetupClass\MyVar{
1755 define arg keys[1]={
1756 {coef}{ other sep={;}{#1} },
1757 },
1758 }
1759 \SetupObject\co{
1760 arg keyval=true,
1761 }
1762 \end{lstlisting}
1763 The key \lstinline!other sep! is a key that controls the separator
1764 between the current argument and the previous argument (it will only be printed if there was a previous argument). By default, this separator is a comma. So in the syntax~\lstinline!\co[*]{\vX,coef=\vR}!,
1765 there are two arguments, \lstinline!\vX! and~\lstinline!\vR!, and the separator is a semicolon.
1766 We shall later (see~\cref{ch:parse_coho_coef})
1767 see another, possibly more natural way to write cohomology with coefficients, and which avoids turning on keyval syntax in the argument.
1768
1769 As mentioned, we had to turn keyval syntax on in order for it to work.
1770 By default, only keys taking no values are turned on in the argument.
1771 The reason is that argument keys taking values are only useful in very rare cases, such as cohomology with coefficients. If such keys were turned on in general, it would mess up
1772 every occurrence of an equality sign in arguments, and the following
1773 would not work:
1774 \begin{LTXexample}
1775 $\Hom[\sheafreg[\vU]]{
1776 \sheafF[res=\vU],
1777 \sheafG[res=\vU]
1778 }$
1779 \end{LTXexample}
1780
1781 The key~\lstinline!arg keyval! can take four arguments: \lstinline!true! (which we used above, keyval syntax is completely on),
1782 \lstinline!false! (no keys allowed), \lstinline!single keys! (the default behaviour where only keys taking no values are allowed), and \lstinline!one single key! (only allows one key, taking no value).
1783
1784 It should be noted that there are several predefined
1785 argument keys on the level
1786 of the class \lstinline!\SemantexBaseObject!.
1787 The full list can be found in \cref{sec:predefined_arg_keys}.
1788
1789 \chapter{Left indices}
1790
1791 Left indices are a recurring problem in all \TeX-based systems
1792 since \TeX\ only has metrics for the positioning of right indices, none for left indices. And it seems that even the later \TeX\ engines are making no attempts at correcting this. So most packages for left indices
1793 use variations of the following approach:
1794 \begin{LTXexample}
1795 $ {}^{*} f $
1796 \end{LTXexample}
1797 Notice the large space between the star and the~\( f \).
1798 To tackle this problem, the author has written
1799 the \pack{leftindex} package which at least attempts to improve
1800 this situation:
1801 \begin{LTXexample}
1802 $ \leftindex^{*} {f} $
1803 \end{LTXexample}
1804 Roughly, what it does is to use a \enquote{height phantom}
1805 and a \enquote{slanting phantom} to position the left superscript.
1806 The vertical positions of the left indices will be calculated using
1807 the height phantom, and the indentation of the left superscript will be calculated
1808 using the slanting phantom. More precisely, it will copy the metrics for the positioning of right indices from the slanting phantom and use that to position the left superscript. By default, both phantoms are set to be equal to the symbol, which goes fine sometimes, and at other times, another slanting phantom has to be specified. Below, the~\lstinline!I!~is the specified, custom slanting phantom:
1809 \begin{LTXexample}
1810 $ \leftindex^{*} {\Gamma} $,
1811 $ \leftindex[I]^* {\Gamma} $,
1812 $ \leftindex^* {A} $,
1813 $ \leftindex[P]^* {A} $
1814 \end{LTXexample}
1815 We refer to the manual of the package \pack{leftindex} for details,
1816 see
1817 \begin{center}
1818 \url{https://ctan.org/pkg/leftindex}
1819 \end{center}
1820
1821 Our solution for left indices in \semantex{} is based directly on the one
1822 from \pack{leftindex}. However, it works much better if you use \semantex
1823 than if you just used \pack{leftindex} alone, due to the ability to centrally control all your notation. This allows you to choose height and slanting phantoms once and for all in the preamble and never have to worry about it in your document body.
1824
1825 Just like we have the keys \lstinline!upper!, \lstinline!lower!, \lstinline!sep upper!, \lstinline!sep lower!, \lstinline!comma upper!, \lstinline!comma lower!, we have a similar collection of keys for left
1826 indices:
1827 \lstinline!upper left!, \lstinline!lower left!, \lstinline!sep upper left!, \lstinline!sep lower left!, \lstinline!comma upper left!, \lstinline!comma lower left!:
1828 \begin{LTXexample}
1829 $ \vf[upper left=*] $,
1830 $ \vGamma[upper left=*] $,
1831 $ \vA[upper left=*] $
1832 \end{LTXexample}
1833 When you create a new object in \semantex, the height and slanting phantoms
1834 will automatically be set to be equal to the symbol. However, as we see
1835 above, we sometimes need to change them.
1836 This can be done using the keys \lstinline!height phantom!
1837 and~\lstinline!slanting phantom!:
1838 \begin{LTXexample}
1839 \SetupObject\vGamma{
1840 slanting phantom=I}
1841 \SetupObject\vA{slanting phantom=P}
1842 $ \vf[upper left=*] $,
1843 $ \vGamma[upper left=*] $,
1844 $ \vA[upper left=*] $
1845 \end{LTXexample}
1846
1847 Sometimes, changing the slanting phantom is not quite enough.
1848 In the previous example, the star is still not quite close enough
1849 to the~\( \vA \), and there is no slanting phantom that is quite slanted enough to correct this. We solve this using
1850 the key~\lstinline!post upper left!. What you add using this key
1851 will be printed after the upper left index, provided the upper left index
1852 is non-empty and hence will be printed in the first place.
1853 There is also a \lstinline!pre upper left!, and there are similarly \lstinline!pre lower left!, \lstinline!post lower left!, \lstinline!pre upper!, \lstinline!post upper!, \lstinline!pre lower!, and~\lstinline!post lower!.
1854 Let us see it in action:
1855 \begin{LTXexample}
1856 \SetupObject\vA{
1857 slanting phantom=P,
1858 post upper left=\!,
1859 }
1860 $ \vA[upper left=*] $
1861 \end{LTXexample}
1862 Note that \semantex{} at least does its best to try to guess
1863 new height and slanting phantoms when you use operations on objects:
1864 \begin{LTXexample}
1865 $ \vA[spar=\Bigg,upper left=*] $,
1866 $ \vP[command=\overline,return,
1867 upper left=*] $
1868 \end{LTXexample}
1869
1870 \chapter{The \texorpdfstring{\texttt{Symbol}}{Symbol} class type (Example: Derived tensor products and fibre products)}\label{chap:symbol_class}
1871
1872 \begingroup
1873
1874 \NewSymbolClass\MyBinaryOperator[
1875 define keys={
1876 {Lder}{upper=L},
1877 {Rder}{upper=R},
1878 },
1879 ]
1880
1881 \NewObject\MyBinaryOperator\tensor{\otimes}[
1882 define keys={
1883 {der}{Lder},
1884 },
1885 ]
1886
1887 \NewObject\MyBinaryOperator\fibre{\times}[
1888 % Americans are free to call it \fiber instead
1889 define keys={
1890 {der}{Rder},
1891 },
1892 ]
1893
1894 \semantex{} has facilities for printing tensor products~\( \tensor \) as well as derived tensor products~\( \tensor[der] \).
1895 This is probably the right time to reveal that \semantex{} supports multiple class \emph{types}.
1896 So far, we have been exclusively using the \lstinline!Variable!
1897 class type, which is what you create when you apply the command~\lstinline!\NewVariableClass!.
1898 The first other class type we shall need is the \lstinline!Symbol! class type.
1899 This has exactly the same syntax as the \lstinline!Variable!
1900 class type, except that it cannot take an argument.
1901 In other words, its syntax is
1902 \begin{lstlisting}
1903 @\usercommand\<object\>@[@\<options\>@]
1904 \end{lstlisting}
1905 You should normally only use it for special constructions like binary operators and not for e.g.\ variables -- the ability to add arguments to variables comes in handy much more often than one might think.
1906 Let us try to use it to define tensor products and fibre products:
1907 \begin{lstlisting}
1908 \NewSymbolClass\MyBinaryOperator[
1909 define keys={
1910 {Lder}{upper=L},
1911 {Rder}{upper=R},
1912 },
1913 ]
1914
1915 \NewObject\MyBinaryOperator\tensor{\otimes}[
1916 define keys={
1917 {der}{Lder},
1918 },
1919 ]
1920
1921 \NewObject\MyBinaryOperator\fibre{\times}[
1922 % Americans are free to call it \fiber instead
1923 define keys={
1924 {der}{Rder},
1925 },
1926 ]
1927 \end{lstlisting}
1928 As you see, this is one of the few cases where I recommend adding keyval
1929 syntax to other classes than your superclass~\lstinline!\MyVar!. Also, notice that it does not have any~\lstinline!parent=\MyVar!, as I do not really see any reason to inherit all the keyval syntax from the \lstinline!\MyVar!~class.
1930 Now we first define keys \lstinline!Lder! and~\lstinline!Rder! for left and right derived binary operators. Next, we build in a shortcut in both \lstinline!\tensor! and~\lstinline!\fibre!
1931 so that we can write simply~\lstinline!der! and get the correct notion of derived functor. Let us see it in action:
1932 \begin{LTXexample}
1933 $\vA \tensor \vB$,
1934 $\vX[*] \tensor[\vR] \vY[*]$
1935 $\vk \tensor[\vA,der] \vk$,
1936 $\vX \fibre[\vY,der] \vX$
1937 \end{LTXexample}
1938 Later (in~\cref{sec:smart_binary_operators}), we shall see another, more advanced
1939 solution for binary operators which also allows us to express the application of the operator
1940 on \( \vn \)~elements.
1941
1942
1943 \endgroup
1944
1945 \chapter{Paired delimiters}
1946
1947 \NewObject\MyVar\norm[
1948 left par=\lVert, right par=\rVert,
1949 define keys[1]={
1950 {default}{ output options={ default={#1} } },
1951 },
1952 ]
1953 \NewObject\MyVar\inner[left par=\langle, right par=\rangle]
1954
1955 In this chapter, se show how to define delimiter commands like \( \norm{---} \) and~\( \inner{---,---} \).
1956 This is easy to do via the keys \lstinline!left par! and~\lstinline!right par!:
1957 \begin{lstlisting}
1958 \NewObject\MyVar\norm[left par=\lVert, right par=\rVert]
1959 \NewObject\MyVar\inner[left par=\langle, right par=\rangle]
1960 \end{lstlisting}
1961 Indeed:
1962 \begin{LTXexample}
1963 $\norm{\va}$,
1964 $\inner{\va,\vb}$,
1965 $\inner{---,---}$
1966 \end{LTXexample}
1967 In the case where you want to use different kinds of
1968 norms, say \( \norm[2]{---} \) or~\( \norm[\infty]{---} \),
1969 you can use the key~\mylst!output options={$\<options\>$}!.
1970 This allows you to pass the~\<options\> to the output class
1971 (in this case,~\lstinline!\MyVar!):
1972 \begin{lstlisting}
1973 \SetupObject\norm{
1974 define keys[1]={
1975 {default}{ output options={ default={#1} } },
1976 },
1977 }
1978 \end{lstlisting}
1979 \begin{LTXexample}
1980 $\norm{\vx}$,
1981 $\norm[2]{\vx}$,
1982 $\norm[\infty]{\vx}$
1983 \end{LTXexample}
1984
1985 We can also create for more complicated constructions, like sets.
1986 The following is inspired from the \pack{mathtools} package where a similar construction is created using the commands from that package. My impression is that Lars Madsen is the main mastermind behind the code I use for the \lstinline!\where!~construction:
1987 \begin{lstlisting}
1988 \newcommand\wherecommand[1]{%
1989 \nonscript\:%
1990 #1\vert
1991 \allowbreak
1992 \nonscript\:%
1993 \mathopen{}%
1994 }
1995
1996 \NewObject\MyVar\where{ \wherecommand{\SemantexDelimiterSize} }
1997
1998 \NewObject\MyVar\Set[
1999 left par=\lbrace, right par=\rbrace,
2000 pre arg={\,},post arg={\,},
2001 % adds \, inside {...}, as recommended by D. Knuth
2002 arg keyval=false,
2003 % this turns off all keyval syntax in the argument
2004 ]
2005 \end{lstlisting}
2006 \newcommand\wherecommand[1]{%
2007 \nonscript\:%
2008 #1\vert
2009 \allowbreak
2010 \nonscript\:%
2011 \mathopen{}%
2012 }
2013
2014 \NewObject\MyVar\where{ \wherecommand{\SemantexDelimiterSize} }
2015
2016 \NewObject\MyVar\Set[
2017 left par=\lbrace, right par=\rbrace,
2018 pre arg={\,},post arg={\,},
2019 % adds \, inside {...}, as recommended by D. Knuth
2020 arg keyval=false,
2021 % this turns off all keyval syntax in the argument
2022 ]
2023
2024 \noindent
2025 As we briefly mentioned previously,
2026 \lstinline!\SemantexDelimiterSize!~is a command
2027 that returns the size of the delimiters in the
2028 argument.
2029 Now you can use
2030 \begin{LTXexample}
2031 $\Set{ \vx\in\vY \where \vx\ge0 }$,
2032 $\Set[par=\big]{ \vx\in\vY \where \vx\ge0 }$
2033 \end{LTXexample}
2034 Don't forget that, because we called~\lstinline!output=\MyVar! in the beginning of this manual,
2035 the output of any of these commands also belongs to class~\lstinline!\MyVar!.
2036 So you can do stuff like
2037 \begin{LTXexample}
2038 $\Set{
2039 \vx \in \vY[\vi]
2040 \where
2041 \vx \ge 0
2042 }[command=\overline,\vi\in\vI]$
2043 \end{LTXexample}
2044
2045
2046 Tuple-like commands are also possible:
2047 \begin{lstlisting}
2048 \NewObject\MyVar\tup[left par=(,right par=)] % tuples
2049 \NewObject\MyVar\pcoor[ % projective coordinates
2050 left par={[}, right par={]},
2051 set arg sep=\mathbin{:},
2052 % changes the argument separator to colon
2053 set arg dots=\dotsb,
2054 % changes what is inserted if you write "..."
2055 ]
2056 \end{lstlisting}
2057 \NewObject\MyVar\tup[left par=(,right par=)] % tuples
2058 \NewObject\MyVar\pcoor[ % projective coordinates
2059 left par={[}, right par={]},
2060 set arg sep=\mathbin{:},
2061 % changes the argument separator to colon
2062 set arg dots=\dotsb,
2063 % changes what is inserted if you write "..."
2064 ]
2065 Let us see them in action:
2066 \begin{LTXexample}
2067 $\tup{\va,\vb,...,\vz}$,
2068 $\pcoor{\va,\vb,...,\vz}$
2069 \end{LTXexample}
2070
2071 One can use similar techniques for other, less obvious purposes, like calculus differentials:
2072 \begin{lstlisting}
2073 \NewVariableClass\CalculusDifferential[
2074 parent=\MyVar,
2075 define arg keys[1]={
2076 {default}{sep={d\!#1}},
2077 % default is the key that is automatically applied by the
2078 % system to anything you write in the argument that is
2079 % not recognized as an argument key. The sep key
2080 % is a key that prints the value of the key with the
2081 % standard argument separator in front.
2082 },
2083 set arg dots=\dotsm,
2084 never par,
2085 % never par is like no par, except no par will still print
2086 % parentheses when there is more than one argument
2087 % -- never par does not even print parentheses in this case
2088 ]
2089
2090 \NewObject\CalculusDifferential\intD[
2091 set arg sep={\,},
2092 next arg with sep=true,
2093 % because of this, even the first argument will
2094 % receive a separator, which in this case
2095 % is a small space
2096 ]
2097
2098 \NewObject\CalculusDifferential\wedgeD[set arg sep=\wedge]
2099 \end{lstlisting}
2100 \NewVariableClass\CalculusDifferential[
2101 parent=\MyVar,
2102 define arg keys[1]={
2103 {default}{sep={d\!#1}},
2104 % default is the key that is automatically applied by the
2105 % system to anything you write in the argument that is
2106 % not recognized as an argument key. The sep key
2107 % is a key that prints the value of the key with the
2108 % standard argument separator in front.
2109 },
2110 set arg dots=\dotsm,
2111 never par,
2112 % never par is like no par, except no par will still print
2113 % parentheses when there is more than one argument
2114 % -- never par does not even print parentheses in this case
2115 ]
2116
2117 \NewObject\CalculusDifferential\intD[
2118 set arg sep={\,},
2119 next arg with sep=true,
2120 % because of this, even the first argument will
2121 % receive a separator, which in this case
2122 % is a small space
2123 ]
2124
2125 \NewObject\CalculusDifferential\wedgeD[set arg sep=\wedge]
2126
2127 \begin{LTXexample}
2128 $\int \vf \intD{\vx[1],
2129 \vx[2],...,\vx[n]}$,
2130
2131 $\int \vf \wedgeD{\vx[1],
2132 \vx[2],...,\vx[n]}$
2133 \end{LTXexample}
2134
2135 \chapter{Using \texorpdfstring{Seman\!\TeX{}}{SemanTeX} in other commands using \texorpdfstring{\texttt{\textbackslash UseClassInCommand}}{\string\UseClassInCommand}}\label{sec:UseClassInCommand}
2136
2137 \SemantexRecordObject{\Frac}
2138 \newcommand\Frac[2]{%
2139 \SemantexRecordSource{\Frac{#1}{#2}}%
2140 \UseClassInCommand\MyVar{\frac{#1}{#2}}%
2141 }
2142
2143 Sometimes, it is useful to create other commands based on \semantex
2144 classes. For instance, if you grow tired of
2145 writing~\lstinline!\MyVar{ \frac{...}{...} }! whenever you
2146 want to apply keys to a fraction, it could make sense to create
2147 a command~\lstinline!\Frac! which automatically wraps
2148 the fraction in~\lstinline!\MyVar!. The first guess how to
2149 do that would be something like
2150 \begin{lstlisting}
2151 \newcommand\Frac[2]{%
2152 \MyVar{\frac{#1}{#2}}%
2153 }
2154 \end{lstlisting}
2155 \begin{LTXexample}
2156 \[
2157 \Frac{1}{2}[spar=\Big,power=2]
2158 \]
2159 \end{LTXexample}
2160 Indeed, this will work fine for most people.
2161 In fact, the only case where this might cause issues
2162 is if you want to use the \pack{stripsemantex} algorithm to strip
2163 your document of \semantex{} markup. But in order to prepare yourself for this possibility, I recommend getting used from the start to doing it
2164 in a slightly more cumbersome way:
2165 \begin{lstlisting}
2166 \SemantexRecordObject{\Frac}
2167 \newcommand\Frac[2]{%
2168 \SemantexRecordSource{\Frac{#1}{#2}}%
2169 \UseClassInCommand\MyVar{\frac{#1}{#2}}%
2170 }
2171 \end{lstlisting}
2172 \begin{LTXexample}
2173 \[
2174 \Frac{1}{2}[spar=\Big,power=2]
2175 \]
2176 \end{LTXexample}
2177
2178 First things first: We used the following command in front
2179 of~\lstinline!\MyVar!:
2180 \begin{lstlisting}
2181 \UseClassInCommand@\usercommand\<Class\>@[@\<options\>@]{@\<symbol\>@}@\<usual syntax of the class\>@
2182 \end{lstlisting}
2183 So the first advantage to writing~\lstinline!\UseClassInCommand\MyVar!
2184 instead of just~\lstinline!\MyVar!
2185 is that you can pass an additional set of options
2186 to the class first. However, there is a more important
2187 difference, namely that this solution makes the command
2188 compatible with the \pack{stripsemantex} algorithm.
2189
2190 The reason the first solution was not compatible
2191 with \pack{stripsemantex} is that, in this case, the algorithm
2192 will desperately look through your document for
2193 the code~\lstinline!\MyVar{ \frac{1}{2} }[spar=\Big,power=2]!
2194 in order to strip it from your document.
2195 But it will find it nowhere, as this code is hidden away
2196 in the \lstinline!\Frac!~command.
2197 Therefore, we do three things:
2198 \begin{itemize}
2199 \item We register the command~\lstinline!\Frac!
2200 as a \semantex{} command using the
2201 line
2202 \begin{lstlisting}
2203 \SemantexRecordObject{\Frac}
2204 \end{lstlisting}
2205 After this, \semantex{} \enquote{knows}
2206 that \lstinline!\Frac!~is part of the
2207 family of \semantex{} markup.
2208 \item We use the command~\lstinline!\SemantexRecordSource!
2209 to \enquote{record} the source of the command internally.
2210 This way, \pack{stripsemantex} will know what to look for
2211 when it moves through the document, trying to strip
2212 it of \semantex{} markup.
2213 It is therefore important that you record
2214 the source exactly like it will be written in
2215 the source.
2216 (You need not worry about missing braces, though;
2217 even if you write~\lstinline!\Frac12! in your document,
2218 \pack{stripsemantex} will still recognize the code
2219 and strip it as expected.)
2220 \item We write~\lstinline!\UseClassInCommand\MyVar!
2221 instead of just~\lstinline!\MyVar!
2222 in order to correctly record the output code internally. Roughly speaking, when you use the command~\lstinline!\UseClassInCommand!,
2223 \semantex{} \enquote{knows} that the class~\lstinline!\MyVar!
2224 is now used as part of some greater construction.
2225 \end{itemize}
2226
2227 \section{Example: Category theory}
2228
2229 \newcommand\categoryformat[1]{{\operatorname{\mathsf{#1}}}}
2230 % This means that we write categories with sans-serif fonts;
2231 % -- but you can change this to your own liking.
2232 % We use \operatorname since it will allow us to use ordinary
2233 % dashes (rather than minuses) in math mode.
2234 % We use an extra pair of braces around \operatorname
2235 % in order to make it an ordinary symbol (instead of an operator).
2236 % This solution is inspired by an answer by egreg (obviously),
2237 % see https://tex.stackexchange.com/a/567886/19809
2238
2239
2240 \NewObject\MyVar\catset{\categoryformat{Set}}
2241 \NewObject\MyVar\cattop{\categoryformat{Top}}
2242 \NewObject\MyVar\catvect{\categoryformat{Vect}}
2243
2244 \SemantexRecordObject{\catxmod}
2245 \newcommand\catxmod[1]{%
2246 \SemantexRecordSource{\catxmod{#1}}%
2247 \UseClassInCommand\MyVar{#1\categoryformat{-mod}}%
2248 }
2249
2250 \SemantexRecordObject{\catmodx}
2251 \newcommand\catmodx[1]{%
2252 \SemantexRecordSource{\catmodx{#1}}%
2253 \UseClassInCommand\MyVar{\categoryformat{mod-}#1}%
2254 }
2255
2256 \SemantexRecordObject{\catxmody}
2257 \newcommand\catxmody[2]{%
2258 \SemantexRecordSource{\catxmody{#1}{#2}}%
2259 \UseClassInCommand\MyVar{#1\categoryformat{-mod-}#2}%
2260 }
2261
2262 \SemantexRecordObject{\catxmodx}
2263 \newcommand\catxmodx[1]{%
2264 \SemantexRecordSource{\catxmodx{#1}}%
2265 \UseClassInCommand\MyVar{#1\categoryformat{-mod-}#1}%
2266 }
2267
2268 The above method can be used to create commands
2269 for typing categories. First and foremost,
2270 it is easy to create objects corresponding
2271 to simple categories like~\( \catset \), \( \cattop \) and~\( \catvect \):
2272 \begin{lstlisting}
2273 \newcommand\categoryformat[1]{{\operatorname{\mathsf{#1}}}}
2274 % This means that we write categories with sans-serif fonts;
2275 % -- but you can change this to your own liking.
2276 % We use \operatorname since it will allow us to use ordinary
2277 % dashes (rather than minuses) in math mode.
2278 % We use an extra pair of braces around \operatorname
2279 % in order to make it an ordinary symbol (instead of an operator).
2280 % This solution is inspired by an answer by egreg (obviously),
2281 % see @\itshape\url{https://tex.stackexchange.com/a/567886/19809}@
2282
2283 \NewObject\MyVar\catset{\categoryformat{Set}}
2284 \NewObject\MyVar\cattop{\categoryformat{Top}}
2285 \NewObject\MyVar\catvect{\categoryformat{Vect}}
2286 \end{lstlisting}
2287 \begin{LTXexample}
2288 $ \catset $,
2289 $ \cattop $,
2290 $ \catvect{\vk} $.
2291 \end{LTXexample}
2292 However, we run into issues with categories like~\( \catxmod{\vR} \)
2293 where we shall constantly have to change the ring~\( \vR \).
2294 For this, we use the constructions we learned at the introduction
2295 to this chapter:
2296 \begin{lstlisting}
2297 \SemantexRecordObject{\catxmod}
2298 \newcommand\catxmod[1]{%
2299 \SemantexRecordSource{\catxmod{#1}}%
2300 \UseClassInCommand\MyVar{#1\categoryformat{-mod}}%
2301 }
2302 \end{lstlisting}
2303 \begin{LTXexample}
2304 $ \catxmod{\vR} $,
2305 $ \catxmod{\vS} $,
2306 $ \catxmod{\vA}[spar,op] $
2307 \end{LTXexample}
2308 (here, we used the key~\lstinline!op!
2309 which we defined in \cref{sec:algebra}).
2310 You can, of course, extend it to all sorts
2311 of other situations, like
2312 \( \catmodx{\vR} \) or~\( \catxmody{\vR}{\vS} \):
2313 \begin{lstlisting}
2314 \SemantexRecordObject{\catmodx}
2315 \newcommand\catmodx[1]{%
2316 \SemantexRecordSource{\catmodx{#1}}%
2317 \UseClassInCommand\MyVar{\categoryformat{mod-}#1}%
2318 }
2319
2320 \SemantexRecordObject{\catxmody}
2321 \newcommand\catxmody[2]{%
2322 \SemantexRecordSource{\catxmody{#1}{#2}}%
2323 \UseClassInCommand\MyVar{#1\categoryformat{-mod-}#2}%
2324 }
2325
2326 \SemantexRecordObject{\catxmodx}
2327 \newcommand\catxmodx[1]{%
2328 \SemantexRecordSource{\catxmodx{#1}}%
2329 \UseClassInCommand\MyVar{#1\categoryformat{-mod-}#1}%
2330 }
2331 \end{lstlisting}
2332
2333 \chapter{The \texorpdfstring{\texttt{parse}}{parse} routine}
2334
2335 \NewObject\MyVar\Mat{\operatorname{Mat}}[
2336 % We provide data sets "rows" and "columns" to
2337 % be set up by the user later
2338 data provide={rows},
2339 data provide={columns},
2340 data provide={field},
2341 define keys[1]={
2342 {rows}{ data set={rows}{#1} }, % set the rows data set
2343 {columns}{ data set={columns}{#1} }, % set the columns data set
2344 {field}{ data set={field}{#1} }, % set the underlying field
2345 {arg}{ field={#1} },
2346 % this way, setting the argument becomes equivalent
2347 % to specifying the underlying field
2348 },
2349 parse options={ % Here we add code to the parse routine
2350 % We check whether columns = rows. If so, we only write
2351 % the number once
2352 str if eq TF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}}
2353 {
2354 set keys x={
2355 lower={\SemantexDataGetExpNot{columns}},
2356 },
2357 }
2358 {
2359 set keys x={
2360 lower={
2361 \SemantexDataGetExpNot{rows}
2362 \times
2363 \SemantexDataGetExpNot{columns}
2364 },
2365 },
2366 },
2367 if blank F={\SemantexDataGetExpNot{field}}
2368 {
2369 set arg keys x={
2370 sep={\SemantexDataGetExpNot{field}},
2371 },
2372 },
2373 },
2374 ]
2375
2376
2377 \NewObject\MyVar\GL{\operatorname{GL}}[
2378 % We provide a few data sets:
2379 data provide=order, % The "order" will be the number n in GL_n(k)
2380 data provide=field, % The "field" is of course the k in GL_n(k)
2381 define keys[1]={
2382 {order}{ data set={order}{#1} }, % Sets the order
2383 {field}{ data set={field}{#1} }, % Sets the field
2384 {arg}{ field={#1} },
2385 % This way, setting the argument becomes equivalent
2386 % to setting the field
2387 },
2388 parse options={
2389 set keys x={
2390 % This means set the keys, but fully expand their values first
2391 lower={\SemantexDataGetExpNot{order}},
2392 },
2393 if blank F={\SemantexDataGetExpNot{field}}
2394 {
2395 set arg keys x={
2396 % Set the argument keys, but fully expand their values first
2397 sep={\SemantexDataGetExpNot{field}},
2398 },
2399 },
2400 },
2401 ]
2402
2403 \SetupObject\co{
2404 data provide=coefficient,
2405 data provide=space,
2406 define keys[1]={
2407 {coef}{ data set={coefficient}{#1} },
2408 {space}{ data set={space}{#1} },
2409 {arg}{ space={#1} },
2410 },
2411 parse options={
2412 if blank F={\SemantexDataGetExpNot{space}}
2413 {
2414 set arg keys x={
2415 sep=\SemantexDataGetExpNot{space},
2416 },
2417 },
2418 if blank F={\SemantexDataGetExpNot{coefficient}}
2419 {
2420 set arg keys x={
2421 other sep={;}{ \SemantexDataGetExpNot{coefficient} },
2422 },
2423 },
2424 },
2425 }
2426
2427 As you can see above, \semantex{} has a \enquote{waterfall-like} behaviour. It runs keys in the order it receives them. This works fine most of the time, but for some more complicated constructions, it is useful to be able to provide a collection of data in any order,
2428 and have the system take care of printing them in the right places,
2429 according to how you program the object in the preamble.
2430 For this purpose, we have the \lstinline!parse!~routine.
2431 Using the \lstinline!parse! routine allows for a comfortable,
2432 HTML-like syntax, e.g.:
2433 \begin{LTXexample}
2434 $ \GL[order=\vn,field=\vk] $,
2435 $ \Mat[rows=\vm,columns=\vn,
2436 field=\vk] $,
2437 $ \co[d=0,coef=\vR,space=\vX] $
2438 \end{LTXexample}
2439 The \lstinline!parse! routine is a collection of code which is
2440 executed right before
2441 an object (or class) is being rendered (but before it outputs).
2442 By default, the parse routine contains no code.
2443 However, you can add code to it using the
2444 key~\mylst!parse options={$\<keys\>$}!.
2445
2446 Even though the \lstinline!parse!~routine is automatically invoked right before rendering, you can also invoke it at any time by force
2447 using the key~\lstinline!parse!. This will also empty the code from the
2448 \lstinline!parse!~routine so that it will not be executed twice:
2449 \begin{LTXexample}
2450 $ \GL[order=\vn,field=\vk,parse,
2451 spar,op] $
2452 \end{LTXexample}
2453 (here we used the key~\lstinline!op! from \cref{sec:algebra}).
2454 Alternatively, you can add a new pair of brackets, which will render the object
2455 and invoke the \lstinline!parse!~routine:
2456 \begin{LTXexample}
2457 $\GL[order=\vn,field=\vk][spar,op]$
2458 \end{LTXexample}
2459 Note, though, that in this case, the \lstinline!spar! and~\lstinline!op!~keys
2460 are not being applied to the object~\lstinline!\GL! itself, but
2461 to the object (of class~\lstinline!\MyVar!) that it outputs. This should not cause
2462 any issues in practice, as long as the keys you are using
2463 are already defined on the level of~\lstinline!\MyVar!.
2464
2465 \section{Example: Matrix sets and groups}
2466
2467 Suppose we want to be able to write the group of invertible \( \vn \times \vn \)-matrices with entries in~\( \vk \)
2468 as~\(
2469 \GL[order=\vn,field=\vk]
2470 \).
2471 We can in principle do the following:
2472 \begingroup
2473 \SetupObject\GL{
2474 data clear=parse options,
2475 define keys[1]={
2476 {arg}{ set arg keys={sep=#1} }
2477 },
2478 }
2479 \begin{lstlisting}
2480 \NewObject\MyVar\GL{\operatorname{GL}}
2481 \end{lstlisting}
2482 \begin{LTXexample}
2483 $ \GL[\vn]{\vk} $.
2484 \end{LTXexample}%
2485 However, this is not quite as systematic and semantic as we might have wanted. Indeed, what if later we would like to change the notation
2486 to~\(
2487 \GL{\vn,\vk}
2488 \)?
2489 We could in principle use a key with 2~values for this.
2490 However, in this section,
2491 we show how to use the \lstinline!parse!~routine
2492 to enable the syntax from the introduction to this chapter.
2493
2494 \endgroup
2495
2496 As mentioned there, we need to add code via the \lstinline!parse!~routine.
2497 However, to make proper use of it, we need some programming keys
2498 and programming commands.
2499 You can find an overview of these in~\cref{sec:programming_keys,sec:programming_commands}.
2500
2501 To set up the notation from above, we do the following:
2502 \begin{lstlisting}
2503 \NewObject\MyVar\GL{\operatorname{GL}}[
2504 % We provide a few data sets:
2505 data provide=order, % The "order" will be the number n in GL_n(k)
2506 data provide=field, % The "field" is of course the k in GL_n(k)
2507 define keys[1]={
2508 {order}{ data set={order}{#1} }, % Sets the order
2509 {field}{ data set={field}{#1} }, % Sets the field
2510 {arg}{ field={#1} },
2511 % This way, setting the argument becomes equivalent
2512 % to setting the field
2513 },
2514 parse options={
2515 set keys x={
2516 % This means set the keys, but fully expand their values first
2517 lower={\SemantexDataGetExpNot{order}},
2518 },
2519 if blank F={\SemantexDataGetExpNot{field}}
2520 {
2521 set arg keys x={
2522 % Set the argument keys, but fully expand their values first
2523 sep={\SemantexDataGetExpNot{field}},
2524 },
2525 },
2526 },
2527 ]
2528 \end{lstlisting}
2529
2530 Notice that we changed the \lstinline!arg!~key.
2531 This means that specifying the argument becomes equivalent to setting the field.
2532 This is what makes the first two pieces of syntax below equivalent:
2533
2534 \begin{LTXexample}
2535 $ \GL[order=\vn,field=\vk] $,
2536 $ \GL[order=\vn]{\vk} $,
2537 $ \GL[order=\vn] $.
2538 \end{LTXexample}
2539
2540 Let us look at a more complicated example:
2541 The set~\( \Mat[rows=\vn,columns=\vm,field=\vk] \)
2542 of \( \vn \times \vm \)-matrices with entries in~\( \vk \).
2543 What makes this example more complicated is not only that we have
2544 an additional piece of data, but that we require
2545 that if the number of rows and columns are equal,
2546 we want it to print~\( \Mat[rows=\vn,columns=\vn,field=\vk] \)
2547 rather than~\( \Mat[rows=\vn,columns={}\vn,field=\vk] \).
2548 We accomplish this by the following:
2549
2550 \begin{lstlisting}
2551 \NewObject\MyVar\Mat{\operatorname{Mat}}[
2552 % We provide data sets "rows" and "columns" to
2553 % be set up by the user later
2554 data provide={rows},
2555 data provide={columns},
2556 data provide={field},
2557 define keys[1]={
2558 {rows}{ data set={rows}{#1} }, % set the rows data set
2559 {columns}{ data set={columns}{#1} }, % set the columns data set
2560 {field}{ data set={field}{#1} }, % set the underlying field
2561 {arg}{ field={#1} },
2562 % this way, setting the argument becomes equivalent
2563 % to specifying the underlying field
2564 },
2565 parse options={ % Here we add code to the parse routine
2566 % We check whether columns = rows. If so, we only write
2567 % the number once
2568 str if eq TF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}}
2569 {
2570 set keys x={
2571 lower={\SemantexDataGetExpNot{columns}},
2572 },
2573 }
2574 {
2575 set keys x={
2576 lower={
2577 \SemantexDataGetExpNot{rows}
2578 \times
2579 \SemantexDataGetExpNot{columns}
2580 },
2581 },
2582 },
2583 if blank F={\SemantexDataGetExpNot{field}}
2584 {
2585 set arg keys x={
2586 sep={\SemantexDataGetExpNot{field}},
2587 },
2588 },
2589 },
2590 ]
2591 \end{lstlisting}
2592
2593 \begin{LTXexample}
2594 $ \Mat[rows=\vm,columns=\vn,
2595 field=\vk] $,
2596 $ \Mat[rows=\vn,columns=\vn,
2597 field=\vk] $.
2598 \end{LTXexample}
2599
2600 \section{Example: Cohomology with coefficients, revisited}\label{ch:parse_coho_coef}
2601
2602 As promised previously, we revisit cohomology with coefficients
2603 and show how to set up a syntax like the below:
2604
2605 \begin{lstlisting}
2606 \SetupObject\co{
2607 data provide=coefficient,
2608 data provide=space,
2609 define keys[1]={
2610 {coef}{ data set={coefficient}{#1} },
2611 {space}{ data set={space}{#1} },
2612 {arg}{ space={#1} },
2613 },
2614 parse options={
2615 if blank F={\SemantexDataGetExpNot{space}}
2616 {
2617 set arg keys x={
2618 sep=\SemantexDataGetExpNot{space},
2619 },
2620 },
2621 if blank F={\SemantexDataGetExpNot{coefficient}}
2622 {
2623 set arg keys x={
2624 other sep={;}{ \SemantexDataGetExpNot{coefficient} },
2625 },
2626 },
2627 },
2628 }
2629 \end{lstlisting}
2630
2631 \begin{LTXexample}
2632 $\co[d=0]$,
2633 $\co[d=0,space=\vX]$,
2634 $\co[d=0,space=\vX,coef=\vR]$
2635 \end{LTXexample}
2636
2637 \section{Example: Partial derivatives}
2638
2639 Let us look at a more complicated example: Let us create a command for partial derivatives:
2640
2641 \NewObject\MyVar\partialdif[
2642 no par,
2643 bool provide={raise function},
2644 bool set true={raise function},
2645 set i dots=\dotsm,
2646 set i sep={\,},
2647 define keys[1]={
2648 {default}{
2649 sep i={\partial #1},
2650 },
2651 {raise}{
2652 str if eq TF={#1}{true}
2653 {
2654 bool set true={raise function},
2655 }
2656 {
2657 str if eq TF={#1}{false}
2658 {
2659 bool set false={raise function},
2660 }
2661 {
2662 ERROR key value not found={raise}{#1},
2663 },
2664 },
2665 },
2666 },
2667 parse options={
2668 if blank TF={ \SemantexDataGetExpNot{upper} }
2669 {
2670 int if greater TF={ \SemantexIntGet{number of lower indices} } { 1 }
2671 {
2672 set keys x={
2673 symbol={
2674 \SemantexExpNot\frac
2675 {
2676 \partial ^ { \SemantexIntGet{number of lower indices} }
2677 \SemantexBoolIfT{raise function}
2678 {
2679 \SemantexDataGetExpNot{arg}
2680 }
2681 }
2682 {
2683 \SemantexDataGetExpNot{lower}
2684 }
2685 },
2686 },
2687 }
2688 {
2689 set keys x={
2690 symbol={
2691 \SemantexExpNot\frac
2692 {
2693 \partial
2694 \SemantexBoolIfT{raise function}
2695 {
2696 \SemantexDataGetExpNot{arg}
2697 }
2698 }
2699 {
2700 \SemantexDataGetExpNot{lower}
2701 }
2702 },
2703 }
2704 },
2705 }
2706 {
2707 set keys x={
2708 symbol={
2709 \SemantexExpNot\frac
2710 {
2711 \partial ^ { \SemantexDataGetExpNot{upper} }
2712 \SemantexBoolIfT{raise function}
2713 {
2714 \SemantexDataGetExpNot{arg}
2715 }
2716 }
2717 {
2718 \SemantexDataGetExpNot{lower}
2719 }
2720 },
2721 },
2722 },
2723 data clear={lower},
2724 data clear={upper},
2725 bool if T={raise function}
2726 {
2727 data clear={arg},
2728 int clear={number of arguments},
2729 },
2730 },
2731 ]
2732
2733 \begin{lstlisting}
2734 \NewObject\MyVar\partialdif[
2735 no par,
2736 bool provide={raise function},
2737 bool set true={raise function},
2738 set i dots=\dotsm,
2739 set i sep={\,},
2740 define keys[1]={
2741 {default}{
2742 sep i={\partial #1},
2743 },
2744 {raise}{
2745 str if eq TF={#1}{true}
2746 {
2747 bool set true={raise function},
2748 }
2749 {
2750 str if eq TF={#1}{false}
2751 {
2752 bool set false={raise function},
2753 }
2754 {
2755 ERROR key value not found={raise}{#1},
2756 },
2757 },
2758 },
2759 },
2760 parse options={
2761 if blank TF={ \SemantexDataGetExpNot{upper} }
2762 {
2763 int if greater TF={ \SemantexIntGet{number of lower indices} } { 1 }
2764 {
2765 set keys x={
2766 symbol={
2767 \SemantexExpNot\frac
2768 {
2769 \partial ^ { \SemantexIntGet{number of lower indices} }
2770 \SemantexBoolIfT{raise function}
2771 {
2772 \SemantexDataGetExpNot{arg}
2773 }
2774 }
2775 {
2776 \SemantexDataGetExpNot{lower}
2777 }
2778 },
2779 },
2780 }
2781 {
2782 set keys x={
2783 symbol={
2784 \SemantexExpNot\frac
2785 {
2786 \partial
2787 \SemantexBoolIfT{raise function}
2788 {
2789 \SemantexDataGetExpNot{arg}
2790 }
2791 }
2792 {
2793 \SemantexDataGetExpNot{lower}
2794 }
2795 },
2796 }
2797 },
2798 }
2799 {
2800 set keys x={
2801 symbol={
2802 \SemantexExpNot\frac
2803 {
2804 \partial ^ { \SemantexDataGetExpNot{upper} }
2805 \SemantexBoolIfT{raise function}
2806 {
2807 \SemantexDataGetExpNot{arg}
2808 }
2809 }
2810 {
2811 \SemantexDataGetExpNot{lower}
2812 }
2813 },
2814 },
2815 },
2816 data clear={lower},
2817 data clear={upper},
2818 bool if T={raise function}
2819 {
2820 data clear={arg},
2821 int clear={number of arguments},
2822 },
2823 },
2824 ]
2825 \end{lstlisting}
2826 Let us see it in action:
2827 \begin{LTXexample}
2828 \[
2829 \partialdif[\vx,\vy,\vz]{
2830 \vf } ,
2831 \partialdif[\vu^2,\vv^2,
2832 d=4]{ \vf },
2833 \partialdif[\vx[1],
2834 \vx[2],...,\vx[\vn],
2835 d=\vn]{ \vf }
2836 \]
2837 \[
2838 \partialdif[\vx,\vy,\vz,raise=false]{ \vf } ,
2839 \partialdif[\vu^2,\vv^2,
2840 d=4,raise=false]{
2841 \vf },
2842 \]
2843 \[
2844 \partialdif[\vx[1],
2845 \vx[2],...,\vx[\vn],
2846 d=\vn,raise=false]{
2847 \vf }
2848 \]
2849 \end{LTXexample}
2850 As you see, we use the \lstinline!d!~key to tell the command what superscript it should put on the~\( \partial \) in the enumerator. If it does not receive a~\lstinline!d!, it counts the number of variables you wrote and prints that. That is why the following would give the wrong result:
2851 \begin{LTXexample}
2852 \[
2853 \partialdif[\vu^2,\vv^2]{
2854 \vf },
2855 \partialdif[\vx[1],
2856 \vx[2],...,\vx[\vn]]{
2857 \vf }
2858 \]
2859 \end{LTXexample}
2860
2861 \section{Example: Smart binary operators}\label{sec:smart_binary_operators}
2862
2863 \begingroup
2864
2865 \NewVariableClass\MyBinaryOperator[
2866 set arg dots=\dotsb,
2867 never par,
2868 prepend keys[1]={
2869 {arg}{
2870 return,
2871 set keys x={
2872 set arg sep=\SemantexDataGetExpNot{symbol},
2873 },
2874 },
2875 },
2876 parse options={
2877 int if greater T={ \SemantexIntGet{number of arguments} } { 0 }
2878 {
2879 symbol={},
2880 output=\MyVar,
2881 },
2882 },
2883 ]
2884
2885 \NewObject\MyBinaryOperator\mult{\cdot}
2886 \NewObject\MyBinaryOperator\tensor{\otimes}
2887
2888 \NewVariableClass\InvisibleBinaryOperator[parent=\MyBinaryOperator, set arg dots=\dotsm]
2889 \NewObject\InvisibleBinaryOperator\invmult{}
2890 \NewObject\InvisibleBinaryOperator\spacemult{\,}
2891
2892 In~\cref{chap:symbol_class}, we saw a simple solution for binary operators using the \lstinline!Symbol!~class.
2893 But that solution only printed the operator itself. However, in semantic markup systems, it is ofen desirable
2894 to also be able to explicitly typeset applications of the operator on \( \vn \)~arguments, like this:
2895 \begin{LTXexample}
2896 Applying the tensor product~$\tensor$ to $\vn$~elements, we get
2897 \[
2898 \tensor{ \vx[1], \vx[2], ...,
2899 \vx[\vn] }.
2900 \]
2901 Applying the multiplication operator~$\mult$ to $\vn$~elements, we get
2902 \[
2903 \mult{ \vx[1], \vx[2], ...,
2904 \vx[\vn] }.
2905 \]
2906 \end{LTXexample}
2907
2908 This can be accomplished using the \lstinline!parse!~routine as follows:
2909
2910 \begin{lstlisting}
2911 \NewVariableClass\MyBinaryOperator[
2912 set arg dots=\dotsb,
2913 never par,
2914 prepend keys[1]={
2915 {arg}{
2916 return,
2917 set keys x={
2918 set arg sep=\SemantexDataGetExpNot{symbol},
2919 },
2920 },
2921 },
2922 parse options={
2923 int if greater T={ \SemantexIntGet{number of arguments} } { 0 }
2924 {
2925 symbol={},
2926 output=\MyVar,
2927 },
2928 },
2929 ]
2930
2931 \NewObject\MyBinaryOperator\tensor{\otimes}
2932 \NewObject\MyBinaryOperator\mult{\cdot}
2933 \end{lstlisting}
2934
2935 In mathematical texts, the multiplication symbols in that last equation would usually be omitted.
2936 However, if we want to make the syntax fully semantic, we should also type these multiplication operators explicitly, even if they will be invisible in the final output.
2937 We do this by changing the argument dots and creating an object with an empty symbol.
2938 Alternatively, if we want to insert a space between the variables being multiplied,
2939 we can set the symbol to~\lstinline!\,!:
2940 \begin{lstlisting}
2941 \NewVariableClass\InvisibleBinaryOperator[parent=\MyBinaryOperator,
2942 set arg dots=\dotsm]
2943 \NewObject\InvisibleBinaryOperator\invmult{}
2944 \NewObject\InvisibleBinaryOperator\spacemult{\,}
2945 \end{lstlisting}
2946 \begin{LTXexample}
2947 In mathematical texts, we denote the product of \( \vn \)~elements simply by
2948 \[
2949 \invmult{ \vx[1], \vx[2], ...,
2950 \vx[\vn] }
2951 =
2952 \spacemult{ \vx[1], \vx[2], ...,
2953 \vx[\vn] }.
2954 \]
2955 \end{LTXexample}
2956
2957 \endgroup
2958
2959 \chapter{\texorpdfstring{\texttt{stripsemantex}}{stripsemantex} -- stripping your document of \texorpdfstring{\semantex}{SemanTeX} markup}
2960
2961 \semantex{} is a big, heavy package, and it might raise eyebrows if you try using it in submissions to journals. On top of that, \url{arXiv.org}
2962 is using \TeX~Live~2016 at the time of writing this, and it has
2963 an old version of \LaTeX3 that seems unable to run \semantex.
2964 To address this issue, \semantex{} has a companion package,
2965 called \pack{stripsemantex}, which allows you to strip the
2966 \semantex{} markup from your document and replace it with raw \LaTeX~code.
2967 While no such algorithm will ever be perfect, it generally works
2968 very well, even for quite complicated constructions,
2969 as long as you use the package in the \enquote{normal}
2970 and supported way.
2971 (If you want proof, have a look at my
2972 recent paper which was stripped using
2973 the algorithm: \url{https://arxiv.org/abs/2008.04794}.)
2974
2975 The system has the following limitations:
2976
2977 \begin{itemize}
2978 \item It is currently only able to strip the \semantex{} markup from your main document (so it will ignore anything in \lstinline!\input{...}! and~\lstinline!\include{...}!). So prior to running \pack{stripsemantex},
2979 you should include your entire document body in your
2980 main \texttt{.tex}~file.
2981 \item Partly because of the previous point, no attempt is made to remove
2982 the \emph{setup} of \semantex,
2983 so commands like \lstinline!\NewObject!, \lstinline!\SetupObject!, and~\lstinline!\SetupClass!
2984 will remain in the document body.
2985 You will then have to remove these yourself afterwards.
2986 But the \semantex{} markup itself should be stripped completely from your document.
2987 \item As mentioned, as long as you do normal, supported things,
2988 everything should work fine. Non-normal, non-supported
2989 things are tings like
2990 \begin{lstlisting}
2991 \va[execute={\vb}]
2992 \end{lstlisting}
2993 \item Things might go wrong if you define new keys
2994 between \lstinline!\begin{document}! and~\lstinline!\end{document}!
2995 whose definitions make use of other \semantex{} objects or classes,
2996 since the algorithm will try to strip these from the definitions.
2997 For instance, don't do stuff like this
2998 after~\lstinline!\begin{document}!:
2999 \begin{lstlisting}
3000 \SetupObject\va{
3001 define keys[1]={
3002 {weirdkey}{ upper=\vb[ {#1} ] }
3003 },
3004 }
3005 \end{lstlisting}
3006 If you do, the algorithm will then try and strip this
3007 occurrence of~\lstinline!\vb! from the key definition.
3008 To avoid such issues, only ever define keys in your preamble,
3009 as the algorithm will ignore everything
3010 before \lstinline!\begin{document}!.
3011 \item When the document has just been stripped,
3012 it will load a small package called \pack{semtex},
3013 which contains a couple of commands that the output will need
3014 in order to run. You will be able to replace all of these commands
3015 by other commands and then render the package \pack{semtex}
3016 unnecessary. More on this in \cref{sec:semtex_package}.
3017 \item When \semantex{} runs, the content of any argument is being wrapped
3018 between \lstinline!\begingroup! and~\lstinline!\endgroup!. This is part of what
3019 makes it possible to use the command~\lstinline!\SemantexDelimiterSize!.
3020 However, these \lstinline!\begingroup! and~\lstinline!\endgroup! will not appear
3021 in the stripped document. This means that if you do stuff like
3022 \begin{lstlisting}
3023 $ \def\foo{bar} \va{ \def\foo{barbar} \vx } \foo $
3024 \end{lstlisting}
3025 then this will print~\( \va{\vx} bar \) before running \pack{stripsemantex},
3026 but~\( \va{\vx} barbar \) after. In order to avoid this, simply don't define
3027 commands inside arguments, which you should never do in the first place (and why would you anyway?).
3028 \end{itemize}
3029
3030 As a small proof of concept, this is what the example in the introduction
3031 would look like when stripped of \semantex{} markup:
3032
3033 \begin{lstlisting}
3034 % Same preamble as before.
3035
3036 \begin{document}
3037
3038 $ \overline{f}^{(n)} $
3039
3040 $ g^{-1}|_{U} (x) $
3041
3042 $ (h^{-1} \mathcal{F})_{p}
3043 = \mathcal{F}_{h(p)} $
3044
3045 \end{document}
3046 \end{lstlisting}
3047
3048 Yes, I know, this was a very simple, unconvincing example.
3049 If you want a less trivial example, as mentioned before,
3050 you can have a look at my latest paper, which was stripped with
3051 (a previous alpha version of) \pack{stripsemantex}:
3052
3053 \begin{center}
3054 \url{https://arxiv.org/abs/2008.04794}
3055 \end{center}
3056
3057 \section{The \texttt{semtex} package}\label{sec:semtex_package}
3058
3059 When you have stripped your document and removed all \semantex{} package setup, it should be safe to remove
3060 the loading of \semantex{} from your preamble.
3061 However, the stripping algorithm will automatically
3062 add the following lines to your document right before~\lstinline!\begin{document}!:
3063 \begin{lstlisting}
3064 % The following was added by "stripsemantex":
3065
3066 \usepackage{semtex,leftindex,graphicx}
3067
3068 \providecommand\SemantexLeft{%
3069 \mathopen{}\mathclose\bgroup\left
3070 }
3071
3072 \providecommand\SemantexRight{%
3073 \aftergroup\egroup\right
3074 }
3075
3076 \makeatletter
3077 \DeclareRobustCommand\SemantexBullet{%
3078 \mathord{\mathpalette\SemantexBullet@\at@{0.5}}%
3079 }
3080 \newcommand\SemantexBullet@\at@[2]{%
3081 \vcenter{\hbox{\scalebox{#2}{$\m@\at@th#1\bullet$}}}%
3082 }
3083 \DeclareRobustCommand\SemantexDoubleBullet{\SemantexBullet \SemantexBullet}
3084 \makeatother
3085 \end{lstlisting}
3086 The package \pack{leftindex} is loaded to take care of any
3087 possible left indices. The package~\pack{graphicx}
3088 is loaded to provide the command~\lstinline!\scalebox!.
3089 This package~\pack{semtex} is a small package whose sole purpose
3090 is to be loaded by stripped \semantex{} documents.
3091 All it does is define the four commands
3092 \lstinline!\SemantexLeft!, \lstinline!\SemantexRight!,
3093 \lstinline!\SemantexBullet!, and~\lstinline!\SemantexDoubleBullet!
3094 so that you can remove these definitions from your document and just rely on the package instead.
3095
3096 Let us take a look at the commands defined by \pack{semtex}:
3097
3098 \begin{itemize}
3099 \item
3100 \mylst!\SemantexBullet!,
3101 \mylst!\SemantexDoubleBullet!
3102
3103 The commands that contain the bullets we use in \semantex,
3104 i.e.~the superscript in~\( \co[*] \).
3105 These bullets are smaller (and prettier, in my opinion)
3106 than the standard \lstinline!\bullet! command from~\LaTeX.
3107
3108 \item
3109 \mylst!\SemantexLeft!,
3110 \mylst!\SemantexRight!
3111
3112 Like \lstinline!\left ...\right!, but fixing some spacing issues
3113 around these.
3114 They are completely equivalent to~\lstinline!\mleft! and~\lstinline!\mright!
3115 from the package~\pack{mleftright}, so it is safe to just load that package
3116 and replace the above commands by \lstinline!\mleft ...\mright! instead,
3117 or use the redefinitions mentioned above.
3118 \end{itemize}
3119
3120 \section{The \texttt{stripsemantex} algorithm}
3121
3122 The stripping algorithm works like this.
3123 It will work in any \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, etc.), but along
3124 the way, you will have to create a small,
3125 separate document and compile it with \hologo{LuaTeX}.
3126 Suppose in the following that you \TeX\ document is called~\texttt{mydoc.tex}.
3127
3128 \begin{enumerate}[(1)]
3129 \item Make sure to collect all of the \semantex{} markup you want
3130 stripped in the main document,~\texttt{mydoc.tex}.
3131 Also make sure to follow the recommendations
3132 in \cref{sec:UseClassInCommand}, in case you have created commands
3133 of the form described there.
3134 \item Put the following somewhere in your preamble, after
3135 the loading of \semantex:
3136 \begin{lstlisting}
3137 \SemantexSetup{semtexfile=true}
3138 \end{lstlisting}
3139 \item Compile your document \texttt{mydoc.tex} using your preferred \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, or whatever).
3140 Because of the previous step, there
3141 will now be a new file, \texttt{mydoc.semtex},
3142 in your folder, where the raw output
3143 of each \semantex{} command is stored. In a moment,
3144 \pack{stripsemantex} will use this information to replace
3145 each command by the raw code it outputs.
3146 \item Create another \TeX\ document in the same folder
3147 as \texttt{mydoc.tex}, and call it \texttt{stripdoc.tex}
3148 (or whatever you want). Put the following into it:
3149 \begin{lstlisting}
3150 \documentclass{article}
3151
3152 \usepackage{stripsemantex}
3153
3154 \begin{document}
3155
3156 \StripSemantex{mydoc}
3157
3158 \end{document}
3159 \end{lstlisting}
3160 Then compile it \textbf{with \hologo{LuaTeX}}.
3161
3162 After this step, another document will have been created in the same
3163 folder, called~\lstinline!mydoc_prestripped.tex!. It will look just like \texttt{mydoc.tex},
3164 but in the document body, each command defined using \semantex{} will now
3165 have an expression of the form~\mylst!\SemantexID{$\<a unique ID\>$}!
3166 preceding it.
3167
3168 \item\label{pt:pre_strip_point}
3169 Compile the document \lstinline!mydoc_prestripped.tex! using the same \TeX\ engine as the one you used
3170 for \texttt{mydoc.tex}.
3171 \item\label{pt:strip_point}
3172 Compile the document~\lstinline!stripdoc.tex! again, this time also \textbf{using \hologo{LuaTeX}}.
3173
3174 \item After the previous step, some (but usually not all) \semantex{} markup will have been
3175 removed from the file~\lstinline!mydoc_prestripped.tex!.
3176 If the stripping algorithm has terminated (which it almost never does after a single run), there will now be a new document in your folder,
3177 called~\lstinline!mydoc_stripped.tex!.
3178 If this document is not there, repeat the steps \ref{pt:pre_strip_point} and~\ref{pt:strip_point}.
3179
3180 Continue this way until the file \lstinline!mydoc_stripped.tex! appears. It can easily require three or more iterations, but each iteration will usually be faster than the previous one, and eventually, the file~\lstinline!mydoc_stripped.tex! will appear.
3181 (Note that at the point~\ref{pt:strip_point}, \pack{stripsemantex} will also issue a warning if the algorithm has not yet terminated, asking you to repeat the steps \ref{pt:pre_strip_point} and~\ref{pt:strip_point}).
3182
3183 Note again that your \semantex{} \textbf{setup}
3184 will not be removed, so there
3185 will still be commands like \lstinline!\NewObject!,
3186 \lstinline!\SetupObject!, \lstinline!\SetupClass!,~etc.
3187 left. You will then have to remove these few commands from your document manually.
3188 \end{enumerate}
3189
3190 \newpage
3191 \section{Stripping comments from the document}
3192
3193 Apart from the machinery for stripping \semantex{} markup from documents,
3194 the package \pack{stripsemantex} also provides the command~\lstinline!\StripSemantexStripComments!,
3195 which is in principle completely unrelated to \semantex{} itself.
3196 This command allows you to strip all comments between \lstinline!\begin{document}! and~\lstinline!\end{document}!.
3197 If your document is again called~\lstinline!mydoc.tex!,
3198 you can create the following document and compile it \textbf{with \hologo{LuaTeX}}:
3199 \begin{lstlisting}
3200 \documentclass{article}
3201
3202 \usepackage{stripsemantex}
3203
3204 \begin{document}
3205
3206 \StripSemantexStripComments{mydoc}
3207
3208 \end{document}
3209 \end{lstlisting}
3210 This will create a new document, called \lstinline!mydoc_comments_stripped.tex!, where all comments
3211 in the document body have been removed.
3212
3213 \chapter{Known bugs}
3214
3215 If you write e.g.~\lstinline!Other spar={[}{]}{\Bigg}!
3216 in a heading, your command will fail for some reason.
3217 It can be solved by omitting the braces around~\lstinline!\Bigg!,
3218 i.e.~by replacing it by~\lstinline!Other spar={[}{]}\Bigg!.
3219
3220 \chapter{The predefined keys, commands, and data}
3221
3222 In this chapter, we give a complete list of the predefined keys.
3223 Firstly,
3224 the keys that can be used inside the command~\lstinline!\SemantexSetup! are:
3225
3226 \begin{itemize}
3227 \item \mylst!keyval parser={$\<command\>$}!
3228
3229 Sets the keyval parser function to~\<command\>.
3230 The \<command\> must take three arguments:
3231 \mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!.
3232 The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two.
3233 For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values,
3234 while \<function\num{2}\>~will be applied to keys taking a value. By default, this key has been set to the \LaTeX3 command~\mylst!\keyval_parse:NNn!.
3235 Another interesting possibility is the command~\lstinline!\ekvparse! from the package~\lstinline!expkv!. This choice will only affect keys for objects and classes,
3236 \emph{not} keys for use inside~\lstinline!\SemantexSetup!.
3237
3238 \item \mylst!single key parser={$\<command\>$}!
3239
3240 Sets the single key parser function to~\<command\>.
3241 The single key parser is the command that parses the content of the argument
3242 when you have applied the setting \mylst!arg keyval=single keys!.
3243 The \<command\> must take two arguments:
3244 \mylst!$\<command\>\<function\>${$\<comma list\>$}!.
3245 The \<function\> must take one argument and will be applied
3246 to each entry in the \<comma list\>.
3247 By default, this key has been set to the \LaTeX3 command~\mylst!\clist_map_function:nN! (but with the arguments in reverse order).
3248
3249 \item \mylst!semtex file={$\values\<true|\default{false}\>$}!
3250
3251 When turned on, a \lstinline!.semtex! file will be created while processing the document.
3252 This is mainly relevant when using \lstinline!stripsemantex!.
3253 \end{itemize}
3254
3255 Apart from this, \semantex{} has a large collection of keys that are predefined for the class \lstinline!\SemantexBaseObject!.
3256 In the following sections, we include the full list.
3257
3258 \section{Keys for defining and removing keys}
3259
3260 \begin{itemize}
3261 \item
3262 \mylst!define keys={$\<key definitions\>$}!
3263
3264 Defines keys taking no values.
3265 The syntax is
3266 \begin{lstlisting}
3267 define keys={
3268 {key1}{ upper=3, lower=7 },
3269 {key2}{ lower=6, upper=4 },
3270 },
3271 \end{lstlisting}
3272
3273 \item
3274 \mylst!define keys[$n$]={$\<key definitions\>$}!
3275
3276 Defines keys taking $n$~values, where $n=0,1,2,\dotsc,8$.
3277 The values are accessed by
3278 writing
3279 \lstinline!#1!,~\lstinline!#2!, \ldots,~\lstinline!#8!.
3280 For technical reasons, nine arguments are not allowed.
3281 The syntax is
3282 \begin{lstlisting}
3283 define keys[2]={
3284 {key1}{ upper=3+#1, lower=7-#2 },
3285 {key2}{ lower=6\cdot#1, upper=4/#2 },
3286 },
3287 \end{lstlisting}
3288
3289 \item
3290 \mylst!append keys={$\<key definitions\>$}!
3291
3292 Appends keys taking no values, i.e.~adds code to the right of that key.
3293 The syntax is identical to the one for~\lstinline!define keys!.
3294
3295 \item
3296 \mylst!prepend keys={$\<key definitions\>$}!
3297
3298 Prepends keys taking no values, i.e.~adds code to the left of that key.
3299 The syntax is identical to the one for~\lstinline!define keys!.
3300
3301 \item
3302 \mylst!append keys[$n$]={$\<key definitions\>$}!
3303
3304 Appends keys taking $n$~values, where~$n=0,1,\dotsc,8$, i.e.~adds code to the right of that key.
3305 The syntax is identical to the one for~\mylst!define keys[$n$]!.
3306
3307 \item
3308 \mylst!prepend keys[$n$]={$\<key definitions\>$}!
3309
3310 Prepends keys taking $n$~values, where~$n=0,1,\dotsc,8$, i.e.~adds code to the left of that key.
3311 The syntax is identical to the one for~\mylst!define keys[$n$]!.
3312
3313 \item
3314 \mylst!remove key=$\<key name\>$!
3315
3316 Removes the key~\<key name\> taking no values.
3317
3318 \item
3319 \mylst!remove key[$n$]=$\<key name\>$!
3320
3321 Removes the key~\<key name\> taking $n$~values, where $n=0,1,2,\dotsc,8$.
3322
3323 \item
3324 \mylst!define arg keys={$\<key definitions\>$}!
3325
3326 Defines argument keys taking no values.
3327 The syntax is similar to the one for~\lstinline!define keys!.
3328
3329 \item
3330 \mylst!define arg keys[$n$]={$\<key definitions\>$}!
3331
3332 Defines argument keys taking $n$~values, where $n=0,1,2,\dotsc,8$.
3333 The syntax is similar to the one for~\mylst!define keys[$n$]!.
3334
3335 \item
3336 \mylst!append arg keys={$\<key definitions\>$}!
3337
3338 Appending argument keys taking no values, i.e.~adds code to the right of that key.
3339 The syntax is identical to the one for~\lstinline!define arg keys!.
3340
3341 \item
3342 \mylst!prepend arg keys={$\<key definitions\>$}!
3343
3344 Prepending argument keys taking no values, i.e.~adds code to the left of that key.
3345 The syntax is identical to the one for~\lstinline!define arg keys!.
3346
3347 \item
3348 \mylst!append arg keys[$n$]={$\<key definitions\>$}!
3349
3350 Appending argument keys taking $n$~values, where~$n=0,1,\dotsc,8$, i.e.~adds code to the right of that key.
3351 The syntax is identical to the one for~\mylst!define arg keys[$n$]!.
3352
3353 \item
3354 \mylst!prepend arg keys[$n$]={$\<key definitions\>$}!
3355
3356 Prepending argument keys taking $n$~values, where~$n=0,1,\dotsc,8$, i.e.~adds code to the left of that key.
3357 The syntax is identical to the one for~\mylst!define arg keys[$n$]!.
3358
3359 \item
3360 \mylst!remove arg key=$\<key name\>$!
3361
3362 Removes the argument key~\<key name\> taking no values.
3363
3364 \item
3365 \mylst!remove arg key[$n$]=$\<key name\>$!
3366
3367 Removes the argument key~\<key name\> taking $n$~values, where $n=0,1,2,\dotsc,8$.
3368 \end{itemize}
3369
3370 \section{Programming keys}\label{sec:programming_keys}
3371
3372 \begin{itemize}
3373 \item
3374 \mylst!execute={$\<\TeX\ code\>$}!
3375
3376 Executes the \<\TeX\ code\> on the spot.
3377
3378 \item
3379 \mylst!set keys={$\<keys\>$}!,
3380 \mylst!keys set={$\<keys\>$}!
3381
3382 Sets the keys \<keys\>.
3383
3384 \item
3385 \mylst!set keys x={$\<keys\>$}!,
3386 \mylst!keys set x={$\<keys\>$}!
3387
3388 Sets the keys \<keys\>, but fully expands their values.
3389
3390 \item
3391 \mylst!data provide={$\<data\>$}!
3392
3393 Provides a new piece of data consisting of a token list.
3394
3395 \item
3396 \mylst!data set={$\<data\>$}{$\<value\>$}!
3397
3398 Sets the \<data\> to \<value\>.
3399
3400 \item
3401 \mylst!data set x={$\<data\>$}{$\<value\>$}!
3402
3403 Sets the \<data\> to \<value\>, but fully expands the \<value\> first.
3404
3405 \item
3406 \mylst!data put left={$\<data\>$}{$\<value\>$}!
3407
3408 Adds the \<value\> to the left of \<data\>.
3409
3410 \item
3411 \mylst!data put left x={$\<data\>$}{$\<value\>$}!
3412
3413 Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first.
3414
3415 \item
3416 \mylst!data put right={$\<data\>$}{$\<value\>$}!
3417
3418 Adds the \<value\> to the right of \<data\>.
3419
3420 \item
3421 \mylst!data put right x={$\<data\>$}{$\<value\>$}!
3422
3423 Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first.
3424
3425 \item
3426 \mylst!data clear={$\<data\>$}!
3427
3428 Clears the piece of data~\<data\>.
3429
3430 \item
3431 \mylst!bool provide={$\<boolean\>$}!
3432
3433 Provides a new piece of data consisting of a boolean.
3434
3435 \item
3436 \mylst!bool set true={$\<boolean\>$}!
3437
3438 Sets the \<boolean\> to true.
3439
3440 \item
3441 \mylst!bool set false={$\<boolean\>$}!
3442
3443 Sets the \<boolean\> to false.
3444
3445 \item
3446 \mylst!bool if TF={$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!, \\
3447 \mylst!bool if T={$\<boolean\>$}{$\<if true\>$}!, \\
3448 \mylst!bool if TF={$\<boolean\>$}{$\<if false\>$}!
3449
3450 Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>.
3451
3452 \item
3453 \mylst!int provide={$\<integer\>$}!
3454
3455 Provides a new piece of data consisting of an integer.
3456
3457 \item
3458 \mylst!int set={$\<integer\>$}{$\<value\>$}!
3459
3460 Sets the \<integer\> to \<value\>.
3461
3462 \item
3463 \mylst!int incr={$\<integer\>$}!
3464
3465 Increases the \<integer\> by~\( 1 \).
3466
3467 \item
3468 \mylst!int if eq TF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
3469 \mylst!int if eq T={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
3470 \mylst!int if eq F={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
3471
3472 Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal,
3473 and runs \<if~true\> or \<if~false\> accordingly.
3474
3475 \item
3476 \mylst!int if greater TF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
3477 \mylst!int if greater T={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
3478 \mylst!int if greater F={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
3479
3480 Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>,
3481 and runs \<if~true\> or \<if~false\> accordingly.
3482
3483 \item
3484 \mylst!int if less TF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
3485 \mylst!int if less T={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
3486 \mylst!int if less F={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
3487
3488 Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>,
3489 and runs \<if~true\> or \<if~false\> accordingly.
3490
3491 \item
3492 \mylst!int clear={$\<integer\>$}!
3493
3494 Clears the \<integer\>, i.e.~sets it to~\( 0 \).
3495
3496 \item
3497 \mylst!if blank TF={$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\
3498 \mylst!if blank T={$\<tokens\>$}{$\<if true\>$}!,\\
3499 \mylst!if blank F={$\<tokens\>$}{$\<if false\>$}!
3500
3501 Fully expands the \<tokens\> and checks if it is blank,
3502 and runs \<if true\> or \<if false\> according to this.
3503
3504 \item
3505 \mylst!str if eq TF={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
3506 \mylst!str if eq T={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\
3507 \mylst!str if eq F={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}!
3508
3509 Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal,
3510 and runs \<if~true\> or \<if~false\> accordingly.
3511
3512 \item
3513 \mylst!ERROR={$\<error message\>$}!
3514
3515 Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>}
3516 or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}.
3517
3518 \item
3519 \mylst!ERROR key value not found={$\<key\>$}{$\<value\>$}!
3520
3521 Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>.
3522
3523 \item
3524 \mylst!ERROR arg key value not found={$\<key\>$}{$\<value\>$}!
3525
3526 Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>.
3527 \end{itemize}
3528
3529 \section{Fundamental keys for class/object information}\label{sec:fundamental_keys}
3530
3531 \begin{itemize}
3532 \item
3533 \mylst!parent={$\<Class\>$}!
3534
3535 Sets the class to have parent~\<Class\>.
3536
3537 \item
3538 \mylst!class={$\<Class\>$}!
3539
3540 Sets the object to have class~\<Class\>.
3541
3542 \item
3543 \mylst!copy={$\<object\>$}!
3544
3545 Sets the object to be a copy
3546 of~\<object\>.
3547 Then \<object\> works as a \enquote{parent object}, and all information
3548 will be inherited from~\<object\> unless modified for the current object.
3549
3550 \item
3551 \mylst!symbol={$\<value\>$}!
3552
3553 Sets the symbol to~\<value\>. At the same time,
3554 the height phantom and the slanting phantom are set to the same value.
3555
3556 \item
3557 \mylst!symbol put left={$\<value\>$}!
3558
3559 Adds \<value\> to the left of the symbol. No change is made to the height
3560 phantom or the slanting phantom.
3561
3562 \item
3563 \mylst!symbol put right={$\<value\>$}!
3564
3565 Adds \<value\> to the right of the symbol. No change is made to the height
3566 phantom or the slanting phantom.
3567
3568 \item
3569 \mylst!height phantom={$\<value\>$}!
3570
3571 Sets the height phantom to~\<value\>.
3572
3573 \item
3574 \mylst!slanting phantom={$\<value\>$}!
3575
3576 Sets the slanting phantom to~\<value\>.
3577
3578 \item
3579 \mylst!grading position={$\values\<\default{upper}|lower\>$}!, \\
3580 \mylst!grading pos={$\values\<\default{upper}|lower\>$}!
3581
3582 Sets whether to use upper (\enquote{cohomological})
3583 or lower (\enquote{homological}) grading.
3584 The default is~\lstinline!upper!.
3585
3586 \item
3587 \mylst!command={$\<command\>$}!
3588
3589 Applies the \<command\> to the symbol.
3590
3591 \item
3592 \mylst!clear command!
3593
3594 Clears the list of commands to be applied to the symbol.
3595
3596 \item
3597 \mylst!return!
3598
3599 Invokes the return routine, i.e.\ adds all commands, indices, and arguments to the symbol, if any such exist.
3600
3601 \item
3602 \mylst!inner return!
3603
3604 Invokes the inner return routine, i.e.\ adds all commands to the symbol, if any such exist.
3605
3606 \item
3607 \mylst!right return!
3608
3609 Invokes the right return routine, i.e.\ adds all commands, right indices, and right arguments to the symbol, if any such exist.
3610
3611 \item
3612 \mylst!left return!
3613
3614 Invokes the left return routine, i.e.\ adds all commands, left indices, and left arguments to the symbol, if any such exist.
3615
3616 \item
3617 \mylst!left index return!
3618
3619 Adds the left indices to the symbol, if any such exists.
3620
3621 \item
3622 \mylst!right index return!
3623
3624 Adds the right indices to the symbol, if any such exists.
3625
3626 \item
3627 \mylst!index return!
3628
3629 Adds all indices, left and right to the symbol, if any such exists.
3630
3631 \item
3632 \mylst!left arg return!
3633
3634 Adds the left argument, if any such exists, to the symbol.
3635
3636 \item
3637 \mylst!right arg return!
3638
3639 Adds the right argument, if any such exists, to the symbol.
3640
3641 \item
3642 \mylst!arg return!
3643
3644 Adds the argument, if any such exists, to the symbol.
3645
3646 \item
3647 \mylst!output={$\<Class\>$}!
3648
3649 Sets the output class to~\<Class\>.
3650
3651 \item
3652 \mylst!do output={$\values\<true|\default{false}\>$}!
3653
3654 Sets whether the current object/class should output or not.
3655 The default is false, but the system will automatically
3656 change this when needed. \emph{Never} set this to
3657 \lstinline!true! by default, as this will
3658 cause an infinite loop.
3659
3660 \item
3661 \mylst!output options={$\<keys\>$}!
3662
3663 Adds the \<keys\> to the output options,
3664 i.e.\ those options passed to the output class.
3665
3666 \item
3667 \mylst!parse options={$\<keys\>$}!
3668
3669 Adds the \<keys\> to the parse options, i.e.~adds it to the key \mylst!parse code!.
3670
3671 \item
3672 \mylst!parse!
3673
3674 Invokes the parse routine, i.e.~runs the key \mylst!parse code! and then empties
3675 the contents of that key.
3676
3677 \item
3678 \mylst!parse code!
3679
3680 The key where the parse options are stored. It is emptied when the parse
3681 routine is invoked.
3682
3683 \item
3684 \mylst!math class={$\<command\>$}!
3685
3686 Sets the \TeX\ math class to be~\<command\>.
3687 The intended values are \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!.
3688
3689 \item
3690 \mylst!default={$\<value\>$}!
3691
3692 This is the key that is applied whenever the
3693 user writes something in the options which is not a key,
3694 e.g.~the~\lstinline!1! in~\lstinline!\vf[1]!.
3695 By default, this keys has been set to be equal to~\lstinline!sep i!,
3696 but it is meant to be changeable by the user.
3697
3698 \item
3699 \mylst!*!
3700
3701 Adds a bullet to the \lstinline!d!-index.
3702
3703 \item
3704 \mylst!**!
3705
3706 Adds a double bullet to the \lstinline!d!-index.
3707
3708 \item
3709 \mylst!---!, \mylst!slot!
3710
3711 Adds a slot to the \lstinline!i!-index.
3712
3713 \item
3714 \mylst!...!, \mylst!dots!
3715
3716 Adds three dots to the \lstinline!i!-index.
3717
3718 \item
3719 \mylst!* with other sep={$\<separator\>$}!
3720
3721 Adds a bullet to the \lstinline!d!-index,
3722 separated by the \<separator\>
3723 from any previous \lstinline!d!-indices.
3724
3725 \item
3726 \mylst!** with other sep={$\<separator\>$}!
3727
3728 Adds a double bullet to the \lstinline!d!-index,
3729 separated by the \<separator\>
3730 from any previous \lstinline!d!-indices.
3731
3732 \item
3733 \mylst!arg={$\<value\>$}!
3734
3735 The key that is applied whenever the user adds
3736 an argument via the standard syntax, e.g.~\lstinline!\vf{\vx}!.
3737 By default, it is set to be equal to \lstinline!set arg single keys!,
3738 but it is meant to be changable by the user.
3739
3740 \item
3741 \mylst!smash!
3742
3743 Applies the command~\lstinline!\smash! to the symbol.
3744 Equivalent to~\lstinline!return, command=\smash!.
3745
3746 \item
3747 \mylst!prime!, \mylst!'!, \mylst!''!, \mylst!'''!
3748
3749 Adds one or more primes to the symbol in the upper index.
3750 The first one is equivalent to \lstinline!upper={\prime},next upper with sep=false!,
3751 and the rest are equivalent to multiple iterations
3752 of~\lstinline!prime!.
3753 \end{itemize}
3754
3755 \section{Keys for the argument parentheses}
3756
3757 \begin{itemize}
3758 \item
3759 \mylst!par!
3760
3761 Turns parentheses on. Equivalent to \lstinline!use par=true!.
3762
3763 \item
3764 \mylst!no par!
3765
3766 Turns parentheses off, but still prints them if more
3767 than one argument is received.
3768 Equivalent to \lstinline!use par=false!.
3769
3770 \item
3771 \mylst!never par!
3772
3773 Turns parentheses completely off, even if more than one argument
3774 is received. (This is ugly and should only be used for special constructions.)
3775 Equivalent to \lstinline!use par=never!.
3776
3777 \item
3778 \mylst!use par={$\values\<\default{true}|false|never\>$}!
3779
3780 Sets whether or not to use parentheses.
3781 If~\lstinline!true!, turns parentheses on (this is the default behaviour).
3782 If~\lstinline!false!, turns parentheses off, but still prints them if more
3783 than one argument is received.
3784 If~\lstinline!never!, turns parentheses completely off, even if more than one argument
3785 is received. (This is ugly and should only be used for special constructions.)
3786 The default value is~\lstinline!true!.
3787
3788 \item
3789 \mylst!par size={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}!
3790
3791 Sets the parentheses size.
3792 Here,~\lstinline!normal! means normal size
3793 parentheses,
3794 \lstinline!auto! and~\lstinline!*!
3795 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
3796 If another value is received, that value
3797 is used for the parenthesis size,
3798 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
3799 \lstinline!\bigg!,~\lstinline!\Bigg!.
3800
3801 \item
3802 \mylst!left par={$\<parenthesis\>$}!
3803
3804 Sets the left parenthesis.
3805 The default value is~\lstinline!(!.
3806
3807 \item
3808 \mylst!right par={$\<parenthesis\>$}!
3809
3810 Sets the right parenthesis.
3811 The default value is~\lstinline!)!.
3812 \end{itemize}
3813
3814 \section{Keys for the \texttt{spar} routine}
3815
3816 \begin{itemize}
3817 \item
3818 \mylst!spar!
3819
3820 Invokes the \lstinline!spar! routine.
3821
3822 \item
3823 \mylst!spar={$\values\<normal|auto|*|\textit{other}\>$}!
3824
3825 Invokes the \lstinline!spar! routine, with
3826 the specified parenthesis size.
3827 Here,~\lstinline!normal! means normal size
3828 parentheses,
3829 \lstinline!auto! and~\lstinline!*!
3830 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
3831 If another value is received, that value
3832 is used for the parenthesis size,
3833 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
3834 \lstinline!\bigg!,~\lstinline!\Bigg!.
3835
3836 \item
3837 \mylst!spar size={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}!
3838
3839 Sets the \lstinline!spar! parenthesis size.
3840 Here,~\lstinline!normal! means normal size
3841 parentheses,
3842 \lstinline!auto! and~\lstinline!*!
3843 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
3844 If another value is received, that value
3845 is used for the parenthesis size,
3846 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
3847 \lstinline!\bigg!,~\lstinline!\Bigg!.
3848
3849 \item
3850 \mylst!left spar={$\<parenthesis\>$}!
3851
3852 Sets the left parenthesis for the \lstinline!spar! routine.
3853 The default value is~\lstinline!(!.
3854
3855 \item
3856 \mylst!right spar={$\<parenthesis\>$}!
3857
3858 Sets the right parenthesis for the \lstinline!spar! routine.
3859 The default value is~\lstinline!)!.
3860
3861 \item
3862 \mylst!other spar={$\<left parenthesis\>$}{$\<right parenthesis\>$}!
3863
3864 Invokes the \lstinline!spar! routine, but with the assigned parentheses.
3865
3866 \item
3867 \mylst!Other spar={$\<left parenthesis\>$}{$\<right parenthesis\>$}{$\values\<normal|auto|*|{\textit{other}}\>$}!
3868
3869 Invokes the \lstinline!spar! routine, but with the assigned parentheses and size.
3870 Here, \lstinline!normal! means normal size
3871 parentheses,
3872 \lstinline!auto! and~\lstinline!*!
3873 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
3874 If another value is received, that value
3875 is used for the parenthesis size,
3876 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
3877 \lstinline!\bigg!,~\lstinline!\Bigg!.
3878 \end{itemize}
3879
3880 \section{Keys for setting the argument}
3881
3882 \begin{itemize}
3883 \item
3884 \mylst!set arg keys={$\<keys\>$}!,
3885 \mylst!arg keys set={$\<keys\>$}!
3886
3887 Sets the argument keys \<keys\>.
3888
3889 \item
3890 \mylst!set arg keys x={$\<keys\>$}!,
3891 \mylst!arg keys set x={$\<keys\>$}!
3892
3893 Sets the argynebt keys \<keys\>, but fully expands their values.
3894
3895 \item
3896 \mylst!set arg single keys={$\<keys\>$}!,
3897 \mylst!arg single keys set={$\<keys\>$}!
3898
3899 Sets the argument keys \<keys\>,
3900 but only supports keys taking no values.
3901 This allows the arguments to contain equality
3902 signs without causing issues.
3903
3904 \item
3905 \mylst!set arg single keys x={$\<keys\>$}!,
3906 \mylst!arg single keys set x={$\<keys\>$}!
3907
3908 Sets the argument keys \<keys\>,
3909 but only supports keys taking no values.
3910 If a key is not found, the value
3911 is fully expanded and printed.
3912 This allows the arguments to contain equality
3913 signs without causing issues.
3914
3915 \item
3916 \mylst!set one arg single key={$\<key\>$}!,
3917 \mylst!one arg single key set={$\<key\>$}!
3918
3919 Sets one single argument key taking no values.
3920 This allows the argument to contain
3921 equality signs and commas without cuasing issues.
3922
3923 \item
3924 \mylst!set one arg single key x={$\<key\>$}!,
3925 \mylst!one arg single key set x={$\<key\>$}!
3926
3927 Sets one single argument key taking no values,
3928 If the key is not found, the value
3929 is fully expanded and printed.
3930 This allows the argument to contain
3931 equality signs and commas without cuasing issues.
3932
3933 \item
3934 \mylst!set arg without keyval={$\<value\>$}!,
3935 \mylst!arg without keyval set={$\<value\>$}!
3936
3937 Sets the argument, allowing no keyval syntax.
3938
3939 \item
3940 \mylst!set arg without keyval x={$\<value\>$}!,
3941 \mylst!arg without keyval set x={$\<value\>$}!
3942
3943 Sets the argument, fully expanding its value,
3944 and allowing no keyval syntax.
3945
3946 \item
3947 \mylst!pre arg={$\<value\>$}!
3948
3949 Sets the pre-argument.
3950
3951 \item
3952 \mylst!pre arg put left={$\<value\>$}!
3953
3954 Adds to the left of the pre-argument.
3955
3956 \item
3957 \mylst!post arg={$\<value\>$}!
3958
3959 Sets the post-argument.
3960
3961 \item
3962 \mylst!post arg put right={$\<value\>$}!
3963
3964 Adds to the right of the post-argument.
3965
3966 \item
3967 \mylst!set arg sep={$\<value\>$}!
3968
3969 Sets the argument separator.
3970 The default value is a comma.
3971
3972 \item
3973 \mylst!set arg slot={$\<value\>$}!
3974
3975 Sets the argument slot.
3976 The default value is~\lstinline!{-}!.
3977
3978 \item
3979 \mylst!set arg dots={$\<value\>$}!
3980
3981 Sets the argument dots.
3982 The default value is~\lstinline!\dots!.
3983
3984 \item
3985 \mylst!arg keyval={$\values\<true|false|\default{single keys}|one single key\>$}!
3986
3987 Sets whether to use argument keyval syntax or not.
3988 If \lstinline!true!, \lstinline!arg! is set equal to~\lstinline!set arg keys!.
3989 If \lstinline!false!, it is set to~\lstinline!set arg without keyval!.
3990 If \lstinline!single keys!, it is set to~\lstinline!set arg single keys!.
3991 If \lstinline!one single key!, it is set to~\lstinline!set one arg single key!.
3992 The default value is~\lstinline!single keys!.
3993
3994 \item
3995 \mylst!arg position={$\values\<left|\default{right}\>$}!,
3996 \mylst!arg pos={$\values\<left|\default{right}\>$}!
3997
3998 Sets the position of the argument.
3999 The default is~\lstinline!right!, so the argument
4000 will be printed to the right of the symbol.
4001
4002 \item
4003 \mylst!next arg with sep={$\values\<true|\default{false}\>$}!
4004
4005 Sets whether the next argument should be
4006 separated from the current one with a
4007 separator or not.
4008 The default is \lstinline!false!, but the
4009 system will automatically change this when needed.
4010
4011 \item
4012 \mylst!sep arg={$\<value\>$}!
4013
4014 Adds \<value\> to the argument, separated from any previous
4015 argument by the default argument separator.
4016
4017 \item
4018 \mylst!comma arg={$\<value\>$}!
4019
4020 Adds \<value\> to the argument, separated from any previous
4021 argument by a comma.
4022
4023 \item
4024 \mylst!arg with other sep={$\<separator\>$}{$\<value\>$}!
4025
4026 Adds \<value\> to the argument, separated from any previous
4027 argument by \<separator\>.
4028
4029 \item
4030 \mylst!arg ... with other sep={$\<separator\>$}!,
4031 \mylst!arg dots with other sep={$\<separator\>$}!
4032
4033 Adds three dots to the argument, separated from any previous
4034 argument by the \<separator\>.
4035
4036 \item
4037 \mylst!arg --- with other sep={$\<separator\>$}!,
4038 \mylst!arg slot with other sep={$\<separator\>$}!
4039
4040 Adds a slot to the argument, separated from any previous
4041 argument by the \<separator\>.
4042
4043 \item
4044 \mylst!arg ...!, \mylst!arg dots!
4045
4046 Adds three dots to the argument,
4047 separated from any previous arguments
4048 by the standard separator.
4049
4050 \item
4051 \mylst!comma arg ...!, \mylst!comma arg dots!
4052
4053 Adds three dots to the argument,
4054 separated from any previous arguments
4055 by a comma.
4056
4057 \item
4058 \mylst!arg ---!, \mylst!arg slot!
4059
4060 Adds a slot to the argument,
4061 separated from any previous arguments
4062 by the standard separator.
4063
4064 \item
4065 \mylst!comma arg ---!,
4066 \mylst!comma arg slot!
4067
4068 Adds a slot to the argument,
4069 separated from any previous arguments
4070 by a comma.
4071
4072 \item
4073 \mylst!clear arg!
4074
4075 Clears the argument.
4076
4077 \item
4078 \mylst!clear pre arg!
4079
4080 Clears the pre-argument.
4081
4082 \item
4083 \mylst!clear post arg!
4084
4085 Clears the post-argument.
4086 \end{itemize}
4087
4088
4089 \section{Keys for the upper index}
4090
4091 \begin{itemize}
4092 \item
4093 \mylst!upper={$\<value\>$}!
4094
4095 Adds to the upper index,
4096 with no separator from any previous upper index.
4097
4098 \item
4099 \mylst!sep upper={$\<value\>$}!
4100
4101 Adds to the upper index,
4102 separated from any previous upper
4103 index by the default separator.
4104
4105 \item
4106 \mylst!comma upper={$\<value\>$}!
4107
4108 Adds to the upper index,
4109 separated from any previous upper
4110 index by a comma.
4111
4112 \item
4113 \mylst!pre upper={$\<value\>$}!
4114
4115 Sets the pre-upper index.
4116
4117 \item
4118 \mylst!pre upper put left={$\<value\>$}!
4119
4120 Adds to the left of the pre-upper index.
4121
4122 \item
4123 \mylst!post upper={$\<value\>$}!
4124
4125 Sets the post-upper index.
4126
4127 \item
4128 \mylst!post upper put right={$\<value\>$}!
4129
4130 Adds to the right of the post-upper index.
4131
4132 \item
4133 \mylst!upper put left={$\<value\>$}!
4134
4135 Adds something to the left of the upper index.
4136 As with keys like~\lstinline!upper!, this
4137 will also increase the number of registered
4138 upper indices by~\( 1 \), and
4139 it will
4140 set \lstinline!next upper with sep=true!.
4141
4142 \item
4143 \mylst!set upper sep={$\<value\>$}!
4144
4145 Sets the upper index separator to~\<value\>.
4146 By default, this is a comma.
4147
4148 \item
4149 \mylst!next upper with sep={$\values\<true|\default{false}\>$}!
4150
4151 Sets whether the next upper index should
4152 be separated from the current one by a separator.
4153
4154 \item
4155 \mylst!upper with other sep={$\<separator\>$}{$\<value\>$}!
4156
4157 Adds \<value\> to the upper index, separated from
4158 any prevous upper index by~\<separator\>.
4159
4160 \item
4161 \mylst!upper ---!,
4162 \mylst!upper slot!
4163
4164 Adds a slot to the upper index,
4165 with no separator from any previous upper index.
4166
4167 \item
4168 \mylst!sep upper ---!,
4169 \mylst!sep upper slot!
4170
4171 Adds a slot to the upper index,
4172 separated from any previous upper
4173 index by the default separator.
4174
4175 \item
4176 \mylst!comma upper ---!,
4177 \mylst!comma upper slot!
4178
4179 Adds a slot to the upper index,
4180 separated from any previous upper
4181 index by a comma.
4182
4183 \item
4184 \mylst!set upper slot={$\<value\>$}!
4185
4186 Sets the slot for the upper index.
4187 By default, this is~\lstinline!{-}!.
4188
4189 \item
4190 \mylst!upper --- with other sep={$\<separator\>$}!,\\
4191 \mylst!upper slot with other sep={$\<separator\>$}!
4192
4193
4194 Adds a slot to the upper index, separated
4195 from any previous upper index by~\<separator\>.
4196
4197 \item
4198 \mylst!upper ...!, \mylst!upper dots!
4199
4200 Adds three dots to the upper index,
4201 with no separator from any previous upper index.
4202
4203 \item
4204 \mylst!sep upper ...!, \mylst!sep upper dots!
4205
4206 Adds three dots to the upper index,
4207 separated from any previous upper
4208 index by the default separator.
4209
4210 \item
4211 \mylst!comma upper ...!, \mylst!comma upper dots!
4212
4213 Adds three dots to the upper index,
4214 separated from any previous upper
4215 index by a comma.
4216
4217 \item
4218 \mylst!set upper dots={$\<value\>$}!
4219
4220 Sets the dots for the upper index.
4221 By default, this is~\lstinline!\dots!.
4222
4223 \item
4224 \mylst!upper ... with other sep={$\<separator\>$}!,\\
4225 \mylst!upper dots with other sep={$\<separator\>$}!
4226
4227 Adds three dots to the upper index,
4228 separated from any previous upper index
4229 by~\<separator\>.
4230
4231 \item
4232 \mylst!upper *!
4233
4234 Adds a bullet to the upper index,
4235 with no separator from any previous upper index.
4236
4237 \item
4238 \mylst!upper **!
4239
4240 Adds a double bullet to the upper index,
4241 with no separator from any previous upper index.
4242
4243 \item
4244 \mylst!sep upper *!
4245
4246 Adds a bullet to the upper index,
4247 separated from any previous upper
4248 index by the default separator.
4249
4250 \item
4251 \mylst!sep upper **!
4252
4253 Adds a double bullet to the upper index,
4254 separated from any previous upper
4255 index by the default separator.
4256
4257 \item
4258 \mylst!comma upper *!
4259
4260 Adds a bullet to the upper index,
4261 separated from any previous upper
4262 index by a comma.
4263
4264 \item
4265 \mylst!comma upper **!
4266
4267 Adds a double bullet to the upper index,
4268 separated from any previous upper
4269 index by a comma.
4270
4271 \item
4272 \mylst!upper * with other sep={$\<separator\>$}!
4273
4274 Adds a bullet to the upper index,
4275 separated from any previous upper index
4276 by~\<separator\>.
4277
4278 \item
4279 \mylst!upper ** with other sep={$\<separator\>$}!
4280
4281 Adds a double bullet to the upper index,
4282 separated from any previous upper index
4283 by~\<separator\>.
4284
4285 \item
4286 \mylst!clear upper!
4287
4288 Clears the upper index.
4289
4290 \item
4291 \mylst!clear pre upper!
4292
4293 Clears the pre-upper index.
4294
4295 \item
4296 \mylst!clear post upper!
4297
4298 Clears the post-upper index.
4299 \end{itemize}
4300
4301 \section{Keys for the lower index}
4302
4303 \begin{itemize}
4304 \item
4305 \mylst!lower={$\<value\>$}!
4306
4307 Adds to the lower index,
4308 with no separator from any previous lower index.
4309
4310 \item
4311 \mylst!sep lower={$\<value\>$}!
4312
4313 Adds to the lower index,
4314 separated from any previous lower
4315 index by the default separator.
4316
4317 \item
4318 \mylst!comma lower={$\<value\>$}!
4319
4320 Adds to the lower index,
4321 separated from any previous lower
4322 index by a comma.
4323
4324 \item
4325 \mylst!pre lower={$\<value\>$}!
4326
4327 Sets the pre-lower index.
4328
4329 \item
4330 \mylst!pre lower put left={$\<value\>$}!
4331
4332 Adds to the left of the pre-lower index.
4333
4334 \item
4335 \mylst!post lower={$\<value\>$}!
4336
4337 Sets the post-lower index.
4338
4339 \item
4340 \mylst!post lower put right={$\<value\>$}!
4341
4342 Adds to the right of the post-lower index.
4343
4344 \item
4345 \mylst!lower put left={$\<value\>$}!
4346
4347 Adds something to the left of the lower index.
4348 As with keys like~\lstinline!lower!, this
4349 will also increase the number of registered
4350 lower indices by~\( 1 \), and
4351 it will
4352 set \lstinline!next lower with sep=true!.
4353
4354 \item
4355 \mylst!set lower sep={$\<value\>$}!
4356
4357 Sets the lower index separator to~\<value\>.
4358 By default, this is a comma.
4359
4360 \item
4361 \mylst!next lower with sep={$\values\<true|\default{false}\>$}!
4362
4363 Sets whether the next lower index should
4364 be separated from the current one by a separator.
4365
4366 \item
4367 \mylst!lower with other sep={$\<separator\>$}{$\<value\>$}!
4368
4369 Adds \<value\> to the lower index, separated from
4370 any prevous lower index by~\<separator\>.
4371
4372 \item
4373 \mylst!lower ---!, \mylst!lower slot!
4374
4375 Adds a slot to the lower index,
4376 with no separator from any previous lower index.
4377
4378 \item
4379 \mylst!sep lower ---!, \mylst!sep lower slot!
4380
4381 Adds a slot to the lower index,
4382 separated from any previous lower
4383 index by the default separator.
4384
4385 \item
4386 \mylst!comma lower ---!, \mylst!comma lower slot!
4387
4388 Adds a slot to the lower index,
4389 separated from any previous lower
4390 index by a comma.
4391
4392 \item
4393 \mylst!set lower slot={$\<value\>$}!
4394
4395 Sets the slot for the lower index.
4396 By default, this is~\lstinline!{-}!.
4397
4398 \item
4399 \mylst!lower --- with other sep={$\<separator\>$}!,\\
4400 \mylst!lower slot with other sep={$\<separator\>$}!
4401
4402
4403 Adds a slot to the lower index, separated
4404 from any previous lower index by~\<separator\>.
4405
4406 \item
4407 \mylst!lower ...!, \mylst!lower dots!
4408
4409 Adds three dots to the lower index,
4410 with no separator from any previous lower index.
4411
4412 \item
4413 \mylst!sep lower ...!, \mylst!sep lower dots!
4414
4415 Adds three dots to the lower index,
4416 separated from any previous lower
4417 index by the default separator.
4418
4419 \item
4420 \mylst!comma lower ...!, \mylst!comma lower dots!
4421
4422 Adds three dots to the lower index,
4423 separated from any previous lower
4424 index by a comma.
4425
4426 \item
4427 \mylst!set lower dots={$\<value\>$}!
4428
4429 Sets the dots for the lower index.
4430 By default, this is~\lstinline!\dots!.
4431
4432 \item
4433 \mylst!lower ... with other sep={$\<separator\>$}!,\\
4434 \mylst!lower dots with other sep={$\<separator\>$}!
4435
4436 Adds three dots to the lower index,
4437 separated from any previous lower index
4438 by~\<separator\>.
4439
4440 \item
4441 \mylst!lower *!
4442
4443 Adds a bullet to the lower index,
4444 with no separator from any previous lower index.
4445
4446 \item
4447 \mylst!lower **!
4448
4449 Adds a double bullet to the lower index,
4450 with no separator from any previous lower index.
4451
4452 \item
4453 \mylst!sep lower *!
4454
4455 Adds a bullet to the lower index,
4456 separated from any previous lower
4457 index by the default separator.
4458
4459 \item
4460 \mylst!sep lower **!
4461
4462 Adds a double bullet to the lower index,
4463 separated from any previous lower
4464 index by the default separator.
4465
4466 \item
4467 \mylst!comma lower *!
4468
4469 Adds a bullet to the lower index,
4470 separated from any previous lower
4471 index by a comma.
4472
4473 \item
4474 \mylst!comma lower **!
4475
4476 Adds a double bullet to the lower index,
4477 separated from any previous lower
4478 index by a comma.
4479
4480 \item
4481 \mylst!lower * with other sep={$\<separator\>$}!
4482
4483 Adds a bullet to the lower index,
4484 separated from any previous lower index
4485 by~\<separator\>.
4486
4487 \item
4488 \mylst!lower ** with other sep={$\<separator\>$}!
4489
4490 Adds a double bullet to the lower index,
4491 separated from any previous lower index
4492 by~\<separator\>.
4493
4494 \item
4495 \mylst!clearlower!
4496
4497 Clears the lower index.
4498
4499 \item
4500 \mylst!clear pre lower!
4501
4502 Clears the pre-lower index.
4503
4504 \item
4505 \mylst!clear post lower!
4506
4507 Clears the post-lower index.
4508 \end{itemize}
4509
4510 \section{Keys for the upper left index}
4511
4512 \begin{itemize}
4513 \item
4514 \mylst!upper left={$\<value\>$}!
4515
4516 Adds to the upper left index,
4517 with no separator from any previous upper left index.
4518
4519 \item
4520 \mylst!sep upper left={$\<value\>$}!
4521
4522 Adds to the upper left index,
4523 separated from any previous upper left
4524 index by the default separator.
4525
4526 \item
4527 \mylst!comma upper left={$\<value\>$}!
4528
4529 Adds to the upper left index,
4530 separated from any previous upper left
4531 index by a comma.
4532
4533 \item
4534 \mylst!pre upper left={$\<value\>$}!
4535
4536 Sets the pre-upper left index.
4537
4538 \item
4539 \mylst!pre upper left put left={$\<value\>$}!
4540
4541 Adds to the left of the pre-upper left index.
4542
4543 \item
4544 \mylst!post upper left={$\<value\>$}!
4545
4546 Sets the post-upper left index.
4547
4548 \item
4549 \mylst!post upper left put right={$\<value\>$}!
4550
4551 Adds to the right of the post-upper left index.
4552
4553 \item
4554 \mylst!upper left put right={$\<value\>$}!
4555
4556 Adds something to the right of the upper left index.
4557 As with keys like~\lstinline!upper left!, this
4558 will also increase the number of registered
4559 upper left indices by~\( 1 \), and
4560 it will
4561 set \lstinline!next upper left with sep=true!.
4562
4563 \item
4564 \mylst!set upper left sep={$\<value\>$}!
4565
4566 Sets the upper left index separator to~\<value\>.
4567 By default, this is a comma.
4568
4569 \item
4570 \mylst!next upper left with sep={$\values\<true|\default{false}\>$}!
4571
4572 Sets whether the next upper left index should
4573 be separated from the current one by a separator.
4574
4575 \item
4576 \mylst!upper left with other sep={$\<separator\>$}{$\<value\>$}!
4577
4578 Adds \<value\> to the upper left index, separated from
4579 any prevous upper left index by~\<separator\>.
4580
4581 \item
4582 \mylst!upper left ---!, \mylst!upper left slot!
4583
4584 Adds a slot to the upper left index,
4585 with no separator from any previous upper left index.
4586
4587 \item
4588 \mylst!sep upper left ---!, \mylst!sep upper left slot!
4589
4590 Adds a slot to the upper left index,
4591 separated from any previous upper left
4592 index by the default separator.
4593
4594 \item
4595 \mylst!comma upper left ---!, \mylst!comma upper left slot!
4596
4597 Adds a slot to the upper left index,
4598 separated from any previous upper left
4599 index by a comma.
4600
4601 \item
4602 \mylst!set upper left slot={$\<value\>$}!
4603
4604 Sets the slot for the upper left index.
4605 By default, this is~\lstinline!{-}!.
4606
4607 \item
4608 \mylst!upper left --- with other sep={$\<separator\>$}!,\\
4609 \mylst!upper left slot with other sep={$\<separator\>$}!
4610
4611
4612 Adds a slot to the upper left index, separated
4613 from any previous upper left index by~\<separator\>.
4614
4615 \item
4616 \mylst!upper left ...!, \mylst!upper left dots!
4617
4618 Adds three dots to the upper left index,
4619 with no separator from any previous upper left index.
4620
4621 \item
4622 \mylst!sep upper left ...!, \mylst!sep upper left dots!
4623
4624 Adds three dots to the upper left index,
4625 separated from any previous upper left
4626 index by the default separator.
4627
4628 \item
4629 \mylst!comma upper left ...!, \mylst!comma upper left dots!
4630
4631 Adds three dots to the upper left index,
4632 separated from any previous upper left
4633 index by a comma.
4634
4635 \item
4636 \mylst!set upper left dots={$\<value\>$}!
4637
4638 Sets the dots for the upper left index.
4639 By default, this is~\lstinline!\dots!.
4640
4641 \item
4642 \mylst!upper left ... with other sep={$\<separator\>$}!,\\
4643 \mylst!upper left dots with other sep={$\<separator\>$}!
4644
4645 Adds three dots to the upper left index,
4646 separated from any previous upper left index
4647 by~\<separator\>.
4648
4649 \item
4650 \mylst!upper left *!
4651
4652 Adds a bullet to the upper left index,
4653 with no separator from any previous upper left index.
4654
4655 \item
4656 \mylst!upper left **!
4657
4658 Adds a double bullet to the upper left index,
4659 with no separator from any previous upper left index.
4660
4661 \item
4662 \mylst!sep upper left *!
4663
4664 Adds a bullet to the upper left index,
4665 separated from any previous upper left
4666 index by the default separator.
4667
4668 \item
4669 \mylst!sep upper left **!
4670
4671 Adds a double bullet to the upper left index,
4672 separated from any previous upper left
4673 index by the default separator.
4674
4675 \item
4676 \mylst!comma upper left *!
4677
4678 Adds a bullet to the upper left index,
4679 separated from any previous upper left
4680 index by a comma.
4681
4682 \item
4683 \mylst!comma upper left **!
4684
4685 Adds a double bullet to the upper left index,
4686 separated from any previous upper left
4687 index by a comma.
4688
4689 \item
4690 \mylst!upper left * with other sep={$\<separator\>$}!
4691
4692 Adds a bullet to the upper left index,
4693 separated from any previous upper left index
4694 by~\<separator\>.
4695
4696 \item
4697 \mylst!upper left ** with other sep={$\<separator\>$}!
4698
4699 Adds a double bullet to the upper left index,
4700 separated from any previous upper left index
4701 by~\<separator\>.
4702
4703 \item
4704 \mylst!clearupper left!
4705
4706 Clears the upper left index.
4707
4708 \item
4709 \mylst!clear pre upper left!
4710
4711 Clears the pre-upper left index.
4712
4713 \item
4714 \mylst!clear post upper left!
4715
4716 Clears the post-upper left index.
4717 \end{itemize}
4718
4719 \section{Keys for the lower left index}
4720
4721 \begin{itemize}
4722 \item
4723 \mylst!lower left={$\<value\>$}!
4724
4725 Adds to the lower left index,
4726 with no separator from any previous lower left index.
4727
4728 \item
4729 \mylst!sep lower left={$\<value\>$}!
4730
4731 Adds to the lower left index,
4732 separated from any previous lower left
4733 index by the default separator.
4734
4735 \item
4736 \mylst!comma lower left={$\<value\>$}!
4737
4738 Adds to the lower left index,
4739 separated from any previous lower left
4740 index by a comma.
4741
4742 \item
4743 \mylst!pre lower left={$\<value\>$}!
4744
4745 Sets the pre-lower left index.
4746
4747 \item
4748 \mylst!pre lower left put left={$\<value\>$}!
4749
4750 Adds to the left of the pre-lower left index.
4751
4752 \item
4753 \mylst!post lower left={$\<value\>$}!
4754
4755 Sets the post-lower left index.
4756
4757 \item
4758 \mylst!post lower left put right={$\<value\>$}!
4759
4760 Adds to the right of the post-lower left index.
4761
4762 \item
4763 \mylst!lower left put right={$\<value\>$}!
4764
4765 Adds something to the right of the lower left index.
4766 As with keys like~\lstinline!lower left!, this
4767 will also increase the number of registered
4768 lower left indices by~\( 1 \), and
4769 it will
4770 set \lstinline!next lower left with sep=true!.
4771
4772 \item
4773 \mylst!set lower left sep={$\<value\>$}!
4774
4775 Sets the lower left index separator to~\<value\>.
4776 By default, this is a comma.
4777
4778 \item
4779 \mylst!next lower left with sep={$\values\<true|\default{false}\>$}!
4780
4781 Sets whether the next lower left index should
4782 be separated from the current one by a separator.
4783
4784 \item
4785 \mylst!lower left with other sep={$\<separator\>$}{$\<value\>$}!
4786
4787 Adds \<value\> to the lower left index, separated from
4788 any prevous lower left index by~\<separator\>.
4789
4790 \item
4791 \mylst!lower left ---!, \mylst!lower left slot!
4792
4793 Adds a slot to the lower left index,
4794 with no separator from any previous lower left index.
4795
4796 \item
4797 \mylst!sep lower left ---!, \mylst!sep lower left slot!
4798
4799 Adds a slot to the lower left index,
4800 separated from any previous lower left
4801 index by the default separator.
4802
4803 \item
4804 \mylst!comma lower left ---!, \mylst!comma lower left slot!
4805
4806 Adds a slot to the lower left index,
4807 separated from any previous lower left
4808 index by a comma.
4809
4810 \item
4811 \mylst!set lower left slot={$\<value\>$}!
4812
4813 Sets the slot for the lower left index.
4814 By default, this is~\lstinline!{-}!.
4815
4816 \item
4817 \mylst!lower left --- with other sep={$\<separator\>$}!,\\
4818 \mylst!lower left slot with other sep={$\<separator\>$}!
4819
4820
4821 Adds a slot to the lower left index, separated
4822 from any previous lower left index by~\<separator\>.
4823
4824 \item
4825 \mylst!lower left ...!, \mylst!lower left dots!
4826
4827 Adds three dots to the lower left index,
4828 with no separator from any previous lower left index.
4829
4830 \item
4831 \mylst!sep lower left ...!, \mylst!sep lower left dots!
4832
4833 Adds three dots to the lower left index,
4834 separated from any previous lower left
4835 index by the default separator.
4836
4837 \item
4838 \mylst!comma lower left ...!, \mylst!comma lower left dots!
4839
4840 Adds three dots to the lower left index,
4841 separated from any previous lower left
4842 index by a comma.
4843
4844 \item
4845 \mylst!set lower left dots={$\<value\>$}!
4846
4847 Sets the dots for the lower left index.
4848 By default, this is~\lstinline!\dots!.
4849
4850 \item
4851 \mylst!lower left ... with other sep={$\<separator\>$}!,\\
4852 \mylst!lower left dots with other sep={$\<separator\>$}!
4853
4854 Adds three dots to the lower left index,
4855 separated from any previous lower left index
4856 by~\<separator\>.
4857
4858 \item
4859 \mylst!lower left *!
4860
4861 Adds a bullet to the lower left index,
4862 with no separator from any previous lower left index.
4863
4864 \item
4865 \mylst!lower left **!
4866
4867 Adds a double bullet to the lower left index,
4868 with no separator from any previous lower left index.
4869
4870 \item
4871 \mylst!sep lower left *!
4872
4873 Adds a bullet to the lower left index,
4874 separated from any previous lower left
4875 index by the default separator.
4876
4877 \item
4878 \mylst!sep lower left **!
4879
4880 Adds a double bullet to the lower left index,
4881 separated from any previous lower left
4882 index by the default separator.
4883
4884 \item
4885 \mylst!comma lower left *!
4886
4887 Adds a bullet to the lower left index,
4888 separated from any previous lower left
4889 index by a comma.
4890
4891 \item
4892 \mylst!comma lower left **!
4893
4894 Adds a double bullet to the lower left index,
4895 separated from any previous lower left
4896 index by a comma.
4897
4898 \item
4899 \mylst!lower left * with other sep={$\<separator\>$}!
4900
4901 Adds a bullet to the lower left index,
4902 separated from any previous lower left index
4903 by~\<separator\>.
4904
4905 \item
4906 \mylst!lower left ** with other sep={$\<separator\>$}!
4907
4908 Adds a double bullet to the lower left index,
4909 separated from any previous lower left index
4910 by~\<separator\>.
4911
4912 \item
4913 \mylst!clearlower left!
4914
4915 Clears the lower left index.
4916
4917 \item
4918 \mylst!clear pre lower left!
4919
4920 Clears the pre-lower left index.
4921
4922 \item
4923 \mylst!clear post lower left!
4924
4925 Clears the post-lower left index.
4926 \end{itemize}
4927
4928 \section{Keys for the \texttt{d}-index}
4929
4930 \begin{itemize}
4931 \item
4932 \mylst!d={$\<value\>$}!
4933
4934 Adds to the \lstinline!d!-index,
4935 with no separator from any previous \lstinline!d!-index.
4936
4937 \item
4938 \mylst!sep d={$\<value\>$}!
4939
4940 Adds to the \lstinline!d!-index,
4941 separated from any previous \lstinline!d!-index
4942 by the default separator.
4943
4944 \item
4945 \mylst!comma d={$\<value\>$}!
4946
4947 Adds to the \lstinline!d!-index,
4948 separated from any previous \lstinline!d!-index
4949 by a comma.
4950
4951 \item
4952 \mylst!pre d={$\<value\>$}!
4953
4954 Sets the pre-\lstinline!d!-index.
4955
4956 \item
4957 \mylst!pre d put left={$\<value\>$}!
4958
4959 Adds to the left of the pre-\lstinline!d!-index.
4960
4961 \item
4962 \mylst!post d={$\<value\>$}!
4963
4964 Sets the post-\lstinline!d!-index.
4965
4966 \item
4967 \mylst!post d put right={$\<value\>$}!
4968
4969 Adds to the right of the post-\lstinline!d!-index.
4970
4971 \item
4972 \mylst!d put left={$\<value\>$}!
4973
4974 Adds something to the left of the \lstinline!d!-index.
4975 As with keys like~\lstinline!d!, this
4976 will also increase the number of registered
4977 \lstinline!d!-indices by~\( 1 \), and
4978 it will
4979 set \lstinline!next d with sep=true!.
4980
4981 \item
4982 \mylst!set d sep={$\<value\>$}!
4983
4984 Sets the \lstinline!d!-index separator to~\<value\>.
4985 By default, this is a comma.
4986
4987 \item
4988 \mylst!next d with sep={$\values\<true|\default{false}\>$}!
4989
4990 Sets whether the next \lstinline!d!-index should
4991 be separated from the current one by a separator.
4992
4993 \item
4994 \mylst!d with other sep={$\<separator\>$}{$\<value\>$}!
4995
4996 Adds \<value\> to the \lstinline!d!-index, separated from
4997 any prevous \lstinline!d!-index by~\<separator\>.
4998
4999 \item
5000 \mylst!d ---!, \mylst!d slot!
5001
5002 Adds a slot to the \lstinline!d!-index,
5003 with no separator from any previous \lstinline!d!-index.
5004
5005 \item
5006 \mylst!sep d ---!, \mylst!sep d slot!
5007
5008 Adds a slot to the \lstinline!d!-index,
5009 separated from any previous \lstinline!d!-index
5010 by the default separator.
5011
5012 \item
5013 \mylst!comma d ---!, \mylst!comma d slot!
5014
5015 Adds a slot to the \lstinline!d!-index,
5016 separated from any previous \lstinline!d!-index
5017 by a comma.
5018
5019 \item
5020 \mylst!set d slot={$\<value\>$}!
5021
5022 Sets the slot for the \lstinline!d!-index.
5023 By default, this is~\lstinline!{-}!.
5024
5025 \item
5026 \mylst!d --- with other sep={$\<separator\>$}!,
5027 \mylst!d slot with other sep={$\<separator\>$}!
5028
5029 Adds a slot to the \lstinline!d!-index, separated
5030 from any previous \lstinline!d!-index by~\<separator\>.
5031
5032 \item
5033 \mylst!d ...!, \mylst!d dots!
5034
5035 Adds three dots to the \lstinline!d!-index,
5036 with no separator from any previous \lstinline!d!-index.
5037
5038 \item
5039 \mylst!sep d ...!, \mylst!sep d dots!
5040
5041 Adds three dots to the \lstinline!d!-index,
5042 separated from any previous \lstinline!d!-index
5043 by the default separator.
5044
5045 \item
5046 \mylst!comma d ...!, \mylst!comma d dots!
5047
5048 Adds three dots to the \lstinline!d!-index,
5049 separated from any previous \lstinline!d!-index
5050 by a comma.
5051
5052 \item
5053 \mylst!set d dots={$\<value\>$}!
5054
5055 Sets the dots for the \lstinline!d!-index.
5056 By default, this is~\lstinline!\dots!.
5057
5058 \item
5059 \mylst!d ... with other sep={$\<separator\>$}!,
5060 \mylst!d dots with other sep={$\<separator\>$}!
5061
5062 Adds three dots to the \lstinline!d!-index,
5063 separated from any previous \lstinline!d!-index
5064 by~\<separator\>.
5065
5066 \item
5067 \mylst!d *!
5068
5069 Adds a bullet to the \lstinline!d!-index,
5070 with no separator from any previous \lstinline!d!-index.
5071
5072 \item
5073 \mylst!d **!
5074
5075 Adds a double bullet to the \lstinline!d!-index,
5076 with no separator from any previous \lstinline!d!-index.
5077
5078 \item
5079 \mylst!sep d *!
5080
5081 Adds a bullet to the \lstinline!d!-index,
5082 separated from any previous \lstinline!d!-index
5083 by the default separator.
5084
5085 \item
5086 \mylst!sep d **!
5087
5088 Adds a double bullet to the \lstinline!d!-index,
5089 separated from any previous \lstinline!d!-index
5090 by the default separator.
5091
5092 \item
5093 \mylst!comma d *!
5094
5095 Adds a bullet to the \lstinline!d!-index,
5096 separated from any previous \lstinline!d!-index
5097 by a comma.
5098
5099 \item
5100 \mylst!comma d **!
5101
5102 Adds a double bullet to the \lstinline!d!-index,
5103 separated from any previous \lstinline!d!-index
5104 by a comma.
5105
5106 \item
5107 \mylst!d * with other sep={$\<separator\>$}!
5108
5109 Adds a bullet to the \lstinline!d!-index,
5110 separated from any previous \lstinline!d!-index
5111 by~\<separator\>.
5112
5113 \item
5114 \mylst!d ** with other sep={$\<separator\>$}!
5115
5116 Adds a double bullet to the \lstinline!d!-index,
5117 separated from any previous \lstinline!d!-index
5118 by~\<separator\>.
5119
5120 \item
5121 \mylst!clear d!
5122
5123 Clears the \lstinline!d!-index.
5124
5125 \item
5126 \mylst!clear pre d!
5127
5128 Clears the pre-\lstinline!d!-index.
5129
5130 \item
5131 \mylst!clear post d!
5132
5133 Clears the post-\lstinline!d!-index.
5134 \end{itemize}
5135
5136 \section{Keys for the \texttt{i}-index}
5137
5138 \begin{itemize}
5139 \item
5140 \mylst!i={$\<value\>$}!
5141
5142 Adds to the \lstinline!i!-index,
5143 with no separator from any previous \lstinline!i!-index.
5144
5145 \item
5146 \mylst!sep i={$\<value\>$}!
5147
5148 Adds to the \lstinline!i!-index,
5149 separated from any previous
5150 \lstinline!i!-index by the default separator.
5151
5152 \item
5153 \mylst!comma i={$\<value\>$}!
5154
5155 Adds to the \lstinline!i!-index,
5156 separated from any previous
5157 \lstinline!i!-index by a comma.
5158
5159 \item
5160 \mylst!pre i={$\<value\>$}!
5161
5162 Sets the pre-\lstinline!i!-index.
5163
5164 \item
5165 \mylst!pre i put left={$\<value\>$}!
5166
5167 Adds to the left of the pre-\lstinline!i!-index.
5168
5169 \item
5170 \mylst!post i={$\<value\>$}!
5171
5172 Sets the post-\lstinline!i!-index.
5173
5174 \item
5175 \mylst!post i put right={$\<value\>$}!
5176
5177 Adds to the right of the post-\lstinline!i!-index.
5178
5179 \item
5180 \mylst!i put left={$\<value\>$}!
5181
5182 Adds something to the left of the \lstinline!i!-index.
5183 As with keys like~\lstinline!i!, this
5184 will also increase the number of registered
5185 \lstinline!i!-indices by~\( 1 \), and
5186 it will
5187 set \lstinline!next i with sep=true!.
5188
5189 \item
5190 \mylst!set i sep={$\<value\>$}!
5191
5192 Sets the \lstinline!i!-index separator to~\<value\>.
5193 By default, this is a comma.
5194
5195 \item
5196 \mylst!next i with sep={$\values\<true|\default{false}\>$}!
5197
5198 Sets whether the next \lstinline!i!-index should
5199 be separated from the current one by a separator.
5200
5201 \item
5202 \mylst!i with other sep={$\<separator\>$}{$\<value\>$}!
5203
5204 Adds \<value\> to the \lstinline!i!-index, separated from
5205 any prevous \lstinline!i!-index by~\<separator\>.
5206
5207 \item
5208 \mylst!i ---!, \mylst!i slot!
5209
5210 Adds a slot to the \lstinline!i!-index,
5211 with no separator from any previous \lstinline!i!-index.
5212
5213 \item
5214 \mylst!sep i ---!, \mylst!sep i slot!
5215
5216 Adds a slot to the \lstinline!i!-index,
5217 separated from any previous \lstinline!i!-index
5218 by the default separator.
5219
5220 \item
5221 \mylst!comma i ---!, \mylst!comma i slot!
5222
5223 Adds a slot to the \lstinline!i!-index,
5224 separated from any previous \lstinline!i!-index
5225 by a comma.
5226
5227 \item
5228 \mylst!set i slot={$\<value\>$}!
5229
5230 Sets the slot for the \lstinline!i!-index.
5231 By default, this is~\lstinline!{-}!.
5232
5233 \item
5234 \mylst!i --- with other sep={$\<separator\>$}!,
5235 \mylst!i slot with other sep={$\<separator\>$}!
5236
5237
5238 Adds a slot to the \lstinline!i!-index, separated
5239 from any previous \lstinline!i!-index by~\<separator\>.
5240
5241 \item
5242 \mylst!i ...!, \mylst!i dots!
5243
5244 Adds three dots to the \lstinline!i!-index,
5245 with no separator from any previous \lstinline!i!-index.
5246
5247 \item
5248 \mylst!sep i ...!, \mylst!sep i dots!
5249
5250 Adds three dots to the \lstinline!i!-index,
5251 separated from any previous \lstinline!i!-index
5252 by the default separator.
5253
5254 \item
5255 \mylst!comma i ...!, \mylst!comma i dots!
5256
5257 Adds three dots to the \lstinline!i!-index,
5258 separated from any previous \lstinline!i!-index
5259 by a comma.
5260
5261 \item
5262 \mylst!set i dots={$\<value\>$}!
5263
5264 Sets the dots for the \lstinline!i!-index.
5265 By default, this is~\lstinline!\dots!.
5266
5267 \item
5268 \mylst!i ... with other sep={$\<separator\>$}!,
5269 \mylst!i dots with other sep={$\<separator\>$}!
5270
5271 Adds three dots to the \lstinline!i!-index,
5272 separated from any previous \lstinline!i!-index
5273 by~\<separator\>.
5274
5275 \item
5276 \mylst!i *!
5277
5278 Adds a bullet to the \lstinline!i!-index,
5279 with no separator from any previous \lstinline!i!-index.
5280
5281 \item
5282 \mylst!i **!
5283
5284 Adds a double bullet to the \lstinline!i!-index,
5285 with no separator from any previous \lstinline!i!-index.
5286
5287 \item
5288 \mylst!sep i *!
5289
5290 Adds a bullet to the \lstinline!i!-index,
5291 separated from any previous
5292 \lstinline!i!-index by the default separator.
5293
5294 \item
5295 \mylst!sep i **!
5296
5297 Adds a double bullet to the \lstinline!i!-index,
5298 separated from any previous
5299 \lstinline!i!-index by the default separator.
5300
5301 \item
5302 \mylst!comma i *!
5303
5304 Adds a bullet to the \lstinline!i!-index,
5305 separated from any previous
5306 \lstinline!i!-index by a comma.
5307
5308 \item
5309 \mylst!comma i **!
5310
5311 Adds a double bullet to the \lstinline!i!-index,
5312 separated from any previous
5313 \lstinline!i!-index by a comma.
5314
5315 \item
5316 \mylst!i * with other sep={$\<separator\>$}!
5317
5318 Adds a bullet to the \lstinline!i!-index,
5319 separated from any previous \lstinline!i!-index
5320 by~\<separator\>.
5321
5322 \item
5323 \mylst!i ** with other sep={$\<separator\>$}!
5324
5325 Adds a double bullet to the \lstinline!i!-index,
5326 separated from any previous \lstinline!i!-index
5327 by~\<separator\>.
5328
5329 \item
5330 \mylst!clear i!
5331
5332 Clears the \lstinline!i!-index.
5333
5334 \item
5335 \mylst!clear pre i!
5336
5337 Clears the pre-\lstinline!i!-index.
5338
5339 \item
5340 \mylst!clear post i!
5341
5342 Clears the post-\lstinline!i!-index.
5343 \end{itemize}
5344
5345 \section{The predefined argument keys}\label{sec:predefined_arg_keys}
5346
5347 These are the predefined keys that work inside the argument.
5348
5349 \begin{itemize}
5350 \item
5351 \mylst!execute={$\<code\>$}!
5352
5353 Executes the \<code\> on the spot.
5354 This is not strictly speaking a logic key,
5355 but this allows you to perform logical
5356 operations that are not allowed
5357 by the other logic keys.
5358
5359 \item
5360 \mylst!set keys={$\<keys\>$}!,
5361 \mylst!keys set={$\<keys\>$}!
5362
5363 Sets the keys \<keys\>.
5364
5365 \item
5366 \mylst!set keys x={$\<keys\>$}!,
5367 \mylst!keys set x={$\<keys\>$}!
5368
5369 Sets the keys \<keys\>, but fully expands their values.
5370
5371 \item
5372 \mylst!set arg keys={$\<keys\>$}!,
5373 \mylst!arg keys set={$\<keys\>$}!
5374
5375 Sets the argument keys \<keys\>.
5376
5377 \item
5378 \mylst!set arg keys x={$\<keys\>$}!,
5379 \mylst!arg keys set x={$\<keys\>$}!
5380
5381 Sets the argument keys \<keys\>, but fully expands their values.
5382
5383 \item
5384 \mylst!set arg single keys={$\<keys\>$}!,
5385 \mylst!arg single keys set={$\<keys\>$}!
5386
5387 Sets the argument keys \<keys\>,
5388 but only supports keys taking no values.
5389 This allows the arguments to contain equality
5390 signs without causing issues.
5391
5392 \item
5393 \mylst!set arg single keys x={$\<keys\>$}!,
5394 \mylst!arg single keys set x={$\<keys\>$}!
5395
5396 Sets the argument keys \<keys\>,
5397 but only supports keys taking no values.
5398 If a key is not found, the value
5399 is fully expanded and printed.
5400 This allows the arguments to contain equality
5401 signs without causing issues.
5402
5403 \item
5404 \mylst!set one arg single key={$\<key\>$}!,
5405 \mylst!one arg single key set={$\<key\>$}!
5406
5407 Sets one single argument key taking no values.
5408 This allows the argument to contain
5409 equality signs and commas without cuasing issues.
5410
5411 \item
5412 \mylst!set one arg single key x={$\<key\>$}!,
5413 \mylst!one arg single key set x={$\<key\>$}!
5414
5415 Sets one single argument key taking no values,
5416 If the key is not found, the value
5417 is fully expanded and printed.
5418 This allows the argument to contain
5419 equality signs and commas without cuasing issues.
5420
5421 \item
5422 \mylst!set arg without keyval={$\<value\>$}!,
5423 \mylst!arg without keyval set={$\<value\>$}!
5424
5425 Sets the argument, allowing no keyval syntax.
5426
5427 \item
5428 \mylst!set arg without keyval x={$\<value\>$}!,
5429 \mylst!arg without keyval set x={$\<value\>$}!
5430
5431 Sets the argument, fully expanding its value,
5432 and allowing no keyval syntax.
5433
5434 \item
5435 \mylst!default={$\<value\>$}!
5436
5437 This is the value that is applied whenever
5438 a value is passed to the argument that is not
5439 recognized as a key, e.g.~the~\lstinline!\vx!
5440 in~\lstinline!\vf{\vx}!.
5441 By default, this is set to be equivalent
5442 to~\lstinline!sep!.
5443
5444 \item
5445 \mylst!sep={$\<value\>$}!
5446
5447 Adds the \<value\> to the argument,
5448 separated from any previous argument
5449 by the default separator.
5450
5451 \item
5452 \mylst!no sep={$\<value\>$}!
5453
5454 Adds the \<value\> to the argument,
5455 with no separator from any previous argument.
5456
5457 \item
5458 \mylst!comma={$\<value\>$}!
5459
5460 Adds the \<value\> to the argument,
5461 separated from any previous argument
5462 by a comma.
5463
5464 \item
5465 \mylst!---!, \mylst!slot!
5466
5467 Adds a slot to the argument,
5468 separated from any previous argument
5469 by the default separator.
5470
5471 \item
5472 \mylst!comma ---!, \mylst!comma slot!
5473
5474 Adds a slot to the argument,
5475 separated from any previous argument
5476 by a comma.
5477
5478 \item
5479 \mylst!...!, \mylst!dots!
5480
5481 Adds three dots to the argument,
5482 separated from any previous argument
5483 by the default separator.
5484
5485 \item
5486 \mylst!comma ...!, \mylst!comma dots!
5487
5488 Adds three dots to the argument,
5489 separated from any previous argument
5490 by a comma.
5491
5492 \item
5493 \mylst!other sep={$\<separator\>$}{$\<value\>$}!
5494
5495 Adds \<value\> to the argument,
5496 separated from any previous argument
5497 by~\<separator\>.
5498
5499 \item
5500 \mylst!--- with other sep={$\<separator\>$}!,
5501 \mylst!slot with other sep={$\<separator\>$}!
5502
5503 Adds a slot to the argument, separated
5504 from any previous argument by \<separator\>.
5505
5506 \item
5507 \mylst!... with other sep={$\<separator\>$}! ,
5508 \mylst!dots with other sep={$\<separator\>$}!
5509
5510 Adds three dots to the argument, separated
5511 from any previous argument by~\<separator\>.
5512 \end{itemize}
5513
5514 \section{The programming commands}\label{sec:programming_commands}
5515
5516 The following commands are available for programming inside keys, including \lstinline!execute={...}!:
5517
5518 \begin{itemize}
5519 \item
5520 \mylst!\SemantexThis!
5521
5522 Returns the name of the current class or object. It is returned in the format \mylst!object_$\<name of object without backslash\>$!
5523 and \mylst!class_$\<name of class without backslash\>$!,
5524 which is the way the names are stored internally.
5525
5526 \item
5527 \mylst!\SemantexSetKeys{$\<keys\>$}!,
5528 \mylst!\SemantexKeysSet{$\<keys\>$}!
5529
5530 Sets the \<keys\>.
5531
5532 \item
5533 \mylst!\SemantexSetKeysx{$\<keys\>$}!,
5534 \mylst!\SemantexKeysSetx{$\<keys\>$}!
5535
5536 Sets the \<keys\>, but fully expands their values.
5537
5538 \item
5539 \mylst!\SemantexSetArgKeys{$\<keys\>$}!,
5540 \mylst!\SemantexArgKeysSet{$\<keys\>$}!
5541
5542 Sets the argument \<keys\>.
5543
5544 \item
5545 \mylst!\SemantexSetArgKeysx{$\<keys\>$}!,
5546 \mylst!\SemantexArgKeysSetx{$\<keys\>$}!
5547
5548 Sets the argument \<keys\>, but fully expands their values.
5549
5550 \item
5551 \mylst!\SemantexSetArgSingleKeys{$\<keys\>$}!,
5552 \mylst!\SemantexArgSingleKeysSet{$\<keys\>$}!
5553
5554 Sets the argument keys \<keys\>,
5555 but only supports keys taking no values.
5556 This allows the arguments to contain equality
5557 signs without causing issues.
5558
5559 \item
5560 \mylst!\SemantexSetArgSingleKeysx{$\<keys\>$}!,
5561 \mylst!\SemantexArgSingleKeysSetx{$\<keys\>$}!
5562
5563 Sets the argument keys \<keys\>,
5564 but only supports keys taking no values.
5565 If a key is not found, the value
5566 is fully expanded and printed.
5567 This allows the arguments to contain equality
5568 signs without causing issues.
5569
5570 \item
5571 \mylst!\SemantexSetOneArgSingleKey{$\<keys\>$}!,
5572 \mylst!\SemantexOneSingleArgKeySet{$\<keys\>$}!
5573
5574 Sets one single argument key taking no values.
5575 This allows the argument to contain
5576 equality signs and commas without cuasing issues.
5577
5578 \item
5579 \mylst!\SemantexSetOneArgSingleKeyx{$\<keys\>$}!,
5580 \mylst!\SemantexOneSingleArgKeySetx{$\<keys\>$}!
5581
5582 Sets one single argument key taking no values,
5583 If the key is not found, the value
5584 is fully expanded and printed.
5585 This allows the argument to contain
5586 equality signs and commas without cuasing issues.
5587
5588 \item
5589 \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!,
5590 \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}!
5591
5592 Sets the argument, allowing no keyval syntax.
5593
5594 \item
5595 \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!,
5596 \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}!
5597
5598 Sets the argument, fully expanding its value,
5599 and allowing no keyval syntax.
5600
5601 \item
5602 \mylst!\SemantexDataProvide{$\<data\>$}!
5603
5604 Provides a new piece of data consisting of a token list.
5605
5606 \item
5607 \mylst!\SemantexDataSet{$\<data\>$}{$\<value\>$}!
5608
5609 Sets the \<data\> to \<value\>.
5610
5611 \item
5612 \mylst!\SemantexDataSetx{$\<data\>$}{$\<value\>$}!
5613
5614 Sets the \<data\> to \<value\>, but fully expands the \<value\> first.
5615
5616 \item
5617 \mylst!\SemantexDataPutLeft{$\<data\>$}{$\<value\>$}!
5618
5619 Adds the \<value\> to the left of \<data\>.
5620
5621 \item
5622 \mylst!\SemantexDataPutLeftx{$\<data\>$}{$\<value\>$}!
5623
5624 Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first.
5625
5626 \item
5627 \mylst!\SemantexDataPutRight{$\<data\>$}{$\<value\>$}!
5628
5629 Adds the \<value\> to the right of \<data\>.
5630
5631 \item
5632 \mylst!\SemantexDataPutRightx{$\<data\>$}{$\<value\>$}!
5633
5634 Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first.
5635
5636 \item
5637 \mylst!\SemantexDataGet{$\<data\>$}!
5638
5639 Returns the value of \<data\>.
5640
5641 \item
5642 \mylst!\SemantexDataGetExpNot{$\<data\>$}!
5643
5644 Returns the value of \<data\>,
5645 enclosed in \lstinline!\unexpanded!
5646 so that it can be used within an \lstinline!x!-type
5647 expansion.
5648
5649 \item
5650 \mylst!\SemantexDataClear{$\<data\>$}!
5651
5652 Clears the piece of data~\<data\>.
5653
5654 \item
5655 \mylst!\SemantexBoolProvide{$\<boolean\>$}!
5656
5657 Provides a new piece of data consisting of a boolean.
5658
5659 \item
5660 \mylst!\SemantexBoolSetTrue{$\<boolean\>$}!
5661
5662 Sets the \<boolean\> to true.
5663
5664 \item
5665 \mylst!\SemantexBoolSetFalse{$\<boolean\>$}!
5666
5667 Sets the \<boolean\> to false.
5668
5669 \item
5670 \mylst!\SemantexBoolIfTF{$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!,\\
5671 \mylst!\SemantexBoolIfT{$\<boolean\>$}{$\<if true\>$}!,\\
5672 \mylst!\SemantexBoolIfF{$\<boolean\>$}{$\<if false\>$}!
5673
5674 Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>.
5675
5676 \item
5677 \mylst!\SemantexIntProvide{$\<integer\>$}!
5678
5679 Provides a new piece of data consisting of an integer.
5680
5681 \item
5682 \mylst!\SemantexIntGet{$\<integer\>$}!
5683
5684 Returns the value of the \<integer\>.
5685
5686 \item
5687 \mylst!\SemantexIntSet{$\<integer\>$}{$\<value\>$}!
5688
5689 Sets the \<integer\> to \<value\>.
5690
5691 \item
5692 \mylst!\SemantexIntIncr{$\<integer\>$}!
5693
5694 Increases the \<integer\> by~\( 1 \).
5695
5696 \item
5697 \mylst!\SemantexIntIfEqTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
5698 \mylst!\SemantexIntIfEqT$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
5699 \mylst!\SemantexIntIfEqF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
5700
5701 Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal,
5702 and runs \<if~true\> or \<if~false\> accordingly.
5703
5704 \item
5705 \mylst!\SemantexIntIfGreaterTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
5706 \mylst!\SemantexIntIfGreaterT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
5707 \mylst!\SemantexIntIfGreaterF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
5708
5709 Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>,
5710 and runs \<if~true\> or \<if~false\> accordingly.
5711
5712 \item
5713 \mylst!\SemantexIntIfLessTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
5714 \mylst!\SemantexIntIfLessT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\
5715 \mylst!\SemantexIntIfLessF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}!
5716
5717 Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>,
5718 and runs \<if~true\> or \<if~false\> accordingly.
5719
5720 \item
5721 \mylst!\SemantexIntClear{$\<integer\>$}!
5722
5723 Clears the \<integer\>, i.e.~sets it to~\( 0 \).
5724
5725 \item
5726 \mylst!\SemantexIfBlankTF{$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\
5727 \mylst!\SemantexIfBlankT{$\<tokens\>$}{$\<if true\>$}!,\\
5728 \mylst!\SemantexIfBlankF{$\<tokens\>$}{$\<if false\>$}!
5729
5730 Fully expands the \<tokens\> and checks if it is blank,
5731 and runs \<if true\> or \<if false\> according to this.
5732
5733 \item
5734 \mylst!\SemantexStrIfEqTF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\
5735 \mylst!\SemantexStrIfEqT{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\
5736 \mylst!\SemantexStrIfEqF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}!
5737
5738 Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal,
5739 and runs \<if~true\> or \<if~false\> accordingly.
5740
5741 \item
5742 \mylst!\SemantexERROR{$\<error message\>$}!
5743
5744 Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>}
5745 or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}.
5746
5747 \item
5748 \mylst!\SemantexERRORKeyValueNotFound{$\<key\>$}{$\<value\>$}!
5749
5750 Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>.
5751
5752 \item
5753 \mylst!\SemantexERRORArgKeyValueNotFound{$\<key\>$}{$\<value\>$}!
5754
5755 Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>.
5756
5757 \item
5758 \mylst!\SemantexExpNot{$\<value\>$}!
5759
5760 An alias for \lstinline!\unexpanded! (also known as \lstinline!\exp_not:N! in~\LaTeX3).
5761 \end{itemize}
5762
5763 \section{The class types}
5764
5765 The \semantex{} system uses several different \emph{class types}.
5766 In fact, all class types are identical internally; the low-level machinery of \semantex{} does not \enquote{know} what type a class has.
5767 The only difference between the class types is the \emph{input syntax}.
5768 In other words, it determines which arguments an object of that class
5769 can take. The syntax for creating new objects
5770 also varies.
5771
5772 Each class has a \lstinline!\New...! as well as a \lstinline!\Declare...! variant, the difference being
5773 that the \lstinline!\New...! variant raises an error if the command name is already taken.
5774 Both variants will raise an error if a \semantex{} class with the same name already exists.
5775 Allowing you to override existing \semantex{} definitions would require fundamental changes
5776 to the system which would slow it down significantly.
5777
5778 Similarly, you can use both of the commands \lstinline!\NewObject! and \lstinline!\DeclareObject!
5779 to define objects, the difference being that \lstinline!\NewObject! raises an error
5780 if the command name is already taken.
5781 Both commands will raise an error if a \semantex{} object with the same name already exists.
5782 Allowing you to override existing \semantex{} definitions would require fundamental changes
5783 to the system which would slow it down significantly.
5784
5785
5786 The current implementation has the following
5787 class types:
5788
5789 \begin{itemize}
5790 \item \lstinline!Variable!:
5791 A new class is defined with the
5792 syntax
5793 \begin{lstlisting}
5794 \NewVariableClass{@\usercommand\<Class\>@}[@\<options\>@]
5795 \DeclareVariableClass{@\usercommand\<Class\>@}[@\<options\>@]
5796 \end{lstlisting}
5797 A new object is declared by
5798 \begin{lstlisting}
5799 \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5800 \DeclareObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5801 \end{lstlisting}
5802 The syntax for this object is
5803 \begin{lstlisting}
5804 @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@}
5805 \end{lstlisting}
5806 \item \lstinline!Symbol!:
5807 A new class is declared with the
5808 syntax
5809 \begin{lstlisting}
5810 \NewSymbolClass@\usercommand\<Class\>@[@\<options\>@]
5811 \DeclareSymbolClass@\usercommand\<Class\>@[@\<options\>@]
5812 \end{lstlisting}
5813 A new object is declared by
5814 \begin{lstlisting}
5815 \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5816 \DeclareObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5817 \end{lstlisting}
5818 The syntax for this object is
5819 \begin{lstlisting}
5820 @\usercommand\<object\>@[@\<options\>@]
5821 \end{lstlisting}
5822 \item \lstinline!Simple!:
5823 A new class is declared with the
5824 syntax
5825 \begin{lstlisting}
5826 \NewSimpleClass@\usercommand\<Class\>@[@\<options\>@]
5827 \DeclareSimpleClass@\usercommand\<Class\>@[@\<options\>@]
5828 \end{lstlisting}
5829 A new object is declared by
5830 \begin{lstlisting}
5831 \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5832 \DeclareObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@]
5833 \end{lstlisting}
5834 The syntax for this object is
5835 \begin{lstlisting}
5836 @\usercommand\<object\>@
5837 \end{lstlisting}
5838 \end{itemize}
5839
5840 Let me add that \semantex{} uses a very clear separation between the input syntax and the underlying machinery. Because of this, if the user needs a different kind of class type, it is not very hard to create one. You must simply open the source code of \semantex, find the class you want to modify, and then copy the definition of the command~\mylst!\New$\<Class type\>$Class! and modify it in whatever way you want.
5841
5842 The last class type, called \lstinline!Simple!,
5843 is the class type of the class~\lstinline!\SemantexBaseObject!. This class is pretty useless as all it does is print its symbol, without allowing any keyval syntax. So you simply should not use it.
5844
5845 \section{The predefined data}
5846
5847 By default, the following data are defined for each class or object and are accessible via
5848 the programming keys and commands:
5849
5850 \begin{itemize}
5851 \item
5852 \mylst!symbol!
5853 (token list):
5854 the symbol.
5855 \item
5856 \mylst!output!
5857 (token list):
5858 the name of the output class.
5859 \item
5860 \mylst!output options!
5861 (token list):
5862 the output options, i.e.~the options to be passed to the output class.
5863 \item
5864 \mylst!math class!
5865 (token list):
5866 the \TeX\ math class command that the final output
5867 is evnetually wrapped around;
5868 the intended use of this is the \TeX\ commands
5869 \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!.
5870 \item
5871 \lstinline!height phantom!
5872 (token list):
5873 the height phantom that is used
5874 for calculating the height of left indices.
5875 \item
5876 \lstinline!slanting phantom!
5877 (token list):
5878 the slanting phantom that is used for
5879 calculating the slanting of left indices.
5880 \item
5881 \lstinline!par size!
5882 (token list):
5883 the size of the argument parentheses.
5884 The value~\lstinline!normal! means normal size
5885 parentheses,
5886 \lstinline!auto! and~\lstinline!*!
5887 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
5888 If another value is received, that value
5889 is used for the parenthesis size,
5890 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
5891 \lstinline!\bigg!,~\lstinline!\Bigg!.
5892 The default value is \lstinline!normal!.
5893 \item
5894 \lstinline!left par!
5895 (token list):
5896 the left argument parenthesis;
5897 the default value is~\lstinline!(!.
5898 \item
5899 \lstinline!right par!
5900 (token list):
5901 the right argument parenthesis;
5902 the default value is~\lstinline!)!.
5903 \item
5904 \lstinline!spar size!
5905 (token list):
5906 the size of the symbol parentheses (for use with the \lstinline!spar!~routine).
5907 The value~\lstinline!normal! means normal size
5908 parentheses,
5909 \lstinline!auto! and~\lstinline!*!
5910 mean auto-scaled parentheses using~\lstinline!\left ...\right!.
5911 If another value is received, that value
5912 is used for the parenthesis size,
5913 so the intended values are~\lstinline!\big!, \lstinline!\Big!,
5914 \lstinline!\bigg!,~\lstinline!\Bigg!.
5915 The default value is \lstinline!normal!.
5916 \item
5917 \lstinline!left spar!
5918 (token list):
5919 the left symbol parenthesis (for use with the \lstinline!spar!~routine);
5920 the default value is~\lstinline!(!.
5921 \item
5922 \lstinline!right spar!
5923 (token list):
5924 the right symbol parenthesis (for use with the \lstinline!spar!~routine);
5925 the default value is~\lstinline!)!.
5926 \item
5927 \lstinline!arg!
5928 (token list):
5929 the argument.
5930 \item
5931 \lstinline!pre arg!
5932 (token list):
5933 to be printed in front of the argument, if the argument is non-empty.
5934 \item
5935 \lstinline!post arg!
5936 (token list):
5937 to be printed after the argument, if the argument is non-empty.
5938 \item
5939 \lstinline!arg sep!
5940 (token list):
5941 the argument separator;
5942 comma by default.
5943 \item
5944 \lstinline!arg slot!
5945 (token list):
5946 the argument slot;
5947 \lstinline!{-}!~by default.
5948 \item
5949 \lstinline!arg dots!
5950 (token list):
5951 the argument dots;
5952 \lstinline!\dots!~by default.
5953 % Upper index:
5954 \item
5955 \lstinline!upper!
5956 (token list):
5957 the upper index.
5958 \item
5959 \lstinline!pre upper!
5960 (token list):
5961 the pre-upper index, to be printed in front of the upper index,
5962 if the upper index is non-empty.
5963 \item
5964 \mylst!post upper!
5965 (token list)
5966 the post-upper index, to be printed after the upper index,
5967 if the upper index is non-empty.
5968 \item
5969 \mylst!upper sep!
5970 (token list):
5971 the upper index separator;
5972 comma by default.
5973 \item
5974 \mylst!upper dots!
5975 (token list):
5976 the upper dots; \lstinline!\dots!~by default.
5977 \item
5978 \mylst!upper slot!
5979 (token list):
5980 the upper slot; \lstinline!{-}!~by default.
5981 % Lower index:
5982 \item
5983 \lstinline!lower!
5984 (token list):
5985 the lower index.
5986 \item
5987 \lstinline!pre lower!
5988 (token list):
5989 the pre-lower index, to be printed in front of the lower index,
5990 if the lower index is non-empty.
5991 \item
5992 \mylst!post lower!
5993 (token list)
5994 the post-lower index, to be printed after the lower index,
5995 if the lower index is non-empty.
5996 \item
5997 \mylst!lower sep!
5998 (token list):
5999 the lower index separator;
6000 comma by default.
6001 \item
6002 \mylst!lower dots!
6003 (token list):
6004 the lower dots; \lstinline!\dots!~by default.
6005 \item
6006 \mylst!lower slot!
6007 (token list):
6008 the lower slot; \lstinline!{-}!~by default.
6009 % Upper left index:
6010 \item
6011 \lstinline!upper left!
6012 (token list):
6013 the upper left index.
6014 \item
6015 \lstinline!pre upper left!
6016 (token list):
6017 the pre-upper left index, to be printed in front of the upper left index,
6018 if the upper left index is non-empty.
6019 \item
6020 \mylst!post upper left!
6021 (token list)
6022 the post-upper left index, to be printed after the upper left index,
6023 if the upper left index is non-empty.
6024 \item
6025 \mylst!upper left sep!
6026 (token list):
6027 the upper left index separator;
6028 comma by default.
6029 \item
6030 \mylst!upper left dots!
6031 (token list):
6032 the upper left dots; \lstinline!\dots!~by default.
6033 \item
6034 \mylst!upper left slot!
6035 (token list):
6036 the upper left slot; \lstinline!{-}!~by default.
6037 % Lower left index:
6038 \item
6039 \lstinline!lower left!
6040 (token list):
6041 the lower left index.
6042 \item
6043 \lstinline!pre lower left!
6044 (token list):
6045 the pre-lower left index, to be printed in front of the lower left index,
6046 if the lower left index is non-empty.
6047 \item
6048 \mylst!post lower left!
6049 (token list)
6050 the post-lower left index, to be printed after the lower left index,
6051 if the lower left index is non-empty.
6052 \item
6053 \mylst!lower left sep!
6054 (token list):
6055 the lower left index separator;
6056 comma by default.
6057 \item
6058 \mylst!lower left dots!
6059 (token list):
6060 the lower left dots; \lstinline!\dots!~by default.
6061 \item
6062 \mylst!lower left slot!
6063 (token list):
6064 the lower left slot; \lstinline!{-}!~by default.
6065 \item
6066 \mylst!upper grading!
6067 (boolean):
6068 whether or not to use
6069 upper (cohomological) grading; true by default.
6070 \item
6071 \mylst!par!
6072 (boolean):
6073 whether or not to use parentheses; true by default.
6074 \item
6075 \mylst!flex par!
6076 (boolean):
6077 if \mylst!par! is set to false, setting \mylst!flex par! to true
6078 will still print a pair of parentheses when there is more than one argument;
6079 false by default.
6080 \item
6081 \mylst!left argument!
6082 (boolean):
6083 if true, the argument (and parentheses)
6084 will be printed to the \emph{left} of the symbol;
6085 false by default.
6086 \item
6087 \mylst!next arg with sep!
6088 (boolean):
6089 if true, the next argument will have a separator printed in front of it.
6090 \item
6091 \mylst!next upper with sep!
6092 (boolean):
6093 If true, the next upper index will have a separator printed in front of it.
6094 \item
6095 \mylst!next lower with sep!
6096 (boolean):
6097 If true, the next lower index will have a separator printed in front of it.
6098 \item
6099 \mylst!next upper left with sep!
6100 (boolean):
6101 If true, the next upper left index will have a separator printed in front of it.
6102 \item
6103 \mylst!next lower left with sep!
6104 (boolean):
6105 If true, the next lower upper index will have a separator printed in front of it.
6106 \item
6107 \mylst!number of arguments!
6108 (integer):
6109 the number of arguments.
6110 \item
6111 \mylst!number of upper indices!
6112 (integer):
6113 the number of upper indices.
6114 \item
6115 \mylst!number of lower indices!
6116 (integer):
6117 the number of lower indices.
6118 \item
6119 \mylst!number of upper left indices!
6120 (integer):
6121 the number of upper left indices.
6122 \item
6123 \mylst!number of lower left indices!
6124 (integer):
6125 the number of lower left indices.
6126 \end{itemize}
6127
6128 \end{document}