diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-08 03:02:12 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-08 03:02:12 +0000 |
commit | bc2d0660f4f460b55009ab4e525f2a0e4cde6187 (patch) | |
tree | d35815089faf23c45f4f21690e42cfcc7c65a5fd /macros/latex/contrib/semantex/semantex.tex | |
parent | 57edbaffbe7daad894e3036a4123acd03e0fdb9b (diff) |
CTAN sync 202009080302
Diffstat (limited to 'macros/latex/contrib/semantex/semantex.tex')
-rw-r--r-- | macros/latex/contrib/semantex/semantex.tex | 4715 |
1 files changed, 4176 insertions, 539 deletions
diff --git a/macros/latex/contrib/semantex/semantex.tex b/macros/latex/contrib/semantex/semantex.tex index f4cf279f0e..81064afc8e 100644 --- a/macros/latex/contrib/semantex/semantex.tex +++ b/macros/latex/contrib/semantex/semantex.tex @@ -23,6 +23,10 @@ \makeevenhead{headings}{\thepage}{}{\itshape\leftmark} %make headings italic instead of slanted (though we do not use headings right now) \makeoddhead{headings}{\itshape\rightmark}{}{\thepage} +\setlrmarginsandblock{4cm}{*}{*} +\setulmarginsandblock{4cm}{*}{*} +\checkandfixthelayout + \raggedbottomsectiontrue%less harse than \raggedbottom %\allowdisplaybreaks %long equations may break @@ -34,26 +38,67 @@ \usepackage[nameinlink]{cleveref} -\title{Seman\!\TeX: Semantic mathematics (v$0.3\alpha$)} +\title{Seman\!\TeX: semantic, keyval-based mathematics (v$0.4\beta$)} \date{\today} \author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})} \hypersetup{ pdfauthor={Sebastian Ørsted}, - pdftitle={SemanTeX: Object-oriented mathematics}, + pdftitle={SemanTeX: semantic, keyval-based mathematics}, %pdfsubject={}, %pdfkeywords={}, %pdfproducer={Latex with hyperref, or other system}, %pdfcreator={pdflatex, or other tool}, } +\usepackage{showexpl} +\lstset{% + language=[LaTeX]TeX, + basicstyle=\ttfamily\small, + commentstyle=\itshape\ttfamily\small, + alsoletter={\\}, + escapechar=@, + breaklines=true, + breakindent={0pt}, + captionpos=t, + pos=r, + tabsize=2, + %inputencoding=utf8, + explpreset={numbers=none,}, + texcl=false, + wide=false, + width=.45\textwidth, +} + +\newcommand\mylst{\lstinline[mathescape]} + +\def\<#1\>{\textrm{\textlangle\textit{#1}\textrangle}} + +\def\usercommand\<#1\>{\textrm{\textbackslash\textlangle\textit{#1}\textrangle}} + +\def\values\<#1\>{\textrm{\textlangle\textup{#1}\textrangle}} +\def\num#1{\textsubscript{\textup{#1}}} -% Settup up SemanTeX: +\newcommand\default[1]{\smash{\underline{\smash{#1}}}} + +\newcommand\commandname[1]{\textbackslash\texttt{#1}} + +\let\pack=\texttt + +\newcommand\semantex{Seman\!\TeX\xspace} + +\newcommand\stripsemantex{\texttt{stripsemantex}\xspace} + +\usepackage{hologo} + +% Setting up SemanTeX: \usepackage{semantex} +\usepackage{expkv} + \NewVariableClass\MyVar[ output=\MyVar, ] @@ -173,58 +218,38 @@ \NewObject\MyHomology\ho{H} -\usepackage{showexpl,newunicodechar} +\makeatother -\newunicodechar{⟨}{\textlangle} -\newunicodechar{⟩}{\textrangle} -\makeatother \begin{document} \maketitle -\lstset{% - language=[LaTeX]TeX, - basicstyle=\ttfamily\small, - commentstyle=\itshape\ttfamily\small, - extendedchars=true, - breaklines=true, - breakindent={0pt}, - captionpos=t, - pos=r, - tabsize=2, - inputencoding=utf8, - extendedchars=true, - explpreset={numbers=none,}, - literate={⟨}{\textlangle}1 {⟩}{\textrangle}1, -} - - - -\newcommand\mybs{$\backslash$} +\noindent +The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the classical math syntax in~\LaTeX. +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. -\newcommand\commandname[1]{\mybs\texttt{#1}} +Furthermore, the package has a companion package, +called \stripsemantex, which allows you to completely strip +your documents of \semantex markup to prepare them e.g.~for publication. -\let\pack=\texttt - -\newcommand\semantex{Seman\!\TeX\xspace} +The package is still in beta, but is considered feature-complete +and more or less stable, so using it at this point should be safe. +Still, suggestions, ideas, and bug reports are more than welcome! -\noindent -The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the classical math syntax in~\LaTeX. -The system uses keyval syntax and is highly customizable. At the same time, care has been taken to make it the syntax as simple, natural, practical, and lightweight as possible. -\textbf{Note: \semantex is still in its alpha stage and cannot be considered stable at this point. You are more than welcome to report bugs and come with suggestions!} +\chapter{Introduction} \begingroup \SetupClass\MyVar{ - singlekeys={ - {conj}{overline}, + definekeys={ + {conj}{command=\overline}, {inv}{upper={-1}}, {inverseimage}{upper={-1},nopar}, }, - valuekeys={ + definekeys[1]={ {der}{upper={ (#1) } }, - {res}{ return ,symbolputright ={|}, lower ={#1} }, + {res}{ rightreturn ,symbolputright ={|}, lower ={#1} }, {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma @@ -301,17 +326,17 @@ $ \vh[inverseimage]{\sheafF}[spar,stalk=\vp] output=\MyVar, % This means that the output of an object % of class \MyVar is also of class \MyVar % We add a few keys for use with the class \MyVar: - singlekeys={ % keys taking no values + definekeys={ % we define a few keys {inv}{upper={-1}}, - {conj}{overline}, + {conj}{command=\overline}, % Applies \overline to the symbol {inverseimage}{upper={-1},nopar}, }, - valuekeys={ % keys taking a value + definekeys[1]={ % we define keys taking 1 value {der}{upper={(#1)}}, {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma - {res}{ return ,symbolputright ={|}, lower ={#1} }, + {res}{ rightreturn, symbolputright={|}, lower={#1} }, }, } @@ -341,7 +366,7 @@ You should think of this as a low-level class, the parent of all other classes. Instead, we create a new, more high-level variable class. We choose to call it \lstinline!\MyVar!. It is best to always start class names with uppercase letters to separate them from objects. -We could write \lstinline!\NewVariableClass\MyVar!, but we choose to +We could create this class by writing \lstinline!\NewVariableClass\MyVar!, but we choose to pass some options to it in~\lstinline![...]!: \begin{lstlisting} \NewVariableClass\MyVar[output=\MyVar] @@ -350,15 +375,15 @@ This \lstinline!output=\MyVar! option will be explained better below. Roughly speaking, it tells \semantex that everything a variable \emph{outputs} will also be a variable. For instance, if the function~\lstinline!\vf! (i.e.~\( \vf \)) is of class~\lstinline!\MyVar!, -then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also of class~\lstinline!\MyVar!. +then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also be of class~\lstinline!\MyVar!. Now we have a class, but we do not have any objects. To create the object~\lstinline!\vf! of class~\lstinline!\MyVar! with symbol~\( f \), we write~\lstinline!\NewObject\MyVar\vf{f}!. -In general, when you have class~\lstinline!\⟨Class⟩!, you +In general, when you have class~\usercommand\<Class\>, you can create objects of that class wtih the syntax \begin{lstlisting} -\NewObject\⟨Class⟩\⟨object⟩{⟨object symbol⟩}[⟨options⟩] +\NewObject@\usercommand\<Class\>\usercommand\<object\>@{@\<object symbol\>@}[@\<options\>@] \end{lstlisting} To distinguish objects from classes, it is a good idea to denote 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.} @@ -374,13 +399,14 @@ $\vf$, $\vx$ \end{LTXexample} Th general syntax of a variable-type object is \begin{lstlisting} -\⟨object⟩[⟨options⟩]{⟨argument⟩} +@\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} \end{lstlisting} -Both \lstinline!⟨options⟩! and \lstinline!⟨argument⟩! are optional +Both \<options\> and \<argument\> are optional arguments (they can be left out if you do not need them). -The \lstinline!⟨options⟩! should consist of a list of options separated by commas, using keyval syntax. On the other hand, \lstinline!⟨argument⟩! is the actual argument of the function. -By design, \semantex does not distinguish between variables and functions, so all variables can take arguments. -This is a design choice to make 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. +The \<options\> should consist of a list of options separated by commas, using keyval syntax. Naturally, \<argument\> is the actual argument of the function. + +By a design choice, \semantex does not distinguish between variables and functions, so all variables can take arguments. +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. So we may write: \begin{LTXexample} $\vf{1}$, $\vf{\vx}$, @@ -388,20 +414,37 @@ $\vx{\vx}$ \end{LTXexample} So far, we do not have very many options to write in the -\lstinline!⟨options⟩! position, since we have not added any keys yet. However, we do have access +\<options\> position, since we have not added any keys yet. However, we do have access to the most important of all options: the \emph{index}. There is a simple shortcut for writing an index: You simply write the index itself in the options tag: \begin{LTXexample} $\vf[1]$, $\vf[\vf]$, $\vf[1,2,\vf]{2}$ \end{LTXexample} -As long as what you write in the options tag is not recognized as a predefined key, it will be printed as the index. +As long as what you write in the options tag is not recognized as a defined key, it will be printed as the index. Other than that, there are two important predefined keys: \lstinline!upper! and \lstinline!lower! which simply add something to the upper and lower index: \begin{LTXexample} $\vf[upper=2]$, $\vf[lower=3]$ \end{LTXexample} +In fact, there are quite a few keys for manipulating upper and lower indices. +Right now, apart from \lstinline!upper! and~\lstinline!lower!, +we shall only need a couple more: +\lstinline!supper! and~\lstinline!slower! mean +\enquote{separator~+~upper} and \enquote{separator~+~lower}\footnote{Yes, I have noticed that the words unfortunately have other meanings already. But the notation has to be brief and consistent, and I have decided convention that \mylst!s$\<anything\>$! means \<anything\>, possibly separated from previous \<anything\> by a separator.}. +These are like \lstinline!upper! and~\lstinline!lower!, +but if there already was an upper or lower index, +the new index will be separated from the old one by a separator. +By default, this separator is a comma. +There are also two more commands, +\lstinline!cupper! and~\lstinline!clower!, +which mean \enquote{comma~+~upper} and~\enquote{comma~+~lower}. +These will use a comma as separator, even if you have changed the +default separator. + +\section{Next step: Defining more variables} + We are soon going to need more variables than just \( \vf \) and~\( \vx \). In fact, I advise you to create a variable for each letter in the Latin and Greek alphabets, both uppercase and lowercase. @@ -516,7 +559,10 @@ $\vf[par=auto]{\frac{1}{2}}$ \end{LTXexample} 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~\lstinline!nopar! (it will still print parentheses if there is more than one argument, though; to exclude this behaviour, run~\lstinline!neverpar! instead): \begin{LTXexample} -$\vf[nopar]{\vx}$ +$\vf[nopar]{\vx}$, +$\vf[nopar]{\vx,\vy}$, +$\vf[neverpar]{\vx}$, +$\vf[neverpar]{\vx,\vy}$ \end{LTXexample} Primes are added via the key~\lstinline!prime! or the keys~\lstinline!'!,~\lstinline!''! and~\lstinline!'''!: @@ -526,37 +572,101 @@ $\vf[''] = \vf[prime,prime]$ $\vf['''] = \vf[prime,prime,prime]$ \end{LTXexample} -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. -Keys are being added via two different keys: -\begin{center} - \lstinline!singlekeys! - \qquad\qquad and \qquad\qquad - \lstinline!valuekeys!. -\end{center} -In short, \lstinline!singlekeys! is for keys that do \emph{not} take a value (i.e.~keys using the syntax~\lstinline!\⟨object⟩[key]!), and \lstinline!valuekeys! is for keys that \emph{do} take a value -(i.e.~keys using the syntax~\lstinline!\⟨object⟩[key=value]!)). -We explain the syntax for using them in the next section where we show how to make keyval syntax for elementary calculus. - \begingroup\color{red}% 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. \endgroup -\chapter{Example: Elementary calculus} +\section{Defining keys} + +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. +To define keys, we use the command~\lstinline!\SetupClass! +(or~\lstinline!\SetupObject! if you want to define it for an individual object) +and the key~\lstinline!definekeys!. +The syntax is as follows: +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {@\<key name\num{1}\>@}{ @\<keys to run\>@ }, + {@\<key name\num{2}\>@}{ @\<keys to run\>@ }, + {@\<key name\num{3}\>@}{ @\<keys to run\>@ }, + @\ldots,@ + }, +} +\end{lstlisting} +For instance, you can do +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {key1}{ upper=3, lower=7 }, + {key2}{ lower=6, upper=4 }, + }, +} +\end{lstlisting} + +Quite often, we shall also need to define +keys that can \emph{take a value}. +A key can take up to~\( 9 \)~values. +To define a key taking \( n \)~values, +use~\mylst!definekeys[$n$]! +for~\( n = 0 , 1 , 2 , \ldots , 9 \). +The syntax is similar to~\lstinline!definekeys!, +except the values can be accessed +by writing~\lstinline!#1!, \lstinline!#2!, \ldots, \lstinline!#9!. +Except for a few special cases, you will probably only +ever need~\lstinline!definekeys[1]!. So you can do +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys[1]={ + {key3}{ upper=\{#1\} }, + {key4}{ lower=(#1) }, + }, + definekeys[2]={ + {key5}{ upper=3+#1, lower=7-#2 }, + {key6}{ lower=6\cdot#1, upper=4/#2 }, + }, +} +\end{lstlisting} +\begingroup +\SetupClass\MyVar{ + definekeys={ + {key1}{ upper=3, slower=7 }, + {key2}{ lower=6, supper=4 }, + }, + definekeys[1]={ + {key3}{ supper=\{#1\} }, + {key4}{ slower=(#1) }, + }, + definekeys[2]={ + {key5}{ supper=3+#1, slower=7-#2 }, + {key6}{ slower=6\cdot#1, supper=4/#2 }, + }, +} +Let us see these rather ridiculous keys in action: + +\begin{LTXexample} +$ \vP[key1,key3=0,key5={3}{4}] $ +\end{LTXexample} + +\endgroup + +\chapter{Some examples} + +\section{Example: Elementary calculus} One thing we might want to do to a variable is \emph{invert} it. We therefore add a key~\lstinline!inv! that adds an upper index~\lstinline!-1! to the symbol. -We add this key using the key \lstinline!singlekeys!, -which is for keys that do not take a value: +We add this key using the key \lstinline!definekeys! +since there is no reason for this key to take a value: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, } \end{lstlisting} \SetupClass\MyVar{ -singlekeys={ +definekeys={ {inv}{ upper={-1} }, }, } @@ -569,25 +679,22 @@ $\vg[1,2,inv]$, $\vh[\va,\vb,inv]$ \end{LTXexample} -Other keys might need to take a value. -For defining such, we have the command~\lstinline!valuekeys!. -%There are two different keys for adding new keys -%to a class: \lstinline!singlekeys! and \lstinline!valuekeys!. -%The difference is that +Other keys might need to take one value. +For defining these, we use the key~\lstinline!definekeys[1]!. For instance, suppose we want a command for deriving a function \( n \)~times. For this, we add the key~\lstinline!der!: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, }, } \end{lstlisting} \SetupClass\MyVar{ -valuekeys={ +definekeys[1]={ {der}{ upper={(#1)} }, }, } @@ -600,17 +707,17 @@ $\vf[der=\vn]{\vx}$ Maybe we also want a more elementary key~\lstinline!power! for raising a variable to a power: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {power}{ upper={#1} }, }, } @@ -624,26 +731,26 @@ Let us try doing something a bit more complicated: adding a key for restricting For this, we do the following: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, - {res}{ return,symbolputright={|}, lower={#1} }, + {res}{ rightreturn,symbolputright={|}, lower={#1} }, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {res}{ return,symbolputright={|}, lower={#1} }, + definekeys[1]={ + {res}{ rightreturn,symbolputright={|}, lower={#1} }, }, } This adds a horizonal line~\enquote{$|$} to the right of the symbol followed by a lower index containing whatever you passed to the key (contained in the \mbox{command~\lstinline!#1!)}. -(There is also an extra key, \lstinline!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}.) +(There is also an extra key, \lstinline!rightreturn!, 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}.) Now we may write the following: \begin{LTXexample} $\vf[res=\vU]{\vx}$, @@ -661,15 +768,16 @@ $\vf[der=\vn]{\vx}{\vy}{\vz} 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: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {bigres}{ return, symbolputright=\big\vert, lower={#1} }, - {Bigres}{ return, symbolputright=\Big\vert, lower={#1} }, - {biggres}{ return, symbolputright=\bigg\vert, lower={#1} }, - {Biggres}{ return, symbolputright=\Bigg\vert, lower={#1} }, - {autores}{ return, Otherspar={.}{\vert}{auto}, - lower={#1} }, - % This auto scales the vertical bar. See the chapter on the - % spar key for information about sparsize and Otherspar + definekeys[1]={ + {bigres}{ rightreturn, symbolputright=\big|, lower={#1} }, + {Bigres}{ rightreturn, symbolputright=\Big|, lower={#1} }, + {biggres}{ rightreturn, symbolputright=\bigg|, lower={#1} }, + {Biggres}{ rightreturn, symbolputright=\Bigg|, lower={#1} }, + {autores}{ Otherspar={.}{|}{auto}, lower={#1} }, + % The last key auto-scales the vertical bar. See @\textit{\cref{sec:spar}}@ + % for information about Otherspar. + % Note that Otherspar automatically invokes rightreturn, + % so no need to run that key twice. }, } \end{lstlisting} @@ -680,26 +788,25 @@ via \lstinline!\NewVariableClass! and then used \lstinline!\SetupClass! to add k \NewVariableClass\MyVar[ output=\MyVar, % This means that the output of an object % of class \MyVar is also of class \MyVar - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, - {res}{ rightreturn, symbolputright={|}, - lower={#1} }, + {res}{ rightreturn, symbolputright={|}, lower={#1} }, }, ] \end{lstlisting} As we proceed in this guide, we shall use \lstinline!\SetupClass! 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. -Let me add that it is possible to create subclasses of existing classes. You just write \lstinline!parent=\⟨Class⟩! in the class declaration to tell that \lstinline!\⟨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. +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. -\chapter{Example: Elementary algebra} +\section{Example: Elementary algebra}\label{sec:algebra} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -714,7 +821,7 @@ for doing algebra. 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: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -726,12 +833,12 @@ As an algebraist, one of the first things you might want to do is to create poly \end{lstlisting} Now we may write \begin{LTXexample} - $\vk[poly]{\vx,\vy,\vz}$ +$\vk[poly]{\vx,\vy,\vz}$ \end{LTXexample} It is straightforward how to do adjust this to instead write the \emph{field} generated by the variables~\( x, y, z \): \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -746,7 +853,7 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {field}{ par, leftpar=(,rightpar=), @@ -759,7 +866,7 @@ key would produce the same result with the current configuration of the class~\l Adding support for free algebras, power series, and Laurent series is almost as easy, but there is a catch: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -785,7 +892,8 @@ Adding support for free algebras, power series, and Laurent series is almost as leftpar=(, rightpar=), prearg={\!\!\SemantexDelimiterSize(}, postarg={\SemantexDelimiterSize)\!\!}, - % These are printed before and after the argument. + % The "prearg" and "postarg" are printed before after + % the argument, if the argument is non-empty. % The command "\SemantexDelimiterSize" is substituted % by \big, \Big, ..., or whatever size the % argument delimiters have @@ -794,7 +902,7 @@ Adding support for free algebras, power series, and Laurent series is almost as } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {freealg}{ par, leftpar=\langle, @@ -828,51 +936,52 @@ $\vk[laurent]{\vz}$ Let us look at some other algebraic operations that we can control via \semantex: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {op}{upper={\mathrm{op}}}, % opposite groups, rings, categories, etc. - {algclosure}{overline}, + {algclosure}{command=\overline}, % algebraic closure - {conj}{overline}, + {conj}{command=\overline}, % complex conjugation {dual}{upper=*}, % dual vector space {perp}{upper=\perp}, % orthogonal complement }, - valuekeys={ - {mod}{symbolputright={/#1}}, + definekeys[1]={ + {mod}{rightreturn,symbolputright={/#1}}, % for modulo notation like R/I - {dom}{symbolputleft={#1\backslash}}, + {dom}{leftreturn,symbolputleft={#1\backslash}}, % for left modulo notation like I\R % "dom" is "mod" spelled backwards {oplus}{upper={\oplus#1}}, % for notation like R^{\oplus n} {tens}{upper={\otimes#1}}, % for notation like R^{\otimes n} - {localize}{symbolputright={ \relax [#1^{-1}] }}, + {localize}{symbolputright={ \lbrack #1^{-1} \rbrack }}, % localization at a multiplicative subset; - % the \relax is necessary becauese, in some cases, - % the [...] can be interpreted as an optional argument - {localizeprime}{lower={#1}}, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. + {localizeprime}{slower={#1}}, % for localization at a prime ideal }, } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {op}{upper={\mathrm{op}}}, % opposite groups, rings, categories, etc. - {algclosure}{overline}, + {algclosure}{command=\overline}, % algebraic closure - {conj}{overline}, + {conj}{command=\overline}, % complex conjugation {dual}{upper=*}, % dual vector space {perp}{upper=\perp}, % orthogonal complement }, - valuekeys={ + definekeys[1]={ {mod}{symbolputright={/#1}}, % for modulo notation like R/I {dom}{symbolputleft={#1\backslash}}, @@ -882,9 +991,9 @@ Let us look at some other algebraic operations that we can control via \semantex % for notatoin like R^{\oplus n} {tens}{upper={\otimes#1}}, % for notation like R^{\otimes n} - {localize}{symbolputright={ [#1^{-1}] }}, + {localize}{symbolputright={ \lbrack #1^{-1} \rbrack }}, % localization at a multiplicative subset - {localizeprime}{lower={#1}}, + {localizeprime}{slower={#1}}, % for localization at a prime ideal }, } @@ -901,7 +1010,35 @@ $\vk[freealg]{\vS}[op]$, $\vV[perp]$ \end{LTXexample} -\chapter{The \texttt{spar} key} +\section{GIT quotients} + +\SetupClass\MyVar{ + definekeys[2]={ + {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, + } +} + +We include a slightly more advanced example +to show the use of keys with more than one value. +Sometimes, a key with one value is simply not enough. For instance, if you +work in geometric invariant theory~(GIT), you will eventually have to take the proj +quotient~\( \vX[projquotient={\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!definekeys[2]!: +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys[2]={ + {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, + } +} +\end{lstlisting} + +\begin{LTXexample} +$ \vX[projquotient={\vchi}{\vG}] $ +\end{LTXexample} + + +\chapter{Some more techniques} + +\section{The \texttt{spar} key}\label{sec:spar} 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 \begin{LTXexample} @@ -939,16 +1076,19 @@ Occassionally, it is useful to be able to input a particular kind of brackets ju without adjusting any settings. For this purpose, we have the \lstinline!otherspar! and~\lstinline!Otherspar!~keys. They use the syntax \begin{lstlisting} -otherspar={⟨opening bracket⟩}{⟨closing bracket⟩} -Otherspar={⟨opening bracket⟩}{⟨closing bracket⟩}{⟨size⟩} +otherspar={@\<opening bracket\>@}{@\<closing bracket\>@} +Otherspar={@\<opening bracket\>@}{@\<closing bracket\>@}{@\values\<normal|auto|*|{\textit{other}}\>@} \end{lstlisting} +The last argument in \lstinline!Otherspar! sets the size of the +parentheses. Let us see them in action: \begin{LTXexample} -$\vf[otherspar={[}{)},otherspar={\{}{\rangle}, +$\vf[otherspar={[}{)}, + otherspar={\{}{\rangle}, Otherspar={\langle}{\rangle}{\Bigg},spar]$ \end{LTXexample} -\chapter{The \texorpdfstring{\texttt{$\backslash$⟨Class⟩}}{Class} command} +\section{The \texorpdfstring{\texttt{$\backslash$\<Class\>}}{Class} command}\label{ch:the_class_command} So far, we have learned that every mathematical entity should be treated as an object of some class. However, then we run into issues the moment we @@ -960,27 +1100,74 @@ We do not want to have to define a new variable with symbol~\( \vf\circ\vg \) just to write something like this. Fortunately, once you have created the class~\lstinline!\MyVar!, you can actually use~\lstinline!\MyVar! as a command to create a quick instance of the class. -More precisely \lstinline!\MyVar{⟨symbol⟩}!~creates a variable on the spot with symbol~\lstinline!⟨symbol⟩!. +More precisely \mylst!\MyVar{$\<symbol\>$}!~creates a variable on the spot with symbol~\mylst!$\<symbol\>$!. So the above equation can be written \begin{LTXexample} -$\MyVar{\vf\circ\vg}[ - spar,der=\vn]{\vx}$ +$\MyVar{\vf\circ\vg}[spar, + der=\vn]{\vx}$ \end{LTXexample} -More generally, when you crate the class~\lstinline!\⟨Class⟩!, +More generally, when you crate the class~\usercommand\<Class\>, you can use it as a command with the following syntax: \begin{lstlisting} -\⟨Class⟩{⟨symbol⟩}[⟨options⟩]⟨usual syntax of class⟩ +@\usercommand\<Class\>@{@\<symbol\>@}[@\<options\>@]@\<usual syntax of class\>@ \end{lstlisting} -\chapter{The \texttt{return} keys}\label{ch:return} +\section{The \texttt{command} key} + +\begingroup +Above, we used the key~\lstinline!command! a couple of times: +\begin{LTXexample} +$\va[command=\overline]$, +$\vH[command=\widetilde]$ +\end{LTXexample} +This key applies the given command to the symbol. +Sometimes, it is useful to put these commands into +keys instead. So you can do stuff like +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {tilde}{command=\tilde}, + {widetilde}{command=\widetilde}, + {bar}{command=\bar}, + {bold}{command=\mathbf}, + {roman}{command=\mathrm}, + }, +} +\end{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {tilde}{command=\tilde}, + {widetilde}{command=\widetilde}, + {bar}{command=\bar}, + {bold}{command=\mathbf}, + {roman}{command=\mathrm}, + }, +} +Let us test: +\begin{LTXexample} +$\va[widetilde]$, +$\va[bold]$, +$\va[roman]$, +$\va[bar]$ +\end{LTXexample} +Note that there is a predefined key,~\lstinline!smash!, +which is equivalent to~\lstinline!command=\smash!. + +\endgroup + +\section{The \texttt{return} keys}\label{ch:return} + +Let us suppose in this section that we have +defined the key~\lstinline!conj! for complex conjugation, +like in the introduction. Suppose you want to take the complex conjugate of the variable~\( \vz[1] \). Then you might write something like \begin{LTXexample} $\vz[1,conj]$ \end{LTXexample} 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] \). This reveals a design choice that has been made in \semantex: -When you add an index or a command via the \lstinline{command} key, +When you add an index or a command via the \lstinline!command! key, it is not immediately applied to the symbol. Rather, both commands and indices are added to a register and are then applied at the very last, right before the symbol is printed. This allows us to respect standard mathematical typography, as shown above. @@ -996,54 +1183,129 @@ $\vf[inv,return,conj]$ \end{LTXexample} In fact, \lstinline!return! is an umbrella key that invokes three different return routines: \lstinline!leftreturn!, \lstinline!innerreturn!, and \lstinline!rightreturn!. The command \lstinline!leftreturn! adds the left indices to the symbol (we have not discussed left indices yet, though). The command \lstinline!innerreturn! adds all commands to the symbol (those defined using the \lstinline!command!~key). Finally, \lstinline!rightreturn! adds all right indices and arguments to the symbol. -In general, the user should probably be satisfied with just using \lstinline!return!. +In general, most of the time, the user should probably be satisfied with just using \lstinline!return!. +\section{Keyval syntax conflicts} -\chapter{The \texttt{command} key} +You can pass anything you want as key values, including other objects. +But you quickly run into the following problem: +Imagine you try setting~\lstinline!\vx[1,power=2]! as the lower +index of a the object~\lstinline!\va!. If you try +\begin{lstlisting} +$ \va[lower=\vx[1,power=2]] $ +\end{lstlisting} +then the system will break. Indeed, the system will see the object~\lstinline!\va! +to which you have passed the two keys +\begin{center} + \lstinline!lower=\vx[1! + \qquad\text{and}\qquad + \lstinline!power=2]!. +\end{center} +To avoid this behaviour, you will have to enclose the key +value in braces: +\begin{LTXexample} +$ \va[lower={\vx[1,power=2]}] $ +\end{LTXexample} -Above, we used the key \lstinline!overline! a couple of times: +So far so good, but if you use our favourite shorthand notation +for lower indices (simply writing the index in the options, like~\lstinline!\va[1]!), +then it still goes wrong: +\begin{lstlisting} +$ \va[{\vx[1,power=2]}] $ +\end{lstlisting} +The reason is that in \LaTeX\ (really, the \pack{xparse} package from \LaTeX3) +interprets \lstinline![{...}]! more or less like~\lstinline![...]! +in this case. +To make up for this, you can use either of the following strategies: \begin{LTXexample} -$\va[overline]$, -$\vH[overline]$ +$ \va[ {\vx[1,power=2]} ] $, +$ \va[\vx[{1,power=2}]] $ \end{LTXexample} -This command applies the command \lstinline!\overline! -to the symbol. In fact, you can create similar commands yourself via -the \lstinline!command! key. -In fact, you could have defined the \lstinline!overline! yourself as follows: +There is a similar problem in the arguments, +since arguments also allow a kind of keyval syntax +(the keys that need equality signs are turned off by default, though; +more on that in \cref{ch:arg_keyval}). +But it will still react on commas and keys like~\lstinline!...!. +Therefore, in order to ensure the correct output, you will also have to enclose any argument containing commas with braces: +\begin{LTXexample} +$ \vf{ \vg[{upper=3,lower=2}] } $, +$ \vf{ {\vg[upper=3,lower=2]} } $ +\end{LTXexample} +As mentioned in \cref{ch:arg_keyval}, you \emph{can} +also turn keyval syntax in arguments completely off, +avoiding such issues. This can be done by setting \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ - {overline}{command=\overline}, - }, + argkeyval=false, } \end{lstlisting} -\SetupClass\MyVar{ - singlekeys={ - {overline}{command=\overline}, - }, -} -This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!\SemantexBaseObject! instead. -Here are some more examples of predefined keys that use the command key: + +\subsection{Cheating your way around keyval syntax conflicts} + +\begingroup +If you grow tired of having to deal with such issues all the time, there +are solutions to either partly or completely avoid this. +The first solution we present does not solve +the problem with~\lstinline!\va[\vx[1,power=2}]!, but +it does solve problems like \begin{lstlisting} -\SetupClass\MyVar{ % do not add these -- they are already predefined! - novalueskeys={ - {smash}{command=\smash}, - {tilde}{command=\tilde}, - {widetilde}{command=\widetilde}, - {bar}{command=\bar}, - {bold}{command=\mathbf}, - {roman}{command=\mathrm}, - }, +$ \va[lower=\vx[lower=3]] $ +\end{lstlisting} +Normally, this will not work, as the underlying keyval machinery +of \LaTeX3 does not allow key values to contain equality signs. +However, there is another keyval package that does: +the excellent package \pack{expkv}. +To switch to the keyval parser of this package, we do + +\begin{lstlisting} +\usepackage{expkv} +\SemantexSetup{ + keyvalparser=\ekvparse, } \end{lstlisting} -Let us test: +\SemantexSetup{ + keyvalparser=\ekvparse, +} +Now you can do \begin{LTXexample} -$\va[widetilde]$, -$\va[bold]$, -$\va[roman]$, -$\va[bar]$ +$ \va[lower=\vx[lower=3]] $ \end{LTXexample} +In general, +using the key +\mylst!keyvalparser={$\<command\>$}! +sets the keyval parser function to be the command~\<command\>. +The \<command\> must take three arguments: +\mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!. +The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two. +For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values, +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. +Changing this key will only affect keys for objects and classes, +\emph{not} keys for use inside~\lstinline!\SemantexSetup!. + +\endgroup + +A more drastic solution is to use the package~\pack{stricttex}, +which has been developed mainly as a companion package to~\semantex. +Unfortunately, it only works in~\hologo{LuaTeX}. +If you don't know what \hologo{LuaTeX} is, that means that you are not +using \hologo{LuaTeX}, and you should note that switching is a rather drastic affair +since your existing font settings might very well not work +with LuaTeX. Also, \semantex does not exactly make your document faster, +and \hologo{LuaTeX} makes it even slower, so think carefully before you make the switch just for this. + +In any case, with \pack{stricttex}, you will be able to make brackets \enquote{strict}, which means that any \lstinline![! will be replaced +by a~\lstinline![{!, and that any~\lstinline!]! will be replaced +by a~\lstinline!}]!. This will make all of the above work just fine: +\begin{lstlisting} +\StrictBracketsOn +$ \va[lower=\vx[lower=3]] $ +$ \va[\vx[1,power=2]] $ +$ \vf{ \vg[upper=3,lower=2] } $ +\StrictBracketsOff +\end{lstlisting} +There is no demonstration on the right since this manual +has not been typeset using \hologo{LuaTeX}, so it would not work. \chapter{Example: Algebraic geometry} @@ -1051,7 +1313,7 @@ Let us discuss how to typeset sheaves and operations on morphisms in algebraic g First of all, adding commands for sheaves is not a big deal: \begin{lstlisting} \NewObject\MyVar\sheafF{\mathcal{F}} -\NewObject\MyVar\sheafG}{\mathcal{G}} +\NewObject\MyVar\sheafG{\mathcal{G}} \NewObject\MyVar\sheafH{\mathcal{H}} \NewObject\MyVar\sheafreg{\mathcal{O}} % sheaf of regular functions @@ -1063,7 +1325,7 @@ Next, for morphisms of schemes~\( \vf \colon \vX \to \vY \), 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: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, @@ -1080,7 +1342,7 @@ we need to be able to typeset comorphisms as well as the one hundred thousand di } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, @@ -1105,7 +1367,7 @@ comorphism~$ \vf[comorphism] and for a sheaf~$ \sheafF $ on~$ \vY $, we can define the pullback~$ \vf[sheafpull]{ \sheafF} $ by letting~$ -\vf[sheafpull]{ \sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$ +\vf[sheafpull]{\sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$ \vf[sheaf!pull]{\sheafF}{\vU} = \cdots $. \end{LTXexample} 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. @@ -1116,33 +1378,30 @@ There are a number of other operations we might want to do for sheaves. We alrea However, we might need to stalk, sheafify, take dual sheaves, and twist sheaves. Let us define keys for this: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma {sheaftwist}{return,symbolputright={(#1)}}, }, - singlekeys={ + definekeys={ {sheafify}{upper=+}, {sheafdual}{upper=\vee}, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma {sheaftwist}{return,symbolputright={(#1)}}, }, - singlekeys={ + definekeys={ {sheafify}{upper=+}, {sheafdual}{upper=\vee}, }, } -The key \lstinline!clower! stands for \enquote{comma lower}. -It is like \lstinline!lower!, except that it checks whether the index -is already non-empty, and if so, it separates the new index from the previous index by a comma. There is, of course, a \lstinline!cupper!~key that does the same with the upper index. \begin{LTXexample} $\sheafF[res=\vU,stalk=\vp]$, $\sheafF[res=\vU,spar,stalk= @@ -1150,7 +1409,7 @@ $\sheafF[res=\vU,spar,stalk= $\sheafreg[\vX,stalk=\vp]$, $\sheafG[sheafify]$, $\vf[inverseimage]{\sheafreg[ -\vY]}[spar,stalk=\vx]$ +\vY]}[spar,stalk=\vx]$, $\sheafG[sheafdual]$, $\sheafreg[\vX][sheaftwist=-1]$, $\sheafreg[sheaftwist=1,sheafdual]$ @@ -1174,25 +1433,27 @@ $\Hom[\vA]{\vM,\vN}$, $\Ext[\vA]{\vM,\vN}$ \end{LTXexample} \SetupClass\MyVar{ -valuekeys={ - {shift}{ return,symbolputright={ \relax [ {#1} ] } }, - % \relax is necessary since otherwise [...] can - % occasionally be interpreted as an optional argument +definekeys[1]={ + {shift}{ rightreturn,symbolputright={ \relax [ {#1} ] } }, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. }, } 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] \): \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {shift}{ return,symbolputright={ \relax [ {#1} ] } }, - % \relax is necessary since otherwise [...] can - % occasionally be interpreted as an optional argument + definekeys[1]={ + {shift}{ rightreturn,symbolputright={ \lbrack #1 \rbrack } }, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. }, } \end{lstlisting} Let us see that it works: \begin{LTXexample} -$\vX\mapsto\vX[shift=\vn]$ +$\vX \mapsto \vX[shift=\vn]$ \end{LTXexample} Finally, let us define a command for the differential (in the homolgoical algebra sense): \begin{lstlisting} @@ -1203,38 +1464,37 @@ Finally, let us define a command for the differential (in the homolgoical algebr $\dif{\vx} = 0$ \end{LTXexample} -\section{The keys \texttt{i = index} and \texttt{d = deg = degree}} +\section{The \texttt{d}-index and the \texttt{i}-index} -Homological algebra is a place where people -have very different opinions about the positions of the gradings. +In branches of mathematics such as homological algebra, +people have very different opinions about the positions of the gradings. 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 -supports both, but the default is upper gradings (the package author has the privilege to decide). +supports both, but the default is upper gradings. You can adjust this by writing \lstinline!gradingposition=upper! or~\lstinline!gradingposition=lower!. -We already learned about the keys \lstinline!upper! and~\lstinline!lower!. -There are two more, \enquote{relative} 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 +We already learned about the keys \lstinline!upper! and~\lstinline!lower!, +as well as their friends \lstinline!supper!, \lstinline!slower!, \lstinline!cupper!, \lstinline!clower!, etc. +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 \begin{center} - \lstinline!index! + \lstinline!d! \qquad\qquad and\qquad\qquad - \lstinline!degree! + \lstinline!i! \end{center} -The \lstinline!degree! is the actual grading in the homological algebra -sense. The \lstinline!index! is an additional index where you can put extra information that you might need. +and consequently, we shall refer to the indices +they correspond to as the \enquote{\lstinline!d!-index} and the \enquote{\lstinline!i!-index}. +The \lstinline!d! stands for \enquote{degree} and corresponds to +the grading. The~\lstinline!i! stands for \enquote{index} +and corresponds to the \enquote{other} index where you may store +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.} + To understand the difference, keep the following two examples -in mind: the hom complex~\( \Hom[*,index=\vA] \) and the simplicial homology~\( \ho[*,index=\vDelta] \) (we will define the command~\lstinline!\ho! for homology in the next section): +in mind: the hom complex~\( \Hom[*,i=\vA] \) and the simplicial homology~\( \ho[*,i=\vDelta] \) (we will define the command~\lstinline!\ho! for homology in the next section): \begin{LTXexample} -$\Hom[index=\vA,degree=0]$, -$\ho[index=\vDelta,degree=1]$ +$\Hom[i=\vA,d=0]$, +$\ho[i=\vDelta,d=1]$ \end{LTXexample} -These names are not perfect; many people would say 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. These names probably become a bit too heavy to write in the long run, so both keys have abbreviated equivalents: -\begin{center} - \lstinline!i! = \lstinline!index! - \qquad\qquad and\qquad\qquad - \lstinline!d! = \lstinline!deg! = \lstinline!degree! -\end{center} Let us see them in action: \begingroup\begin{LTXexample} $ \vX[d=3,i=\vk] $ @@ -1245,7 +1505,7 @@ $ \vX[d=3,i=\vk] $ $ \vX[d=3,i=\vk] $ \end{LTXexample}\endgroup -\noindent (We haven't seen the command \lstinline!\SetupObject! before, but I imagine you can guess what it does). +\noindent If you want to print a bullet as the degree, there is the predefined key~\lstinline!*! for this: \begingroup\begin{LTXexample} $ \vX[*] $ @@ -1257,7 +1517,7 @@ $ \vX[*] $ $ \vX[*] $ \end{LTXexample}\endgroup -I guess it is also time to reveal that the previously mentioned shorthand notation~\lstinline!\vx[1]! for indices always prints the~\lstinline!1! on the \lstinline{index} position. So changing the grading position changes the position of the index: +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: \begingroup\begin{LTXexample} $ \vX[1] $ @@ -1267,7 +1527,7 @@ $ \vX[1] $ $ \vX[1] $ \end{LTXexample}\endgroup -In other words, in the first example above, we could have written +\noindent In other words, in the first example above, we could have written \begin{LTXexample} $\Hom[\vA,d=0]$, $\ho[\vDelta,d=1]$ @@ -1281,9 +1541,9 @@ $\vf[i]$, $\vf[i=]$, $\vf[d]$, $\vf[d=]$ \end{LTXexample} As we see, it is only when a \lstinline!d! or~\lstinline!i! key is followed by an equality sign~\lstinline!=! -that the routines of these keys are invoked. -In fact, \semantex carefully separates -\lstinline!valuekeys! from \lstinline!singlekeys!. +that the actions of these keys are invoked. +In fact, \semantex carefully separates keys taking +a value from keys taking no values. \section{The \texorpdfstring{\texttt{Cohomology}}{Cohomology} class type} @@ -1308,12 +1568,14 @@ Let us try to use it: \NewObject\MyHomology\ho{H} \end{lstlisting} -The cohomology command~\lstinline!\co! in general works very much +The cohomology command~\lstinline!\co! we just created works very much like a command of \lstinline!Variable! type. However, the input syntax is a bit different: \begin{lstlisting} -\co[⟨options⟩]{⟨degree⟩}{⟨argument⟩} +\co[@\<options\>@]{@\<degree\>@}{@\<argument\>@} \end{lstlisting} -All three arguments are optional. Let us see it in practice: +All three arguments are optional. The~\<degree\> is printed +in the \lstinline!d!-index. +Let us see it in practice: \begin{LTXexample} $\co{0}$, $\co{*}$, $\co{\vi}{\vX}$, @@ -1335,15 +1597,15 @@ You might also want to implement feature like reduced cohomology, \v{C}ech cohom and hypercohomology. This is quite easy with the \lstinline!command! key: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {reduced}{command=\widetilde}, {cech}{command=\check}, - {hyper{command=\mathbb}, + {hyper}{command=\mathbb}, }, } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {reduced}{command=\widetilde}, {cech}{command=\check}, {hyper}{command=\mathbb}, @@ -1375,7 +1637,7 @@ on the level of the function itself (\( \vf \)~in this case). This can be done the following way: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}^{#1}, @@ -1385,7 +1647,7 @@ This can be done the following way: symbolputleft=\mathbb{R}^{#1}, }, }, - singlekeys={ + definekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}, @@ -1398,7 +1660,7 @@ This can be done the following way: } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}^{#1}, @@ -1408,7 +1670,7 @@ This can be done the following way: symbolputleft=\mathbb{R}^{#1}, }, }, - singlekeys={ + definekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}, @@ -1438,19 +1700,17 @@ except it allows you to inherit the settings from an \emph{object} rather than a $\RHom{\vX,\vY}$ \end{LTXexample} -\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)} +\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)}\label{ch:arg_keyval} \SetupClass\MyVar{ - argvaluekeys={ + defineargkeys[1]={ {coef}{ othersep={;}{#1} }, }, } \SetupObject\co{ - valuekeys={ - {arg}{argwithkeyval={#1}}, - }, -}% + argkeyval=true, +} Imagine we want to do cohomology with coefficients in some ring~\( \vR \). It is common to write this as~\( \co{*}{\vX,coef=\vR} \) @@ -1459,17 +1719,19 @@ with a semicolon instead of a comma. This can be implemented, too, with the synt $\co{*}{\vX,coef=\vR}$ \end{LTXexample} This shows that arguments of functions also support keyval syntax. -In order to customize this, there are two extra keys: -\begin{center} -\lstinline!argsinglekeys! -\qquad\qquad\text{and}\qquad\qquad -\lstinline!argvaluekeys! -\end{center} -These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!. +To define argument keys, +we use the key~\lstinline!defineargkeys!, +or~\mylst!defineargkeys[$n$]! if you want it to be +able to take $n$~values for~$n=0,1,2,\ldots,9$. The syntax for these is +just like the syntax for the keys~\lstinline!definekeys! +and~\mbox{\mylst!definekeys[$n$]!}. +However, for reasons we shall see in a moment, argument +keys (at least those taking values) are actually turned off +by default, so we shall have to turn them on first: \begin{lstlisting} \SetupClass\MyVar{ argkeyval=true, % this turns keyval syntax in arguments on - argvaluekeys={ + defineargkeys[1]={ {coef}{ othersep={;}{#1} }, }, } @@ -1477,10 +1739,12 @@ These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!. The key \lstinline!othersep! is a key that controls the separator 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}!, there are two arguments, \lstinline!\vX! and~\lstinline!\vR!, and the separator is a semicolon. +We shall later (see~\cref{ch:parse_coho_coef}) +see another, possibly more natural way to write cohomology with coefficients, and which avoids turning on keyval syntax in the argument. -As you see above, we had to turn keyval syntax on in order for it to work. -By default, only singlekeys are turned on in the argument, not valuekeys. -The reason is that valuekeys in arguments are only useful in very rare cases, like cohomology with coefficients. If such keys were turned on in general, it would mess up +As mentioned, we had to turn keyval syntax on in order for it to work. +By default, only keys taking no values are turned on in the argument. +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 every occurrence of an equality sign in arguments, and the following would not work: \begin{LTXexample} @@ -1490,97 +1754,142 @@ $\Hom[\sheafreg[\vU]]{ }$ \end{LTXexample} -The key~\lstinline!argkeyval! can take four arguments: \lstinline!true! (as above), -\lstinline!false! (no singlekeys or valuekeys allowed), \lstinline!singlekeys! (the default behaviour where only singlekeys are turned on), and \lstinline!onesinglekey! (only allows one singlekey). +The key~\lstinline!argkeyval! can take four arguments: \lstinline!true! (which we used above, keyval syntax is completely on), +\lstinline!false! (no keys allowed), \lstinline!singlekeys! (the default behaviour where only keys taking no values are allowed), and \lstinline!onesinglekey! (only allows one key, taking no value). It should be noted that there are several predefined -singlekeys which are defined on the level -of the class \lstinline!\SemantexBaseObject!. The full list is:\fxfatal{Finish this} +argument keys on the level +of the class \lstinline!\SemantexBaseObject!. +The full list can be found in \cref{sec:predefined_arg_keys}. -\begin{itemize} - \item slot, \ldots -\end{itemize} +\chapter{Left indices} -We should also talk about the \lstinline!arg! key. +Left indices are a recurring problem in all \TeX-based systems +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 +use variations of the following approach: +\begin{LTXexample} +$ {}^{*} f $ +\end{LTXexample} +Notice the large space between the star and the~\( f \). +To tackle this problem, the author has written +the \pack{leftindex} package which at least attempts to improve +this situation: +\begin{LTXexample} +$ \leftindex^{*} {f} $ +\end{LTXexample} +Roughly, what it does is to use a \enquote{height phantom} +and a \enquote{slanting phantom} to position the left superscript. +The vertical positions of the left indices will be calculated using +the height phantom, and the indentation of the left superscript will be calculated +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: +\begin{LTXexample} +$ \leftindex^{*} {\Gamma} $, +$ \leftindex[I]^* {\Gamma} $, +$ \leftindex^* {A} $, +$ \leftindex[P]^* {A} $ +\end{LTXexample} +We refer to the manual of the package \pack{leftindex} for details, +see~\url{https://ctan.org/pkg/leftindex}. -\chapter{Multi-value keys} +Our solution for left indices in \semantex is based directly on the one +from \pack{leftindex}. However, it works much better if you use \semantex +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. -\SetupClass\MyVar{ - 2valuekeys={ - {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, - } -} +Just like we have keys like \lstinline!upper!, \lstinline!lower!, \lstinline!supper!, \lstinline!slower!, \lstinline!cupper!, \lstinline!clower!, +etc., we have a similar collection of keys for the left +indices: +\lstinline!upperleft!, \lstinline!lowerleft!, \lstinline!supperleft!, \lstinline!slowerleft!, \lstinline!cupperleft!, \lstinline!clowerleft!: +\begin{LTXexample} +$ \vf[upperleft=*] $, +$ \vGamma[upperleft=*] $, +$ \vA[upperleft=*] $ +\end{LTXexample} +When you create a new object in \semantex, the height and slanting phantoms +will automatically be set to be equal to the symbol. However, as we see +above, we sometimes need to change them. +This can be done using the keys \lstinline!heightphantom! +and~\lstinline!slantingphantom!: +\begin{LTXexample} +\SetupObject\vGamma{ + slantingphantom=I} +\SetupObject\vA{slantingphantom=P} +$ \vf[upperleft=*] $, +$ \vGamma[upperleft=*] $, +$ \vA[upperleft=*] $ +\end{LTXexample} -Sometimes, a key with one value is simply not enough. For instance, if you -work in~GIT, you will eventually have to take the proj -quotient~\( \vX[projquotient={\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 have the key~\lstinline!2valuekeys!. It works exactly like \lstinline!valuekeys!, except you get to use two arguments instead of one: -\begin{lstlisting} -\SetupClass\MyVar{ - 2valuekeys={ - {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, - } +Sometimes, changing the slanting phantom is not quite enough. +In the previous example, the star is still not quite close enough +to the~\( \vA \), and there is no slanting phantom that is quite slanted enough to correct this. We solve this using +the key~\lstinline!postupperleft!. What you add using this key +will be printed after the upper left index, provided the upper left index +is non-empty and hence will be printed in the first place. +There is also a \lstinline!preupperleft!, and there are similarly \lstinline!prelowerleft!, \lstinline!postlowerleft!, \lstinline!preupper!, \lstinline!postupper!, \lstinline!prelower!, and~\lstinline!postlower!. +Let us see it in action: +\begin{LTXexample} +\SetupObject\vA{ + slantingphantom=P, + postupperleft=\!, } -\end{lstlisting} - +$ \vA[upperleft=*] $ +\end{LTXexample} +Note that \semantex at least does its best to try to guess +new height and slanting phantoms when you use operations on objects: \begin{LTXexample} -$\vX[projquotient={\vchi}{\vG}] $ +$ \vA[spar=\Bigg,upperleft=*] $, +$ \vP[command=\overline,return, + upperleft=*] $ \end{LTXexample} -There are also commands \lstinline!3valuekeys!, \lstinline!4valuekeys!, \ldots, \lstinline!9valuekeys!. The syntax for these is completely analoguous. -There are also commands \lstinline!arg2valuekeys!, \lstinline!arg3valuekeys!, \ldots, \lstinline!arg9valuekeys! for keys in arguments with multiple values. +\chapter{The \texorpdfstring{\texttt{Symbol}}{Symbol} class type (Example: Derived tensor products and fibre products)} -\chapter{The \texttt{Simple} class type (Example: Derived tensor products and fibre products)} - -\NewSimpleClass\MyBinaryOperator[ - singlekeys={ +\NewSymbolClass\MyBinaryOperator[ + definekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, - mathbin, % this makes sure that the output is wrapped in \mathbin ] \NewObject\MyBinaryOperator\tensor{\otimes}[ - singlekeys={ + definekeys={ {der}{Lder}, }, ] \NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - singlekeys={ + definekeys={ {der}{Rder}, }, ] -The \semantex system has facilities for printing tensor products~\( \tensor \) as well as derived tensor products~\( \tensor[der] \). -For this, we need the \lstinline!Simple! class type. +\semantex has facilities for printing tensor products~\( \tensor \) as well as derived tensor products~\( \tensor[der] \). +For this, we need the \lstinline!Symbol! class type. This has exactly the same syntax as the \lstinline!Variable! class type, except that it cannot take an argument. In other words, its syntax is \begin{lstlisting} -\⟨object⟩[⟨options⟩] +@\usercommand\<object\>@[@\<options\>@] \end{lstlisting} -(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 imagine.) +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. Let us try to use it to define tensor products and fibre products: \begin{lstlisting} -\NewSimpleClass\MyBinaryOperator[ - singlekeys={ +\NewSymbolClass\MyBinaryOperator[ + definekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, - mathbin, - % this makes sure that the output is wrapped in \mathbin ] \NewObject\MyBinaryOperator\tensor{\otimes}[ - singlekeys={ + definekeys={ {der}{Lder}, }, ] \NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - singlekeys={ + definekeys={ {der}{Rder}, }, ] @@ -1596,83 +1905,6 @@ $\vk \tensor[\vA,der] \vk$, $\vX \fibre[\vY,der] \vX$ \end{LTXexample} -\chapter{Class types} - -The \semantex system uses several different \emph{class types}. -We have been almost exclusively using the \lstinline!Variable! class type (which is by far the most important one), but in the last chpaters, we were introduced to the \lstinline!Cohomology! and the \lstinline!Simple! class types. - -In fact, all class types are identical internally; the low-level machinery of \semantex does not \enquote{know} what type a class has. -The only difference between the class types is the \emph{input syntax}. -In other words, it determines which arguments an object of that class -can take. The syntax for creating new objects -also varies. - -The current implementation has the following -class types: - -\begin{itemize} - \item \lstinline!Variable!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewVariableClass{\⟨Class⟩}[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Cohomology!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewCohomologyClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨degree⟩}{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Simple!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewSimpleClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Delimiter!: - A new class is declared with the syntax - \begin{lstlisting} - \NewDelimiterClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} -\end{itemize} - -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~\lstinline!\New⟨Class type⟩Class! and modify it in whatever way you want. - -There is another class type, called the \lstinline!plain! class type, which 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 don't use it. - \chapter{The \texorpdfstring{\texttt{Delimiter}}{Delimiter} class type} \NewDelimiterClass\MyDelim[parent=\MyVar] @@ -1686,7 +1918,7 @@ that are defined using brackets only. Let us define a class of type \lstinline!D \end{lstlisting} Now we can create instances of the class~\lstinline!\MyDelim! with the following syntax: \begin{lstlisting} -\NewObject\MyDelim\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩ +\NewObject\MyDelim@\usercommand\<object\>@{@\<left bracket\>@}{@\<right bracket\>@}[@\<options\>@] \end{lstlisting} Now we can do the following: \begin{lstlisting} @@ -1712,11 +1944,9 @@ The following is inspired from the \pack{mathtools} package where a similar cons \NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, - % adds \, inside {...}, as recommended by D. Knuth - valuekeys={ - {arg}{argwithoutkeyval={#1}}, + % adds \, inside {...}, as recommended by D. Knuth + argkeyval=false, % this turns off all keyval syntax in the argument - } ] \end{lstlisting} \newcommand\where{ @@ -1729,25 +1959,28 @@ The following is inspired from the \pack{mathtools} package where a similar cons \NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, - % adds \, inside {...}, as recommended by D. Knuth - valuekeys={ - {arg}{argwithoutkeyval={#1}}, + % adds \, inside {...}, as recommended by D. Knuth + argkeyval=false, % this turns off all keyval syntax in the argument - } ] +As we briefly mentioned previously, +\lstinline!\SemantexDelimiterSize!~is a command +that returns the size of the delimiters in the +argument. Now you can use \begin{LTXexample} -$\Set{ \vx \in \vY \where -\vx \ge 0 }$ +$\Set{ \vx\in\vY \where \vx\ge0 }$, +$\Set[par=\big]{ \vx\in\vY \where \vx\ge0 }$ \end{LTXexample} -Don't forget that anything created with \semantex -outputs as a variable-type object. So you can do stuff like +Don't forget that, since the class~\lstinline!\MyDelim! inherits from~\lstinline!\MyVar!, +the output of any of these commands has class~\lstinline!\MyVar!. +So you can do stuff like \begin{LTXexample} $\Set{ \vx \in \vY[\vi] \where \vx \ge 0 -}[conj,\vi\in\vI]$ +}[command=\overline,\vi\in\vI]$ \end{LTXexample} @@ -1772,14 +2005,15 @@ $\tup{\va,\vb,...,\vz}$, $\pcoor{\va,\vb,...,\vz}$ \end{LTXexample} -One can also use tuples for other, less obvious purposes, like calculus differentials: +One can also use delimiters for other, less obvious purposes, like calculus differentials: \begin{lstlisting} \NewDelimiterClass\CalculusDifferential[ parent=\MyVar, - argvaluekeys={ + defineargkeys[1]={ {default}{s={d\!#1}}, % default is the key that is automatically applied by the - % system to anything you write in the argument. The s key + % system to anything you write in the argument that is + % not recognized as an argument key. The s key % is a key that prints the value of the key with the % standard argument separator in front. }, @@ -1790,14 +2024,25 @@ One can also use tuples for other, less obvious purposes, like calculus differen % -- neverpar does not even print parentheses in this case ] -\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},iffirstarg=false] +\NewObject\CalculusDifferential\intD{(}{)}[ + setargsep={\,}, + nextargwithsep=true, + % because of this, even the first argument will + % receive a separator, which in this case + % is a small space +] \NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] \end{lstlisting} \NewDelimiterClass\CalculusDifferential[ parent=\MyVar, - argvaluekeys={ + defineargkeys[1]={ {default}{s={d\!#1}}, + % default is the key that is automatically applied by the + % system to anything you write in the argument that is + % not recognized as an argument key. The s key + % is a key that prints the value of the key with the + % standard argument separator in front. }, setargdots=\cdots, neverpar, @@ -1806,7 +2051,7 @@ One can also use tuples for other, less obvious purposes, like calculus differen % -- neverpar does not even print parentheses in this case ] -\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},ifnextargwithsep=false] +\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},nextargwithsep=true] \NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] @@ -1818,35 +2063,218 @@ $\int \vf \wedgeD{\vx[1], \vx[2],...,\vx[n]}$ \end{LTXexample} -\chapter{The \texttt{parse} routine} +\chapter{Using \texorpdfstring{Seman\!\TeX}{SemanTeX} in other commands using \texorpdfstring{\texttt{\textbackslash UseClassInCommand}}{\UseClassInCommand}}\label{sec:UseClassInCommand} -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 data set in any order and have them printed in a fixed order. For this purpose, we have the \lstinline!parse! routine. +\SemantexRecordObject{\Frac} +\newcommand\Frac[2]{ + \SemantexRecordSource{\Frac{#1}{#2}} + \UseClassInCommand\MyVar{ \frac{#1}{#2} } +} +Sometimes, it is useful to create other commands based on \semantex +classes. For instance, if you grow tired of +writing~\lstinline!\MyVar{ \frac{...}{...} }! whenever you +want to apply keys to a fraction, it could make sense to create +a command~\lstinline!\Frac! which automatically wraps +the fraction in~\lstinline!\MyVar!. The first guess how to +do that would be something like +\begin{lstlisting} +\newcommand\Frac[2]{ \MyVar{ \frac{#1}{#2} } } +\end{lstlisting} +\begin{LTXexample} +\[ + \Frac{1}{2}[spar=\Big,power=2] +\] +\end{LTXexample} +Indeed, this will work fine for most people. +In fact, the only case where this might cause issues +is if you want to use the \pack{stripsemantex} algorithm to strip +your document of \semantex markup. But in order to prepare yourself for this possibility, I recommend getting used from the start to doing it +in a slightly more cumbersome way: +\begin{lstlisting} +\SemantexRecordObject{\Frac} +\newcommand\Frac[2]{ + \SemantexRecordSource{\Frac{#1}{#2}} + \UseClassInCommand\MyVar{ \frac{#1}{#2} } +} +\end{lstlisting} +\begin{LTXexample} +\[ + \Frac{1}{2}[spar=\Big,power=2] +\] +\end{LTXexample} +First things first: We used the following command in front +of~\lstinline!\MyVar!: +\begin{lstlisting} +\UseClassInCommand@\usercommand\<Class\>@[@\<options\>@]{@\<symbol\>@}@\<usual syntax of the class\>@ +\end{lstlisting} +So the first advantage to writing~\lstinline!\UseClassInCommand\MyVar! +instead of just~\lstinline!\MyVar! +is that you can pass an additional set of options +to the class first. However, there is a more important +difference, namely that this solution makes the command +compatible with the \pack{stripsemantex} algorithm. + +The reason the first solution was not compatible +with \pack{stripsemantex} is that, in this case, the algorithm +will desperately look through your document for +the code~\lstinline!\MyVar{ \frac{1}{2} }[spar=\Big,power=2]! +in order to strip it from your document. +But it will find it nowhere, as this code is hidden away +in the \lstinline!\Frac!~command. +Therefore, we do three things: +\begin{itemize} + \item We register the command~\lstinline!\Frac! + as a \semantex command using the + line + \begin{lstlisting} +\SemantexRecordObject{\Frac} + \end{lstlisting} + After this, \semantex \enquote{knows} + that \lstinline!\Frac!~is part of the + family of \semantex markup. + \item We use the command~\lstinline!\SemantexRecordSource! + to \enquote{record} the source of the command internally. + This way, \pack{stripsemantex} will know what to look for + when it moves through the document, trying to strip + it of \semantex markup. + It is therefore important that you record + the source exactly like it will be written in + the source. + (You need not worry about missing braces, though; + even if you write~\lstinline!\Frac12! in your document, + \pack{stripsemantex} will still recognize the code + and strip it as expected.) + \item We write~\lstinline!\UseClassInCommand\MyVar! + instead of just~\lstinline!\MyVar! + in order to correctly record the output code internally. Roughly speaking, when you use the command~\lstinline!\UseClassInCommand!, + \semantex \enquote{knows} that the class~\lstinline!\MyVar! + is now used as part of some greater construction. +\end{itemize} + +\section{Example: Category theory} + +\newcommand\categoryformat[1]{\textsf{#1}} + % This means that we write categories with sans-serif fonts; + % -- but you can change this to your own liking + % We use \textsf rather than \mathsf in order + % to allow syntax like $R$-mod + +\NewVariableClass{\Category}[parent=\MyVar,command=\categoryformat] + +\NewObject\Category\catset{Set} +\NewObject\Category\cattop{Top} +\NewObject\Category\catvect{Vect} + +\SemantexRecordObject{\catxmod} +\newcommand\catxmod[1]{ + \SemantexRecordSource{\catxmod{#1}} + \UseClassInCommand\Category{$#1$-mod} +} + +\SemantexRecordObject{\catmodx} +\newcommand\catmodx[1]{ + \SemantexRecordSource{\catmodx{#1}} + \UseClassInCommand\Category{mod-$#1$} +} + +\SemantexRecordObject{\catxmody} +\newcommand\catxmody[2]{ + \SemantexRecordSource{\catxmody{#1}{#2}} + \UseClassInCommand\Category{$#1$-mod-$#2$} +} + +\SemantexRecordObject{\catxmodx} +\newcommand\catxmodx[1]{ + \SemantexRecordSource{\catxmodx{#1}} + \UseClassInCommand\Category{$#1$-mod-$#1$} +} + +The above method can be used to create commands +for typing categories. First and foremost, +it is easy to create a class for categories +and write simple categories like~\( \catset \), \( \cattop \)~and \( \catvect \): +\begin{lstlisting} +\newcommand\categoryformat[1]{\textsf{#1}} + % This means that we write categories with sans-serif fonts; + % -- but you can change this to your own liking. + % We use \textsf rather than \mathsf in order + % to allow syntax like $R$-mod + +\NewVariableClass{\Category}[parent=\MyVar,command=\categoryformat] + +\NewObject\Category\catset{Set} +\NewObject\Category\cattop{Top} +\NewObject\Category\catvect{Vect} +\end{lstlisting} +\begin{LTXexample} +$ \catset $, +$ \cattop $, +$ \catvect{\vk} $. +\end{LTXexample} +However, we run into issues with categories like~\( \catxmod{\vR} \) +where we shall constantly have to change the ring~\( \vR \). +For this, we use the constructions we learned at the introduction +to this chapter: +\begin{lstlisting} +\SemantexRecordObject{\catxmod} +\newcommand\catxmod[1]{ + \SemantexRecordSource{\catxmod{#1}} + \UseClassInCommand\Category{$#1$-mod} +} +\end{lstlisting} +\begin{LTXexample} +$ \catxmod{\vR} $, +$ \catxmod{\vS} $, +$ \catxmod{\vA}[spar,op] $ +\end{LTXexample} +(here, we used the key~\lstinline!op! +which we defined in \cref{sec:algebra}). +You can, of course, extend it to all sorts +of other situations, like +\( \catmodx{\vR} \) or~\( \catxmody{\vR}{\vS} \): +\begin{lstlisting} +\SemantexRecordObject{\catmodx} +\newcommand\catmodx[1]{ + \SemantexRecordSource{\catmodx{#1}} + \UseClassInCommand\Category{mod-$#1$} +} + +\SemantexRecordObject{\catxmody} +\newcommand\catxmody[2]{ + \SemantexRecordSource{\catxmody{#1}{#2}} + \UseClassInCommand\Category{$#1$-mod-$#2$} +} + +\SemantexRecordObject{\catxmodx} +\newcommand\catxmodx[1]{ + \SemantexRecordSource{\catxmodx{#1}} + \UseClassInCommand\Category{$#1$-mod-$#1$} +} +\end{lstlisting} + +\chapter{The \texorpdfstring{\texttt{parse}}{parse} routine} -Suppose we want to be able to write the set of \( \vn \times \vm \)-matrices with entries in~\( \vk \) as~\( \MyVar{\operatorname{Mat}}[\vn\times\vm]{\vk} \). We can in principle do the following: -\begingroup\begin{LTXexample} -\NewObject\MyVar\Mat{ - \operatorname{Mat}} -$ \Mat[\vn\times\vm]{\vk} $. -\end{LTXexample}\endgroup% \NewObject\MyVar\Mat{\operatorname{Mat}}[ % We provide data sets "rows" and "columns" to % be set up by the user later dataprovide={rows}, dataprovide={columns}, - valuekeys={ + dataprovide={field}, + definekeys[1]={ {rows}{ dataset={rows}{#1} }, % set the rows data set {columns}{ dataset={columns}{#1} }, % set the columns data set + {field}{ dataset={field}{#1} }, % set the underlying field + {arg}{ field={#1} }, + % this way, setting the argument becomes equivalent + % to specifying the underlying field }, parseoptions={ % Here we add code to the parse routine % We check whether columns = rows. If so, we only write % the number once - ifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} + strifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} { - % We use a very weird key called "setkeysx" -- this - % fully executes the content of the keys before - % setting them setkeysx={ lower={\SemantexDataGetExpNot{columns}}, }, @@ -1860,35 +2288,190 @@ $ \Mat[\vn\times\vm]{\vk} $. }, }, }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] + + +\NewObject\MyVar\GL{\operatorname{GL}}[ + % We provide a few data sets: + dataprovide=order, % The "order" will be the number n in GL_n(k) + dataprovide=field, % The "field" is of course the k in GL_n(k) + definekeys[1]={ + {order}{ dataset={order}{#1} }, % Sets the order + {field}{ dataset={field}{#1} }, % Sets the field + {arg}{ field={#1} }, + % This way, setting the argument becomes equivalent + % to setting the field }, -]% -\noindent However, this is not quite as systematic and semantic as we might have wanted. Indeed, what if later you would like to change the notation to~\( \MyVar{\operatorname{Mat}}[\vn,\vm]{\vk} \)? (In this case, you could use multi-value keys, though.) -In this chapter, we show how to eanble a syntax like the following instead: + parseoptions={ + setkeysx={ + % This means set the keys, but fully expand their values first + lower={\SemantexDataGetExpNot{order}}, + }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + % Set the argument keys, but fully expand their values first + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] + +\SetupObject\co{ + dataprovide=coefficient, + dataprovide=space, + definekeys[1]={ + {coef}{ dataset={coefficient}{#1} }, + {space}{ dataset={space}{#1} }, + {arg}{ space={#1} }, + }, + parseoptions={ + ifblankF={\SemantexDataGetExpNot{space}} + { + setargkeysx={ + s=\SemantexDataGetExpNot{space}, + }, + }, + ifblankF={\SemantexDataGetExpNot{coefficient}} + { + setargkeysx={ + othersep={;}{ \SemantexDataGetExpNot{coefficient} }, + }, + }, + }, +} + +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, +and have the system take care of printing them in the right places, +according to how you program the object in the preamble. +For this purpose, we have the \lstinline!parse!~routine. +Using the \lstinline!parse! routine allows for a comfortable, +HTML-like syntax, e.g.: \begin{LTXexample} -$ \Mat[rows=\vn,columns=\vm]{\vk} $, $ \Mat[rows=\vn,columns=\vn]{\vk} $ +$ \GL[order=\vn,field=\vk] $, +$ \Mat[rows=\vm,columns=\vn, + field=\vk] $, +$ \co[d=0,coef=\vR,space=\vX] $ \end{LTXexample} +The \lstinline!parse! routine is a collection of code which is +executed right before +an object (or class) is being rendered (but before it outputs). +By default, the parse routine contains no code. +However, you can add code to it using the +key~\mylst!parseoptions={$\<keys\>$}!. + +\section{Example: Matrix sets and groups} + +Suppose we want to be able to write the group of invertible \( \vn \times \vn \)-matrices with entries in~\( \vk \) +as~\( + \GL[order=\vn,field=\vk] +\). +We can in principle do the following: +\begingroup +\SetupObject\GL{ + dataclear=parseoptions, + definekeys[1]={ + {arg}{ setargkeys={s=#1} } + }, +} +\begin{lstlisting} +\NewObject\MyVar\GL{\operatorname{GL}} +\end{lstlisting} +\begin{LTXexample} +$ \GL[\vn]{\vk} $. +\end{LTXexample}% +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 +to~\( + \GL{\vn,\vk} +\)? +We could in principle use a key with 2~values for this. +However, in this section, +we show how to use the \lstinline!parse!~routine +to enable the syntax from the introduction to this chapter. + +\endgroup + +As mentioned there, we need to add code via the \lstinline!parse!~routine. +However, to make proper use of it, we need some programming keys +and programming commands. +You can find an overview of these in~\cref{sec:programming_keys,sec:programming_commands}. + +To set up the notation from above, we do the following: +\begin{lstlisting} +\NewObject\MyVar\GL{\operatorname{GL}}[ + % We provide a few data sets: + dataprovide=order, % The "order" will be the number n in GL_n(k) + dataprovide=field, % The "field" is of course the k in GL_n(k) + definekeys[1]={ + {order}{ dataset={order}{#1} }, % Sets the order + {field}{ dataset={field}{#1} }, % Sets the field + {arg}{ field={#1} }, + % This way, setting the argument becomes equivalent + % to setting the field + }, + parseoptions={ + setkeysx={ + % This means set the keys, but fully expand their values first + lower={\SemantexDataGetExpNot{order}}, + }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + % Set the argument keys, but fully expand their values first + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] +\end{lstlisting} + +Notice that we changed the \lstinline!arg!~key. +This means that specifying the argument becomes equivalent to setting the field. +This is what makes the first two pieces of syntax below equivalent: + +\begin{LTXexample} +$ \GL[order=\vn,field=\vk] $, +$ \GL[order=\vn]{\vk} $, +$ \GL[order=\vn] $. +\end{LTXexample} + +Let us look at a more complicated example: +The set~\( \Mat[rows=\vn,columns=\vm,field=\vk] \) +of \( \vn \times \vm \)-matrices with entries in~\( \vk \). +What makes this example more complicated is not only that we have +an additional piece of data, but that we require +that if the number of rows and columns are equal, +we want it to print~\( \Mat[rows=\vn,columns=\vn,field=\vk] \) +rather than~\( \Mat[rows=\vn,columns={}\vn,field=\vk] \). +We accomplish this by the following: -The important ingredient here is the \lstinline!parse! routine. This routine is executed right before the function is being rendered, and you can add code to it via the -key~\lstinline!parseoptions!. However, we need a bit more programming keys to make it work. Let us see it in action and explain the syntax below: \begin{lstlisting} \NewObject\MyVar\Mat{\operatorname{Mat}}[ % We provide data sets "rows" and "columns" to % be set up by the user later dataprovide={rows}, dataprovide={columns}, - valuekeys={ + dataprovide={field}, + definekeys[1]={ {rows}{ dataset={rows}{#1} }, % set the rows data set {columns}{ dataset={columns}{#1} }, % set the columns data set + {field}{ dataset={field}{#1} }, % set the underlying field + {arg}{ field={#1} }, + % this way, setting the argument becomes equivalent + % to specifying the underlying field }, parseoptions={ % Here we add code to the parse routine % We check whether columns = rows. If so, we only write % the number once - ifeqTF={\SemantexDataGetExpNot{columns}} - {\SemantexDataGetExpNot{rows}} + strifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} { - % We use a very weird key called "setkeysx" -- this - % fully executes the content of the keys before - % setting them setkeysx={ lower={\SemantexDataGetExpNot{columns}}, }, @@ -1902,102 +2485,62 @@ key~\lstinline!parseoptions!. However, we need a bit more programming keys to ma }, }, }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + s={\SemantexDataGetExpNot{field}}, + }, + }, }, ] \end{lstlisting} -Here we used a lot of programmking keys. Let us see the full list of them. -(An important notice: For some of these keys, such as \lstinline!boolifTF!, you currently cannot use spaces in the \lstinline!⟨bool⟩! argument, so e.g. \lstinline!boolifTF{ mybool } { ... } { ... }! will not work; you have to write \lstinline!boolifTF{mybool}!. I am trying to solve this problem, but have not yet been able to do so.) - -\begin{lstlisting} -dataprovide={⟨data⟩}, % provides data -dataset={⟨data⟩}{⟨value⟩}, % sets data -datasetx={⟨data⟩}{⟨value⟩}, % sets data after expanding it -dataputright={⟨data⟩}{⟨value⟩}, % adds to the right of data -dataputrightx={⟨data⟩}{⟨value⟩}, % adds to the right of data after expanding it -dataputleft={⟨data⟩}{⟨value⟩}, % adds to the left of data -dataputleftx={⟨data⟩}{⟨value⟩}, % adds to the left of data after expanding it -dataclear={⟨data⟩,} % clears a piece of data -setkeys={⟨keys⟩}, % sets the keys in question, which is rather useless since you could have just written those keys directly instead -keysset={⟨keys⟩}, % equivalent to setkeys -setkeysx={⟨keys⟩}, % executes the keys in question after expanding them -keysset={⟨keys⟩}, % equivalent to setkeysx -ifeqTF={⟨str1⟩}{⟨str2⟩}{⟨if true⟩}{⟨if false⟩}, % checks if strings are equal -ifeqT={⟨str1⟩}{⟨str2⟩}{⟨if true⟩}, -ifeqF={⟨str1⟩}{⟨str2⟩}{⟨if false⟩}, -ifblankTF={⟨str⟩}{⟨if true⟩}{⟨if false⟩}, % checks if string is blank -ifblankT={⟨str⟩}{⟨if true⟩}, -ifblankF={⟨str⟩}{⟨if false⟩}, -boolprovide={⟨bool⟩}, % provides a boolean -boolsettrue={⟨bool⟩}, % sets the boolean to true -boolsetfalse={⟨bool⟩}, % sets the boolean to false -boolifTF={⟨bool⟩}{⟨if true⟩}{⟨if false⟩}, % checks if boolean is true -boolifT={⟨bool⟩}{⟨if true⟩}, -boolifF={⟨bool⟩}{⟨if false⟩, -intprovide={⟨int⟩}, % provides an integer -intclear={⟨int⟩}, % sets the integer to 0 -intincr={⟨int⟩}, % adds 1 to the integer -intset={⟨int⟩}{⟨value⟩}, % sts the integer -intifgreaterthanTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks which number of greater -intifgreaterthanT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intifgreaterthanF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -intifequalTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks if the numbers are equal -intifequalT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intifequalF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -intiflessthanTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks which number of less -intiflessthanT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intiflessthanF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -ERRORkeyvaluenotfound={⟨key⟩}{⟨value⟩}, % throws an error saying that the key has been set to an unkonwn value -ERROR={⟨error text⟩}, % throws a general error with the provided error test -execute={⟨error text⟩}, % executes the code in question -\end{lstlisting} - -When using these keys (including inside the key~\lstinline!execute!), you can use a number of commands that provide and manipulate data. Most of them are just command versions of the keys above, and for now, I leave it to the reader to guess what they do based on the above picture: - -\begin{lstlisting} -\SemantexDataProvide -\SemantexDataSet -\SemantexDataSetx -\SemantexDataPutRight -\SemantexDataPutRightx -\SemantexDataPutLeft -\SemantexDataPutLeftx -\SemantexDataGet -\SemantexDataGetExpNot -\SemantexDataClear -\SemantexKeysSet -\SemantexKeysSetx -\SemantexStrIfEqTF -\SemantexStrIfEqT -\SemantexStrIfEqF -\SemantexIfBlankTF -\SemantexIfBlankT -\SemantexIfBlankF -\SemantexBoolProvide -\SemantexBoolSetTrue -\SemantexBoolSetFalse -\SemantexBoolIfTF -\SemantexBoolIfT -\SemantexBoolIfF -\SemantexIntProvide -\SemantexIntGet -\SemantexIntClear -\SemantexIntIncr -\SemantexIntSet -\SemantexIntIfGreaterThanTF -\SemantexIntIfGreaterThanT -\SemantexIntIfGreaterThanF -\SemantexIntIfEqualTF -\SemantexIntIfEqualT -\SemantexIntIfEqualF -\SemantexIntIfLessThanTF -\SemantexIntIfLessThanT -\SemantexIntIfLessThanF -\SemantexExpNot##1 -\SemantexERRORKeyValueNotFound -\SemantexERROR +\begin{LTXexample} +$ \Mat[rows=\vm,columns=\vn, + field=\vk] $, +$ \Mat[rows=\vn,columns=\vn, + field=\vk] $. +\end{LTXexample} + +\section{Example: Cohomology with coefficients, revisited}\label{ch:parse_coho_coef} + +As promised previously, we revisit cohomology with coefficients +and show how to set up a syntax like the below: + +\begin{lstlisting} +\SetupObject\co{ + dataprovide=coefficient, + dataprovide=space, + definekeys[1]={ + {coef}{ dataset={coefficient}{#1} }, + {space}{ dataset={space}{#1} }, + {arg}{ space={#1} }, + }, + parseoptions={ + ifblankF={\SemantexDataGetExpNot{space}} + { + setargkeysx={ + s=\SemantexDataGetExpNot{space}, + }, + }, + ifblankF={\SemantexDataGetExpNot{coefficient}} + { + setargkeysx={ + othersep={;}{ \SemantexDataGetExpNot{coefficient} }, + }, + }, + }, +} \end{lstlisting} +\begin{LTXexample} +$\co[d=0]$, +$\co[d=0,space=\vX]$, +$\co[d=0,space=\vX,coef=\vR]$ +\end{LTXexample} + +\section{Example: Partial derivatives} + Let us look at a more complicated example: Let us create a command for partial derivatives: \NewObject\MyVar\partialdif[ @@ -2006,17 +2549,17 @@ Let us look at a more complicated example: Let us create a command for partial d boolsettrue={raisefunction}, setidots=\cdots, setisep=\,, - valuekeys={ + definekeys[1]={ {default}{ si={\partial #1}, }, {raise}{ - ifeqTF={#1}{true} + strifeqTF={#1}{true} { boolsettrue={raisefunction}, } { - ifeqTF={#1}{false} + strifeqTF={#1}{false} { boolsetfalse={raisefunction}, } @@ -2027,22 +2570,22 @@ Let us look at a more complicated example: Let us create a command for partial d }, }, parseoptions={ - ifblankTF={ \SemantexDataGet{upper} } + ifblankTF={ \SemantexDataGetExpNot{upper} } { - intifgreaterthanTF={ \SemantexIntGet{numberoflowerindices} } { 1 } + intifgreaterTF={ \SemantexIntGet{numberoflowerindices} } { 1 } { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial ^ { \SemantexIntGet{numberoflowerindices} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2050,16 +2593,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, } @@ -2068,16 +2611,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { - \partial ^ { \SemantexDataGet{upper} } + \partial ^ { \SemantexDataGetExpNot{upper} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2087,7 +2630,7 @@ Let us look at a more complicated example: Let us create a command for partial d boolifT={raisefunction} { dataclear={arg}, - dataclear={numberofarguments}, + intclear={numberofarguments}, }, }, ] @@ -2099,17 +2642,17 @@ Let us look at a more complicated example: Let us create a command for partial d boolsettrue={raisefunction}, setidots=\cdots, setisep=\,, - valuekeys={ + definekeys[1]={ {default}{ si={\partial #1}, }, {raise}{ - ifeqTF={#1}{true} + strifeqTF={#1}{true} { boolsettrue={raisefunction}, } { - ifeqTF={#1}{false} + strifeqTF={#1}{false} { boolsetfalse={raisefunction}, } @@ -2120,22 +2663,22 @@ Let us look at a more complicated example: Let us create a command for partial d }, }, parseoptions={ - ifblankTF={ \SemantexDataGet{upper} } + ifblankTF={ \SemantexDataGetExpNot{upper} } { - intifgreaterthanTF={ \SemantexIntGet{numberoflowerindices} } { 1 } + intifgreaterTF={ \SemantexIntGet{numberoflowerindices} } { 1 } { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial ^ { \SemantexIntGet{numberoflowerindices} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2143,16 +2686,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, } @@ -2161,16 +2704,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { - \partial ^ { \SemantexDataGet{upper} } + \partial ^ { \SemantexDataGetExpNot{upper} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2180,7 +2723,7 @@ Let us look at a more complicated example: Let us create a command for partial d boolifT={raisefunction} { dataclear={arg}, - dataclear={numberofarguments}, + intclear={numberofarguments}, }, }, ] @@ -2218,14 +2761,3108 @@ As you see, we use the \lstinline!d!~key to tell the command what superscript it \] \end{LTXexample} -\chapter{Bugs} +\chapter{\texorpdfstring{\texttt{stripsemantex}}{stripsemantex} -- stripping your document of \texorpdfstring{\semantex}{SemanTeX} markup} + +\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} +is using \TeX~Live~2016 at the time of writing this, and it has +an old version of \LaTeX3 that seems unable to run \semantex. +To address this issue, \semantex has a companion package, +called \pack{stripsemantex}, which allows you to strip the +\semantex markup from your document and replace it with raw \LaTeX~code. +While no such algorithm will ever be perfect, it generally works +very well, even for quite complicated constructions, +as long as you use the package in the \enquote{normal} +and supported way. +(If you want proof, have a look at my +recent paper which was stripped using +the algorithm: \url{https://arxiv.org/abs/2008.04794}.) + +The system has the following limitations: + +\begin{itemize} + \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}, + you should include your entire document body in your + main \texttt{.tex}~file. + \item As mentioned, as long as you do normal, supported things, + everything should work fine. Non-normal, non-supported + things are tings like + \begin{lstlisting} +\va[execute={\vb}] + \end{lstlisting} + \item Occasionally, you will have to run the stripping algorithm + multiple times. This happens e.g.~if you have + a key that does stuff like \lstinline!symbolputleft=\vH[d=0]!, + i.e.~keys that are defined using other objects. When you run + \pack{stripsemantex}, such objects will remain in the text until you run it again. + \item Partly because of the previous point, no attempt is made to remove + the \emph{setup} of \semantex, + so commands like \lstinline!\NewObject!, \lstinline!\SetupObject!, and~\lstinline!\SetupClass! + will remain in the document body. + You will then have to remove these yourself afterwards. + But the \semantex markup itself should be stripped completely from your document + (possibly after more than one run of the algorithm). + \item Things might go wrong if you define new keys + between \lstinline!\begin{document}! and~\lstinline!\end{document}! + whose definitions make use of \semantex objects or classes, + since the algorithm will try to strip these from the definitions. + For instance, don't do stuff like this + after~\lstinline!\begin{document}!: + \begin{lstlisting} +\SetupObject\va{ + definekeys[1]={ + {weirdkey}{ upper=\vb[ {#1} ] } + }, +} + \end{lstlisting} + If you do, the algorithm will then try and strip this + occurrence of~\lstinline!\vb! from the key definition. + To avoid such issues, only ever define keys in your preamble, + as the algorithm will ignore everything + before \lstinline!\begin{document}!. + \item When the document has just been stripped, + it will load a small package called \pack{semtex}, + which contains a couple of commands that the output will need + in order to run. You should be able to replace most (often all) of these commands + by other commands and then render the package \pack{semtex} + unnecessary. More on this in \cref{sec:semtex_package}. +\end{itemize} + +As a small proof of concept, this is what the example in the introduction +would look like when stripped of \semantex markup: + +\begin{lstlisting} +% Same preamble as before. + +\begin{document} + +$ \overline{f}^{(n)} $ + +$ g^{-1}|_{U} (x) $ + +$ (h^{-1} \mathcal{F})_{p} + = \mathcal{F}_{h(p)} $ + +\end{document} +\end{lstlisting} + +Yes, I know, this was a very simple, unconvincing example. +If you want a less trivial example, as mentioned before, +you can have a look at my latest paper, which was stripped with +(a previous alpha version of) \pack{stripsemantex}: + +\begin{center} + \url{https://arxiv.org/abs/2008.04794} +\end{center} + +\section{The \texttt{semtex} package}\label{sec:semtex_package} + +When you have stripped your document and removed all \semantex package setup, it should be safe to remove +the loading of \semantex from your preamble. +However, the stripping algorithm will automatically +add the following right before~\lstinline!\begin{document}!: +\begin{lstlisting} +% The following was added by "stripsemantex" + +\usepackage{semtex,leftindex,graphicx} + +\providecommand\SemantexLeft{% + \mathopen{}\mathclose\bgroup\left +} + +\providecommand\SemantexRight{% + \aftergroup\egroup\right +} + +\providecommand\SemantexBullet{% + \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}% +} +\providecommand\SemantexDoubleBullet{% + \SemantexBullet\SemantexBullet +} +\end{lstlisting} +The package \pack{leftindex} is loaded to take care of any +possible left indices. The package~\pack{graphicx} +is loaded to provide the command~\lstinline!\scalebox!. +This package~\pack{semtex} is a small package whose sole purpose +is to be loaded by stripped \semantex documents. +It contains a couple of simple commands that the document +needs immediately after the stripping. +Depending on your document, +you should be able to completely replace these commands +by commands from other packages, or define them yourself, rendering the package~\pack{semtex} +unnecessary. +And actually, four of those commands are the commands +\lstinline!\SemantexLeft!, \lstinline!\SemantexRight!, +\lstinline!\SemantexBullet!, and~\lstinline!\SemantexDoubleBullet! +which are provided right below, making it even faster to just remove~\pack{semtex}. + +In total, the package~\pack{semtex} adds the following commands: + +\begin{itemize} + \item + \mylst!\SemantexBullet!, + \mylst!\SemantexDoubleBullet! + + The commands that contain the bullets we use in \semantex, + i.e.~the superscript in~\( \co{*} \). + These bullets are smaller (and prettier, in my opinion) + than the standard \lstinline!\bullet! command from~\LaTeX. + + \item + \mylst!\SemantexLeft!, + \mylst!\SemantexRight! + + Like \lstinline!\left...\right!, but fixing some spacing issues + around these. + They are completely equivalent to~\lstinline!\mleft! and~\lstinline!\mright! + from the package~\pack{mleftright}, so it is safe to just load that package + and replace the above commands by \lstinline!\mleft...\mright! instead, + or use the redefinitions mentioned above. + + \item + \mylst!\SemantexParentheses{$\values\<normal|auto|*|{\textit{other}}\>$}{$\<left parenthesis\>$}!\\ + \mbox{\qquad}\mylst!{$\<right parenthesis\>$}{$\<content\>$}!, + + This one writes \<content\> enclosed in the pair of parentheses + and with the size given by the first argument. + Here,~\lstinline!normal! means normal size + parentheses, + and + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using the commands~\lstinline!\SemantexLeft...\SemantexRight!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The important property of this command is that + inside the~\<content\>, you can access the delimiter size + at any point using the command~\lstinline!\SemantexDelimiterSize!. In other words, when + no~\lstinline!\SemantexDelimiterSize! is found inside the~\<content\>, + the command is completely redundant. We shall see + in a moment how to make sure it does not appear in your output + unless absolutely necessary. + + \item + \mylst!\SemantexNoParentheses{$\<content\>$}! + + This command prints the content with no parentheses, but importantly, it also resets + the command \lstinline!\SemantexDelimiterSize! + to~\lstinline!{}!, i.e.~blank. + As with the command~\lstinline!\SemantexParentheses!, + we shall see in a moment how to make this + command not appear in your output + unless absolutely necessary. +\end{itemize} + +As you see, most of these commands can be removed completely +or replaced by commands from other packages. The one +issue is with the annoying +commands \lstinline!\SemantexParentheses! +and~\lstinline!\SemantexNoParentheses!. +These exist solely for the purpose of allowing the use of +the command~\lstinline!\SemantexDelimiterSize! in the content. +However, there are very few cases, such as set constructions, where +\lstinline!\SemantexDelimiterSize! is even necessary. Therefore, +\textbf{it is possible to turns the use of these commands off}. +More precisely, there is a key that can be +activated for any object or class: +\begin{center} + \mylst!allowSemantexDelimiterSize=$\values\<\default{true}|false\>$! +\end{center} +When this is set to false, \semantex will not use the +commands~\lstinline!\SemantexParentheses! +and~\lstinline!\SemantexNoParentheses! internally, +and consequently, \lstinline!\SemantexDelimiterSize! will not work in that class or object. +Instead, it will simply print the parentheses as raw code, +and this is what will appear in your stripped document instead. +The natural thing to do is to turn it off by default and +only turn it back on for the few cases where you really need it: + +\begin{lstlisting} +\SetupClass\MyVar{allowSemantexDelimiterSize=false} + +% We turn it back on for the set constructions +% as defined above. +\SetupObject\Set{allowSemantexDelimiterSize=true} +\end{lstlisting} + +\section{The \texttt{stripsemantex} algorithm} + +The stripping algorithm works like this. +It will work in any \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, etc.), but along +the way, you will have to create a small, +separate document and compile it with \hologo{LuaTeX}. +Suppose in the following that you \TeX\ document is called~\texttt{mydoc.tex}. + +\begin{enumerate}[(1)] + \item Make sure to collect all of the \semantex markup you want + stripped in the main document,~\texttt{mydoc.tex}. + Also make sure to follow the recommendations + in \cref{sec:UseClassInCommand}, in case you have created keys + of the form described there. + \item Set~\lstinline!allowSemantexDelimiterSize=false! + for your main class~\lstinline!\MyVar!, and only + turn it back on in the few cases where you need it, + i.e.~when you need to use the command~\lstinline!\SemantexDelimiterSize!. + \item Put the following somewhere in your preamble, after + the loading of \semantex: + \begin{lstlisting} +\SemantexSetup{ + semtexfile=true, +} + \end{lstlisting} + \item Compile your document \texttt{mydoc.tex} using your preferred \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, or whatever). + Because of the previous step, there + will now be a new file, \texttt{mydoc.semtex}, + in your folder, where the raw output + of each \semantex command is stored. In a moment, + \pack{stripsemantex} will use this information to replace + each command by the raw code it outputs. + \item Create another \TeX\ document in the same folder + as \texttt{mydoc.tex}, and call it \texttt{stripdoc.tex} + (or whatever you want). Put the following into it: + \begin{lstlisting} +\documentclass{article} + +\usepackage{stripsemantex} + +\begin{document} + +\StripSemantexCopyFile{mydoc} + +%\StripSemantexStripFile{mydoc} + +\end{document} + \end{lstlisting} + Then compile it \textbf{with \hologo{LuaTeX}}. + \item After the previous step, another document will have been created in the same + folder, called~\lstinline!mydoc_prestripped.tex!. It will look just like \texttt{mydoc.tex}, + but in the document body, each \semantex markup command will now + have a command \mylst!\SemantexIDcommand{$\<a unique ID\>$}! + preceding it. Compile this new document \lstinline!mydoc_prestripped.tex! using the same \TeX\ engine as the one you used + for \texttt{mydoc.tex}. + \item\label{pt:strip_point} Edit~\texttt{stripdoc.tex}, commenting out the line~\lstinline!\StripSemantexCopyFile{mydoc}!, and + uncommentng the next one, so that the file now looks like this: + \begin{lstlisting} +\documentclass{article} + +\usepackage{stripsemantex} + +\begin{document} + +%\StripSemantexCopyFile{mydoc} + +\StripSemantexStripFile{mydoc} + +\end{document} + \end{lstlisting} + Then compile this document again, this time also \textbf{using \hologo{LuaTeX}}. + This will create a document called \lstinline!mydoc_stripped.tex!, which should (hopefully) + be completely stripped of \semantex markup in the document body. + Occasionally, as mentioned above, a few such commands may remain, in which case you will simply + have to repeat the above steps, this time with the document~\texttt{mydoc.tex} + replaced by~\lstinline!mydoc_stripped.tex!. + Note again that your \semantex \textbf{setup} + will not be removed, so there + will still be commands like \lstinline!\NewObject!, + \lstinline!\SetupObject!, \lstinline!\SetupClass!,~etc. + left. You will then have to remove these few commands from your document manually. +\end{enumerate} + +There is also another command in the \pack{stripsemantex} package, +called simply \mylst!\StripSemantex!, which will +run either the command \mylst!\StripSemantexCopyFile! or the command \mylst!\StripSemantexStripFile!, +depending on which of the files \lstinline!mydoc.semtex! +and~\mylst!mydoc_prestripped.semtex! is newer. +This will allow you to not have to edit +the file \texttt{stripdoc.tex} +at point~\ref{pt:strip_point}. +Unfortunately, due to a bug in \LaTeX3, +this command does not work right now (in~\hologo{LuaTeX}). This bug has been reported +and has hopefully already been fixed by the time you read this. + +\chapter{Known bugs} + +If you write e.g.~\lstinline!Otherspar={[}{]}{\Bigg}! +in a heading, your command will fail for some reason. +It can be solved by omitting the braces around~\lstinline!\Bigg!, +i.e.~by replacing it by~\lstinline!Otherspar={[}{]}\Bigg!. + +\chapter{The predefined keys, commands, and data} + +In this chapter, we give a complete list of the predefined keys. +Firstly, +the keys that can be used inside the command~\lstinline!\SemantexSetup! are: + +\begin{itemize} + \item \mylst!keyvalparser={$\<command\>$}! + + Sets the keyval parser function to~\<command\>. + The \<command\> must take three arguments: + \mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!. + The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two. + For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values, + 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!. + Another interesting possibility is the command~\lstinline!\ekvparse! from the package~\lstinline!expkv!. This choice will only affect keys for objects and classes, + \emph{not} keys for use inside~\lstinline!\SemantexSetup!. + + \item \mylst!semtexfile={$\values\<true|\default{false}\>$}! + + When turned on, a \lstinline!.semtex! file will be created while processing the document. + This is mainly relevant when using \lstinline!stripsemantex!. +\end{itemize} + +Apart from this, \semantex has a large collection of keys that are predefined for the class \lstinline!\SemantexBaseObject!. +In the following sections, we include the full list. + +\section{Keys for defining and removing keys} + +\begin{itemize} + \item + \mylst!definekeys={$\<key definitions\>$}! + + Defines keys taking no values. + The syntax is + \begin{lstlisting} + definekeys={ + {key1}{ upper=3, lower=7 }, + {key2}{ lower=6, upper=4 }, + }, + \end{lstlisting} + + \item + \mylst!definekeys[$n$]={$\<key definitions\>$}! + + Defines keys taking $n$~values, where $n=0,1,2,\ldots,9$. + The values are accessed by + writing + \lstinline!#1!,~\lstinline!#2!, \ldots,~\lstinline!#9!. + The syntax is + \begin{lstlisting} + definekeys[2]={ + {key1}{ upper=3+#1, lower=7-#2 }, + {key2}{ lower=6\cdot#1, upper=4/#2 }, + }, + \end{lstlisting} + + \item + \mylst!removekey=$\<key name\>$! + + Removes the key~\<key name\> taking no values. + + \item + \mylst!removekey[$n$]=$\<key name\>$! + + Removes the key~\<key name\> taking $n$~values, where $n=0,1,2,\ldots,9$. + + \item + \mylst!defineargkeys={$\<key definitions\>$}! + + Defines argument keys taking no values. + The syntax is similar to the one for~\lstinline!definekeys!. + + \item + \mylst!defineargkeys[$n$]={$\<key definitions\>$}! + + Defines argument keys taking $n$~values, where $n=0,1,2,\ldots,9$. + The syntax is similar to the one for~\mylst!definekeys[$n$]!. + + \item + \mylst!removeargkey=$\<key name\>$! + + Removes the argument key~\<key name\> taking no values. + + \item + \mylst!removeargkey[$n$]=$\<key name\>$! + + Removes the argument key~\<key name\> taking $n$~values, where $n=0,1,2,\ldots,9$. +\end{itemize} + +\section{Programming keys}\label{sec:programming_keys} + +\begin{itemize} + \item + \mylst!execute={$\<\TeX\ code\>$}! + + Executes the \<\TeX\ code\> on the spot. + + \item + \mylst!setkeys={$\<keys\>$}!, + \mylst!keysset={$\<keys\>$}! + + Sets the keys \<keys\>. + + \item + \mylst!setkeysx={$\<keys\>$}!, + \mylst!keyssetx={$\<keys\>$}! + + Sets the keys \<keys\>, but fully expands their values. + + \item + \mylst!dataprovide={$\<data\>$}! + + Provides a new piece of data consisting of a token list. + + \item + \mylst!dataset={$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>. + + \item + \mylst!datasetx={$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>, but fully expands the \<value\> first. + + \item + \mylst!dataputleft={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>. + + \item + \mylst!dataputleftx={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!dataputright={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>. + + \item + \mylst!dataputrightx={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!dataclear={$\<data\>$}! + + Clears the piece of data~\<data\>. + + \item + \mylst!boolprovide={$\<boolean\>$}! + + Provides a new piece of data consisting of a boolean. + + \item + \mylst!boolsettrue={$\<boolean\>$}! + + Sets the \<boolean\> to true. + + \item + \mylst!boolsettrue={$\<boolean\>$}! + + Sets the \<boolean\> to false. + + \item + \mylst!boolifTF={$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!boolifT={$\<boolean\>$}{$\<if true\>$}!, \\ + \mylst!boolifTF={$\<boolean\>$}{$\<if false\>$}! + + Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>. + + \item + \mylst!intprovide={$\<integer\>$}! + + Provides a new piece of data consisting of an integer. + + \item + \mylst!intset={$\<integer\>$}{$\<value\>$}! + + Sets the \<integer\> to \<value\>. + + \item + \mylst!intincr={$\<integer\>$}! + + Increases the \<integer\> by~\( 1 \). + + \item + \mylst!intifeqTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intifeqT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intifeqF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intifgreaterTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intifgreaterT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intifgreaterF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intiflessTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intiflessT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intiflessF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intclear={$\<integer\>$}! + + Clears the \<integer\>. + + \item + \mylst!ifblankTF={$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!ifblankT={$\<tokens\>$}{$\<if true\>$}!,\\ + \mylst!ifblankF={$\<tokens\>$}{$\<if false\>$}! + + Fully expands the \<tokens\> and checks if it is blank, + and runs \<if true\> or \<if false\> according to this. + + \item + \mylst!strifeqTF={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!strifeqT={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!strifeqF={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}! + + Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!ERROR={$\<error message\>$}! + + Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>} + or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}. + + \item + \mylst!ERRORkeyvaluenotfound={$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>. + + \item + \mylst!ERRORargkeyvaluenotfound={$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>. +\end{itemize} + +\section{Fundamental keys for class/object information} + +\begin{itemize} + \item + \mylst!parent={$\<Class\>$}! + + Sets the class to have parent~\<Class\>. + + \item + \mylst!class={$\<Class\>$}! + + Sets the object to have class~\<Class\>. + + \item + \mylst!copy={$\<object\>$}!, + \mylst!clone={$\<object\>$}! + + Sets the object to be a copy (also known as a clone) + of~\<object\>. + Then \<object\> works as a \enquote{parent object}, and all information + will be inherited from~\<object\> unless modified for the current object. + + \item + \mylst!symbol={$\<value\>$}! + + Sets the symbol to~\<value\>. At the same time, + the height phantom and the slanting phantom are set to the same value. + + \item + \mylst!symbolputleft={$\<value\>$}! + + Adds \<value\> to the left of the symbol. No change is made to the height + phantom or the slanting phantom. + + \item + \mylst!symbolputright={$\<value\>$}! + + Adds \<value\> to the right of the symbol. No change is made to the height + phantom or the slanting phantom. + + \item + \mylst!heightphantom={$\<value\>$}! + + Sets the height phantom to~\<value\>. + + \item + \mylst!slantingphantom={$\<value\>$}! + + Sets the slanting phantom to~\<value\>. + + \item + \mylst!gradingposition={$\values\<\default{upper}|lower\>$}!, \\ + \mylst!gradingpos={$\values\<\default{upper}|lower\>$}! + + Sets whether to use upper (\enquote{cohomological}) + or lower (\enquote{homological}) grading. + The default is~\lstinline!upper!. + + \item + \mylst!command={$\<command\>$}! + + Applies the \<command\> to the symbol. + + \item + \mylst!clearcommand! + + Clears the list of commands to be applied to the symbol. + + \item + \mylst!return! + + Invokes the return routine. + + \item + \mylst!leftreturn! + + Invokes the left return routine. + + \item + \mylst!rightreturn! + + Invokes the right return routine. + + \item + \mylst!innerreturn! + + Invokes the inner return routine. + + \item + \mylst!output={$\<Class\>$}! + + Sets the output class to~\<Class\>. + + \item + \mylst!dooutput={$\values\<true|\default{false}\>$}! + + Sets whether the current object/class should output or not. + The default is false, but the system will automatically + change this when needed. \emph{Never} set this to + \lstinline!true! by default, as this will + cause an infinite loop. + + \item + \mylst!outputoptions={$\<keys\>$}! + + Adds the \<keys\> to the output options, + i.e.\ those options passed to the output class. + + \item + \mylst!parseoptions={$\<keys\>$}! + + Adds the \<keys\> to the parse options. + + \item + \mylst!parse! + + Invokes the parse routine. + + \item + \mylst!texclass={$\<command\>$}! + + Sets the \TeX\ character class to be~\<command\>. + The intended values are \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!. + + \item + \mylst!allowSemantexDelimiterSize={$\values\<\default{true}|false\>$}! + + Sets whether to allow the command \lstinline!\SemantexDelimiterSize! + inside the argument. + The default is~\lstinline!true!. + The only real reason to turn this off is if you are using + \lstinline!stripsemantex! to strip the document of \semantex markup. + For if it is set to false, the system will not + add \lstinline!\SemantexParentheses! and \lstinline!\SemantexNoParentheses! + all over the place to set the value of \lstinline!\SemantexDelimiterSize!, + and this probably looks better in the outputted code. + + \item + \mylst!default={$\<value\>$}! + + This is the key that is applied whenever the + user writes something in the options which is not a key, + e.g.~the~\lstinline!1! in~\lstinline!\vf[1]!. + By default, this keys has been set to be equal to~\lstinline!si!, + but it is meant to be changeable by the user. + + \item + \mylst!degreedefault={$\<value\>$}! + + This is the key where the grading goes. + It is the one used by \lstinline!Cohomology! class types. + By default, this key has been set to be equal to~\lstinline!sd!, + but it is meant to be changable by the user. + + \item + \mylst!*! + + Adds a bullet to the \lstinline!d!-index. + + \item + \mylst!**! + + Adds a double bullet to the \lstinline!d!-index. + + \item + \mylst!-! + + Adds a slot to the \lstinline!i!-index. + + \item + \mylst!...! + + Adds three dots to the \lstinline!i!-index. + + \item + \mylst!*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!d!-index, + separated by the \<separator\> + from any previous \lstinline!d!-indices. + + \item + \mylst!**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!d!-index, + separated by the \<separator\> + from any previous \lstinline!d!-indices. + + \item + \mylst!arg={$\<value\>$}! + + The key that is applied whenever the user adds + an argument via the standard syntax, e.g.~\lstinline!\vf{\vx}!. + By default, it is set to be equal to \lstinline!setargsinglekeys!, + but it is meant to be changable by the user. + + \item + \mylst!smash! + + Applies the command~\lstinline!\smash! to the symbol. + Equivalent to~\lstinline!command=\smash!. + + \item + \mylst!prime!, \mylst!'!, \mylst!''!, \mylst!'''! + + Adds one or more primes to the symbol in the upper index. + Equivalent to \lstinline!upper={\prime}!, \lstinline!upper={\prime\prime}!, + etc. +\end{itemize} + +\section{Keys for the argument parentheses} -The biggest unsolved problem I know of is how to correctly strip spaces in programming keys such as \lstinline!boolifTF!. Similarly, I would also like to allow keys to be defined using the -syntax~\lstinline!{ inv } { upper=-1 }! rather than~\lstinline!{inv}{ upper=-1 }!. This will hopefully be solved soon. +\begin{itemize} + \item + \mylst!par! + + Turns parentheses on. Equivalent to \lstinline!usepar=true!. + + \item + \mylst!nopar! + + Turns parentheses off, but still prints them if more + than one argument is received. + Equivalent to \lstinline!usepar=false!. + + \item + \mylst!neverpar! + + Turns parentheses completely off, even if more than one argument + is received. (This is ugly and should only be used for special constructions.) + Equivalent to \lstinline!usepar=never!. + + \item + \mylst!usepar={$\values\<\default{true}|false|never\>$}! + + Sets whether or not to use parentheses. + If~\lstinline!true!, turns parentheses on (this is the default behaviour). + If~\lstinline!false!, turns parentheses off, but still prints them if more + than one argument is received. + If~\lstinline!never!, turns parentheses completely off, even if more than one argument + is received. (This is ugly and should only be used for special constructions.) + The default value is~\lstinline!true!. + + \item + \mylst!parsize={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}! + + Sets the parentheses size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!leftpar={$\<parenthesis\>$}! + + Sets the left parenthesis. + The default value is~\lstinline!(!. + + \item + \mylst!rightpar={$\<parenthesis\>$}! + + Sets the right parenthesis. + The default value is~\lstinline!)!. +\end{itemize} + +\section{Keys for the \texttt{spar} routine} + +\begin{itemize} + \item + \mylst!spar! + + Invokes the \lstinline!spar! routine. + + \item + \mylst!spar={$\values\<normal|auto|*|\textit{other}\>$}! + + Invokes the \lstinline!spar! routine, with + the specified parenthesis size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!sparsize={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}! + + Sets the \lstinline!spar! parenthesis size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!leftspar={$\<parenthesis\>$}! + + Sets the left parenthesis for the \lstinline!spar! routine. + The default value is~\lstinline!(!. + + \item + \mylst!rightspar={$\<parenthesis\>$}! + + Sets the right parenthesis for the \lstinline!spar! routine. + The default value is~\lstinline!)!. + + \item + \mylst!otherspar={$\<left parenthesis\>$}{$\<right parenthesis\>$}! + + Invokes the \lstinline!spar! routine, but with the assigned parentheses. + + \item + \mylst!Otherspar={$\<left parenthesis\>$}{$\<right parenthesis\>$}{$\values\<normal|auto|*|{\textit{other}}\>$}! + + Invokes the \lstinline!spar! routine, but with the assigned parentheses and size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. +\end{itemize} + +\section{Keys for setting the argument} + +\begin{itemize} + \item + \mylst!setargkeys={$\<keys\>$}!, + \mylst!argkeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>. + + \item + \mylst!setargkeysx={$\<keys\>$}!, + \mylst!argkeyssetx={$\<keys\>$}! + + Sets the argynebt keys \<keys\>, but fully expands their values. + + \item + \mylst!setargsinglekeys={$\<keys\>$}!, + \mylst!argsinglekeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setargsinglekeysx={$\<keys\>$}!, + \mylst!argsinglekeyssetx={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setoneargsinglekey={$\<key\>$}!, + \mylst!oneargsinglekeyset={$\<key\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setoneargsinglekeyx={$\<key\>$}!, + \mylst!oneargsinglekeysetx={$\<key\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setargwithoutkeyval={$\<value\>$}!, + \mylst!argwithoutkeyvalset={$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!setargwithoutkeyvalx={$\<value\>$}!, + \mylst!argwithoutkeyvalsetx={$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!prearg={$\<value\>$}! + + Sets the pre-argument. + + \item + \mylst!postarg={$\<value\>$}! + + Sets the post-argument. + + \item + \mylst!setargsep={$\<value\>$}! + + Sets the argument separator. + The default value is a comma. + + \item + \mylst!setargslot={$\<value\>$}! + + Sets the argument slot. + The default value is~\lstinline!{-}!. + + \item + \mylst!setargdots={$\<value\>$}! + + Sets the argument dots. + The default value is~\lstinline!\dots!. + + \item + \mylst!argkeyval={$\values\<true|false|\default{singlekeys}|onesinglekey\>$}! + + Sets whether to use argument keyval syntax or not. + If \lstinline!true!, \lstinline!arg! is set equal to~\lstinline!setargkeys!. + If \lstinline!false!, it is set to~\lstinline!setargwithoutkeyval!. + If \lstinline!singlekeys!, it is set to~\lstinline!setargsinglekeys!. + If \lstinline!onesinglekey!, it is set to~\lstinline!setoneargsinglekey!. + The default value is~\lstinline!singlekeys!. + + \item + \mylst!argposition={$\values\<left|\default{right}\>$}! + + Sets the position of the argument. + The default is~\lstinline!right!, so the argument + will be printed to the right of the symbol. + + \item + \mylst!nextargwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next argument should be + separated from the current one with a + separator or not. + The default is \lstinline!false!, but the + system will automatically change this when needed. + + \item + \mylst!sarg={$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by the default argument separator. + + \item + \mylst!carg={$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by a comma. + + \item + \mylst!argwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by \<separator\>. + + \item + \mylst!arg...withothersep={$\<separator\>$}!, + \mylst!argdotswithothersep={$\<separator\>$}! + + Adds three dots to the argument, separated from any previous + argument by the \<separator\>. + + \item + \mylst!arg-withothersep={$\<separator\>$}!, + \mylst!argslotwithothersep={$\<separator\>$}! + + Adds a slot to the argument, separated from any previous + argument by the \<separator\>. + + \item + \mylst!argdots!, \mylst!arg...! + + Adds three dots to the argument, + separated from any previous arguments + by the standard separator. + + \item + \mylst!cargdots!, \mylst!carg...! + + Adds three dots to the argument, + separated from any previous arguments + by a comma. + + \item + \mylst!argslot!, \mylst!arg-! + + Adds a slot to the argument, + separated from any previous arguments + by the standard separator. + + \item + \mylst!cargslot!, \mylst!carg-! + + Adds a slot to the argument, + separated from any previous arguments + by a comma. + + \item + \mylst!cleararg! + + Clears the argument. + + \item + \mylst!clearprearg! + + Clears the pre-argument. + + \item + \mylst!clearpostarg! + + Clears the post-argument. +\end{itemize} + + +\section{Keys for the upper index} + +\begin{itemize} + \item + \mylst!upper={$\<value\>$}! + + Adds to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper={$\<value\>$}! + + Adds to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper={$\<value\>$}! + + Adds to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!preupper={$\<value\>$}! + + Sets the pre-upper index. + + \item + \mylst!postupper={$\<value\>$}! + + Sets the post-upper index. + + \item + \mylst!upperputleft={$\<value\>$}! + + Adds something to the left of the upper index. + As with keys like~\lstinline!upper!, this + will also increase the number of registered + upper indices by~\( 1 \), and + it will + set \lstinline!nextupperwithsep=true!. + + \item + \mylst!setuppersep={$\<value\>$}! + + Sets the upper index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextupperwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next upper index should + be separated from the current one by a separator. + + \item + \mylst!upperwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the upper index, separated from + any prevous upper index by~\<separator\>. + + \item + \mylst!upper-!, \mylst!upperslot! + + Adds a slot to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper-!, \mylst!supperslot! + + Adds a slot to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper-!, \mylst!cupperslot! + + Adds a slot to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!setupperslot={$\<value\>$}! + + Sets the slot for the upper index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!upper-withothersep={$\<separator\>$}!, + \mylst!upperslotwithothersep={$\<separator\>$}! + + + Adds a slot to the upper index, separated + from any previous upper index by~\<separator\>. + + \item + \mylst!upper...!, \mylst!upperdots! + + Adds three dots to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper...!, \mylst!supperdots! + + Adds three dots to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper...!, \mylst!cupperdots! + + Adds three dots to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!setupperdots={$\<value\>$}! + + Sets the dots for the upper index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!upper...withothersep={$\<separator\>$}!, + \mylst!upperdotswithothersep={$\<separator\>$}! + + Adds three dots to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!upper*! + + Adds a bullet to the upper index, + with no separator from any previous upper index. + + \item + \mylst!upper**! + + Adds a double bullet to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper*! + + Adds a bullet to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!supper**! + + Adds a double bullet to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper*! + + Adds a bullet to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!cupper**! + + Adds a double bullet to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!upper*withothersep={$\<separator\>$}! + + Adds a bullet to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!upper**withothersep={$\<separator\>$}! + + Adds a double bullet to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!clearupper! + + Clears the upper index. + + \item + \mylst!clearpreupper! + + Clears the pre-upper index. + + \item + \mylst!clearpostupper! + + Clears the post-upper index. +\end{itemize} + +\section{Keys for the lower index} + +\begin{itemize} + \item + \mylst!lower={$\<value\>$}! + + Adds to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower={$\<value\>$}! + + Adds to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower={$\<value\>$}! + + Adds to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!prelower={$\<value\>$}! + + Sets the pre-lower index. + + \item + \mylst!postlower={$\<value\>$}! + + Sets the post-lower index. + + \item + \mylst!lowerputleft={$\<value\>$}! + + Adds something to the left of the lower index. + As with keys like~\lstinline!lower!, this + will also increase the number of registered + lower indices by~\( 1 \), and + it will + set \lstinline!nextlowerwithsep=true!. + + \item + \mylst!setlowersep={$\<value\>$}! + + Sets the lower index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextlowerwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next lower index should + be separated from the current one by a separator. + + \item + \mylst!lowerwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the lower index, separated from + any prevous lower index by~\<separator\>. + + \item + \mylst!lower-!, \mylst!lowerslot! + + Adds a slot to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower-!, \mylst!slowerslot! + + Adds a slot to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower-!, \mylst!clowerslot! + + Adds a slot to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!setlowerslot={$\<value\>$}! + + Sets the slot for the lower index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!lower-withothersep={$\<separator\>$}!, + \mylst!lowerslotwithothersep={$\<separator\>$}! + + + Adds a slot to the lower index, separated + from any previous lower index by~\<separator\>. + + \item + \mylst!lower...!, \mylst!lowerdots! + + Adds three dots to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower...!, \mylst!slowerdots! + + Adds three dots to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower...!, \mylst!clowerdots! + + Adds three dots to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!setlowerdots={$\<value\>$}! + + Sets the dots for the lower index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!lower...withothersep={$\<separator\>$}!, + \mylst!lowerdotswithothersep={$\<separator\>$}! + + Adds three dots to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!lower*! + + Adds a bullet to the lower index, + with no separator from any previous lower index. + + \item + \mylst!lower**! + + Adds a double bullet to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower*! + + Adds a bullet to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!slower**! + + Adds a double bullet to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower*! + + Adds a bullet to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!clower**! + + Adds a double bullet to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!lower*withothersep={$\<separator\>$}! + + Adds a bullet to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!lower**withothersep={$\<separator\>$}! + + Adds a double bullet to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!clearlower! + + Clears the lower index. + + \item + \mylst!clearprelower! + + Clears the pre-lower index. + + \item + \mylst!clearpostlower! + + Clears the post-lower index. +\end{itemize} + +\section{Keys for the upper left index} + +\begin{itemize} + \item + \mylst!upperleft={$\<value\>$}! + + Adds to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft={$\<value\>$}! + + Adds to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft={$\<value\>$}! + + Adds to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!preupperleft={$\<value\>$}! + + Sets the pre-upper left index. + + \item + \mylst!postupperleft={$\<value\>$}! + + Sets the post-upper left index. + + \item + \mylst!upperleftputleft={$\<value\>$}! + + Adds something to the left of the upper left index. + As with keys like~\lstinline!upperleft!, this + will also increase the number of registered + upper left indices by~\( 1 \), and + it will + set \lstinline!nextupperleftwithsep=true!. + + \item + \mylst!setupperleftsep={$\<value\>$}! + + Sets the upper left index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextupperleftwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next upper left index should + be separated from the current one by a separator. + + \item + \mylst!upperleftwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the upper left index, separated from + any prevous upper left index by~\<separator\>. + + \item + \mylst!upperleft-!, \mylst!upperleftslot! + + Adds a slot to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft-!, \mylst!supperleftslot! + + Adds a slot to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft-!, \mylst!cupperleftslot! + + Adds a slot to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!setupperleftslot={$\<value\>$}! + + Sets the slot for the upper left index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!upperleft-withothersep={$\<separator\>$}!, + \mylst!upperleftslotwithothersep={$\<separator\>$}! + + + Adds a slot to the upper left index, separated + from any previous upper left index by~\<separator\>. + + \item + \mylst!upperleft...!, \mylst!upperleftdots! + + Adds three dots to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft...!, \mylst!supperleftdots! + + Adds three dots to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft...!, \mylst!cupperleftdots! + + Adds three dots to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!setupperleftdots={$\<value\>$}! + + Sets the dots for the upper left index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!upperleft...withothersep={$\<separator\>$}!, + \mylst!upperleftdotswithothersep={$\<separator\>$}! + + Adds three dots to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!upperleft*! + + Adds a bullet to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!upperleft**! + + Adds a double bullet to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft*! + + Adds a bullet to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!supperleft**! + + Adds a double bullet to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft*! + + Adds a bullet to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!cupperleft**! + + Adds a double bullet to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!upperleft*withothersep={$\<separator\>$}! + + Adds a bullet to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!upperleft**withothersep={$\<separator\>$}! + + Adds a double bullet to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!clearupperleft! + + Clears the upper left index. + + \item + \mylst!clearpreupperleft! + + Clears the pre-upper left index. + + \item + \mylst!clearpostupperleft! + + Clears the post-upper left index. +\end{itemize} + +\section{Keys for the lower left index} + +\begin{itemize} + \item + \mylst!lowerleft={$\<value\>$}! + + Adds to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft={$\<value\>$}! + + Adds to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft={$\<value\>$}! + + Adds to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!prelowerleft={$\<value\>$}! + + Sets the pre-lower left index. + + \item + \mylst!postlowerleft={$\<value\>$}! + + Sets the post-lower left index. + + \item + \mylst!lowerleftputleft={$\<value\>$}! + + Adds something to the left of the lower left index. + As with keys like~\lstinline!lowerleft!, this + will also increase the number of registered + lower left indices by~\( 1 \), and + it will + set \lstinline!nextlowerleftwithsep=true!. + + \item + \mylst!setlowerleftsep={$\<value\>$}! + + Sets the lower left index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextlowerleftwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next lower left index should + be separated from the current one by a separator. + + \item + \mylst!lowerleftwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the lower left index, separated from + any prevous lower left index by~\<separator\>. + + \item + \mylst!lowerleft-!, \mylst!lowerleftslot! + + Adds a slot to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft-!, \mylst!slowerleftslot! + + Adds a slot to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft-!, \mylst!clowerleftslot! + + Adds a slot to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!setlowerleftslot={$\<value\>$}! + + Sets the slot for the lower left index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!lowerleft-withothersep={$\<separator\>$}!, + \mylst!lowerleftslotwithothersep={$\<separator\>$}! + + + Adds a slot to the lower left index, separated + from any previous lower left index by~\<separator\>. + + \item + \mylst!lowerleft...!, \mylst!lowerleftdots! + + Adds three dots to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft...!, \mylst!slowerleftdots! + + Adds three dots to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft...!, \mylst!clowerleftdots! + + Adds three dots to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!setlowerleftdots={$\<value\>$}! + + Sets the dots for the lower left index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!lowerleft...withothersep={$\<separator\>$}!, + \mylst!lowerleftdotswithothersep={$\<separator\>$}! + + Adds three dots to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!lowerleft*! + + Adds a bullet to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!lowerleft**! + + Adds a double bullet to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft*! + + Adds a bullet to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!slowerleft**! + + Adds a double bullet to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft*! + + Adds a bullet to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!clowerleft**! + + Adds a double bullet to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!lowerleft*withothersep={$\<separator\>$}! + + Adds a bullet to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!lowerleft**withothersep={$\<separator\>$}! + + Adds a double bullet to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!clearlowerleft! + + Clears the lower left index. + + \item + \mylst!clearprelowerleft! + + Clears the pre-lower left index. + + \item + \mylst!clearpostlowerleft! + + Clears the post-lower left index. +\end{itemize} + +\section{Keys for the \texttt{d}-index} + +\begin{itemize} + \item + \mylst!d={$\<value\>$}! + + Adds to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd={$\<value\>$}! + + Adds to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd={$\<value\>$}! + + Adds to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!pred={$\<value\>$}! + + Sets the pre-\lstinline!d!-index. + + \item + \mylst!postd={$\<value\>$}! + + Sets the post-\lstinline!d!-index. + + \item + \mylst!dputleft={$\<value\>$}! + + Adds something to the left of the \lstinline!d!-index. + As with keys like~\lstinline!d!, this + will also increase the number of registered + \lstinline!d!-indices by~\( 1 \), and + it will + set \lstinline!nextdwithsep=true!. + + \item + \mylst!setdsep={$\<value\>$}! + + Sets the \lstinline!d!-index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextdwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next \lstinline!d!-index should + be separated from the current one by a separator. + + \item + \mylst!dwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the \lstinline!d!-index, separated from + any prevous \lstinline!d!-index by~\<separator\>. + + \item + \mylst!d-!, \mylst!dslot! + + Adds a slot to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd-!, \mylst!sdslot! + + Adds a slot to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd-!, \mylst!cdslot! + + Adds a slot to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!setdslot={$\<value\>$}! + + Sets the slot for the \lstinline!d!-index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!d-withothersep={$\<separator\>$}!, + \mylst!dslotwithothersep={$\<separator\>$}! + + + Adds a slot to the \lstinline!d!-index, separated + from any previous \lstinline!d!-index by~\<separator\>. + + \item + \mylst!d...!, \mylst!ddots! + + Adds three dots to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd...!, \mylst!sddots! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd...!, \mylst!cddots! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!setddots={$\<value\>$}! + + Sets the dots for the \lstinline!d!-index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!d...withothersep={$\<separator\>$}!, + \mylst!ddotswithothersep={$\<separator\>$}! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!d*! + + Adds a bullet to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!d**! + + Adds a double bullet to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd*! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!sd**! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd*! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!cd**! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!d*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!d**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!cleard! + + Clears the \lstinline!d!-index. + + \item + \mylst!clearpred! + + Clears the pre-\lstinline!d!-index. + + \item + \mylst!clearpostd! + + Clears the post-\lstinline!d!-index. +\end{itemize} + +\section{Keys for the \texttt{i}-index} + +\begin{itemize} + \item + \mylst!i={$\<value\>$}! + + Adds to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si={$\<value\>$}! + + Adds to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!ci={$\<value\>$}! + + Adds to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!prei={$\<value\>$}! + + Sets the pre-\lstinline!i!-index. + + \item + \mylst!posti={$\<value\>$}! + + Sets the post-\lstinline!i!-index. + + \item + \mylst!iputleft={$\<value\>$}! + + Adds something to the left of the \lstinline!i!-index. + As with keys like~\lstinline!i!, this + will also increase the number of registered + \lstinline!i!-indices by~\( 1 \), and + it will + set \lstinline!nextiwithsep=true!. + + \item + \mylst!setisep={$\<value\>$}! + + Sets the \lstinline!i!-index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextiwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next \lstinline!i!-index should + be separated from the current one by a separator. + + \item + \mylst!iwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the \lstinline!i!-index, separated from + any prevous \lstinline!i!-index by~\<separator\>. + + \item + \mylst!i-!, \mylst!islot! + + Adds a slot to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si-!, \mylst!sislot! + + Adds a slot to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by the default separator. + + \item + \mylst!ci-!, \mylst!cislot! + + Adds a slot to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by a comma. + + \item + \mylst!setislot={$\<value\>$}! + + Sets the slot for the \lstinline!i!-index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!i-withothersep={$\<separator\>$}!, + \mylst!islotwithothersep={$\<separator\>$}! + + + Adds a slot to the \lstinline!i!-index, separated + from any previous \lstinline!i!-index by~\<separator\>. + + \item + \mylst!i...!, \mylst!idots! + + Adds three dots to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si...!, \mylst!sidots! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by the default separator. + + \item + \mylst!ci...!, \mylst!cidots! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by a comma. + + \item + \mylst!setidots={$\<value\>$}! + + Sets the dots for the \lstinline!i!-index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!i...withothersep={$\<separator\>$}!, + \mylst!idotswithothersep={$\<separator\>$}! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!i*! + + Adds a bullet to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!i**! + + Adds a double bullet to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si*! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!si**! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!ci*! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!ci**! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!i*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!i**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!cleari! + + Clears the \lstinline!i!-index. + + \item + \mylst!clearprei! + + Clears the pre-\lstinline!i!-index. + + \item + \mylst!clearposti! + + Clears the post-\lstinline!i!-index. +\end{itemize} + +\section{The predefined argument keys}\label{sec:predefined_arg_keys} + +These are the predefined keys that work inside the argument. + +\begin{itemize} + \item + \mylst!execute={$\<code\>$}! + + Executes the \<code\> on the spot. + This is not strictly speaking a logic key, + but this allows you to perform logical + operations that are not allowed + by the other logic keys. + + \item + \mylst!setkeys={$\<keys\>$}!, + \mylst!keysset={$\<keys\>$}! + + Sets the keys \<keys\>. + + \item + \mylst!setkeysx={$\<keys\>$}!, + \mylst!keyssetx={$\<keys\>$}! + + Sets the keys \<keys\>, but fully expands their values. + + \item + \mylst!setargkeys={$\<keys\>$}!, + \mylst!argkeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>. + + \item + \mylst!setargkeysx={$\<keys\>$}!, + \mylst!argkeyssetx={$\<keys\>$}! + + Sets the argynebt keys \<keys\>, but fully expands their values. + + \item + \mylst!setargsinglekeys={$\<keys\>$}!, + \mylst!argsinglekeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setargsinglekeysx={$\<keys\>$}!, + \mylst!argsinglekeyssetx={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setoneargsinglekey={$\<key\>$}!, + \mylst!oneargsinglekeyset={$\<key\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setoneargsinglekeyx={$\<key\>$}!, + \mylst!oneargsinglekeysetx={$\<key\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setargwithoutkeyval={$\<value\>$}!, + \mylst!argwithoutkeyvalset={$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!setargwithoutkeyvalx={$\<value\>$}!, + \mylst!argwithoutkeyvalsetx={$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!default={$\<value\>$}! + + This is the value that is applied whenever + a value is passed to the argument that is not + recognized as a key, e.g.~the~\lstinline!\vx! + in~\lstinline!\vf{\vx}!. + By default, this is set to be equivalent + to~\lstinline!s!. + + \item + \mylst!s={$\<value\>$}! + + Adds the \<value\> to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c={$\<value\>$}! + + Adds the \<value\> to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!-!, \mylst!slot! + + Adds a slot to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c-!, \mylst!cslot! + + Adds a slot to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!...!, \mylst!dots! + + Adds three dots to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c...!, \mylst!cdots! + + Adds three dots to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!othersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the argument, + separated from any previous argument + by~\<separator\>. + + \item + \mylst!-withothersep={$\<separator\>$}! , + \mylst!slotwithothersep={$\<separator\>$}! + + Adds a slot to the argument, separated + from any previous argument by \<separator\>. + + \item + \mylst!...withothersep={$\<separator\>$}! , + \mylst!dotswithothersep={$\<separator\>$}! + + Adds three dots to the argument, separated + from any previous argument by~\<separator\>. +\end{itemize} + +\section{The programming commands}\label{sec:programming_commands} + +The following commands are available for programming inside \lstinline!execute={...}!: + +\begin{itemize} + \item + \mylst!\SemantexThis! + + Returns the name of the current class or object. The name is stored in the form \mylst!object_$\<name of object without backslash\>$! + or~\mylst!class_$\<name of class without backslash\>$!, + which is the way the names are stored internally. + + \item + \mylst!\SemantexSetKeys{$\<keys\>$}!, + \mylst!\SemantexKeysSet{$\<keys\>$}! + + Sets the \<keys\>. + + \item + \mylst!\SemantexSetKeysx{$\<keys\>$}!, + \mylst!\SemantexKeysSetx{$\<keys\>$}! + + Sets the \<keys\>, but fully expands their values. + + \item + \mylst!\SemantexSetArgKeys{$\<keys\>$}!, + \mylst!\SemantexArgKeysSet{$\<keys\>$}! + + Sets the argument \<keys\>. + + \item + \mylst!\SemantexSetArgKeysx{$\<keys\>$}!, + \mylst!\SemantexArgKeysSetx{$\<keys\>$}! + + Sets the argument \<keys\>, but fully expands their values. + + \item + \mylst!\SemantexSetArgSingleKeys{$\<keys\>$}!, + \mylst!\SemantexArgSingleKeysSet{$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!\SemantexSetArgSingleKeysx{$\<keys\>$}!, + \mylst!\SemantexArgSingleKeysSetx{$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!\SemantexSetOneArgSingleKey{$\<keys\>$}!, + \mylst!\SemantexOneSingleArgKeySet{$\<keys\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!\SemantexSetOneArgSingleKeyx{$\<keys\>$}!, + \mylst!\SemantexOneSingleArgKeySetx{$\<keys\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!, + \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!, + \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!\SemantexDataProvide{$\<data\>$}! + + Provides a new piece of data consisting of a token list. + + \item + \mylst!\SemantexDataSet{$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>. + + \item + \mylst!\SemantexDataSetx{$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataPutLeft{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>. + + \item + \mylst!\SemantexDataPutLeftx{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataPutRight{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>. + + \item + \mylst!\SemantexDataPutRightx{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataGet{$\<data\>$}! + + Returns the value of \<data\>. + + \item + \mylst!\SemantexDataGetExpNot{$\<data\>$}! + + Returns the value of \<data\>, + enclosed in \lstinline!\unexpanded! + so that it can be used within an \lstinline!x!-type + expansion. + + \item + \mylst!\SemantexDataClear{$\<data\>$}! + + Clears the piece of data~\<data\>. + + \item + \mylst!\SemantexBoolProvide{$\<boolean\>$}! + + Provides a new piece of data consisting of a boolean. + + \item + \mylst!\SemantexBoolSetTrue{$\<boolean\>$}! + + Sets the \<boolean\> to true. + + \item + \mylst!\SemantexBoolSetFalse{$\<boolean\>$}! + + Sets the \<boolean\> to false. + + \item + \mylst!\SemantexBoolIfTF{$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!\SemantexBoolIfT{$\<boolean\>$}{$\<if true\>$}!,\\ + \mylst!\SemantexBoolIfF{$\<boolean\>$}{$\<if false\>$}! + + Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>. + + \item + \mylst!\SemantexIntProvide{$\<integer\>$}! + + Provides a new piece of data consisting of an integer. + + \item + \mylst!\SemantexIntGet{$\<integer\>$}! + + Returns the value of the \<integer\>. + + \item + \mylst!\SemantexIntSet{$\<integer\>$}{$\<value\>$}! + + Sets the \<integer\> to \<value\>. + + \item + \mylst!\SemantexIntIncr{$\<integer\>$}! + + Increases the \<integer\> by~\( 1 \). + + \item + \mylst!\SemantexIntIfEqTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfEqT$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfEqF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntIfGreaterTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfGreaterT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfGreaterF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntIfLessTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfLessT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfLessF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntClear{$\<integer\>$}! + + Clears the \<integer\>. + + \item + \mylst!\SemantexIfBlankTF{$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!\SemantexIfBlankT{$\<tokens\>$}{$\<if true\>$}!,\\ + \mylst!\SemantexIfBlankF{$\<tokens\>$}{$\<if false\>$}! + + Fully expands the \<tokens\> and checks if it is blank, + and runs \<if true\> or \<if false\> according to this. + + \item + \mylst!\SemantexStrIfEqTF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexStrIfEqT{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexStrIfEqF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}! + + Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexERROR{$\<error message\>$}! + + Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>} + or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}. + + \item + \mylst!\SemantexERRORKeyValueNotFound{$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>. -For now, the system seems to work fine as long as you do \enquote{normal} things. The only real bug that I currently know of occurs if you use the key~\lstinline!Otherspar! in a heading. Then it all dies painfully. -Then again, why the heck would you do that in the first place? Who scales parentheses in headings? + \item + \mylst!\SemantexERRORArgKeyValueNotFound{$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>. -%\input{testground} + \item + \mylst!\SemantexExpNot{$\<value\>$}! + + An alias for \lstinline!\unexpanded! (also known as \lstinline!\exp_not:N! in~\LaTeX3). +\end{itemize} + +\section{The class types} + +The \semantex system uses several different \emph{class types}. +In fact, all class types are identical internally; the low-level machinery of \semantex does not \enquote{know} what type a class has. +The only difference between the class types is the \emph{input syntax}. +In other words, it determines which arguments an object of that class +can take. The syntax for creating new objects +also varies. + +The current implementation has the following +class types: + +\begin{itemize} + \item \lstinline!Variable!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewVariableClass{@\usercommand\<Class\>@}[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Cohomology!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewCohomologyClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<degree\>@}{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Symbol!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewSimpleClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@] + \end{lstlisting} + \item \lstinline!Delimiter!: + A new class is declared with the syntax + \begin{lstlisting} + \NewDelimiterClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<left bracket\>@}{@\<right bracket\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Simple!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewSimpleClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@ + \end{lstlisting} +\end{itemize} + +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. + +The last class type, called \lstinline!Simple!, +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. + +\section{The predefined data} + +By default, the following data are defined for each class or object and are accessible via +the programming keys and commands: + +\begin{itemize} + \item + \mylst!symbol! + (token list): + the symbol. + \item + \mylst!output! + (token list): + the name of the output class. + \item + \mylst!outputoptions! + (token list): + the output options, i.e.~the options to be passed to the output class. + \item + \mylst!parseoptions! + (token list): + the parse options, i.e.~the options that are invoked + during the parse routine. + \item + \mylst!texclass! + (token list): + the \TeX\ character class command that the final output + is evnetually wrapped around; + the intended use of this is the \TeX\ commands + \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!. + \item + \lstinline!heightphantom! + (token list): + the height phantom that is used + for calculating the height of left indices. + \item + \lstinline!slantingphantom! + (token list): + the slanting phantom that is used for + calculating the slanting of left indices. + \item + \lstinline!parsize! + (token list): + the size of the argument parentheses. + Here, the value~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The default value is \lstinline!normal!. + \item + \lstinline!leftpar! + (token list): + the left argument parenthesis; + the default value is~\lstinline!(!. + \item + \lstinline!rightpar! + (token list): + the right argument parenthesis; + the default value is~\lstinline!)!. + \item + \lstinline!sparsize! + (token list): + the size of the symbol parentheses (for use with the \lstinline!spar!~routine). + Here, the value~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The default value is \lstinline!normal!. + \item + \lstinline!leftspar! + (token list): + the left symbol parenthesis (for use with the \lstinline!spar!~routine); + the default value is~\lstinline!(!. + \item + \lstinline!rightspar! + (token list): + the right symbol parenthesis (for use with the \lstinline!spar!~routine); + the default value is~\lstinline!)!. + \item + \lstinline!arg! + (token list): + the argument. + \item + \lstinline!prearg! + (token list): + to be printed in front of the argument, if the argument is non-empty. + \item + \lstinline!postarg! + (token list): + to be printed after the argument, if the argument is non-empty. + \item + \lstinline!argsep! + (token list): + the argument separator; + comma by default. + \item + \lstinline!argslot! + (token list): + the argument slot; + \lstinline!{-}!~by default. + \item + \lstinline!argdots! + (token list): + the argument dots; + \lstinline!\dots!~by default. + % Upper index: + \item + \lstinline!upper! + (token list): + the upper index. + \item + \lstinline!preupper! + (token list): + the pre-upper index, to be printed in front of the upper index, + if the upper index is non-empty. + \item + \mylst!postupper! + (token list) + the post-upper index, to be printed after the upper index, + if the upper index is non-empty. + \item + \mylst!uppersep! + (token list): + the upper index separator; + comma by default. + \item + \mylst!upperdots! + (token list): + the upper dots; \lstinline!\dots!~by default. + \item + \mylst!upperslot! + (token list): + the upper slot; \lstinline!{-}!~by default. + % Lower index: + \item + \lstinline!lower! + (token list): + the lower index. + \item + \lstinline!prelower! + (token list): + the pre-lower index, to be printed in front of the lower index, + if the lower index is non-empty. + \item + \mylst!postlower! + (token list) + the post-lower index, to be printed after the lower index, + if the lower index is non-empty. + \item + \mylst!lowersep! + (token list): + the lower index separator; + comma by default. + \item + \mylst!lowerdots! + (token list): + the lower dots; \lstinline!\dots!~by default. + \item + \mylst!lowerslot! + (token list): + the lower slot; \lstinline!{-}!~by default. + % Upper left index: + \item + \lstinline!upperleft! + (token list): + the upper left index. + \item + \lstinline!preupperleft! + (token list): + the pre-upper left index, to be printed in front of the upper left index, + if the upper left index is non-empty. + \item + \mylst!postupperleft! + (token list) + the post-upper left index, to be printed after the upper left index, + if the upper left index is non-empty. + \item + \mylst!upperleftsep! + (token list): + the upper left index separator; + comma by default. + \item + \mylst!upperleftdots! + (token list): + the upper left dots; \lstinline!\dots!~by default. + \item + \mylst!upperleftslot! + (token list): + the upper left slot; \lstinline!{-}!~by default. + % Lower left index: + \item + \lstinline!lowerleft! + (token list): + the lower left index. + \item + \lstinline!prelowerleft! + (token list): + the pre-lower left index, to be printed in front of the lower left index, + if the lower left index is non-empty. + \item + \mylst!postlowerleft! + (token list) + the post-lower left index, to be printed after the lower left index, + if the lower left index is non-empty. + \item + \mylst!lowerleftsep! + (token list): + the lower left index separator; + comma by default. + \item + \mylst!lowerleftdots! + (token list): + the lower left dots; \lstinline!\dots!~by default. + \item + \mylst!lowerleftslot! + (token list): + the lower left slot; \lstinline!{-}!~by default. + \item + \mylst!uppergrading! + (boolean): + whether or not to use + upper (cohomological) grading; true by default. + \item + \mylst!par! + (boolean): + whether or not to use parentheses; true by default. + \item + \mylst!flexpar! + (boolean): + if \mylst!par! is set to false, setting \mylst!flexpar! to true + will still print a pair of parentheses when there is more than one argument; + false by default. + \item + \mylst!leftargument! + (boolean): + if true, the argument (and parentheses) + will be printed to the \emph{left} of the symbol; + false by default. + \item + \mylst!nextargwithsep! + (boolean): + if true, the next argument will have a separator printed in front of it. + \item + \mylst!nextupperwithsep! + (boolean): + If true, the next upper index will have a separator printed in front of it. + \item + \mylst!nextlowerwithsep! + (boolean): + If true, the next lower index will have a separator printed in front of it. + \item + \mylst!nextupperleftwithsep! + (boolean): + If true, the next upper left index will have a separator printed in front of it. + \item + \mylst!nextlowerleftwithsep! + (boolean): + If true, the next lower upper index will have a separator printed in front of it. + \item + \mylst!allowSemantexDelimiterSize! + (boolean): + if true, the argument will + allow the command \lstinline!\SemantexDelimiterSize! + inside the argument; + the default is~\lstinline!true!. + The only real reason to turn this off is if you are using + \lstinline!stripsemantex! to strip the document of \semantex markup. + For if it is set to false, the system will not + add \lstinline!\SemantexParentheses! and \lstinline!\SemantexNoParentheses! + all over the place to set the value of \lstinline!\SemantexDelimiterSize!, + and this probably looks better in the outputted code. + \item + \mylst!numberofarguments! + (integer): + the number of arguments. + \item + \mylst!numberofupperindices! + (integer): + the number of upper indices. + \item + \mylst!numberoflowerindices! + (integer): + the number of lower indices. + \item + \mylst!numberofupperleftindices! + (integer): + the number of upper left indices. + \item + \mylst!numberoflowerindices! + (integer): + the number of lower left indices. +\end{itemize} \end{document}
\ No newline at end of file |