summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/semantex/semantex.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/semantex/semantex.tex')
-rw-r--r--Master/texmf-dist/doc/latex/semantex/semantex.tex1800
1 files changed, 1073 insertions, 727 deletions
diff --git a/Master/texmf-dist/doc/latex/semantex/semantex.tex b/Master/texmf-dist/doc/latex/semantex/semantex.tex
index da8cfd390b0..c273d1dcecf 100644
--- a/Master/texmf-dist/doc/latex/semantex/semantex.tex
+++ b/Master/texmf-dist/doc/latex/semantex/semantex.tex
@@ -9,9 +9,7 @@
\frenchspacing
-\usepackage{mathtools,etoolbox, microtype,xspace}
-
-
+\usepackage{mathtools,etoolbox, microtype,xspace,color}
\usepackage[shortlabels]{enumitem}%control lists
@@ -36,7 +34,7 @@
\usepackage[nameinlink]{cleveref}
-\title{Seman\!\TeX: Object-oriented mathematics (v$0.1\alpha$)}
+\title{Seman\!\TeX: Semantic mathematics (v$0.2\alpha$)}
\date{\today}
\author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})}
@@ -56,139 +54,129 @@
\usepackage{semantex}
-\newvariableclass{var}[
- output=var,
+\NewVariableClass\MyVar[
+ output=\MyVar,
]
-\newvar\va{a}
-\newvar\vb{b}
-\newvar\vc{c}
-\newvar\vd{d}
-\newvar\ve{e}
-\newvar\vf{f}
-\newvar\vg{g}
-\newvar\vh{h}
-\newvar\vi{i}
-\newvar\vj{j}
-\newvar\vk{k}
-\newvar\vl{l}
-\newvar\vm{m}
-\newvar\vn{n}
-\newvar\vo{o}
-\newvar\vp{p}
-\newvar\vq{q}
-\newvar\vr{r}
-\newvar\vs{s}
-\newvar\vt{t}
-\newvar\vu{u}
-\newvar\vv{v}
-\newvar\vw{w}
-\newvar\vx{x}
-\newvar\vy{y}
-\newvar\vz{z}
-
-\newvar\vA{A}
-\newvar\vB{B}
-\newvar\vC{C}
-\newvar\vD{D}
-\newvar\vE{E}
-\newvar\vF{F}
-\newvar\vG{G}
-\newvar\vH{H}
-\newvar\vI{I}
-\newvar\vJ{J}
-\newvar\vK{K}
-\newvar\vL{L}
-\newvar\vM{M}
-\newvar\vN{N}
-\newvar\vO{O}
-\newvar\vP{P}
-\newvar\vQ{Q}
-\newvar\vR{R}
-\newvar\vS{S}
-\newvar\vT{T}
-\newvar\vU{U}
-\newvar\vV{V}
-\newvar\vW{W}
-\newvar\vX{X}
-\newvar\vY{Y}
-\newvar\vZ{Z}
-
-\newvar\valpha{\alpha}
-\newvar\vvaralpha{\varalpha}
-\newvar\vbeta{\beta}
-\newvar\vgamma{\gamma}
-\newvar\vdelta{\delta}
-\newvar\vepsilon{\epsilon}
-\newvar\vvarepsilon{\varepsilon}
-\newvar\vzeta{\zeta}
-\newvar\veta{\eta}
-\newvar\vtheta{\theta}
-\newvar\viota{\iota}
-\newvar\vkappa{\kappa}
-\newvar\vlambda{\lambda}
-\newvar\vmu{\mu}
-\newvar\vnu{\nu}
-\newvar\vxi{\xi}
-\newvar\vpi{\pi}
-\newvar\vvarpi{\varpi}
-\newvar\vrho{\rho}
-\newvar\vsigma{\sigma}
-\newvar\vtau{\tau}
-\newvar\vupsilon{\upsilon}
-\newvar\vphi{\phi}
-\newvar\vvarphi{\varphi}
-\newvar\vchi{\chi}
-\newvar\vpsi{\psi}
-\newvar\vomega{\omega}
-
-\newvar\vGamma{\Gamma}
-\newvar\vDelta{\Delta}
-\newvar\vTheta{\Theta}
-\newvar\vLambda{\Lambda}
-\newvar\vXi{\Xi}
-\newvar\vPi{\Pi}
-\newvar\vSigma{\Sigma}
-\newvar\vUpsilon{\Upsilon}
-\newvar\vPhi{\Phi}
-\newvar\vPsi{\Psi}
-\newvar\vOmega{\Omega}
-
-\newvar\sheafF{\mathcal{F}}
-\newvar\sheafG{\mathcal{G}}
-\newvar\sheafO{\mathcal{O}}
-\newvar\sheafHom{\mathcal{H}\!\!om}
-
-\newvar\Hom{\operatorname{Hom}}
-
-\usepackage{showexpl,newunicodechar}
-
-\newunicodechar{⟨}{\textlangle}
-\newunicodechar{⟩}{\textrangle}
-
-
-\setupclass{var}{
- novaluekeys={
- {inverseimage}{upper={-1},nopar},
- },
-}
-
-\newcohomologyclass{cohomology}[
- parent=var,
- valuekeys={
- {arg}{argwithkeyval={#1}},
- },
- gradingpos=upper,
+\NewObject\MyVar\va{a}
+\NewObject\MyVar\vb{b}
+\NewObject\MyVar\vc{c}
+\NewObject\MyVar\vd{d}
+\NewObject\MyVar\ve{e}
+\NewObject\MyVar\vf{f}
+\NewObject\MyVar\vg{g}
+\NewObject\MyVar\vh{h}
+\NewObject\MyVar\vi{i}
+\NewObject\MyVar\vj{j}
+\NewObject\MyVar\vk{k}
+\NewObject\MyVar\vl{l}
+\NewObject\MyVar\vm{m}
+\NewObject\MyVar\vn{n}
+\NewObject\MyVar\vo{o}
+\NewObject\MyVar\vp{p}
+\NewObject\MyVar\vq{q}
+\NewObject\MyVar\vr{r}
+\NewObject\MyVar\vs{s}
+\NewObject\MyVar\vt{t}
+\NewObject\MyVar\vu{u}
+\NewObject\MyVar\vv{v}
+\NewObject\MyVar\vw{w}
+\NewObject\MyVar\vx{x}
+\NewObject\MyVar\vy{y}
+\NewObject\MyVar\vz{z}
+
+\NewObject\MyVar\vA{A}
+\NewObject\MyVar\vB{B}
+\NewObject\MyVar\vC{C}
+\NewObject\MyVar\vD{D}
+\NewObject\MyVar\vE{E}
+\NewObject\MyVar\vF{F}
+\NewObject\MyVar\vG{G}
+\NewObject\MyVar\vH{H}
+\NewObject\MyVar\vI{I}
+\NewObject\MyVar\vJ{J}
+\NewObject\MyVar\vK{K}
+\NewObject\MyVar\vL{L}
+\NewObject\MyVar\vM{M}
+\NewObject\MyVar\vN{N}
+\NewObject\MyVar\vO{O}
+\NewObject\MyVar\vP{P}
+\NewObject\MyVar\vQ{Q}
+\NewObject\MyVar\vR{R}
+\NewObject\MyVar\vS{S}
+\NewObject\MyVar\vT{T}
+\NewObject\MyVar\vU{U}
+\NewObject\MyVar\vV{V}
+\NewObject\MyVar\vW{W}
+\NewObject\MyVar\vX{X}
+\NewObject\MyVar\vY{Y}
+\NewObject\MyVar\vZ{Z}
+
+\NewObject\MyVar\valpha{\alpha}
+\NewObject\MyVar\vvaralpha{\varalpha}
+\NewObject\MyVar\vbeta{\beta}
+\NewObject\MyVar\vgamma{\gamma}
+\NewObject\MyVar\vdelta{\delta}
+\NewObject\MyVar\vepsilon{\epsilon}
+\NewObject\MyVar\vvarepsilon{\varepsilon}
+\NewObject\MyVar\vzeta{\zeta}
+\NewObject\MyVar\veta{\eta}
+\NewObject\MyVar\vtheta{\theta}
+\NewObject\MyVar\viota{\iota}
+\NewObject\MyVar\vkappa{\kappa}
+\NewObject\MyVar\vlambda{\lambda}
+\NewObject\MyVar\vmu{\mu}
+\NewObject\MyVar\vnu{\nu}
+\NewObject\MyVar\vxi{\xi}
+\NewObject\MyVar\vpi{\pi}
+\NewObject\MyVar\vvarpi{\varpi}
+\NewObject\MyVar\vrho{\rho}
+\NewObject\MyVar\vsigma{\sigma}
+\NewObject\MyVar\vtau{\tau}
+\NewObject\MyVar\vupsilon{\upsilon}
+\NewObject\MyVar\vphi{\phi}
+\NewObject\MyVar\vvarphi{\varphi}
+\NewObject\MyVar\vchi{\chi}
+\NewObject\MyVar\vpsi{\psi}
+\NewObject\MyVar\vomega{\omega}
+
+\NewObject\MyVar\vGamma{\Gamma}
+\NewObject\MyVar\vDelta{\Delta}
+\NewObject\MyVar\vTheta{\Theta}
+\NewObject\MyVar\vLambda{\Lambda}
+\NewObject\MyVar\vXi{\Xi}
+\NewObject\MyVar\vPi{\Pi}
+\NewObject\MyVar\vSigma{\Sigma}
+\NewObject\MyVar\vUpsilon{\Upsilon}
+\NewObject\MyVar\vPhi{\Phi}
+\NewObject\MyVar\vPsi{\Psi}
+\NewObject\MyVar\vOmega{\Omega}
+
+\NewObject\MyVar\sheafF{\mathcal{F}}
+\NewObject\MyVar\sheafG{\mathcal{G}}
+\NewObject\MyVar\sheafreg{\mathcal{O}}
+\NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}}
+
+\NewObject\MyVar\Hom{\operatorname{Hom}}
+
+\NewCohomologyClass\MyCohomology[
+ parent=\MyVar,
+ gradingposition=upper,
]
-\newcohomologyclass{homology}[
- parent=cohomology,
- gradingpos=lower,
+\NewCohomologyClass\MyHomology[
+ parent=\MyCohomology,
+ gradingposition=lower,
]
-\newcohomology\co{H}
+\NewObject\MyCohomology\co{H}
-\newhomology\ho{H}
+\NewObject\MyHomology\ho{H}
+
+\usepackage{showexpl,newunicodechar}
+
+\newunicodechar{⟨}{\textlangle}
+\newunicodechar{⟩}{\textrangle}
\makeatother
@@ -214,100 +202,200 @@
-\newcommand*\mybs{$\backslash$}
+\newcommand\mybs{$\backslash$}
-\newcommand*\commandname[1]{\mybs\texttt{#1}}
+\newcommand\commandname[1]{\mybs\texttt{#1}}
\let\pack=\texttt
\newcommand\semantex{Seman\!\TeX\xspace}
\noindent
-The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the ordinary math syntax. The system is object-oriented and uses keyval syntax, and everything is highly customizable. At the same time, care has been taken to make it intuitive, natural, practical, and with an easy-to-use and lightweight syntax.
+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!}
\begingroup
- \setupclass{var}{
- novaluekeys={
+ \SetupClass\MyVar{
+ singlekeys={
+ {conj}{overline},
+ {inv}{upper={-1}},
{inverseimage}{upper={-1},nopar},
},
valuekeys={
- {stalk}{lower=#1},
- {res}{ return,symbolputright={|}, lower={#1} },
- },
- argvaluekeys={
- {coef}{sep={;}{#1}},
+ {der}{upper={ (#1) } },
+ {res}{ return ,symbolputright ={|}, lower ={#1} },
+ {stalk}{clower={#1}},
+ % "clower" means "comma lower", i.e. lower index
+ % separated from any previous lower index by a comma
},
}
- Traditional math notation in \TeX\ is not particularly semantic -- you usually type the raw \emph{notation} rather than the underlying
- \emph{meaning} of your math.
- Take, for instance, the following equations from algebraic geometry:
- \begin{align*}
- \vf[inverseimage]{\sheafF}[spar,stalk=\vp]
- &=
- \sheafF[stalk=\vf{\vp}] ,
- \\
- \sheafO[\vU]
- &=
- \sheafO[\vX,res=\vU] ,
- \\
- \sheafHom{ \sheafF , \sheafG }{\vU}
- &=
- \Hom[\sheafO[\vU]]{ \sheafF[res=\vU] , \sheafG[res=\vU] } ,
- \\
- \co{0}{\vU,coef=\sheafO[\vX]} &= \sheafO[\vX]{\vU}
- .
- \end{align*}
- Here, \( \sheafF \) and~\( \sheafG \)
- are sheaves on some scheme~\( \vX \),
- \( \sheafO[\vX] \)~is the structure sheaf,
- and~\( \vU \subset \vX \) an open subset.
- In traditional \TeX, you would probably define a collection of commands \lstinline!\sheafF!, \lstinline!\sheafG!, \lstinline!\sheafO!, and~\lstinline!\sheafHom! for~\( \sheafF \),~\( \sheafG \), \( \sheafO \), and~\( \sheafHom \) and then proceed
- something like
- \begin{lstlisting}
-(f^{-1}\sheafF)_{p}=\sheafF_{f(p)},
-\sheafO_{U} = \sheafO_{X}|_{U},
-\sheafHom( \sheafF , \sheafG)(U)
- = \Hom_{\sheafO_{X} ( \sheafF|_{U} , \sheafG|_{V} ),
- H^{0}(U;\sheafF) = \sheafF(U).
- \end{lstlisting}
- For more than~90~\% of all mathematicians, this solution will be completely satisfactory; it prints what it is supposed to, and that's that.
- If this is how you feel, there is absolutely no reason for you to continue reading. This package is for the remaining less than~10~\% who would prefer to write
- something like the following instead:
- \begin{lstlisting}
-\vf[inverseimage]{ \sheafF }[spar,stalk=\vp]
- = \sheafF[ stalk=\vf{\vp} ] ,
-\sheafO[\vU] = \sheafO[ \vX, res=\vU ],
-\sheafHom{ \sheafF , \sheafG }{\vU}
- = \Hom[\sheafO[\vU]]{ \sheafF[res=\vU], \sheafG[res=\vU] },
-\co{0}{ \vU, coef=\sheafO[\vX] } = \sheafO[\vX]{\vU}.
- \end{lstlisting}
- A lot of comments are in order.
- The whole syntax will be explained in later chapters, but let us take a moment to look at these examples and understand the logic.
- First of all, what is up with all the~\lstinline!v!'s in the command names \lstinline!\vf!, \lstinline!\vX!, \lstinline!\vU!? The~\lstinline!v!~stands for \textquote{variable}, and it is the prefix I recommend using for all standard variables. So for all letters in the alphabet, uppercase and lowercase, as well as the Greek ones, there will be a command: \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!,~etc.
- It is not always necessary to use them; for instance, in the above example, both \lstinline!\vX! and \lstinline!\vU! could have been replaced by simply~\lstinline!X!,~\lstinline!U! without changing anything. This is because we did not apply any arguments to these symbols. However, for the sake of consistency, I prefer to switch completely to using commands instead of writing the symbols directly.
- How \emph{you} use the system is completely up to you.
+ Let us take an example from elementary analysis
+ to demonstrate the idea of the package:
+ Suppose we want to take the complex conjugate of a function~\( \vf \)
+ and then derive it \( \vn \)~times, i.e.~take~\( \smash{ \vf[conj,der=\vn] } \).
+ \semantex allows you to typeset this something like this:
+\begin{LTXexample}
+$ \vf[conj,der=\vn] $
+\end{LTXexample}
+ I shall explain the syntax in detail below, but some immediate comments are in order: First and foremost, the~\lstinline!v!
+ in the command names \lstinline!\vf! and~\lstinline!\vn! stands for~\enquote{variable}, so these commands are the
+ variables \( \vf \) and~\( \vn \).
+ In \semantex, it is usually best to create
+ commands \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!, \ldots
+ for each variable you are using, upper- and lowercase.
+ However, it is completely up to the user how to do that and what to call them.
+ Note also that all of the keys
+ \lstinline!inv!,~\lstinline!res!,~etc.\ are defined by the
+ \emph{user}, and they can be modified and adjusted for all sorts of situations in any kinds of mathematics.
+ In other words, for the most part, you get to choose your own syntax.
- In \semantex, all entries are being built up from the inside and out.
- The basic syntax layout for most \semantex commands is
- \begin{lstlisting}
-\command[options]{argument}
- \end{lstlisting}
- Let us try focusing on the first example from above:
- \begin{LTXexample}
-$\vf[inverseimage]{\sheafF}[spar,stalk=\vp]$
- \end{LTXexample}
- You always start with a central piece: a \emph{symbol}.
- In the case of~\lstinline!\vf!, the symbol is~\( f \). After the symbol follows the options we apply to it, written in brackets~\lstinline![...]!. In this case, we the option~\lstinline!inverseimage!. This tells \semantex that we want the inverse image functor~\( \vf[inverseimage] \), so it adds a superscript~\lstinline!-1! to the symbol. After this, we apply the function~\lstinline!\vf[inverseimage]! to something, namely the sheaf~{$\sheafF$}. This is done by enclosing them in braces~\lstinline!{...}!.\footnote{You should be aware that this argument in braces~\texttt{\{...\}} is \emph{optional}. You can simply write~\texttt{$\backslash$vf[inverseimage]} if you want, and it will produce~\smash{\( \vf[inverseimage] \)}.}
+ Next, suppose we want to invert a function~\( \vg \) and restrict it to a subset~\( \vU \), and then apply it to~\( \vx \),
+ i.e.~take~\( \vg[inv,res=\vU]{\vx} \). This can be done by writing
+\begin{LTXexample}
+$ \vg[inv,res=\vU]{\vx} $
+\end{LTXexample}
+ Next, let us take an example from algebraic geometry:
+ Suppose \( \sheafF \)~is a sheaf and \( \vh \)~a~map,
+ and that we want to typeset the
+ equation~\( \smash{
+ \vh[inverseimage]{\sheafF}[
+ spar,stalk=\vp]
+ =
+ \sheafF[stalk=\vh{\vp}]
+ } \),
+ saying that the stalk of the inverse image~\( \vh[inverseimage]{\sheafF} \)
+ at the point~\( \vp \) is~\( \smash{ \sheafF[stalk=\vh{\vp}] } \).
+ This can be accomplished by typing
+\begin{LTXexample}
+$ \vh[inverseimage]{\sheafF}[spar,stalk=\vp]
+=
+\sheafF[stalk=\vh{\vp}] $
+\end{LTXexample}
+ Here, \lstinline!spar! (an abbreviation for~\enquote{symbol parentheses})
+ is the key that adds the parentheses around~\( \vh[inverseimage]{\sheafF} \).
- Next, we want to take the stalk of this sheaf at the point~\( \vp \). If we simply wrote~\lstinline!\vf[inverseimage]{\sheafF}[stalk=\vp]!, we would get~\smash{\( \vf[inverseimage]{\sheafF}[stalk=\vp] \)}, which looks confusing. So we want to enclose~\smash{\( \vf[inverseimage]{\sheafF} \)} in parentheses before taking the stalk. This is done with the key~\lstinline!spar! (an abbreviation for \textquote{symbol parentheses}).
- This key takes whatever has been typed so far, symbol and indices, and adds parentheses around it (of course, type and size is adjustable).
- This~\lstinline!spar! is a key you fill find yourself using a lot.
+ Let us see how you could set up all the above notation:
+\begin{lstlisting}
+\documentclass{article}
+
+\usepackage{amsmath,semantex}
+
+\NewVariableClass\MyVar % creates a new class of variables, called "\MyVar"
+
+% Now we create a couple of variables of the class \MyVar:
+\NewObject\MyVar\vf{f}
+\NewObject\MyVarr\vg{g}
+\NewObject\MyVar\vh{h}
+\NewObject\MyVar\sheafF{\mathcal{F}}
+
+% Now we set up the class \MyVar:
+\SetupClass\MyVar{
+ 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
+ {inv}{upper={-1}},
+ {conj}{overline},
+ {inverseimage}{upper={-1},nopar},
+ },
+ valuekeys={ % keys taking a 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} },
+ },
+}
+\end{lstlisting}
\endgroup
+%\begingroup
+% \SetupClass\MyVar{
+% singlekeys={
+% {inverseimage}{upper={-1},nopar},
+% },
+% valuekeys={
+% {stalk}{lower=#1},
+% {res}{ return,symbolputright={|}, lower={#1} },
+% },
+% argvaluekeys={
+% {coef}{othersep={;}{#1}},
+% },
+% }
+%
+% Traditional math notation in \TeX\ is not particularly semantic -- you usually type the raw \emph{notation} rather than the underlying
+% \emph{meaning} of your math.
+% Take, for instance, the following equations from algebraic geometry:
+% \begin{align*}
+% \vf[inverseimage]{\sheafF}[spar,stalk=\vp]
+% &=
+% \sheafF[stalk=\vf{\vp}] ,
+% \\
+% \sheafreg[\vU]
+% &=
+% \sheafreg[\vX,res=\vU] ,
+% \\
+% \sheafHom{ \sheafF , \sheafG }{\vU}
+% &=
+% \Hom[\sheafreg[\vU]]{ \sheafF[res=\vU] , \sheafG[res=\vU] } ,
+% \\
+% \co{0}{\vU,coef=\sheafreg[\vX]}
+% &= \sheafreg[\vX]{\vU}
+% .
+% \end{align*}
+% Here, \( \sheafF \) and~\( \sheafG \)
+% are sheaves on some scheme~\( \vX \),
+% \( \sheafreg[\vX] \)~is the structure sheaf,
+% and~\( \vU \subset \vX \) an open subset.
+% In traditional \TeX, you would probably define a collection of commands \lstinline!\sheafF!, \lstinline!\sheafG!, \lstinline!\sheafreg!, and~\lstinline!\sheafHom! for~\( \sheafF \),~\( \sheafG \), \( \sheafreg \), and~\( \sheafHom \) and then proceed
+% something like
+% \begin{lstlisting}
+%(f^{-1}\sheafF)_{p}=\sheafF_{f(p)},
+%\sheafreg_{U} = \sheafreg_{X}|_{U},
+%\sheafHom( \sheafF , \sheafG)(U)
+% = \Hom_{\sheafreg_{X} ( \sheafF|_{U} , \sheafG|_{V} ),
+% H^{0}(U;\sheafF) = \sheafF(U).
+% \end{lstlisting}
+% For more than~90~\% of all mathematicians, this solution will be completely satisfactory; it prints what it is supposed to, and that's that.
+% If this is how you feel, there is absolutely no reason for you to continue reading. This package is for the remaining less than~10~\% who would prefer to write
+% something like the following instead:
+% \begin{lstlisting}
+%\vf[inverseimage]{ \sheafF }[spar,stalk=\vp]
+% = \sheafF[ stalk=\vf{\vp} ] ,
+%\sheafreg[\vU] = \sheafreg[ \vX, res=\vU ],
+%\sheafHom{ \sheafF , \sheafG }{\vU}
+% = \Hom[\sheafreg[\vU]]{ \sheafF[res=\vU], \sheafG[res=\vU] },
+%\co{0}{ \vU, coef=\sheafreg[\vX] } = \sheafreg[\vX]{\vU}.
+% \end{lstlisting}
+%
+% A lot of comments are in order.
+% The whole syntax will be explained in later chapters, but let us take a moment to look at these examples and understand the logic.
+% First of all, what is up with all the~\lstinline!v!'s in the command names \lstinline!\vf!, \lstinline!\vX!, \lstinline!\vU!? The~\lstinline!v!~stands for \textquote{variable}, and it is the prefix I recommend using for all standard variables. So for all letters in the alphabet, uppercase and lowercase, as well as the Greek ones, there will be a command: \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!,~etc.
+% It is not always necessary to use them; for instance, in the above example, both \lstinline!\vX! and \lstinline!\vU! could have been replaced by simply~\lstinline!X!,~\lstinline!U! without changing anything. This is because we did not apply any arguments to these symbols. However, for the sake of consistency, I prefer to switch completely to using commands instead of writing the symbols directly.
+% How \emph{you} use the system is completely up to you.
+%
+% In \semantex, all entries are being built up from the inside and out.
+% The basic syntax layout for most \semantex commands is
+% \begin{lstlisting}
+%\⟨object⟩[⟨options⟩]{⟨argument⟩}
+% \end{lstlisting}
+% Let us try focusing on the first example from above:
+% \begin{LTXexample}
+%$\vf[inverseimage]{\sheafF}[spar,stalk=\vp]$
+% \end{LTXexample}
+% You always start with a central piece: a \emph{⟨symbol⟩}.
+% In the case of~\lstinline!\vf!, the symbol is~\( f \). After the symbol follows the options we apply to it, written in brackets~\lstinline![...]!. In this case, we the option~\lstinline!inverseimage!. This tells \semantex that we want the inverse image functor~\( \vf[inverseimage] \), so it adds a superscript~\lstinline!-1! to the symbol. After this, we apply the function~\lstinline!\vf[inverseimage]! to something, namely the sheaf~{$\sheafF$}. This is done by enclosing them in braces~\lstinline!{...}!.\footnote{You should be aware that this argument in braces~\texttt{\{...\}} is \emph{optional}. You can simply write~\texttt{$\backslash$vf[inverseimage]} if you want, and it will produce~\smash{\( \vf[inverseimage] \)}.}
+%
+%
+% Next, we want to take the stalk of this sheaf at the point~\( \vp \). If we simply wrote~\lstinline!\vf[inverseimage]{\sheafF}[stalk=\vp]!, we would get~\smash{\( \vf[inverseimage]{\sheafF}[stalk=\vp] \)}, which looks confusing. So we want to enclose~\smash{\( \vf[inverseimage]{\sheafF} \)} in parentheses before taking the stalk. This is done with the key~\lstinline!spar! (an abbreviation for \textquote{symbol parentheses}).
+% This key takes whatever has been typed so far, symbol and indices, and adds parentheses around it (of course, type and size is adjustable).
+% This~\lstinline!spar! is a key you fill find yourself using a lot.
+%\endgroup
+
\chapter{Getting started}
To get started using \semantex, load down the package
@@ -316,54 +404,59 @@ with
\usepackage{semantex}
\end{lstlisting}
The \semantex system is object-oriented; all entities are objects of some class. When you load the package, there
-is only one class by default, which is simply called \lstinline!semantexvariable!.
+is only one class by default, which is simply called \lstinline!\SemantexVariable!.
You should think of this as a low-level class, the parent of all other classes. Therefore, I highly advice against using it directly or modifying it.
Instead, we create a new, more high-level variable class.
-To make notations brief, we call it \lstinline!var!.
-We could write \lstinline!\newvariableclass{var}!, but we choose to
+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
pass some options to it in~\lstinline![...]!:
\begin{lstlisting}
-\newvariableclass{var}[output=var]
+\NewVariableClass\MyVar[output=\MyVar]
\end{lstlisting}
-This \lstinline!output=var! option will be explained better below.
+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!var!,
-then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also of class~\lstinline!var!.
+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!.
Now we have a class, but we do not have any objects.
-When we create the class~\lstinline!var!, the system
-automatically defines the command \lstinline!\newvar!
-that creates a new object of class~\lstinline!var!. The syntax is
+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
+can create objects of that class wtih the syntax
\begin{lstlisting}
-\newvar\⟨variable name⟩{⟨variable symbol⟩}[options]
+\NewObject\⟨Class⟩\⟨object⟩{⟨object symbol⟩}[⟨options⟩]
\end{lstlisting}
-For instance, we may write
+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.}
+So after writing,
\begin{lstlisting}
-\newvar\vf{f}
-\newvar\vx{x}
+\NewObject\MyVar\vf{f}
+\NewObject\MyVar\vx{x}
\end{lstlisting}
-to get two variables \lstinline!\vf! and~\lstinline!\vx! with symbols \( f \) resp.~\( x \).
+we get two variables \lstinline!\vf! and~\lstinline!\vx! with symbols \( f \) resp.~\( x \).
Let us perform a stupid test to see if the variables work:
\begin{LTXexample}
$\vf$, $\vx$
\end{LTXexample}
-Th general syntax of a variable-type command is
+Th general syntax of a variable-type object is
\begin{lstlisting}
-\command[options]{argument}
+\⟨object⟩[⟨options⟩]{⟨argument⟩}
\end{lstlisting}
-Both \lstinline!options! and \lstinline!argument! are optional
+Both \lstinline!⟨options⟩! and \lstinline!⟨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.
+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.
So we may write:
\begin{LTXexample}
-$\vf{1}$, $\vf{\vx}$
+$\vf{1}$, $\vf{\vx}$,
+$\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
+\lstinline!⟨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}
@@ -382,99 +475,99 @@ 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.
This is pretty time-consuming, so I did it for you already:
\begin{lstlisting}
-\newvar\va{a}
-\newvar\vb{b}
-\newvar\vc{c}
-\newvar\vd{d}
-\newvar\ve{e}
-\newvar\vf{f}
-\newvar\vg{g}
-\newvar\vh{h}
-\newvar\vi{i}
-\newvar\vj{j}
-\newvar\vk{k}
-\newvar\vl{l}
-\newvar\vm{m}
-\newvar\vn{n}
-\newvar\vo{o}
-\newvar\vp{p}
-\newvar\vq{q}
-\newvar\vr{r}
-\newvar\vs{s}
-\newvar\vt{t}
-\newvar\vu{u}
-\newvar\vv{v}
-\newvar\vw{w}
-\newvar\vx{x}
-\newvar\vy{y}
-\newvar\vz{z}
-
-\newvar\vA{A}
-\newvar\vB{B}
-\newvar\vC{C}
-\newvar\vD{D}
-\newvar\vE{E}
-\newvar\vF{F}
-\newvar\vG{G}
-\newvar\vH{H}
-\newvar\vI{I}
-\newvar\vJ{J}
-\newvar\vK{K}
-\newvar\vL{L}
-\newvar\vM{M}
-\newvar\vN{N}
-\newvar\vO{O}
-\newvar\vP{P}
-\newvar\vQ{Q}
-\newvar\vR{R}
-\newvar\vS{S}
-\newvar\vT{T}
-\newvar\vU{U}
-\newvar\vV{V}
-\newvar\vW{W}
-\newvar\vX{X}
-\newvar\vY{Y}
-\newvar\vZ{Z}
-
-\newvar\valpha{\alpha}
-\newvar\vvaralpha{\varalpha}
-\newvar\vbeta{\beta}
-\newvar\vgamma{\gamma}
-\newvar\vdelta{\delta}
-\newvar\vepsilon{\epsilon}
-\newvar\vvarepsilon{\varepsilon}
-\newvar\vzeta{\zeta}
-\newvar\veta{\eta}
-\newvar\vtheta{\theta}
-\newvar\viota{\iota}
-\newvar\vkappa{\kappa}
-\newvar\vlambda{\lambda}
-\newvar\vmu{\mu}
-\newvar\vnu{\nu}
-\newvar\vxi{\xi}
-\newvar\vpi{\pi}
-\newvar\vvarpi{\varpi}
-\newvar\vrho{\rho}
-\newvar\vsigma{\sigma}
-\newvar\vtau{\tau}
-\newvar\vupsilon{\upsilon}
-\newvar\vphi{\phi}
-\newvar\vvarphi{\varphi}
-\newvar\vchi{\chi}
-\newvar\vpsi{\psi}
-\newvar\vomega{\omega}
-
-\newvar\vGamma{\Gamma}
-\newvar\vDelta{\Delta}
-\newvar\vTheta{\Theta}
-\newvar\vLambda{\Lambda}
-\newvar\vXi{\Xi}
-\newvar\vPi{\Pi}
-\newvar\vSigma{\Sigma}
-\newvar\vUpsilon{\Upsilon}
-\newvar\vPhi{\Phi}
-\newvar\vPsi{\Psi}
-\newvar\vOmega{\Omega}
+\NewObject\MyVar\va{a}
+\NewObject\MyVar\vb{b}
+\NewObject\MyVar\vc{c}
+\NewObject\MyVar\vd{d}
+\NewObject\MyVar\ve{e}
+\NewObject\MyVar\vf{f}
+\NewObject\MyVar\vg{g}
+\NewObject\MyVar\vh{h}
+\NewObject\MyVar\vi{i}
+\NewObject\MyVar\vj{j}
+\NewObject\MyVar\vk{k}
+\NewObject\MyVar\vl{l}
+\NewObject\MyVar\vm{m}
+\NewObject\MyVar\vn{n}
+\NewObject\MyVar\vo{o}
+\NewObject\MyVar\vp{p}
+\NewObject\MyVar\vq{q}
+\NewObject\MyVar\vr{r}
+\NewObject\MyVar\vs{s}
+\NewObject\MyVar\vt{t}
+\NewObject\MyVar\vu{u}
+\NewObject\MyVar\vv{v}
+\NewObject\MyVar\vw{w}
+\NewObject\MyVar\vx{x}
+\NewObject\MyVar\vy{y}
+\NewObject\MyVar\vz{z}
+
+\NewObject\MyVar\vA{A}
+\NewObject\MyVar\vB{B}
+\NewObject\MyVar\vC{C}
+\NewObject\MyVar\vD{D}
+\NewObject\MyVar\vE{E}
+\NewObject\MyVar\vF{F}
+\NewObject\MyVar\vG{G}
+\NewObject\MyVar\vH{H}
+\NewObject\MyVar\vI{I}
+\NewObject\MyVar\vJ{J}
+\NewObject\MyVar\vK{K}
+\NewObject\MyVar\vL{L}
+\NewObject\MyVar\vM{M}
+\NewObject\MyVar\vN{N}
+\NewObject\MyVar\vO{O}
+\NewObject\MyVar\vP{P}
+\NewObject\MyVar\vQ{Q}
+\NewObject\MyVar\vR{R}
+\NewObject\MyVar\vS{S}
+\NewObject\MyVar\vT{T}
+\NewObject\MyVar\vU{U}
+\NewObject\MyVar\vV{V}
+\NewObject\MyVar\vW{W}
+\NewObject\MyVar\vX{X}
+\NewObject\MyVar\vY{Y}
+\NewObject\MyVar\vZ{Z}
+
+\NewObject\MyVar\valpha{\alpha}
+\NewObject\MyVar\vvaralpha{\varalpha}
+\NewObject\MyVar\vbeta{\beta}
+\NewObject\MyVar\vgamma{\gamma}
+\NewObject\MyVar\vdelta{\delta}
+\NewObject\MyVar\vepsilon{\epsilon}
+\NewObject\MyVar\vvarepsilon{\varepsilon}
+\NewObject\MyVar\vzeta{\zeta}
+\NewObject\MyVar\veta{\eta}
+\NewObject\MyVar\vtheta{\theta}
+\NewObject\MyVar\viota{\iota}
+\NewObject\MyVar\vkappa{\kappa}
+\NewObject\MyVar\vlambda{\lambda}
+\NewObject\MyVar\vmu{\mu}
+\NewObject\MyVar\vnu{\nu}
+\NewObject\MyVar\vxi{\xi}
+\NewObject\MyVar\vpi{\pi}
+\NewObject\MyVar\vvarpi{\varpi}
+\NewObject\MyVar\vrho{\rho}
+\NewObject\MyVar\vsigma{\sigma}
+\NewObject\MyVar\vtau{\tau}
+\NewObject\MyVar\vupsilon{\upsilon}
+\NewObject\MyVar\vphi{\phi}
+\NewObject\MyVar\vvarphi{\varphi}
+\NewObject\MyVar\vchi{\chi}
+\NewObject\MyVar\vpsi{\psi}
+\NewObject\MyVar\vomega{\omega}
+
+\NewObject\MyVar\vGamma{\Gamma}
+\NewObject\MyVar\vDelta{\Delta}
+\NewObject\MyVar\vTheta{\Theta}
+\NewObject\MyVar\vLambda{\Lambda}
+\NewObject\MyVar\vXi{\Xi}
+\NewObject\MyVar\vPi{\Pi}
+\NewObject\MyVar\vSigma{\Sigma}
+\NewObject\MyVar\vUpsilon{\Upsilon}
+\NewObject\MyVar\vPhi{\Phi}
+\NewObject\MyVar\vPsi{\Psi}
+\NewObject\MyVar\vOmega{\Omega}
\end{lstlisting}
Just like~\lstinline!\vf!, these can all be regarded as functions, so~\lstinline!\va{\vb}!~produces~\( \va{\vb} \).
@@ -489,7 +582,7 @@ $\vf[par=\bigg]{\vx}$,
$\vf[par=\Bigg]{\vx}$,
$\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!:
+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}$
\end{LTXexample}
@@ -504,29 +597,34 @@ $\vf['''] = \vf[prime,prime,prime]$
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!novaluekeys!
+ \lstinline!singlekeys!
\qquad\qquad and \qquad\qquad
\lstinline!valuekeys!.
\end{center}
-In short, \lstinline!novaluekeys! is for keys that do \emph{not} take a value (i.e.~keys using the syntax~\lstinline!\command[key]!), and \lstinline!valuekeys! is for keys that \emph{do} take a value
-(i.e.~keys using the syntax~\lstinline!\command[key=value]!)).
+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}
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!novaluekeys!:
+We add this key using the key \lstinline!singlekeys!,
+which is for keys that do not take a value:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{inv}{ upper={-1} },
},
}
\end{lstlisting}
-\setupclass{var}{
-novaluekeys={
+\SetupClass\MyVar{
+singlekeys={
{inv}{ upper={-1} },
},
}
@@ -538,19 +636,17 @@ $\va[inv]$, $\vf[inv]$,
$\vg[1,2,inv]$,
$\vh[\va,\vb,inv]$
\end{LTXexample}
-The key \lstinline!novaluekeys! is for keys that take no value,
-like \lstinline!inv!.
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!novaluekeys! and \lstinline!valuekeys!.
+%to a class: \lstinline!singlekeys! and \lstinline!valuekeys!.
%The difference is that
For instance, suppose we want a command for deriving a function \( n \)~times.
-For this, we add the following extra keyval key~\lstinline!der!:
+For this, we add the key~\lstinline!der!:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{inv}{ upper={-1} },
},
valuekeys={
@@ -558,58 +654,55 @@ For this, we add the following extra keyval key~\lstinline!der!:
},
}
\end{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{der}{ upper={(#1)} },
},
}
The~\lstinline!#1! will contain whatever the
-user added as the value of the key.
+user wrote as the value of the key.
Now we can write:
\begin{LTXexample}
$\vf[der=\vn]{\vx}$
\end{LTXexample}
-Maybe we also want a more elementary operation:
-raising a variable to some \emph{power}.
-We could have called the key \lstinline!power!, but this is long and cumbersome, so let us simply call it \lstinline!to!:
+Maybe we also want a more elementary key~\lstinline!power! for raising a variable to a power:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{inv}{ upper={-1} },
},
valuekeys={
{der}{ upper={(#1)} },
- {to}{ upper={#1} },
+ {power}{ upper={#1} },
},
}
\end{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
- {to}{ upper={#1} },
+ {power}{ upper={#1} },
},
}
This allows us to write
\begin{LTXexample}
-$\vx[to=2]$,
-$\vy[1,to=2] + \vy[2,to=2]$
+$\vx[power=2]$,
+$\vy[1,power=2] + \vy[2,power=2]$
\end{LTXexample}
-In the long run, you might want to define a command~\lstinline!squared! or~\lstinline!sq! and make it equivalent to~\lstinline!to=2!.
-Let us try doing something a bit more complicated: Adding a key for restricting a function to a smaller subset.
+Let us try doing something a bit more complicated: adding a key for restricting a function to a smaller subset.
For this, we do the following:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{inv}{ upper={-1} },
},
valuekeys={
{der}{ upper={(#1)} },
- {to}{ upper={#1} },
+ {power}{ upper={#1} },
{res}{ return,symbolputright={|}, lower={#1} },
},
}
\end{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{res}{ return,symbolputright={|}, lower={#1} },
},
@@ -626,54 +719,56 @@ $\vg[1,res=\vY]{\vy}$,
$\vh[inv,res=\vT]{\vz}$
\end{LTXexample}
-If the reader starts playing around with the \semantex functions, they will discover that whenever you apply a function to something, the result becomes a new function that can take an argument itself. This behaviour is both useful and extremely necessary in order for the package to be useful in practice. For instance, you may write
+If the reader starts playing around with the \semantex functions, they will discover that whenever you apply a function to something, the result becomes a new function that can take an argument itself (this is why we wrote~\lstinline!output=\MyVar! in the definition of the class~\lstinline!\MyVar!). This behaviour is both useful and extremely necessary in order for the package to be useful in practice. For instance, you may write
\begin{LTXexample}
$\vf[der=\vn]{\vx}{\vy}{\vz}
=\vg{\vu,\vv,\vw}[3]{
- \vx[1],\vx[2]}[8,1,der=2]{\vt}$
+ \vx[1],\vx[2]}[8,1,der=2]{
+ \vt}$
\end{LTXexample}
-Some people prefer to be able to scale the restriction
-line. I rarely do that, but for that purpose, we could do the following:
+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{var}{
+\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, sparsize=auto, otherspar=.\vert,
- sparsize=normal, lower={#1} },
- % This auto scales the vertical bar. See the chapter on the spar
- % key for information about sparsize and otherspar
+ {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
},
}
\end{lstlisting}
-So to sum up, we first defined a class~\lstinline!var!
-via \lstinline!\newvariableclass! and then used \lstinline!\setupclass! to add keys to it. In fact, we could have done it all at once by passing these options directly to \lstinline!\newvariableclass!:
+So to sum up, we first defined a class~\lstinline!\MyVar!
+via \lstinline!\NewVariableClass! and then used \lstinline!\SetupClass! to add keys to it. In fact, we could have done it all at once by passing these options directly to \lstinline!\NewVariableClass!:
\begin{lstlisting}
- \newvariableclass{var}[
- output=var,
- novaluekeys={
- {inv}{ upper={-1} },
- },
- valuekeys={
- {der}{ upper={(#1)} },
- {to}{ upper={#1} },
- {res}{ rightreturn, symbolputright={|},
- lower={#1} },
- },
- ]
+\NewVariableClass\MyVar[
+ output=\MyVar, % This means that the output of an object
+ % of class \MyVar is also of class \MyVar
+ singlekeys={
+ {inv}{ upper={-1} },
+ },
+ valuekeys={
+ {der}{ upper={(#1)} },
+ {power}{ upper={#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!var!. However, when you set up your own system, you may as well just add all of the keys like this when you create the class and then be done with it.
+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 \lstinline!parent=myclass! in the class declaration to tell that \lstinline!myclass! 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!var! that has all the keyval syntax and only use subclasses for further \emph{customization}. We shall see examples of this below.
\chapter{Example: Elementary algebra}
-\setupclass{var}{
- novaluekeys={
- {pol}{
+\SetupClass\MyVar{
+ singlekeys={
+ {poly}{
par, % This tells semantex to use parentheses around
% the argument in the first place, in case this
% had been turned off
@@ -682,13 +777,13 @@ Let me add that it is possible to create subclasses of existing classes. You jus
},
}
-Let us try to use the \semantex system to build some commands
+Let us try to use \semantex to build some commands
for doing algebra.
-As an algebraist, one of the first things you might want to do is to create polynomial rings~\( \vk[pol]{\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:
+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{var}{
- novaluekeys={
- {pol}{
+\SetupClass\MyVar{
+ singlekeys={
+ {poly}{
par, % This tells semantex to use parentheses around
% the argument in the first place, in case this
% had been turned off
@@ -699,13 +794,13 @@ 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[pol]{\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{var}{
- novaluekeys={
- {pol}{
+\SetupClass\MyVar{
+ singlekeys={
+ {poly}{
par, % This tells semantex to use parentheses around
% the argument in the first place, in case this
% had been turned off
@@ -718,8 +813,8 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{field}{
par,
leftpar=(,rightpar=),
@@ -727,13 +822,13 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge
},
}
Now \lstinline!\vk[field]{\vx,\vy,\vz}! produces~\( \vk[field]{\vx,\vy,\vz} \). Of course, leaving out the \lstinline!field!
-key would produce the same result with the current configuration of~\lstinline!var!. However, it is still best to use a key for this, both because this makes the semantics more clear, but also because you might later change some settings that would cause the default behaviour to be different.
+key would produce the same result with the current configuration of the class~\lstinline!\MyVar!. However, it is still best to use a key for this, both because this makes the semantics more clear, but also because you might later change some settings that would cause the default behaviour to be different.
-Adding support for free algebras and fields is almost as easy, but there is a catch:
+Adding support for free algebras, power series, and Laurent series is almost as easy, but there is a catch:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
- {pol}{
+\SetupClass\MyVar{
+ singlekeys={
+ {poly}{
par, % This tells semantex to use parentheses around
% the argument in the first place, in case this
% had been turned off
@@ -756,18 +851,18 @@ Adding support for free algebras and fields is almost as easy, but there is a ca
{laurent}{
par,
leftpar=(, rightpar=),
- prearg={\!\!\noexpand\semantexdelimsize(},
- postarg={\noexpand\semantexdelimsize)\!\!},
+ prearg={\!\!\noexpand\SemantexDelimiterSize(},
+ postarg={\noexpand\SemantexDelimiterSize)\!\!},
% These are printed before and after the argument.
- % The command "\semantexdelimsize" is substituted
+ % The command "\SemantexDelimiterSize" is substituted
% by \big, \Big, ..., or whatever size the
% argument delimiters have
},
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{freealg}{
par,
leftpar=\noexpand\langle,
@@ -781,10 +876,10 @@ Adding support for free algebras and fields is almost as easy, but there is a ca
{laurent}{
par,
leftpar=(, rightpar=),
- prearg={\!\!\noexpand\semantexdelimsize(},
- postarg={\noexpand\semantexdelimsize)\!\!},
+ prearg={\!\!\noexpand\SemantexDelimiterSize(},
+ postarg={\noexpand\SemantexDelimiterSize)\!\!},
% These are printed before and after the argument.
- % The command "\semantexdelimsize" is substituted
+ % The command "\SemantexDelimiterSize" is substituted
% by \big, \Big, ..., or whatever size the
% argument delimiters have
},
@@ -803,8 +898,8 @@ $\vk[laurent]{\vz}$
Let us look at some other algebraic operations that we can control via \semantex:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{op}{upper={\noexpand\mathrm{op}}},
% opposite groups, rings, categories, etc.
{algclosure}{overline},
@@ -835,8 +930,8 @@ Let us look at some other algebraic operations that we can control via \semantex
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{op}{upper={\noexpand\mathrm{op}}},
% opposite groups, rings, categories, etc.
{algclosure}{overline},
@@ -887,7 +982,7 @@ does not yield a satisfactory result. However, the \lstinline!spar! key saves th
\begin{LTXexample}
$\vf[der=\vn,spar,inv]$
\end{LTXexample}
-So \lstinline!spar! simply adds a pair of parentheses around the current symbol, complete with all indices that you may have added to it so for. The name \lstinline!spar! stands for \enquote{symbol parentheses}. You can add as many as you like:
+So \lstinline!spar! simply adds a pair of parentheses around the current symbol, complete with all indices that you may have added to it so far. The name \lstinline!spar! stands for \enquote{symbol parentheses}. You can add as many as you like:
\begin{LTXexample}
$ \vf[1,res=\vV,spar,conj,op,spar,0,inv,spar,mod=\vI,spar,dual]{\vx} $
\end{LTXexample}
@@ -907,18 +1002,73 @@ So returning to the above example, we can write
\begin{LTXexample}
$\vf[1,res=\vV,spar,conj,op,spar=\big,0,inv,spar=\Big,mod=\vI,spar=\bigg,dual]{\vx}$
\end{LTXexample}
-To adjust the type of parentheses, use the \lstinline!leftspar! and \lstinline!rightspar! keys:
+To adjust the type of brackets, use the \lstinline!leftspar! and \lstinline!rightspar! keys:
\begin{LTXexample}
$\vf[leftspar={[},rightspar={\}},spar,spar=\Bigg]$
\end{LTXexample}
-Occassionally, it is useful to be able to input a particular kind of parentheses just once,
-without adjusting any settings. For this purpose, we have the (previously mentioned)
-\lstinline!otherspar!~key. It uses the syntax~\lstinline!otherspar={opening parenthesis}{closing parenthesis}!:
+Occassionally, it is useful to be able to input a particular kind of brackets just once,
+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⟩}
+\end{lstlisting}
+Let us see them in action:
\begin{LTXexample}
$\vf[otherspar={[}{)},otherspar={\{}{\rangle},
- spar]$
+ Otherspar={\langle}{\rangle}{\Bigg},spar]$
\end{LTXexample}
+\chapter{The \texorpdfstring{\texttt{$\backslash$⟨Class⟩}}{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
+want to write expressions like
+\[
+ \MyVar{\vf\circ\vg}[spar,der=\vn]{\vx}.
+\]
+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⟩!.
+So the above equation can be written
+\begin{LTXexample}
+$\MyVar{\vf\circ\vg}[
+ spar,der=\vn]{\vx}$
+\end{LTXexample}
+More generally, when you crate the class~\lstinline!\⟨Class⟩!,
+you can use it as a command with the following syntax:
+\begin{lstlisting}
+\⟨Class⟩{⟨symbol⟩}[⟨options⟩]⟨usual syntax of class⟩
+\end{lstlisting}
+
+\chapter{The \texttt{return} keys}\label{ch:return}
+
+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,
+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.
+
+However, there are other times when this behaviour is not what you want.
+For instance, if you want to comjugate the inverse of a function, the following looks wrong:
+\begin{LTXexample}
+$\vf[inv,conj]$
+\end{LTXexample}
+Therefore, there is a command \lstinline!return! that can be applied at any point to invoke the routine of adding all indices and commands to the symbol. Let us try it out:
+\begin{LTXexample}
+$\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!.
+
\chapter{The \texttt{command} key}
@@ -932,21 +1082,21 @@ 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:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{overline}{command=\noexpand\overline},
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{overline}{command=\noexpand\overline},
},
}
-This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!automathvariable! instead. We need the key \lstinline!\noexpand! in order for everything to expand properly. This is only necessary for some commands, and to tell the truth, I haven't quite figured out the system of which commands need it and which ones do not. However, as usual, if something does not work, try throwing in some \lstinline!\noexpand!'s and see if it solves the problem.
+This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!\SemantexVariable! instead. We need the key \lstinline!\noexpand! in order for everything to expand properly. This is only necessary for some commands, and to tell the truth, I haven't quite figured out the system of which commands need it and which ones do not. However, as usual, if something does not work, try throwing in some \lstinline!\noexpand!'s and see if it solves the problem.
Here are some more examples of predefined keys that use the command key:
\begin{lstlisting}
-\setupclass{var}{ % do not add these -- they are already predefined!
+\SetupClass\MyVar{ % do not add these -- they are already predefined!
novalueskeys={
{smash}{command=\noexpand\smash},
{tilde}{command=\noexpand\tilde},
@@ -965,141 +1115,116 @@ $\va[roman]$,
$\va[bar]$
\end{LTXexample}
-\chapter{The \texttt{return} keys}\label{ch:return}
-
-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 do not normally 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,
-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.
-
-However, there are other times when this behaviour is not what you want.
-For instance, if you want to comjugate the inverse of a function, the following looks wrong:
-\begin{LTXexample}
-$\vf[inv,conj]$
-\end{LTXexample}
-Therefore, there is a command \lstinline!return! that can be applied at any point to invoke the routine of adding all indices and commands to the symbol. Let us try it out:
-\begin{LTXexample}
-$\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!.
\chapter{Example: Algebraic geometry}
Let us discuss how to typeset sheaves and operations on morphisms in algebraic geometry.
First of all, adding commands for sheaves is not a big deal:
\begin{lstlisting}
-\newvar\sheafF{\mathcal{F}}
-\newvar\sheafG}{\mathcal{G}}
-\newvar\sheafH{\mathcal{H}}
-\newvar\sheafO{\mathcal{O}}
-\newvar\sheafHom{\mathcal{H}\!\!om}
+\NewObject\MyVar\sheafF{\mathcal{F}}
+\NewObject\MyVar\sheafG}{\mathcal{G}}
+\NewObject\MyVar\sheafH{\mathcal{H}}
+\NewObject\MyVar\sheafreg{\mathcal{O}}
+ % sheaf of regular functions
+\NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}}
\end{lstlisting}
You can of course add as many sheaf commands as you need.
-Also, to make notations shorter, you could consider
-calling the commands~\lstinline!\shF!, \lstinline!\shG!, \lstinline!\shH!, \lstinline!\shO!, and~\lstinline!\shHom! instead, as I usually do.
-You may also want to have a separate command~\lstinline!shreg!
-for the sheaf~\( \sheafO \)
-of regular functions.
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!var! key:
+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{var}{
- novaluekeys={
- {comor}{upper=\#},
+\SetupClass\MyVar{
+ singlekeys={
+ {comorphism}{upper=\#},
% comorphisms, i.e. f^{\#}
{inverseimage}{upper={-1},nopar},
% inverse image of sheaves
- {shpull}{upper=*,nopar},
+ {sheafpull}{upper=*,nopar},
% sheaf *-pullback
- {shpush}{lower=*,nopar},
+ {sheafpush}{lower=*,nopar},
% sheaf *-pushforward
- {sh!pull}{upper=!,nopar},
+ {sheaf!pull}{upper=!,nopar},
% sheaf !-pullback
- {sh!push}{lower=!,nopar},
+ {sheaf!push}{lower=!,nopar},
% sheaf !-pushforward
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
- {comor}{upper=\#},
+\SetupClass\MyVar{
+ singlekeys={
+ {comorphism}{upper=\#},
% comorphisms, i.e. f^{\#}
{inverseimage}{upper={-1},nopar},
% inverse image of sheaves
- {shpull}{upper=*,nopar},
+ {sheafpull}{upper=*,nopar},
% sheaf *-pullback
- {shpush}{lower=*,nopar},
+ {sheafpush}{lower=*,nopar},
% sheaf *-pushforward
- {sh!pull}{upper=!,nopar},
+ {sheaf!pull}{upper=!,nopar},
% sheaf !-pullback
- {sh!push}{lower=!,nopar},
+ {sheaf!push}{lower=!,nopar},
% sheaf !-pushforward
},
}
-We have added the command \lstinline!nopar! to all pullback and pushforward commands since it is custom to write, say,~\( \vf[shpull]{\sheafF} \) rather than~\( \vf[shpull,par]{\sheafF} \). Of course, you can decide that for yourself, and in any case, you can write~\lstinline!\vf[shpull,par]{\shF}! if you want to force it to use parentheses in a particular case. Of course, since all \semantex variables can be used as functions, so can whatever these pullback and pushforward operations output. So we may write:
+We have added the command \lstinline!nopar! to all pullback and pushforward commands since it is custom to write, say,~\( \vf[sheafpull]{\sheafF} \) rather than~\( \vf[sheafpull,par]{\sheafF} \). Of course, you can decide that for yourself, and in any case, you can write~\lstinline!\vf[sheafpull,par]{\sheafF}! if you want to force it to use parentheses in a particular case. Of course, since all \semantex variables can be used as functions, so can whatever these pullback and pushforward operations output. So we may write:
\begin{LTXexample}
For a morphism~$ \vf \colon
\vX \to \vY $ with
-comorphism~$ \vf[comor]
-\colon \sheafO[\vY] \to
-\vf[shpush]{\sheafO[\vX]} $,
+comorphism~$ \vf[comorphism]
+\colon \sheafreg[\vY] \to
+\vf[sheafpush]{\sheafreg[\vX]} $,
and for a sheaf~$ \sheafF $ on~$ \vY $, we can define the
-pullback~$ \vf[shpull]{
+pullback~$ \vf[sheafpull]{
\sheafF} $ by letting~$
-\vf[shpull]{ \sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$
-\vf[sh!pull]{\sheafF}{\vU} = \cdots $.
+\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 other things in math called pullbacks, so I prefer to use the \lstinline!sh!~prefix to show that this is for sheaves.
+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.
Probably, in the long run, an algebraic geometer might also want
to abbreviate~\lstinline!inverseimage! to~\lstinline!invim!.
There are a number of other operations we might want to do for sheaves. We already defined the key~\lstinline!res! for restriction, so there is no need to define this again.
However, we might need to stalk, sheafify, take dual sheaves, and twist sheaves. Let us define keys for this:
\begin{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{stalk}{clower={#1}},
- {twist}{return,symbolputright={(#1)}},
+ % "clower" means "comma lower", i.e. lower index
+ % separated from any previous lower index by a comma
+ {sheaftwist}{return,symbolputright={(#1)}},
},
- novaluekeys={
+ singlekeys={
{sheafify}{upper=+},
- {shdual}{upper=\vee},
+ {sheafdual}{upper=\vee},
},
}
\end{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{stalk}{clower={#1}},
- {twist}{return,symbolputright={(#1)}},
+ % "clower" means "comma lower", i.e. lower index
+ % separated from any previous lower index by a comma
+ {sheaftwist}{return,symbolputright={(#1)}},
},
- novaluekeys={
+ singlekeys={
{sheafify}{upper=+},
- {shdual}{upper=\vee},
+ {sheafdual}{upper=\vee},
},
}
-The key \lstinline!clower! stands for \enquote{comma-lower}.
+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=
\vp]$,
-$\sheafO[\vX,stalk=\vp]$,
+$\sheafreg[\vX,stalk=\vp]$,
$\sheafG[sheafify]$,
-$\vf[inverseimage]{\sheafO[
+$\vf[inverseimage]{\sheafreg[
\vY]}[spar,stalk=\vx]$
-$\sheafG[shdual]$,
-$\sheafO[\vX][twist=-1]$,
-$\sheafO[twist=1,shdual]$
+$\sheafG[sheafdual]$,
+$\sheafreg[\vX][sheaftwist=-1]$,
+$\sheafreg[sheaftwist=1,sheafdual]$
\end{LTXexample}
\chapter{Example: Homological algebra}
@@ -1108,18 +1233,18 @@ Before you venture into homological algebra, you should probably
define some keys for the standard constructions:
\begin{lstlisting}
-\newvar\Hom{\operatorname{Hom}}
-\newvar\Ext{\operatorname{Ext}}
-\newvar\Tor{\operatorname{Tor}}
+\NewObject\MyVar\Hom{\operatorname{Hom}}
+\NewObject\MyVar\Ext{\operatorname{Ext}}
+\NewObject\MyVar\Tor{\operatorname{Tor}}
\end{lstlisting}
-\newvar\Ext{\operatorname{Ext}}
-\newvar\Tor{\operatorname{Tor}}
+\NewObject\MyVar\Ext{\operatorname{Ext}}
+\NewObject\MyVar\Tor{\operatorname{Tor}}
Now the ability to easily print indices via the options key will come in handy:
\begin{LTXexample}
$\Hom[\vA]{\vM,\vN}$,
$\Ext[\vA]{\vM,\vN}$
\end{LTXexample}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{shift}{ return,symbolputright={ \relax [ {#1} ] } },
% \relax is necessary since otherwise [...] can
@@ -1128,7 +1253,7 @@ valuekeys={
}
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{var}{
+\SetupClass\MyVar{
valuekeys={
{shift}{ return,symbolputright={ \relax [ {#1} ] } },
% \relax is necessary since otherwise [...] can
@@ -1140,6 +1265,14 @@ Let us see that it works:
\begin{LTXexample}
$\vX\mapsto\vX[shift=\vn]$
\end{LTXexample}
+Finally, let us define a command for the differential (in the homolgoical algebra sense):
+\begin{lstlisting}
+\NewObject\MyVar\dif{d}[nopar]
+\end{lstlisting}%
+\NewObject\MyVar\dif{d}[nopar]%
+\begin{LTXexample}
+$\dif{\vx} = 0$
+\end{LTXexample}
\section{The keys \texttt{i = index} and \texttt{d = deg = degree}}
@@ -1148,7 +1281,7 @@ 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).
You can adjust this by writing
-\lstinline!gradingpos=upper! or~\lstinline!gradingpos=lower!.
+\lstinline!gradingposition=upper! or~\lstinline!gradingposition=lower!.
We already learned about the keys \lstinline!upper! and~\lstinline!lower!.
@@ -1167,29 +1300,29 @@ $\Hom[index=\vA,degree=0]$,
$\ho[index=\vDelta,degree=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 heave to write in the long run, so both keys have abbreviated equivalents:
+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}
+ \lstinline!d! = \lstinline!deg! = \lstinline!degree!
\end{center}
Let us see them in action:
\begingroup\begin{LTXexample}
$ \vX[d=3,i=\vk] $
-\setupobject\vX{
- gradingpos=lower
+\SetupObject\vX{
+ gradingposition=lower
}
$ \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 (We haven't seen the command \lstinline!\SetupObject! before, but I imagine you can guess what it does).
If you want to print a bullet as the degree, there is the predefined key~\lstinline!*! for this:
\begingroup\begin{LTXexample}
$ \vX[*] $
-\setupobject\vX{
- gradingpos=lower
+\SetupObject\vX{
+ gradingposition=lower
}
$ \vX[*] $
@@ -1199,8 +1332,8 @@ I guess it is also time to reveal that the previously mentioned shorthand notati
\begingroup\begin{LTXexample}
$ \vX[1] $
-\setupobject\vX{
- gradingpos=lower
+\SetupObject\vX{
+ gradingposition=lower
}
$ \vX[1] $
@@ -1212,8 +1345,8 @@ $\ho[\vDelta,d=1]$
\end{LTXexample}
-Note that the use of the short notations \lstinline!d! and~\lstinline!i! does not mean you cannot write e.g. \lstinline!\vx[d]! and~\lstinline!\vx[i]!.
-In fact, this is not the case:
+Note that the use of the short notations \lstinline!d! and~\lstinline!i! does not prevent you from writing \lstinline!\vx[d]! and~\lstinline!\vx[i]!.
+This still works fine:
\begin{LTXexample}
$\vf[i]$, $\vf[i=]$,
$\vf[d]$, $\vf[d=]$
@@ -1221,31 +1354,35 @@ $\vf[d]$, $\vf[d=]$
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!novaluekeys!.
+\lstinline!valuekeys! from \lstinline!singlekeys!.
-\section{The \texttt{cohomology} class type}
+\section{The \texorpdfstring{\texttt{Cohomology}}{Cohomology} class type}
Now homological algebra is hard unless we can do \emph{cohomology} and \emph{homology}. In principle, this is not hard
to do, as we can write e.g.~\lstinline!\vH[d=0]{\vX}! to get~\( \vH[d=0]{\vX} \).
However, some people might find it cumbersome to have to write~\lstinline!d=! every time you want to print an index.
This is probably the right time to reveal that \semantex supports multiple class \emph{types}.
-So far, we have been exclusively using the \lstinline!variable!
-class type, but there are several others.
-The first one we shall need is the \lstinline!cohomology! class type, which has a different input syntax that fits cohomology.
+So far, we have been exclusively using the \lstinline!Variable!
+class type, which is what you create when you apply the command~\lstinline!\NewVariableClass!.
+The first other class type we shall need is the \lstinline!Cohomology! class type, which has a different input syntax that fits cohomology.
Let us try to use it:
\begin{lstlisting}
-\newcohomologyclass{cohomology}[parent=var,gradingpos=upper]
+\NewCohomologyClass\MyCohomology[
+ parent=\MyVar,gradingposition=upper
+]
-\newcohomology\co{H}
+\NewObject\MyCohomology\co{H}
-\newcohomologyclass{homology}[parent=cohomology,gradingpos=lower]
+\NewCohomologyClass\MyHomology[
+ parent=\MyCohomology,gradingposition=lower
+]
-\newhomology\ho{H}
+\NewObject\MyHomology\ho{H}
\end{lstlisting}
The cohomology command~\lstinline!\co! in general works very much
-like a command of variable type. However, the input syntax is a bit different:
+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:
\begin{LTXexample}
@@ -1268,16 +1405,16 @@ Of course, you can define similar commands for cocycles, coboundaries, and all s
You might also want to implement feature like reduced cohomology, \v{C}ech cohomology,
and hypercohomology. This is quite easy with the \lstinline!command! key:
\begin{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{reduced}{command=\widetilde},
{cech}{command=\noexpand\check},
{hyper{command=\noexpand\mathbb},
},
}
\end{lstlisting}
-\setupclass{var}{
- novaluekeys={
+\SetupClass\MyVar{
+ singlekeys={
{reduced}{command=\widetilde},
{cech}{command=\noexpand\check},
{hyper}{command=\noexpand\mathbb},
@@ -1290,14 +1427,14 @@ $\co[cech]{*}$,
$\co[hyper,cech]{0}{\vX}$
\end{LTXexample}
-The cohomology class also provides a nice way
+The \lstinline!Cohomology! class type also provides a nice way
to implement derived functors:
\begin{lstlisting}
-\newcohomology\Lder{\mathbb{L}}[nopar]
-\newcohomology\Rder{\mathbb{R}}[nopar]
+\NewObject\MyCohomology\Lder{\mathbb{L}}[nopar]
+\NewObject\MyCohomology\Rder{\mathbb{R}}[nopar]
\end{lstlisting}
-\newcohomology\Lder{\mathbb{L}}[nopar]
-\newcohomology\Rder{\mathbb{R}}[nopar]
+\NewObject\MyCohomology\Lder{\mathbb{L}}[nopar]
+\NewObject\MyCohomology\Rder{\mathbb{R}}[nopar]
For instance, we can write
\begin{LTXexample}
$\Lder{\vi}{\vf}$,
@@ -1308,7 +1445,7 @@ Alternatively, the user might prefer to use keyval syntax
on the level of the function itself (\( \vf \)~in this case).
This can be done the following way:
\begin{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{Lder} {
innerreturn,leftreturn,
@@ -1319,7 +1456,7 @@ This can be done the following way:
symbolputleft=\noexpand\mathbb{R}^{#1},
},
},
- novaluekeys={
+ singlekeys={
{Lder} {
innerreturn,leftreturn,
symbolputleft=\noexpand\mathbb{L},
@@ -1331,7 +1468,7 @@ This can be done the following way:
},
}
\end{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
valuekeys={
{Lder} {
innerreturn,leftreturn,
@@ -1342,7 +1479,7 @@ This can be done the following way:
symbolputleft=\noexpand\mathbb{R}^{#1},
},
},
- novaluekeys={
+ singlekeys={
{Lder} {
innerreturn,leftreturn,
symbolputleft=\noexpand\mathbb{L},
@@ -1363,23 +1500,29 @@ $\Hom[Rder]{\vX,\vY}$
If you get tired of having to write \lstinline!\Hom[Rder]! all
the time, you can create a shortcut:
\begin{lstlisting}
-\newvar\RHom[copy=\Hom,Rder]
+\NewObject\MyVar\RHom[clone=\Hom,Rder]
\end{lstlisting}
-\newvar\RHom[copy=\Hom,Rder]
-The \lstinline!copy! key is like the \lstinline!parent! key,
+\NewObject\MyVar\RHom[clone=\Hom,Rder]
+The \lstinline!clone! key is like the \lstinline!parent! key,
except it allows you to inherit the settings from an \emph{object} rather than a \emph{class}. Notice that we did not specify a symbol; the symbol argument is optional, and in this case, it was unnecessary, as the symbol was inherited from~\lstinline!\Hom!. Let us see it in action:
\begin{LTXexample}
$\RHom{\vX,\vY}$
\end{LTXexample}
-\section{Keyval syntax in arguments (Example: Cohomology with coefficients)}
+\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)}
-\setupclass{var}{
+\SetupClass\MyVar{
argvaluekeys={
- {coef}{ sep={;}{#1} },
+ {coef}{ othersep={;}{#1} },
},
}
+\SetupObject\co{
+ valuekeys={
+ {arg}{argwithkeyval={#1}},
+ },
+}%
+
Imagine we want to do cohomology with coefficients in some ring~\( \vR \).
It is common to write this as~\( \co{*}{\vX,coef=\vR} \)
with a semicolon instead of a comma. This can be implemented, too, with the syntax
@@ -1389,20 +1532,20 @@ $\co{*}{\vX,coef=\vR}$
This shows that arguments of functions also support keyval syntax.
In order to customize this, there are two extra keys:
\begin{center}
-\lstinline!argnovaluekeys!
+\lstinline!argsinglekeys!
\qquad\qquad\text{and}\qquad\qquad
\lstinline!argvaluekeys!
\end{center}
-These work exactly like \lstinline!novaluekeys! and~\lstinline!valuekeys!.
+These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!.
\begin{lstlisting}
-\setupclass{var}{
+\SetupClass\MyVar{
argvaluekeys={
- {coef}{ sep={;}{#1} },
+ {coef}{ othersep={;}{#1} },
},
}
\end{lstlisting}
(But it will not quite work yet -- stay tuned for a moment!)
-The key \lstinline!sep! is a key that controls the separator
+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.
@@ -1410,7 +1553,7 @@ However, even with the above setup, the notation \lstinline!\co{*}{\vX,coef=\vR}
just yet. For the keys you define using \lstinline!argvaluekeys!
are turned off by default. To turn them on for the object~\lstinline!\co!, run the following code:
\begin{lstlisting}
-\setupobject\co{
+\SetupObject\co{
valuekeys={
{arg}{argwithkeyval={#1}},
},
@@ -1420,15 +1563,15 @@ The reason the keys are turned off by default is that keys in arguments that sup
every occurrence of an equality sign in arguments, and the following
would not work:
\begin{LTXexample}
-$\Hom[\sheafO[\vU]]{
+$\Hom[\sheafreg[\vU]]{
\sheafF[res=\vU],
\sheafG[res=\vU]
}$
\end{LTXexample}
It should be noted that there are several predefined
-keys (of type \mbox{\lstinline!novaluekey!)} which are defined on the level
-of the class \lstinline!semantexvariable!. The full list is:\fxfatal{Finish this}
+keys (of type \mbox{\lstinline!singlekey!)} which are defined on the level
+of the class \lstinline!\SemantexVariable!. The full list is:\fxfatal{Finish this}
\begin{itemize}
\item slot, \ldots
@@ -1436,41 +1579,68 @@ of the class \lstinline!semantexvariable!. The full list is:\fxfatal{Finish this
We should also talk about the \lstinline!arg! key.
-\section{The \texttt{binary} class type (Example: Derived tensor products and fibre products)}
+\chapter{Multi-value keys}
+
+\SetupClass\MyVar{
+ 2valuekeys={
+ {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } },
+ }
+}
-\newbinaryclass{binaryoperator}[
- novaluekeys={
+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 } },
+ }
+}
+\end{lstlisting}
+
+\begin{LTXexample}
+$\vX[projquotient={\vchi}{\vG}] $
+\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 \texttt{Simple} class type (Example: Derived tensor products and fibre products)}
+
+\NewSimpleClass\MyBinaryOperator[
+ singlekeys={
{Lder}{upper=L},
{Rder}{upper=R},
},
mathbin, % this makes sure that the output is wrapped in \mathbin
]
-\newbinaryoperator\tens{\otimes}[
- novaluekeys={
+\NewObject\MyBinaryOperator\tensor{\otimes}[
+ singlekeys={
{der}{Lder},
},
]
-\newbinaryoperator\fibre{\times}[
+\NewObject\MyBinaryOperator\fibre{\times}[
% Americans are free to call it \fiber instead
- novaluekeys={
+ singlekeys={
{der}{Rder},
},
]
-The \semantex system has facilities for printing tensor products~\( \tens \) as well as derived tensor products~\( \tens[der] \).
-For this, we need the \lstinline!binary! 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
+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.
+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}
-\command[options]
+\⟨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.)
Let us try to use it to define tensor products and fibre products:
\begin{lstlisting}
-\newbinaryclass{binaryoperator}[
- novaluekeys={
+\NewSimpleClass\MyBinaryOperator[
+ singlekeys={
{Lder}{upper=L},
{Rder}{upper=R},
},
@@ -1478,64 +1648,34 @@ Let us try to use it to define tensor products and fibre products:
% this makes sure that the output is wrapped in \mathbin
]
-\newbinaryoperator\tens{\otimes}[
- novaluekeys={
+\NewObject\MyBinaryOperator\tensor{\otimes}[
+ singlekeys={
{der}{Lder},
},
]
-\newbinaryoperator\fibre{\times}[
+\NewObject\MyBinaryOperator\fibre{\times}[
% Americans are free to call it \fiber instead
- novaluekeys={
+ singlekeys={
{der}{Rder},
},
]
\end{lstlisting}
As you see, this is one of the few cases where I recommend adding keyval
-syntax on the level of subclasses. Also, notice that it does not have any~\lstinline!parent=var!, as I do not really see any reason to inherit all the keyval syntax from the \lstinline!var!~class.
-Now we first define keys \lstinline!Lder! and~\lstinline!Rder! for left and right derived binary operators. Next, we build in a shortcut in both \lstinline!\tens! and~\lstinline!\fibre!
+syntax to other classes than your superclass~\lstinline!\MyVar!. Also, notice that it does not have any~\lstinline!parent=\MyVar!, as I do not really see any reason to inherit all the keyval syntax from the \lstinline!\MyVar!~class.
+Now we first define keys \lstinline!Lder! and~\lstinline!Rder! for left and right derived binary operators. Next, we build in a shortcut in both \lstinline!\tensor! and~\lstinline!\fibre!
so that we can write simply~\lstinline!der! and get the correct notion of derived functor. Let us see it in action:
\begin{LTXexample}
-$\vA \tens \vB$,
-$\vX[*] \tens[\vR] \vY[*]$
-$\vk \tens[\vA,der] \vk$,
+$\vA \tensor \vB$,
+$\vX[*] \tensor[\vR] \vY[*]$
+$\vk \tensor[\vA,der] \vk$,
$\vX \fibre[\vY,der] \vX$
\end{LTXexample}
-\chapter{The \texorpdfstring{\texttt{$\backslash$⟨classname⟩}}{classname} 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
-want to write expressions like
-\[
- \var{\vf\circ\vg}[spar,der=\vn]{\vx}.
-\]
-We do not want to have to define a new variable
-with symbol~\( \vf\circ\vg \) in order to write something like this.
-Fortunately, once you have created the class~\lstinline!var!,
-you get an extra command~\lstinline!\var! that has the following syntax
-\begin{lstlisting}
-\var{symbol}[options]{argument}
-\end{lstlisting}
-In other words, it allows you to create a variable on the spot and give in an arbitrary symbol. So the above equation can be written
-\begin{LTXexample}
-$\var{\vf\circ\vg}[
- spar,der=\vn]{\vx}$
-\end{LTXexample}
-More generally, whenever you create a class with name \lstinline!⟨classname⟩!, you automatically get a command
-named~\lstinline!\⟨classname⟩!.
-It has the same input syntax as the class in question,
-except that, as above, the first argument is the symbol:
-\begin{lstlisting}
-\⟨classname⟩{symbol}⟨usual syntax of class⟩
-\end{lstlisting}
-
-Actually, now might be the right time to reveal that the low-level machinery in \semantex does not actually see the difference between an object and a class. Yep, this is how it has been implemented, and there are probably some object-oriented purists who will say that this goes against some general programming philosophy nonsense. So when you create the class \lstinline!⟨classname⟩!, you really create the above object which has a special syntax. And now all other objects of that class simply inherit from this object. (As we saw from above, you can actually inherit from any object; you just write~\lstinline!copy=\objectname! instead of using \lstinline!parent!.)
-
\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 section, we were introduced to the \lstinline!cohomology! and the \lstinline!binary! 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}.
@@ -1547,84 +1687,84 @@ The current implementation has the following
class types:
\begin{itemize}
- \item \lstinline!variable!:
+ \item \lstinline!Variable!:
A new class is declared with the
syntax
\begin{lstlisting}
- \newvariableclass{⟨classname⟩}[options]
+ \NewVariableClass{\⟨Class⟩}[⟨options⟩]
\end{lstlisting}
A new object is declared by
\begin{lstlisting}
- \new⟨classname⟩\⟨objectname⟩{symbol}[options]
+ \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩]
\end{lstlisting}
The syntax for this object is
\begin{lstlisting}
- \⟨objectname⟩[options]{argument}
+ \⟨object⟩[⟨options⟩]{⟨argument⟩}
\end{lstlisting}
- \item \lstinline!cohomology!:
+ \item \lstinline!Cohomology!:
A new class is declared with the
syntax
\begin{lstlisting}
- \newcohomologyclassclass{⟨classname⟩}[options]
+ \NewCohomologyClass\⟨Class⟩[⟨options⟩]
\end{lstlisting}
A new object is declared by
\begin{lstlisting}
- \new⟨classname⟩\⟨objectname⟩{symbol}[options]
+ \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩]
\end{lstlisting}
The syntax for this object is
\begin{lstlisting}
- \⟨objectname⟩[options]{degree}{argument}
+ \⟨object⟩[⟨options⟩]{⟨degree⟩}{⟨argument⟩}
\end{lstlisting}
- \item \lstinline!binary!:
+ \item \lstinline!Simple!:
A new class is declared with the
syntax
\begin{lstlisting}
- \newdelimiterclass{⟨classname⟩}[options]
+ \NewSimpleClass\⟨Class⟩[⟨options⟩]
\end{lstlisting}
A new object is declared by
\begin{lstlisting}
- \new⟨classname⟩\⟨objectname⟩{left bracket}{right bracket}[options]
+ \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩]
\end{lstlisting}
The syntax for this object is
\begin{lstlisting}
- \⟨objectname⟩[options]{argument}
+ \⟨object⟩[⟨options⟩]{⟨argument⟩}
\end{lstlisting}
- \item \lstinline!delimiter!:
+ \item \lstinline!Delimiter!:
A new class is declared with the syntax
\begin{lstlisting}
- \newtupleclass{⟨classname⟩}[options]
+ \NewDelimiterClass\⟨Class⟩[⟨options⟩]
\end{lstlisting}
A new object is declared by
\begin{lstlisting}
- \new⟨classname⟩\⟨objectname⟩{left bracket}{right bracket}[options]
+ \NewObject\⟨Class⟩\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩]
\end{lstlisting}
The syntax for this object is
\begin{lstlisting}
- \⟨objectname⟩[options]{argument}
+ \⟨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.
+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.
-\chapter{The \texorpdfstring{\texttt{delimiter}}{delimiter} class type}
+\chapter{The \texorpdfstring{\texttt{Delimiter}}{Delimiter} class type}
-\newdelimiterclass{delim}[parent=var]
-\newdelim\norm{\lVert}{\rVert}
-\newdelim\inner{\langle}{\rangle}
+\NewDelimiterClass\MyDelim[parent=\MyVar]
+\NewObject\MyDelim\norm{\lVert}{\rVert}
+\NewObject\MyDelim\inner{\langle}{\rangle}
Delimiters are what they sound like: functions like \( \norm{slot} \) and~\( \inner{slot,slot} \)
-that are defined using brackets only. Let us define a class of type delimiter:
+that are defined using brackets only. Let us define a class of type \lstinline!Delimiter!:
\begin{lstlisting}
-\newdelimiterclass{delim}[parent=var]
+\NewDelimiterClass\MyDelim[parent=\MyVar]
\end{lstlisting}
-Now we get a command \lstinline!\newdelim! with the following syntax:
+Now we can create instances of the class~\lstinline!\MyDelim! with the following syntax:
\begin{lstlisting}
-\newdelim\⟨objectname⟩{left bracket}{right bracket}[options]
+\NewObject\MyDelim\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩
\end{lstlisting}
Now we can do the following:
\begin{lstlisting}
-\newdelim\norm{\lVert}{\rVert}
-\newdelim\inner{\langle}{\rangle}
+\NewObject\MyDelim\norm{\lVert}{\rVert}
+\NewObject\MyDelim\inner{\langle}{\rangle}
\end{lstlisting}
Indeed:
\begin{LTXexample}
@@ -1633,16 +1773,17 @@ $\inner{\va,\vb}$,
$\inner{slot,slot}$
\end{LTXexample}
We can also use it for more complicated constructions, like sets.
+The following is inspired from the \pack{mathtools} package where a similar construction is created using the commands from that package. My impression is that Lars Madsen is the main mastermind behind the code I use for the \lstinline!\where!~command:
\begin{lstlisting}
\newcommand\where{
\nonscript\:
- \semantexdelimsize\vert
+ \SemantexDelimiterSize\vert
\allowbreak
\nonscript\:
\mathopen{}
}
-\newdelim\Set{\lbrace}{\rbrace}[
+\NewObject\MyDelim\Set{\lbrace}{\rbrace}[
prearg={\,},postarg={\,},
% adds \, inside {...}, as recommended by D. Knuth
valuekeys={
@@ -1653,13 +1794,13 @@ We can also use it for more complicated constructions, like sets.
\end{lstlisting}
\newcommand\where{
\nonscript\:
- \semantexdelimsize\vert
+ \SemantexDelimiterSize\vert
\allowbreak
\nonscript\:
\mathopen{}
}
-\newdelim\Set{\lbrace}{\rbrace}[
+\NewObject\MyDelim\Set{\lbrace}{\rbrace}[
prearg={\,},postarg={\,},
% adds \, inside {...}, as recommended by D. Knuth
valuekeys={
@@ -1685,16 +1826,18 @@ $\Set{
Tuple-like commands are also possible:
\begin{lstlisting}
-\newdelim\tup{(}{)} % tuples
-\newdelim\pcoor{[}{]}[ % projective coordinates
- argsep=\mathpunct{:}, % changes the argument separator to :
- argdots=\cdots, % changes what is inserted if you write "..."
+\NewObject\MyDelim\tup{(}{)} % tuples
+\NewObject\MyDelim\pcoor{[}{]}[ % projective coordinates
+ setargsep=\mathpunct{:},
+ % changes the argument separator to colon
+ setargdots=\cdots,
+ % changes what is inserted if you write "..."
]
\end{lstlisting}
-\newdelim\tup{(}{)} % tuples
-\newdelim\pcoor{[}{]}[ % projective coordinates
- argsep=\mathpunct{:}, % changes the argument separator to :
- argdots=\cdots, % changes what is inserted if you write "..."
+\NewObject\MyDelim\tup{(}{)} % tuples
+\NewObject\MyDelim\pcoor{[}{]}[ % projective coordinates
+ setargsep=\mathpunct{:}, % changes the argument separator to :
+ setargdots=\cdots, % changes what is inserted if you write "..."
]
Let us see them in action:
\begin{LTXexample}
@@ -1704,178 +1847,381 @@ $\pcoor{\va,\vb,...,\vz}$
One can also use tuples for other, less obvious purposes, like calculus differentials:
\begin{lstlisting}
-\newdelimiterclass{calculusdifferential}[
- parent=var,
+\NewDelimiterClass\CalculusDifferential[
+ parent=\MyVar,
argvaluekeys={
- {default}{standardsep={d\!#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
+ % is a key that prints the value of the key with the
+ % standard argument separator in front.
},
- argdots=\cdots,
- ifpar=false,
+ setargdots=\cdots,
+ neverpar,
+ % neverpar is like nopar, except nopar will still print
+ % parentheses when there is more than one argument
+ % -- neverpar does not even print parentheses in this case
]
-\newcalculusdifferential\intD{(}{)}[argsep={\,},iffirstarg=false]
+\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},iffirstarg=false]
-\newcalculusdifferential\wedgeD{(}{)}[argsep=\wedge]
+\NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge]
\end{lstlisting}
-\newdelimiterclass{calculusdifferential}[
- parent=var,
+\NewDelimiterClass\CalculusDifferential[
+ parent=\MyVar,
argvaluekeys={
- {default}{standardsep={d\!#1}},
+ {default}{s={d\!#1}},
},
- argdots=\cdots,
- ifpar=false,
+ setargdots=\cdots,
+ neverpar,
+ % neverpar is like nopar, except nopar will still print
+ % parentheses when there is more than one argument
+ % -- neverpar does not even print parentheses in this case
]
-\newcalculusdifferential\intD{(}{)}[argsep={\,},iffirstarg=false]
+\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},ifnextargwithsep=false]
-\newcalculusdifferential\wedgeD{(}{)}[argsep=\wedge]
+\NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge]
\begin{LTXexample}
-$\int \vf \intD{\vx[1],\vx[2],...,\vx[n]}$,
+$\int \vf \intD{\vx[1],
+ \vx[2],...,\vx[n]}$,
-$\int \vf \wedgeD{\vx[1],\vx[2],...,\vx[n]}$
+$\int \vf \wedgeD{\vx[1],
+ \vx[2],...,\vx[n]}$
\end{LTXexample}
-\chapter{The \texttt{execute} and \texttt{parseoptions} keys}
+\chapter{The \texttt{parse} routine}
-As you can see above, \semantex has a ``waterfall-like'' behaviour. It parses 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!execute! and \lstinline!parseoptions!~keys.
+As you can see above, \semantex has a ``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.
-\newvar\Mat{\operatorname{Mat}}[
+
+
+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%
+\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} \)?
+Therefore, we do something like the following instead (we explain the notation below):
+\begin{lstlisting}
+\NewObject\MyVar\Mat{\operatorname{Mat}}[
execute={
- \semantexdataprovide{rows}
- \semantexdataprovide{columns}
+ \SemantexDataProvide{rows}
+ \SemantexDataProvide{columns}
+ % provides data sets for number of rows and columns
+ % for this object
},
valuekeys={
{rows}{
execute={
- \semantexdataset{rows}{#1}
+ \SemantexDataSet{rows}{#1}
},
},
{columns}{
execute={
- \semantexdataset{columns}{#1}
+ \SemantexDataSet{columns}{#1}
},
},
},
parseoptions={
execute={
- \semantexstrifeq{\semantexdatagetexpnot{columns}}{\semantexdatagetexpnot{rows}}
+ \SemantexStrIfEqTF{\SemantexDataGetExpNot{columns}}
+ {\SemantexDataGetExpNot{rows}}
+ % tests if rows = columns
{
- \semantexsetkeysx{
+ \SemantexKeysSetx{
lower={
- \semantexdatagetexpnot{columns}
+ \SemantexDataGetExpNot{columns}
}
}
}
{
- \semantexsetkeysx{
+ \SemantexKeysSetx{
lower={
- \semantexdatagetexpnot{rows}
+ \SemantexDataGetExpNot{rows}
\times
- \semantexdatagetexpnot{columns}
+ \SemantexDataGetExpNot{columns}
}
}
}
},
},
]
-
-Suppose we want to be able to write the set of \( \vn \times \vm \)-matrices with entries in~\( \vk \) as~\( \Mat[rows=\vn,columns=\vm]{\vk} \). We can in principle do the following:
-\begin{LTXexample}
-$ \Mat[\vn\times\vm]{\vk} $.
-\end{LTXexample}
-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~\( \Mat[\vn,\vm]{\vk} \)?
-Therefore, we do something like the following instead (we explain the notation below):
-\begin{lstlisting}
-\newvar\Mat{\operatorname{Mat}}[
+\end{lstlisting}%
+\NewObject\MyVar\Mat{\operatorname{Mat}}[
execute={
- \semantexdataprovide{rows}
- \semantexdataprovide{columns}
- % provides data sets for number of rows and columns
- % for this object
+ \SemantexDataProvide{rows}
+ \SemantexDataProvide{columns}
},
valuekeys={
{rows}{
execute={
- \semantexdataset{rows}{#1}
+ \SemantexDataSet{rows}{#1}
},
},
{columns}{
execute={
- \semantexdataset{columns}{#1}
+ \SemantexDataSet{columns}{#1}
},
},
},
parseoptions={
execute={
- \semantexstrifeq{\semantexdatagetexpnot{columns}}
- {\semantexdatagetexpnot{rows}}
- % tests if rows = columns
+ \SemantexStrIfEqTF{\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}}
{
- \semantexsetkeysx{
+ \SemantexKeysSetx{
lower={
- \semantexdatagetexpnot{columns}
+ \SemantexDataGetExpNot{columns}
}
}
}
{
- \semantexsetkeysx{
+ \SemantexKeysSetx{
lower={
- \semantexdatagetexpnot{rows}
+ \SemantexDataGetExpNot{rows}
\times
- \semantexdatagetexpnot{colums}
+ \SemantexDataGetExpNot{columns}
}
}
}
},
},
-]
-\end{lstlisting}
+]%
Now we can do the following:
\begin{LTXexample}
$ \Mat[rows=\vn,columns=\vm]{\vk} $, $ \Mat[rows=\vn,columns=\vn]{\vk} $
\end{LTXexample}
-The key~\lstinline!execute! is a key that basically just executes code. You can in principle write any \TeX\ code there, and it will be applied right at the spot. However, inside the \lstinline!execute!~key, you can also use the following locally defined commands. These can be used to handle the data that is associated with the object in question:
+The key~\lstinline!execute! is a key that basically just executes code. You can in principle write any \TeX\ code there, and it will be applied right at the spot. However, inside the \lstinline!execute!~key, you can also use the following locally defined commands. These can be used to handle the data that is associated with the object in question. I don't have time to document them right now, so you'll have to guess what they do from the name for now, or you can find their definition in the source code of the package.
\begin{lstlisting}
-\semantexdataprovide{name} % provides a data set with this name
-\semantexdataset{name}{value} % sets the data set
-\semantexdatasetx{name}{value} % sets the data set, but fully expands the argument
-\semantexdataputright{name}{value} % adds something to the right of the data set
-\semantexdataputrightx{name}{value} % the same, but fully expands first
-\semantexdataputleft{name}{value} % adds something to the left of the data set
-\semantexdataputleftx{name}{value} % the same, but fully expands first
-\semantexdataget{name}{value} % outputs the data set
-\semantexdatagetexpnot{name}{value} % outputs the data set wrapped in a \noexpand
-\semantexdataclear{name} % clears the data set
-\semantexsetkeys{keys} % sets keys
-\semantexsetkeysx{keys} % sets keys after expanding
-\semantexstrifeq{str1}{str2}{if true}{if false} % tests if str1 = str2
-\semantexboolprovide{name} % provides a boolean
-\semantexboolsettrue{name} % sets the boolean to true
-\semantexboolsetfalse{name} % sets the boolean to false
-\semantexboolif{name}{if true}{if false} % tests the boolean
+\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
+\SemantexIntIfPositiveTF
+\SemantexIntIfPositiveT
+\SemantexIntIfPositiveF
+\SemantexIntIfGreaterThanOneTF
+\SemantexIntIfGreaterThanOneT
+\SemantexIntIfGreaterThanOneF
+\SemantexExpNot
\end{lstlisting}
-The key~\lstinline!parseoptions! is a key that is executed right before rendering the object. This is where you write whatever the system is supposed to \emph{do} with the data sets you provide.
+The key~\lstinline!parseoptions! is a key that is executed right before rendering the object. This is where you write whatever the system is supposed to \emph{do} with the data sets you provide. You can also force it to be applied at any point by using the \lstinline!parse!~key.
-\chapter{Bugs}
+Let us look at a more complicated example: Let us create a command for partial derivatives:
+
+\NewObject\MyVar\partialdif[
+ nopar,
+ execute={
+ \SemantexBoolProvide{raisedfunction}
+ \SemantexBoolSetTrue{raisedfunction}
+ },
+ setidots=\cdots,
+ setisep=\,,
+ valuekeys={
+ {default}{
+ si={\partial #1},
+ },
+ },
+ singlekeys={
+ {raisedfunction}{
+ execute={
+ \SemantexBoolSetTrue{raisedfunction}
+ },
+ },
+ {noraisedfunction}{
+ execute={
+ \SemantexBoolSetFalse{raisedfunction}
+ },
+ },
+ },
+ parseoptions={
+ execute={
+ \SemantexIfBlankTF{ \SemantexDataGet{upper} }
+ {
+ \SemantexKeysSetx{
+ symbol={
+ \frac
+ {
+ \partial ^ { \SemantexIntGet{numberoflowerindices} }
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataGetExpNot{arg}
+ }
+ }
+ {
+ \SemantexDataGetExpNot{lower}
+ }
+ },
+ }
+ }
+ {
+ \SemantexKeysSetx{
+ symbol={
+ \frac
+ {
+ \partial ^ { \SemantexDataGet{upper} }
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataGetExpNot{arg}
+ }
+ }
+ {
+ \SemantexDataGetExpNot{lower}
+ }
+ },
+ }
+ }
+ \SemantexDataClear{lower}
+ \SemantexDataClear{upper}
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataClear{arg}
+ \SemantexIntClear{numberofarguments}
+ }
+ },
+ },
+]
-The most important current (known) bug happens if you create a variable whose symbol is a mathematical operator. For instance, write
\begin{lstlisting}
-\newvar\Int{\int}
+\NewObject\MyVar\partialdif[
+ nopar,
+ execute={
+ \SemantexBoolProvide{raisedfunction}
+ \SemantexBoolSetTrue{raisedfunction}
+ },
+ setidots=\cdots,
+ setisep=\,,
+ valuekeys={
+ {default}{
+ si={\partial #1},
+ },
+ },
+ singlekeys={
+ {raisedfunction}{
+ execute={
+ \SemantexBoolSetTrue{raisedfunction}
+ },
+ },
+ {noraisedfunction}{
+ execute={
+ \SemantexBoolSetFalse{raisedfunction}
+ },
+ },
+ },
+ parseoptions={
+ execute={
+ \SemantexIfBlankTF{ \SemantexDataGet{upper} }
+ {
+ \SemantexKeysSetx{
+ symbol={
+ \frac
+ {
+ \partial ^ { \SemantexIntGet{numberoflowerindices} }
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataGetExpNot{arg}
+ }
+ }
+ {
+ \SemantexDataGetExpNot{lower}
+ }
+ },
+ }
+ }
+ {
+ \SemantexKeysSetx{
+ symbol={
+ \frac
+ {
+ \partial ^ { \SemantexDataGet{upper} }
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataGetExpNot{arg}
+ }
+ }
+ {
+ \SemantexDataGetExpNot{lower}
+ }
+ },
+ }
+ }
+ \SemantexDataClear{lower}
+ \SemantexDataClear{upper}
+ \SemantexBoolIfT{raisedfunction}
+ {
+ \SemantexDataClear{arg}
+ \SemantexIntClear{numberofarguments}
+ }
+ },
+ },
+]
\end{lstlisting}
-\newvar\Int{\int}
-
+Let us see it in action:
\begin{LTXexample}
-$\int$ \\
-$\Int$ \\
-See the difference: \rlap{$\int$}$\Int$
+\[
+ \partialdif[\vx,\vy,\vz]{
+ \vf } ,
+ \partialdif[\vu^2,\vv^2,
+ d=4]{ \vf },
+ \partialdif[\vx[1],
+ \vx[2],...,\vx[\vn],
+ d=\vn]{ \vf }
+\]
+\[
+ \partialdif[\vx,\vy,\vz,noraisedfunction]{ \vf } ,
+ \partialdif[\vu^2,\vv^2,
+ d=4,noraisedfunction]{
+ \vf },
+ \partialdif[\vx[1],
+ \vx[2],...,\vx[\vn],
+ d=\vn,noraisedfunction]{
+ \vf }
+\]
\end{LTXexample}
-It turns out to be equivalent to the difference between
-\lstinline!$\int$! and~\lstinline!${}\int$!. In other words, this~\lstinline!{}!
-affects the spacing a tiny bit.
-I more or less know where this bug appears, but cannot really solve it without breaking the expansion somewhere else. Suggestions and advice are more than welcome! Then again, even if it affects the spacing a little bit, it still looks fine, only a bit different.
+As you see, we use the \lstinline!d!~key to tell the command what superscript it should put on the~\( \partial \) in the enumerator. If it does not receive a~\lstinline!d!, it counts the number of variables you wrote and prints that. That is why the following would give the wrong result:
+\begin{LTXexample}
+\[
+ \partialdif[\vu^2,\vv^2]{
+ \vf },
+ \partialdif[\vx[1],
+ \vx[2],...,\vx[\vn]]{
+ \vf }
+\]
+\end{LTXexample}
+
+\chapter{Bugs}
+
+Lots of things can be improved in the system, including the order in which things are being expanded internally. I am not going to explain this is detail for now, but hope to correct this in the future. For now, the system seems to work fine as long as you do \enquote{normal} things and insert~\lstinline!\noexpand!'s whenever something goes wrong. The only real bug that I currently know of occurs if you use the key~\lstinline!Othersep! 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?
%\input{testground}