Debian Codegraph @

texmf-dist/source/latex/moremath/moremath.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2024 Marcel Ilg
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 %
10 % https://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3 or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status ‘maintained’.
16 %
17 % The Current Maintainer of this work is Marcel Ilg.
18 %
19 % This work consists of the files listed in MANIFEST.md.
20 % \fi
21 %
22 % \iffalse
23 %
24 %<*driver>
25 % Generated by ctanbib
26 \begin{filecontents*}[overwrite]{\jobname.bib}
27 @preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" }
28 @manual{amsfonts,
29 title = {The \ctanbibpkgname{amsfonts} package},
30 subtitle = {TeX fonts from the American Mathematical Society},
31 author = {{The American Mathematical Society}},
32 url = {https://ctan.org/pkg/amsfonts},
33 urldate = {2024-07-04},
34 date = {},
35 version = {3.04},
36 }
37
38 @preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" }
39 @manual{amsmath,
40 title = {The \ctanbibpkgname{amsmath} package},
41 subtitle = {AMS mathematical facilities for LaTeX},
42 author = {{The LaTeX Project Team}},
43 url = {https://ctan.org/pkg/amsmath},
44 urldate = {2024-07-04},
45 date = {2023-05-13},
46 version = {2.17o},
47 }
48
49 @preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" }
50 @manual{bm,
51 title = {The \ctanbibpkgname{bm} package},
52 subtitle = {Access bold symbols in maths mode},
53 author = {Carlisle, David and Mittelbach, Frank and {The LaTeX Project Team}},
54 url = {https://ctan.org/pkg/bm},
55 urldate = {2024-07-04},
56 date = {2023-12-19},
57 version = {1.2f},
58 }
59
60 @preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" }
61 @manual{mathtools,
62 title = {The \ctanbibpkgname{mathtools} package},
63 subtitle = {Mathematical tools to use with amsmath},
64 author = {Høgholm, Morten and Madsen, Lars and Robertson, Will and Wright, Joseph and {The LaTeX Project Team}},
65 url = {https://ctan.org/pkg/mathtools},
66 urldate = {2024-07-04},
67 date = {2024-03-11},
68 version = {1.30},
69 }
70
71 @comment{Below are non-package References}
72
73 @article{package-rollback,
74 title = {A rollback concept for packages and classes},
75 author = {Frank Mitelbach},
76 year = {2018},
77 journaltitle = {TUGboat},
78 number = 2,
79 url = {https://www.latex-project.org/publications/2018-FMi-TUB-tb122mitt-version-rollback.pdf},
80 urldate = {2024-08-06},
81 }
82 \end{filecontents*}
83 \begin{filecontents*}[overwrite]{\jobname-ams-op-table.tex}
84 \begin{tabular}{rlrlrlrl}
85 \cs[module=amsmath,replace=false]{arccos} &\(\arccos\) &\cs[module=amsmath,replace=false]{deg} &\( \deg \) &\cs[module=amsmath,replace=false]{lg} &\( \lg \) &\cs[module=amsmath,replace=false]{projlim} &\( \projlim \)\\
86 \cs[module=amsmath,replace=false]{arcsin} &\(\arcsin\) &\cs[module=amsmath,replace=false]{det} &\( \det \) &\cs[module=amsmath,replace=false]{lim} &\( \lim \) &\cs[module=amsmath,replace=false]{sec} &\( \sec \)\\
87 \cs[module=amsmath,replace=false]{arctan} &\(\arctan\) &\cs[module=amsmath,replace=false]{dim} &\( \dim \) &\cs[module=amsmath,replace=false]{liminf} &\( \liminf \) &\cs[module=amsmath,replace=false]{sin} &\( \sin \)\\
88 \cs[module=amsmath,replace=false]{arg} &\(\arg\) &\cs[module=amsmath,replace=false]{exp} &\( \exp \) &\cs[module=amsmath,replace=false]{limsup} &\( \limsup \) &\cs[module=amsmath,replace=false]{sinh} &\( \sinh \)\\
89 \cs[module=amsmath,replace=false]{cos} &\(\cos\) &\cs[module=amsmath,replace=false]{gcd} &\( \gcd \) &\cs[module=amsmath,replace=false]{ln} &\( \ln \) &\cs[module=amsmath,replace=false]{sup} &\( \sup \)\\
90 \cs[module=amsmath,replace=false]{cosh} &\(\cosh\) &\cs[module=amsmath,replace=false]{hom} &\( \hom \) &\cs[module=amsmath,replace=false]{log} &\( \log \) &\cs[module=amsmath,replace=false]{tan} &\( \tan \)\\
91 \cs[module=amsmath,replace=false]{cot} &\(\cot\) &\cs[module=amsmath,replace=false]{inf} &\( \inf \) &\cs[module=amsmath,replace=false]{max} &\( \max \) &\cs[module=amsmath,replace=false]{tanh} &\( \tanh \)\\
92 \cs[module=amsmath,replace=false]{coth} &\(\coth\) &\cs[module=amsmath,replace=false]{injlim} &\(\injlim\) &\cs[module=amsmath,replace=false]{min} &\( \min \) & &\\
93 \cs[module=amsmath,replace=false]{csc} &\(\csc\) &\cs[module=amsmath,replace=false]{ker} &\(\ker\) &\cs[module=amsmath,replace=false]{Pr} &\( \Pr \) & &\\
94 \end{tabular}
95 \begin{center}
96 \begin{tabular}{rlrl}
97 \cs[module=amsmath,replace=false]{varinjlim} &\(\varinjlim\) &\cs[module=amsmath,replace=false]{varliminf} &\(\varliminf\)\\
98 \cs[module=amsmath,replace=false]{varprojlim} &\(\varprojlim\) &\cs[module=amsmath,replace=false]{varlimsup} &\(\varlimsup\)\\
99 \end{tabular}
100 \end{center}
101 \end{filecontents*}
102
103
104 % custom commands for use inside the documentation
105 \ExplSyntaxOn
106 % Property list storing version date information
107 \prop_new:N \l__moremathdoc_version_date_prop
108
109 \cs_new_protected:Nn \moremathdoc_add_version:nn
110 {
111 \prop_put_if_new:Nnn \l__moremathdoc_version_date_prop {#1} {#2}
112 }
113
114 \cs_new_protected:Nn \moremathdoc_get_version:n
115 {
116 \group_begin:
117 \prop_get:NnNT \l__moremathdoc_version_date_prop {#1} \l_tmpa_tl
118 {
119 \tl_use:N \l_tmpa_tl
120 }
121 \group_end:
122 }
123
124 \NewDocumentCommand \AddVersion { m m }
125 {
126 \moremathdoc_add_version:nn {#1} {#2}
127 }
128
129 \NewDocumentCommand \GetVersionDate { m }
130 {
131 \moremathdoc_get_version:n {#1}
132 }
133 \ExplSyntaxOff
134
135 \documentclass[%
136 %show-notes,%
137 ]{l3doc}
138
139 \SetupDoc{reportchangedates=true}
140 \RecordChanges
141
142 \usepackage[american]{babel}
143 \AddBabelHook[american]{nofrench}{afterextras}{\frenchspacing}
144
145 \usepackage[style=alphabetic]{biblatex}
146 \addbibresource{\jobname.bib}
147
148 \usepackage{csquotes}
149 \SetCiteCommand{\autocite}
150
151 \usepackage{amssymb}
152 \usepackage[bm]{moremath}
153
154 % renew the ctanbibpkgname command
155 \NewDocumentCommand\ctanbibpkgname{m}{\pkg{#1}}
156
157 % Example operators and commands
158 \DeclareMathOperator{\glorb}{glorb}
159 \DeclarePairedDelimiter{\inparen}{\lparen}{\rparen}
160 \DeclareDelimitedOperator{\pglorb}{\glorb}{\inparen}
161
162 \begin{document}
163 \DocInput{moremath.dtx}
164 \end{document}
165 %</driver>
166 % \fi
167 %
168 % ^^X Get the package version name etc.
169 % \GetFileInfo{moremath.sty}
170 %
171 % ^^X Register changes here
172 % \AddVersion{v0.1.0}{2024-06-28}
173 % \AddVersion{v0.2.0}{2024-07-04}
174 % \AddVersion{v0.3.0}{2024-07-08}
175 % \AddVersion{v0.4.0}{2024-07-15}
176 % \AddVersion{v0.5.0}{2024-08-20}
177 %
178 % ^^X Placeholder for unreleased versions
179 % \AddVersion{vUNRELEASED}{UNRELEASED}
180 %
181 % \begin{documentation}
182 %
183 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Initial development release}
184 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
185 % Split the documentation into several parts.
186 % }
187 % \changes{v0.4.0}{\GetVersionDate{v0.4.0}}{
188 % \textbf{Breaking Change:} Rename the package
189 % and the \meta{prefix} used for function names from
190 % "conmath" to "moremath".
191 % }
192 %
193 % \title{The \pkg{moremath} package\thanks{This document coresponds to
194 % \textsf{moremath}~\fileversion, dated \filedate.}}
195 %
196 % \author{Marcel Ilg\thanks{\texttt{mister01x (at) web (dot) de}}}
197 %
198 % \date{Released \filedate}
199 %
200 % \maketitle
201 %
202 % \begin{abstract}
203 % The \pkg{moremath} package provides several document level commands
204 % to ease the typesetting
205 % and \LaTeX{} code readability of certain mathematical constructs.
206 % It provides complementary commands to all operators defined by \pkg{amsmath},
207 % the commands typeset delimiters that may be automatically, manually or
208 % not scaled at all.
209 % The commands also accept optional sub- and superscripts to the operators.
210 %
211 % Furthermore it provides several commands to typeset gradient, divergence,
212 % curl, and Laplace operators,
213 % for which there are also versions with delimiters.
214 % Those commands also accept an optional subscript
215 % and their appearance can be modified using key-value options.
216 %
217 % Additionally commands are provided for producing row and column vectors,
218 % as well as (anti-)diagonal matrices,
219 % utilizing \pkg{mathtools} \env{matrix*} family of environments.
220 %
221 % Most of the document level commands defined by this package can also
222 % be disabled using a package load-time option to avoid clashes with
223 % commands defined by other packages.
224 % \end{abstract}
225 %
226 % \section*{Note: This Package is Still in its Initial Development Phase}
227 % Do not expect a stable interface until version 1.0.0 has been reached!
228 % While I try to keep the interface stable and backwards compatible,
229 % I am unable to promise this.
230 %
231 % \tableofcontents
232 %
233 % \part{Document Author Documentation}
234 % \label{pt:doc-auth}
235 %
236 % \section{Introduction}
237 % \label{sec:intro}
238 %
239 % When typesetting mathematics in \LaTeX{} it is very common to often encounter,
240 % code patterns such as |\sin \left( \frac{x}{2} \right)|.
241 % While this above code works as expected its not especially easy for human
242 % readers of this code to immediately understand what that code is going to
243 % do.
244 %
245 % This package tries to ease readability of such commonly used constructs
246 % by providing commands that (hopefully) increase readability,
247 % as well as speeding up writing math in \LaTeX{}.
248 % Using \pkg{moremath} the above code can be simplified to |\psin*{\frac{x}{2}}|,
249 % which is shorter and better \enquote{human readable}.
250 % The package also provides the possibility for users to define such delimited operators,
251 % on their own.
252 %
253 % There are also other things that can be improved when typesetting math.
254 % One prominent example is the typesetting of row and column vectors,
255 % which require the use of a \env{matrix} environment.
256 % For this case \pkg{moremath} provides commands which accept a comma separated
257 % list of vector entries,
258 % obliterating the need for a \env{matrix} environment to typeset vectors.
259 %
260 % The same goes for (anti-)diagonal matrices,
261 % only the elements of the diagonal are of importance here.
262 % Therefore the production of those matrices may also be simplified into a single command,
263 % which again improves readability of the code compared to a mostly empty \env{matrix} environment.
264 %
265 % Another feature of this package is the definition of several (delimited)
266 % vector calculus operators such as gradient, divergence and curl operators,
267 % this does not only improve the semantics of the math code
268 % (|\mathop{\nabla} f| vs.\ |\grad f|),
269 % but also tries to provide the correct spacing between the operator and its
270 % arguments.
271 %
272 % The \pkg{moremath} package is written using \LaTeX{}3
273 % and provides a small \LaTeX{}3 interface for class and package writers.
274 %
275 % The source code for \pkg{moremath} is hosted on GitHub at
276 % \begin{center}
277 % \url{https://github.com/Mister00X/moremath}
278 % \end{center}
279 % If you have any issues or found a bug, feel free to register an issue there.
280 %
281 % \section{Dependencies}
282 % \label{sec:deps}
283 %
284 % The main dependency of this package is \pkg{mathtools}~\autocite{mathtools}.
285 % Optionally the \pkg{bm}~\autocite{bm} may be loaded.
286 %
287 % If the option "no-vector" has \emph{not} been given as a package load time option,
288 % this package also loads the \pkg{amssymb}~\autocite{amsfonts} package.
289 %
290 % \section{Package Options}
291 % \label{sec:pack-opts}
292 %
293 % ^^X SUBSECTION: Package Load Time Options
294 % \subsection{Package Load Time Options}
295 % \label{sec:pkg-load-time-opts}
296 % The options described in this section \emph{must} be given
297 % at package load time i.e.\ as package options.
298 % All options which are not described below will be passed to
299 % \pkg{mathtools}~\autocite{mathtools},
300 % see its documentation for more information.
301 %
302 % \DescribeOption{bm} The \verb|bm| option
303 % loads the \pkg{bm}~\autocite{bm} package which provides a better version of
304 % the \cs{boldsymbol} command.
305 %
306 %
307 %
308 %
309 % The options
310 % \DescribeOption{no-vector} "no-vector",
311 % \DescribeOption{no-abs-shorthands} "no-abs-shorthands",
312 % \DescribeOption{no-operators} "no-operators",
313 % \DescribeOption{no-crvector} "no-crvector",
314 % and \DescribeOption{no-matrix} "no-matrix"
315 % disable the definition of the predefined commands described in sections~\ref{sec:vector-calculus},
316 % \ref{sec:shorthands},
317 % \ref{sec:delim-ops},
318 % \ref{sec:rc-vectors},
319 % and~\ref{sec:matrices}
320 % respectively.
321 %
322 % \DescribeOption{nopredef}
323 % The option |nopredef| achieves the same as the three
324 % |no-|\meta{functionality} options above.
325 % It accepts multiple values, valid option values are:
326 % |vector|,
327 % |abs|,
328 % |operators|,
329 % |crvector|,
330 % |matrix|,
331 % and |all|.
332 % The values
333 % |abs|,
334 % |operators|,
335 % and |vector|
336 % disable the predefined
337 % document level commands for
338 % delimited operators,
339 % vector calculus
340 % and the shorthands for absolute value and norm respectively.
341 % The values "crvector" and "matrix" disable the shorthand commands
342 % for row and column vectors, and simple matrices respectively.
343 % The special value |all| disables all of them.
344 %
345 % The option accepts multiple values which can be given as a comma separated
346 % list, or as multiple key-value options, like in the examples below:
347 % \begin{verbatim}
348 % \usepackage[nopredef={vector,abs,operators}]{moremath}
349 % \end{verbatim}
350 % This is equivalent to
351 % \begin{verbatim}
352 % \usepackage[nopredef=all]{moremath}
353 % \end{verbatim}
354 % and to:
355 % \begin{verbatim}
356 % \usepackage[nopredef=vector,nopredef=abs,nopredef=operators]{moremath}
357 % \end{verbatim}
358 %
359 % The command \cs{NewDelimitedOperator} is not affected by any of the above
360 % settings.
361 %
362 % ^^X SUBSECTION: General Options
363 % \subsection{General Options}
364 % \label{sec:pkg-general-options}
365 %
366 % The options described in this section
367 % \emph{must not} be given as package options,
368 % instead they should be set using \cs{moremathsetup}
369 % or given as optional argument to the commands described later.
370 % \begin{function}[updated = 2024-07-15]{\moremathsetup}
371 % \begin{syntax}
372 % \cs{moremathsetup}\marg{kv~list}
373 % \end{syntax}
374 % Sets the options specified in the \meta{key-value list},
375 % the assignment is local to the current group.
376 % If a \meta{value} contains a comma it needs to be wrapped in braces.
377 % This command may be used anywhere in the document after \pkg{moremath}
378 % has been loaded.
379 % \end{function}
380 %
381 % \subsubsection{Options Affecting Vector Calculus Operators}
382 % \label{sec:options-vec-calc}
383 %
384 % \DescribeOption{nabla}
385 % The option |nabla| sets the symbol to use by the document level commands
386 % described in section~\ref{sec:vector-calculus} to use for the nabla.
387 % It accepts a list of \meta{tokens}. Its default value is |\nabla|.
388 %
389 % \DescribeOption{arrownabla}
390 % The option |arrownabla| puts a small arrow over the gradient operator symbol.
391 % Its default value is |false|.
392 %
393 % \DescribeOption{boldnabla}
394 % The option |boldnabla| makes the nabla symbol bold.
395 % If the |bm| package option has been given the |\boldsymbol| command from
396 % the \pkg{bm} package is used for the bold symbol,
397 % otherwise the \pkg{amsmath}~\autocite{amsmath} version is used.
398 %
399 % \DescribeOption{grad-op}
400 % The option |grad-op| may be used to overwrite,
401 % the built in version of the gradient operator, it accepts a \meta{token list}.
402 % Use at your own responsibility.
403 %
404 % \DescribeOption{laplacian-symb}
405 % The option |laplacian-symb| sets the symbol to use by the document level
406 % commands described in section~\ref{sec:vector-calculus} to use for the
407 % Laplace operator. It accepts a list of \meta{tokens}.
408 %
409 % \DescribeOption{delta-laplace}
410 % The option |delta-laplace| replaces the Laplace operator symbol
411 % (by default \(\laplacian\)) with a uppercase delta
412 % (\(\laplacian[delta-laplace=true]\)).
413 % Its default value is |false|.
414 %
415 % \DescribeOption{arrowlaplace}
416 % The option |arrowlaplace| if set to |true| makes the Laplace operator look
417 % like this: \(\laplacian[arrowlaplace=true]\).
418 %
419 % \DescribeOption{laplacian}
420 % Like the option |grad-op| above the option |laplacian| may be used to
421 % overwrite the built-in version of the Laplace operator.
422 % Use at your own responsibility.
423 %
424 % \DescribeOption{dalembert-symb}
425 % Like the option "nabla" this sets the symbol to use by the document level
426 % commands described in section~\ref{sec:dalembert-op-cmds} to use as symbol
427 % for the \foreignlanguage{french}{d'Alembert} operator. It accepts a list of
428 % \meta{tokens}. It's default value is \cs[module=amssymb,replace=false]{square}.
429 %
430 % \DescribeOption{vcenter}
431 % The option "vcenter" controls if certain mathematical symbols
432 % of the operators described in section~\ref{sec:vector-calculus} should be
433 % vertically centered along the math-axis.
434 % The default value of this option is "true".
435 %
436 %
437 %
438 % \subsubsection{Options Affecting Matrices and Vectors}
439 % \label{sec:options-matrix}
440 %
441 % The options in this section only affect the commands described in sections~\ref{sec:rc-vectors}
442 % and~\ref{sec:matrices}. To set them with \cs{moremathsetup} it is necessary
443 % to add the prefix |matrix / | to these options,
444 % so that the resulting command looks like \cs{moremathsetup}\texttt{\{matrix / \meta{option}\}}.
445 % When using these options inside the optional argument of the commands described
446 % in sections~\ref{sec:rc-vectors} and~\ref{sec:matrices}, the prefix "matrix /"
447 % must be omitted.
448 %
449 % \DescribeOption{delimiter}
450 % The option |delimiter| determines the delimiters used for the matrices,
451 % valid values are "p" for parenthesis, "b" for brackets, "B" for braces,
452 % "v" for single vertical lines (\enquote{\(\vert\)}),
453 % "V" for double vertical lines (\enquote{\(\Vert\)}) or empty for no delimiters.
454 % The default value is "{}" (empty).
455 %
456 % \DescribeOption{fill}
457 % The fill option determines the values an (anti-)diagonal matrix is filled with,
458 % outside the diagonal. The default is again empty.
459 %
460 % \DescribeOption{align}
461 % This option determines the alignment of the numbers inside the matrix.
462 % The value of this option gets passed to the optional argument of the \env{matrix*}
463 % or \env{smallmatrix*} family of environments defined by \pkg{mathtools}~\autocite{mathtools}.
464 % Valid values for both types of those environments are |l| for left alignment,
465 % |r| for right alignment and |c| for centered alignment. The default is |c|.
466 %
467 % \begin{texnote}
468 % The non-"small" versions of the commands described in the sections~\ref{sec:rc-vectors}
469 % and~\ref{sec:matrices}, accept \textcquote{mathtools}{\textelp{}
470 % any column type valid in the usual \env{array} environment.}
471 % \end{texnote}
472 %
473 %
474 % \section{Delimited Operators}
475 % \label{sec:delim-ops}
476 %
477 % \subsection{Delimited Operators Predefined by \pkg{moremath}}
478 % \label{sec:delim-op-predef}
479 %
480 % \DescribeOption{no-operators}
481 % If the package load time option |no-operators| is not given this package defines several
482 % delimited mathematical operators.
483 %
484 % \begin{table}
485 % \caption{%
486 % Operator commands defined by the \pkg{amsmath}~\autocite{amsmath}
487 % package.}
488 % \label{tab:amsmath-operators}
489 % \vspace{.5\baselineskip}
490 % \input{\jobname-ams-op-table.tex}
491 % \end{table}
492 %
493 % \begin{function}{
494 % \parccos, \barccos, \Barccos, \varccos, \Varccos,
495 % }
496 % \begin{syntax}
497 % \cs{parccos} \oarg{size cmd} \marg{contents}
498
499 % \cs{parccos} \oarg{size cmd} \textasciicircum\marg{superscript} \marg{contents}
500 %
501 % \cs{parccos} \oarg{size cmd} \_\marg{subscript} \marg{contents}
502 %
503 % \cs{parccos} \oarg{size cmd} \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents}
504 %
505 % \cs{parccos}* \marg{contents}
506 %
507 % \cs{parccos}* \textasciicircum\marg{superscript} \marg{contents}
508 %
509 % \cs{parccos}* \_\marg{subscript} \marg{contents}
510 % \cs{parccos}* \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents}
511 %
512 %
513 % \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \marg{contents}
514 % \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \textasciicircum\marg{superscript} \marg{contents}
515 % \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \_\marg{subscript} \marg{contents}
516 % \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents}
517 % \cs[no-index]{\meta{prefix}\meta{op name}}* \marg{contents}
518 % \cs[no-index]{\meta{prefix}\meta{op name}}* \textasciicircum\marg{superscript} \marg{contents}
519 % \cs[no-index]{\meta{prefix}\meta{op name}}* \_\marg{subscript} \marg{contents}
520 % \cs[no-index]{\meta{prefix}\meta{op name}}* \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents}
521 % \end{syntax}
522 % For all of the operators predefined by \pkg{amsmath}~\autocite{amsmath},
523 % which are shown in table~\ref{tab:amsmath-operators},
524 % \pkg{moremath} declares delimited versions.
525 % The name of those commands follows the scheme \cs[no-index]{\meta{prefix}\meta{op}},
526 % where \meta{prefix} is one of |p|, |b|, |B|, |v|, or |V|
527 % and \meta{op} is the name of one of the operators shown in table~\ref{tab:amsmath-operators}.
528 %
529 % The \meta{prefix}es |p|, |b|, |B|, |v|, and |V| stand for
530 % parenthesis, brackets, braces, single vertical lines (\enquote{\(\vert\)}), and double vertical lines
531 % (\enquote{\(\Vert\)}) respectively.
532 %
533 % The commands accept a \meta{size cmd} optional argument, which is usually one of
534 % \cs{big}, \cs{Big}, \cs{bigg} and \cs{Bigg}.
535 % These \meta{size cmd}s are used to change the size of the delimiters.
536 %
537 % The commands also accept sub- and superscripts,
538 % which have to be issued \emph{after} the optional argument (if present),
539 % but before the mandatory argument \meta{contents}.
540 %
541 % The starred variant uses automatic scaling for the delimiters depending on the height of its contents.
542 % \end{function}
543 %
544 % \paragraph{Examples}
545 %
546 % The following examples showcase the use of those predefined delimited operators:
547 % \begin{enumerate}
548 % \item Different delimited operators without any scaling:
549 %
550 % \begin{verbatim}
551 % \[
552 % \pcos{x} \times \bcos{y}
553 % \times \Bcos{z} \times \vcos{a}
554 % \times \Vcos{b}
555 % \]
556 % \end{verbatim}
557 % \[
558 % \pcos{x} \times \bcos{y}
559 % \times \Bcos{z} \times \vcos{a}
560 % \times \Vcos{b}
561 % \]
562 %
563 % \item Delimited operator with automatic scaling:
564 %
565 % \begin{minipage}{.49\linewidth}
566 % \begin{verbatim}
567 % \[
568 % \pcos*{\frac{x^{2}}{2}}
569 % \]
570 % \end{verbatim}
571 % \end{minipage}\hfill
572 % \begin{minipage}{.49\linewidth}
573 % \[
574 % \pcos*{\frac{x^{2}}{2}}
575 % \]
576 % \end{minipage}
577 %
578 % \item Delimited operator with manual scaling:
579 %
580 % \begin{minipage}{.49\linewidth}
581 % \begin{verbatim}
582 % \[
583 % \pcos[\Big]{\frac{x^{2}}{2}}
584 % \]
585 % \end{verbatim}
586 % \end{minipage}\hfill
587 % \begin{minipage}{.49\linewidth}
588 % \[
589 % \pcos[\Big]{\frac{x^{2}}{2}}
590 % \]
591 % \end{minipage}
592 %
593 % \item Delimited operator with subscript:
594 %
595 % \begin{minipage}{.49\linewidth}
596 % \begin{verbatim}
597 % \[
598 % \plog_{10}{1+x}
599 % \]
600 % \end{verbatim}
601 % \end{minipage}\hfill
602 % \begin{minipage}{.49\linewidth}
603 % ^^X XXX: Using an underscore is broken here (because of l3doc???) therefore I
604 % ^^X use "\sb" instead.
605 % \[
606 % \plog\sb{10}{1+x}
607 % \]
608 % \end{minipage}
609 %
610 % \item Delimited operator with superscript:
611 %
612 % \begin{minipage}{.49\linewidth}
613 % \begin{verbatim}
614 % \[
615 % \pcos^{2}{x}
616 % \]
617 % \end{verbatim}
618 % \end{minipage}\hfill
619 % \begin{minipage}{.49\linewidth}
620 % \[
621 % \pcos^{2}{x}
622 % \]
623 % \end{minipage}
624 %
625 % \item Delimited operator with both sub- and superscript and manual scaling:
626 %
627 % \begin{minipage}{.49\linewidth}
628 % \begin{verbatim}
629 % \[
630 % \pcos[\Big]^{2}_{x}{\frac{x}{2}}
631 % \]
632 % \end{verbatim}
633 % \end{minipage}\hfill
634 % \begin{minipage}{.49\linewidth}
635 % ^^X XXX: Again use "\sb" instead of "_" because of l3doc
636 % \[
637 % \pcos[\Big]^{2}\sb{x}{\frac{x}{2}}
638 % \]
639 % \end{minipage}
640 % \end{enumerate}
641 %
642 %
643 % \subsection{Declaring New Delimited Operators}
644 % \label{sec:delim-op-new}
645 %
646 % \begin{function}{\DeclareDelimitedOperator}
647 % \begin{syntax}
648 % \cs{DeclareDelimitedOperator}\marg{new op}\marg{op}\marg{delim}
649 % \end{syntax}
650 % Creates a new delimited operator,
651 % the name of the new command will be \meta{new op}.
652 % The \meta{op} is the command of the operator to use,
653 % which is usually a command declared with
654 % \cs[module=amsmath,replace=false]{DeclareMathOperator}.
655 % \meta{delim} is the command to use as paired delimiter,
656 % it is expected to behave like a paired delimiter declared by
657 % \pkg{mathtools}~\autocite{mathtools}
658 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}.
659 % \end{function}
660 %
661 % \paragraph{Example: Creating a New Delimited Operator}
662 % The following code creates a new operator and a paired delimiter
663 % and uses it afterwards to declare a paired operator.
664 % \begin{verbatim}
665 % \documentclass{scrartcl}
666 %
667 % \DeclareMathOperator{\glorb}{glorb}
668 % \DeclarePairedDelimiter{\inparen}{\lparen}{\rparen}
669 % \DeclarePairedOperator{\pglorb}{\glorb}{\inparen}
670 %
671 % \begin{document}
672 % \[
673 % \pglorb{a}
674 % \]
675 % \end{document}
676 % \end{verbatim}
677 % The result then looks like this:
678 % \[
679 % \pglorb{a}
680 % \]
681 %
682 %
683 % \section{Vector Calculus Operators}
684 % \label{sec:vector-calculus}
685 %
686 % \DescribeOption{no-vector}
687 % The commands in this section are only declared if the option |no-vector|
688 % has not been given to the package as a load time option.
689 %
690 % \DescribeOption{vcenter}
691 % The option "vcenter" controls if the symbols for the operators described below
692 % should be vertically centered along the math axis. Its default value is "true".
693 %
694 % This option only shows its effects if other options like "arrownabla",
695 % "arrowlaplace", or "boldnabla" are set to "true".
696 % Like in the example below:
697 % \begin{quote}
698 % \begin{verbatim}
699 % \begin{gather*}
700 % \grad f(x) \quad \grad[arrownabla,vcenter=false] f(x)
701 % \quad \grad[arrownabla,vcenter=true] f(x)\\
702 % \laplacian f(x) \quad \laplacian[arrowlaplace,vcenter=false] f(x)
703 % \quad \laplacian[arrowlaplace,vcenter=true] f(x)
704 % \end{gather*}
705 % \end{verbatim}
706 % \begin{gather*}
707 % \grad f(x) \quad \grad[arrownabla,vcenter=false] f(x)
708 % \quad \grad[arrownabla,vcenter=true] f(x)\\
709 % \laplacian f(x) \quad \laplacian[arrowlaplace,vcenter=false] f(x)
710 % \quad \laplacian[arrowlaplace,vcenter=true] f(x)
711 % \end{gather*}
712 % \end{quote}
713 %
714 % All of the commands described in this section take key-value options
715 % as optional argument, which are described in section~\ref{sec:options-vec-calc}
716 %
717 % \subsection{Gradient Operator Commands}
718 % \label{sec:grad-op-cmds}
719 %
720 % \subsubsection{Standalone Operator Command}
721 % \label{sec:grad-op-standalone}
722 %
723 % \begin{function}[updated=2024-07-08]{
724 % \grad,
725 % }
726 % \begin{syntax}
727 % \cs{grad} \oarg{kv opts}
728 % \cs{grad} \oarg{kv opts} \_\marg{subscript}
729 % \end{syntax}
730 % The \cs{grad} command produces a gradient operator
731 % looking like this \enquote{\(\grad\)} by default.
732 % The optional argument \meta{kv opts} accepts the key-value options
733 % described in section~\ref{sec:options-vec-calc},
734 % whitespace between the command name
735 % and \oarg{kv~opts} is \emph{not allowed}.
736 % An optional subscript using "_" may be given after the optional argument.
737 % \end{function}
738 %
739 % \paragraph{Examples of Use}
740 % \begin{enumerate}
741 % \item Standalone gradient operator (with and without subscript):
742 %
743 % \begin{minipage}{.49\linewidth}
744 % \begin{verbatim}
745 % \[
746 % \grad f(x), \quad \grad_{x} f(x)
747 % \]
748 % \end{verbatim}
749 % \end{minipage}\hfill
750 % \begin{minipage}{.49\linewidth}
751 % \[
752 % \grad f(x), \quad \grad\sb{x} f(x)
753 % \]
754 % \end{minipage}
755 %
756 % \item Bold version of the gradient operator:
757 %
758 % \begin{minipage}{.49\linewidth}
759 % \begin{verbatim}
760 % \[
761 % \grad[boldnabla] f(x)
762 % \]
763 % \end{verbatim}
764 % \end{minipage}\hfill
765 % \begin{minipage}{.49\linewidth}
766 % \[
767 % \grad[boldnabla] f(x)
768 % \]
769 % \end{minipage}
770 %
771 % \item Gradient operator with an arrow:
772 %
773 % \begin{minipage}{.49\linewidth}
774 % \begin{verbatim}
775 % \[
776 % \grad[arrownabla] f(x)
777 % \]
778 % \end{verbatim}
779 % \end{minipage}
780 % \begin{minipage}{.49\linewidth}
781 % \[
782 % \grad[arrownabla] f(x)
783 % \]
784 % \end{minipage}
785 % \end{enumerate}
786 %
787 % \subsubsection{Operators with Delimiters}
788 % \label{sec:grad-op-delim}
789 %
790 % \begin{function}{
791 % \pgrad,
792 % \bgrad,
793 % \Bgrad,
794 % \vgrad,
795 % \Vgrad
796 % }
797 % \begin{syntax}
798 % \cs[no-index]{\meta{delim}grad} \oarg{size cmd} \marg{content}
799 % \cs[no-index]{\meta{delim}grad} \oarg{kv opts} \marg{content}
800 % \cs[no-index]{\meta{delim}grad} \oarg{size cmd} \_\marg{subscript} \marg{content}
801 % \cs[no-index]{\meta{delim}grad} \oarg{kv opts} \_\marg{subscript} \marg{content}
802 % \cs[no-index]{\meta{delim}grad}* \oarg{kv opts} \marg{content}
803 % \cs[no-index]{\meta{delim}grad}* \oarg{kv opts} \_\marg{subscript} \marg{content}
804 % \end{syntax}
805 % The \cs[no-index]{\meta{delim}grad} family of commands produces
806 % gradient operator which is followed by \meta{contents} inside delimiters.
807 % The delimiter is determined by the first letter of the command \meta{delim},
808 % which may be "p" for parenthesis, "b" for brackets, "B" for braces,
809 % "v" for a single vertical line (\enquote{\(\vert\)}), or "V" for a double
810 % vertical line (\enquote{\(\Vert\)}).
811 %
812 % The commands accept either a \meta{size command} as optional argument,
813 % which gets passed to \pkg{mathtools}~\autocite{mathtools} paired delimiter
814 % or a list of \meta{key-value option}s,
815 % the \meta{kv opts} \emph{must} be given using the complete syntax,
816 % i.e.\ \meta{key}"="\meta{value},
817 % shorthands for options with an implicit default value (|arrownabla|),
818 % will not work here.
819 % The \meta{size~command} is usually one of \cs{big}, \cs{Big}, \cs{bigg} and
820 % \cs{Bigg}.
821 % Valid \meta{kv opts} are all options described in section~\ref{sec:options-vec-calc}
822 % and the key "scale" which accepts a \meta{size cmd}.
823 %
824 % \begin{quote}
825 % \textbf{Note:}\\
826 % Do not mix \meta{kv opts} and \meta{size cmd},
827 % use either |\pgrad[\big]{f(x)}| or |\pgrad[arrownabla=true,scale=\big]{f(x)}|.
828 % \end{quote}
829 %
830 % \medskip\noindent
831 % An optional \meta{subscript} may be given between the optional argument,
832 % and \meta{contents}. One use case for this subscript is to write formulae
833 % using the so called Feynman-notation, where the gradient operator acts
834 % only on one variable.
835 %
836 % The starred version of the commands automatically scale the delimiters
837 % with its contents.
838 % \end{function}
839 %
840 % \paragraph{Examples:}
841 % \begin{enumerate}
842 % \item Gradient operator with non-scaled delimiters:
843 %
844 % \begin{minipage}{.49\linewidth}
845 % \begin{verbatim}
846 % \[
847 % \pgrad{1+\vec{x}}
848 % \]
849 % \end{verbatim}
850 % \end{minipage}\hfill
851 % \begin{minipage}{.49\linewidth}
852 % \[
853 % \pgrad{1+\vec{x}}
854 % \]
855 % \end{minipage}
856 %
857 % \item Bold version:
858 %
859 % \begin{minipage}{.49\linewidth}
860 % \begin{verbatim}
861 % \[
862 % \pgrad[boldnabla=true]{1+\vec{x}}
863 % \]
864 % \end{verbatim}
865 % \end{minipage}\hfill
866 % \begin{minipage}{.49\linewidth}
867 % \[
868 % \pgrad[boldnabla=true]{1+\vec{x}}
869 % \]
870 % \end{minipage}
871 %
872 % \item Gradient operator with automatically scaled delimiters:
873 %
874 % \begin{minipage}{.49\linewidth}
875 % \begin{verbatim}
876 % \[
877 % \pgrad*{\frac{1}{x}}
878 % \]
879 % \end{verbatim}
880 % \end{minipage}\hfill
881 % \begin{minipage}{.49\linewidth}
882 % \[
883 % \pgrad*{\frac{1}{x}}
884 % \]
885 % \end{minipage}
886 %
887 % \item Manually scaled version:
888 %
889 % \begin{minipage}{.49\linewidth}
890 % \begin{verbatim}
891 % \begin{gather*}
892 % \pgrad[\Big]{\frac{1}{x}}\\[.5ex]
893 % \pgrad[scale=\Big]{\frac{1}{x}}
894 % \end{gather*}
895 % \end{verbatim}
896 % \end{minipage}\hfill
897 % \begin{minipage}{.49\linewidth}
898 % \begin{gather*}
899 % \pgrad[\Big]{\frac{1}{x}}\\[.5ex]
900 % \pgrad[scale=\Big]{\frac{1}{x}}
901 % \end{gather*}
902 % \end{minipage}
903 %
904 % \item Feynman-notation:
905 %
906 % \begin{minipage}{.49\linewidth}
907 % \begin{verbatim}
908 % \[
909 % \pgrad_{x}{x+y+z}
910 % \]
911 % \end{verbatim}
912 % \end{minipage}\hfill
913 % \begin{minipage}{.49\linewidth}
914 % \[
915 % \pgrad\sb{x}{x+y+z}
916 % \]
917 % \end{minipage}
918 % \end{enumerate}
919 %
920 % \subsection{Divergence Operator Commands}
921 % \label{sec:div-op-cmds}
922 %
923 % \subsubsection{Standalone Operator Command}
924 % \label{sec:div-op-standalone}
925 %
926 % \begin{function}[updated=2024-07-08]{\divergence}
927 % \begin{syntax}
928 % \cs{divergence} \oarg{kv opts}
929 % \cs{divergence} \oarg{kv opts} \_\marg{subscript}
930 % \end{syntax}
931 % The \cs{divergence} command produces the divergence operator
932 % \enquote{\(\divergence\)},
933 % its usage is analogous to the use of the \cs{grad} command,
934 % which is described in section~\ref{sec:grad-op-standalone}.
935 % \end{function}
936 %
937 % \paragraph{Examples}
938 % \begin{enumerate}
939 % \item Standalone divergence operator
940 %
941 % \begin{minipage}{.49\linewidth}
942 % \begin{verbatim}
943 % \[
944 % \divergence f(x)
945 % \]
946 % \end{verbatim}
947 % \end{minipage}\hfill
948 % \begin{minipage}{.49\linewidth}
949 % \[\divergence f\]
950 % \end{minipage}
951 %
952 % \item Standalone divergence operator
953 % with an arrow over the gradient operator
954 %
955 % \begin{minipage}{.49\linewidth}
956 % \begin{verbatim}
957 % \[
958 % \divergence[arrownabla] f(x)
959 % \]
960 % \end{verbatim}
961 % \end{minipage}\hfill
962 % \begin{minipage}{.49\linewidth}
963 % \[\divergence[arrownabla] f(x)\]
964 % \end{minipage}
965 %
966 % \item Standalone divergence operator with subscript
967 %
968 % \begin{minipage}{.49\linewidth}
969 % \begin{verbatim}
970 % \[
971 % \divergence_{x} f(x)
972 % \]
973 % \end{verbatim}
974 % \end{minipage}\hfill
975 % ^^X We need to use \sb because of the subscript package
976 % \begin{minipage}{.49\linewidth}
977 % \[\divergence\sb{x} f(x)\]
978 % \end{minipage}
979 % \end{enumerate}
980 % \subsubsection{Operators with Delimiters}
981 % \label{sec:div-op-delim}
982 %
983 % \begin{function}{
984 % \pdiv,
985 % \bdiv,
986 % \Bdiv,
987 % \vdiv,
988 % \Vdiv
989 % }
990 % \begin{syntax}
991 % \cs[no-index]{\meta{delim}div} \oarg{size cmd} \marg{content}
992 % \cs[no-index]{\meta{delim}div} \oarg{kv opts} \marg{content}
993 % \cs[no-index]{\meta{delim}div} \oarg{size cmd} \_\marg{subscript} \marg{content}
994 % \cs[no-index]{\meta{delim}div} \oarg{kv opts} \_\marg{subscript} \marg{content}
995 % \cs[no-index]{\meta{delim}div}* \oarg{kv opts} \marg{content}
996 % \cs[no-index]{\meta{delim}div}* \oarg{kv opts} \_\marg{subscript} \marg{content}
997 % \end{syntax}
998 % The \cs[no-index]{\meta{delim}div} family of commands produces the divergence
999 % operator with its arguments placed inside delimiters.
1000 % The usage of these commands is analogous to the \cs[no-index]{\meta{delim}grad}
1001 % family of commands described in section~\ref{sec:grad-op-delim}.
1002 % \end{function}
1003 %
1004 % \paragraph{Examples}
1005 %
1006 % \begin{enumerate}
1007 % \item Divergence operator with parenthesis and no scaling
1008 %
1009 % \begin{minipage}{.49\linewidth}
1010 % \begin{verbatim}
1011 % \[
1012 % \pdiv{1+x}
1013 % \]
1014 % \end{verbatim}
1015 % \end{minipage}\hfill
1016 % \begin{minipage}{.49\linewidth}
1017 % \[\pdiv{1+x}\]
1018 % \end{minipage}
1019 % \item Bold version with manual scaling and subscript
1020 %
1021 % \begin{verbatim}
1022 % \[
1023 % \pdiv[boldnabla=true,scale=\Big]_{x}{1 + \frac{1}{x}}
1024 % \]
1025 % \end{verbatim}
1026 % \[\pdiv[boldnabla=true,scale=\Big]\sb{x}{1+\frac{1}{x}}\]
1027 %
1028 % \item Automatic scaling
1029 %
1030 % \begin{minipage}{.49\linewidth}
1031 % \begin{verbatim}
1032 % \[
1033 % \pdiv*{1 + \frac{1}{x}}
1034 % \]
1035 % \end{verbatim}
1036 % \end{minipage}\hfill
1037 % \begin{minipage}{.49\linewidth}
1038 % \[\pdiv*{1 + \frac{1}{x}}\]
1039 % \end{minipage}
1040 % \end{enumerate}
1041 %
1042 % \subsection{Curl Operator Commands}
1043 % \label{sec:curl-op-cmds}
1044 %
1045 % \subsubsection{Standalone Operator Command}
1046 % \label{sec:curl-op-standalone}
1047 %
1048 % \begin{function}[updated=2024-07-08]{\curl}
1049 % \begin{syntax}
1050 % \cs{curl} \oarg{kv opts}
1051 % \cs{curl} \oarg{kv opts} \_\marg{subscript}
1052 % \end{syntax}
1053 % The \cs{curl} command produces the curl operator \enquote{\(\curl\)},
1054 % its usage is analogous to the use of the \cs{grad} command
1055 % described in section~\ref{sec:grad-op-standalone}.
1056 % \end{function}
1057 %
1058 % \paragraph{Examples}
1059 % \begin{enumerate}
1060 % \item Standalone curl operator
1061 %
1062 % \begin{minipage}{.49\linewidth}
1063 % \begin{verbatim}
1064 % \[
1065 % \curl f(x)
1066 % \]
1067 % \end{verbatim}
1068 % \end{minipage}\hfill
1069 % \begin{minipage}{.49\linewidth}
1070 % \[\curl f(x)\]
1071 % \end{minipage}
1072 %
1073 % \item Standalone curl operator with an arrow over the gradient operator
1074 %
1075 % \begin{minipage}{.49\linewidth}
1076 % \begin{verbatim}
1077 % \[
1078 % \curl[arrownabla] f(x)
1079 % \]
1080 % \end{verbatim}
1081 % \end{minipage}\hfill
1082 % \begin{minipage}{.49\linewidth}
1083 % \[\curl[arrownabla] f(x)\]
1084 % \end{minipage}
1085 %
1086 % \item Standalone curl operator with subscript
1087 %
1088 % \begin{minipage}{.49\linewidth}
1089 % \begin{verbatim}
1090 % \[
1091 % \curl_{x} f(x,y)
1092 % \]
1093 % \end{verbatim}
1094 % \end{minipage}\hfill
1095 % \begin{minipage}{.49\linewidth}
1096 % \[\curl\sb{x} f(x,y)\]
1097 % \end{minipage}
1098 % \end{enumerate}
1099 %
1100 % \subsubsection{Operators with Delimiters}
1101 % \label{sec:curl-op-delim}
1102 %
1103 % \begin{function}{
1104 % \pcurl,
1105 % \bcurl,
1106 % \Bcurl,
1107 % \vcurl,
1108 % \Vcurl
1109 % }
1110 % \begin{syntax}
1111 % \cs[no-index]{\meta{delim}curl} \oarg{size cmd} \marg{content}
1112 % \cs[no-index]{\meta{delim}curl} \oarg{kv opts} \marg{content}
1113 % \cs[no-index]{\meta{delim}curl} \oarg{size cmd} \_\marg{subscript} \marg{content}
1114 % \cs[no-index]{\meta{delim}curl} \oarg{kv opts} \_\marg{subscript} \marg{content}
1115 % \cs[no-index]{\meta{delim}curl}* \oarg{kv opts} \marg{content}
1116 % \cs[no-index]{\meta{delim}curl}* \oarg{kv opts} \_\marg{subscript} \marg{content}
1117 % \end{syntax}
1118 % The \cs[no-index]{\meta{delim}curl} family of commands produce the curl operator
1119 % with its arguments placed inside delimiters.
1120 % The usage of these commands is analogous to the \cs[no-index]{\meta{delim}grad}
1121 % family of commmands described in section~\ref{sec:grad-op-delim}.
1122 % \end{function}
1123 %
1124 % \paragraph{Examples}
1125 % \begin{enumerate}
1126 % \item Curl operator with parenthesis without scaling
1127 %
1128 % \begin{minipage}{.49\linewidth}
1129 % \begin{verbatim}
1130 % \[
1131 % \pcurl{1+x}
1132 % \]
1133 % \end{verbatim}
1134 % \end{minipage}\hfill
1135 % \begin{minipage}{.49\linewidth}
1136 % \[\pcurl{1+x}\]
1137 % \end{minipage}
1138 %
1139 % \item Bold version with manual scaling and subscript
1140 %
1141 % \begin{verbatim}
1142 % \[
1143 % \pcurl[boldnabla=true,scale=\Big]_{x}{1 + \frac{1}{x}}
1144 % \]
1145 % \end{verbatim}
1146 % \[
1147 % \pcurl[boldnabla=true,scale=\Big]\sb{x}{1 + \frac{1}{x}}
1148 % \]
1149 %
1150 % \item Automatic scaling
1151 %
1152 % \begin{minipage}{.49\linewidth}
1153 % \begin{verbatim}
1154 % \[
1155 % \pcurl*{1 + \frac{1}{x}}
1156 % \]
1157 % \end{verbatim}
1158 % \end{minipage}\hfill
1159 % \begin{minipage}{.49\linewidth}
1160 % \[\pcurl*{1 + \frac{1}{x}}\]
1161 % \end{minipage}
1162 % \end{enumerate}
1163 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
1164 % Fixed example to match description.
1165 % }
1166 %
1167 %
1168 % \subsection{Laplace Operator Commands}
1169 % \label{sec:laplace-op-cmds}
1170 %
1171 % This section describes commands which can be used to typeset a Laplace
1172 % operator.
1173 %
1174 %
1175 % Like the commands described in sections~\ref{sec:grad-op-cmds},
1176 % \ref{sec:div-op-cmds}, and~\ref{sec:curl-op-cmds}
1177 % the commands in this section accept key-value options via an optional
1178 % argument.
1179 % There is some deviation from the options compared to the above commands:
1180 % The "arrownabla" option is ignored,
1181 % instead the "arrowlaplace" option produces an arrow over the operator.
1182 % The "boldnabla" option on the other hand is not ignored.
1183 % Finally the "delta-laplace" option replaces the symbol used
1184 % for the operator from \(\laplacian\) to \(\laplacian[delta-laplace]\)
1185 %
1186 % \subsubsection{Standalone Operator Command}
1187 % \label{sec:laplace-op-standalone}
1188 %
1189 %
1190 % \begin{function}[updated=2024-07-08]{\laplacian}
1191 % \begin{syntax}
1192 % \cs{laplacian} \oarg{kv opts}
1193 % \cs{laplacian} \oarg{kv opts} \_\marg{subscript}
1194 % \end{syntax}
1195 % The \cs{laplacian} command produces a Laplace operator,
1196 % which looks by default like this: \(\laplacian\).
1197 %
1198 % Its interface is analogous to the \cs{grad}, \cs{divergence},
1199 % and \cs{curl} commands described above,
1200 % with the difference in key-value options described at the start of this
1201 % subsection.
1202 % \end{function}
1203 %
1204 %
1205 % \subsubsection{Operators with Delimiters}
1206 % \label{sec:laplace-op-delim}
1207 %
1208 % \begin{function}{
1209 % \plaplacian,
1210 % \blaplacian,
1211 % \Blaplacian,
1212 % \vlaplacian,
1213 % \Vlaplacian
1214 % }
1215 % \begin{syntax}
1216 % \cs[no-index]{\meta{delim}laplacian} \oarg{size cmd} \marg{content}
1217 % \cs[no-index]{\meta{delim}laplacian} \oarg{kv opts} \marg{content}
1218 % \cs[no-index]{\meta{delim}laplacian} \oarg{size cmd} \_\marg{subscript} \marg{content}
1219 % \cs[no-index]{\meta{delim}laplacian} \oarg{kv opts} \_\marg{subscript} \marg{content}
1220 % \cs[no-index]{\meta{delim}laplacian}* \oarg{kv opts} \marg{content}
1221 % \cs[no-index]{\meta{delim}laplacian}* \oarg{kv opts} \_\marg{subscript} \marg{content}
1222 % \end{syntax}
1223 % \end{function}
1224 %
1225 % \paragraph{Examples}
1226 % \begin{enumerate}
1227 % \item Laplace operator delimited by parenthesis without scaling
1228 %
1229 % \begin{minipage}{.49\linewidth}
1230 % \begin{verbatim}
1231 % \[
1232 % \plaplacian{1+x}
1233 % \]
1234 % \end{verbatim}
1235 % \end{minipage}\hfill
1236 % \begin{minipage}{.49\linewidth}
1237 % \[\plaplacian{1+x}\]
1238 % \end{minipage}
1239 %
1240 % \item Version with arrow, manual scaling and subscript
1241 %
1242 % \begin{verbatim}
1243 % \[
1244 % \plaplacian[arrowlaplace=true,scale=\Big]_{x}{1 + \frac{1}{x}}
1245 % \]
1246 % \end{verbatim}
1247 % \[
1248 % \plaplacian[arrowlaplace=true,scale=\Big]\sb{x}{1 + \frac{1}{x}}
1249 % \]
1250 %
1251 % \item Version with automatic scaling
1252 %
1253 % \begin{minipage}{.49\linewidth}
1254 % \begin{verbatim}
1255 % \[
1256 % \plaplacian*{1 + \frac{1}{x}}
1257 % \]
1258 % \end{verbatim}
1259 % \end{minipage}\hfill
1260 % \begin{minipage}{.49\linewidth}
1261 % \[\plaplacian*{1 + \frac{1}{x}}\]
1262 % \end{minipage}
1263 %
1264 % \item Using a delta as symbol for the Laplacian
1265 %
1266 % \begin{minipage}{.49\linewidth}
1267 % \begin{verbatim}
1268 % \[
1269 % \plaplacian[delta-laplace=true]{1+x}
1270 % \]
1271 % \end{verbatim}
1272 % \end{minipage}\hfill
1273 % \begin{minipage}{.49\linewidth}
1274 % \[\plaplacian[delta-laplace=true]{1+x}\]
1275 % \end{minipage}
1276 % \end{enumerate}
1277 %
1278 %
1279 % \subsection{^^X
1280 % Commands Producing a \foreignlanguage{french}{d'Alembert} operator
1281 % }
1282 % \label{sec:dalembert-op-cmds}
1283 %
1284 % \subsubsection{Standalone Operator Command}
1285 % \label{sec:dalembert-op-standalone}
1286 %
1287 % \begin{function}[
1288 % added = 2024-07-04,
1289 % updated=2024-07-08,
1290 % ]{\quabla}
1291 % \begin{syntax}
1292 % \cs{quabla} \oarg{kv~opts}
1293 % \cs{quabla} \oarg{kv~opts} \_\marg{subscript}
1294 % \end{syntax}
1295 % The \cs{quabla} command produces
1296 % the \foreignlanguage{french}{d'Alembert} operator \enquote{\(\quabla\)}.
1297 % This command accepts an optional subscript.
1298 % \end{function}
1299 %
1300 % The command is called \cs{quabla} because thats shorter and easier to type than
1301 % \cs[no-index]{dalembertian}.
1302 % If you want to have a command called \cs[no-index]{dalembertian},
1303 % put the following in your documents preamble.
1304 % \begin{verbatim}
1305 % \NewCommandCopy\quabla\dalembertian
1306 % \end{verbatim}
1307 %
1308 % \paragraph{Example of Use:}
1309 % \begin{quote}
1310 % \begin{minipage}{.49\linewidth}
1311 % \begin{verbatim}
1312 % \[
1313 % \quabla f(x)
1314 % \]
1315 % \end{verbatim}
1316 % \end{minipage}\hfill
1317 % \begin{minipage}{.49\linewidth}
1318 % \[\quabla f(x)\]
1319 % \end{minipage}
1320 % \end{quote}
1321 %
1322 %
1323 % \subsubsection{Operators with Delimiters}
1324 % \label{sec:dalembert-op-delim}
1325 %
1326 % \begin{function}[added = 2024-07-04]{
1327 % \pquabla,
1328 % \bquabla,
1329 % \Bquabla,
1330 % \vquabla,
1331 % \Vquabla,
1332 % }
1333 % \begin{syntax}
1334 % \cs[no-index]{\meta{delim}quabla} \oarg{size~cmd} \marg{contents}
1335 % \cs[no-index]{\meta{delim}quabla} \oarg{kv~opts} \marg{contents}
1336 % \cs[no-index]{\meta{delim}quabla} \oarg{size~cmd} \_\marg{subscript} \marg{contents}
1337 % \cs[no-index]{\meta{delim}quabla} \oarg{kv~opts} \_\marg{subscript} \marg{contents}
1338 % \cs[no-index]{\meta{delim}quabla}* \oarg{kv~opts} \marg{contents}
1339 % \cs[no-index]{\meta{delim}quabla}* \oarg{kv~opts} \_\marg{subscript} \marg{contents}
1340 % \end{syntax}
1341 % The \cs[no-index]{\meta{delim}quabla} family of commands produce a
1342 % \foreignlanguage{french}{d'Alembert} operator with <contents> placed inside
1343 % delimiters.
1344 % Their usage is analogous to the \cs[no-index]{\meta{delim}grad} family of
1345 % commands described in section~\ref{sec:grad-op-delim}.
1346 % \end{function}
1347 %
1348 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
1349 % Fixed syntax description of standalone operators not matching reality.
1350 % }
1351 %
1352 %
1353 % \section{Row- and Column Vectors}
1354 % \label{sec:rc-vectors}
1355 %
1356 % \DescribeOption{no-crvector}
1357 % The command in this section are only declared if the option |no-crvector|
1358 % has not been given as a package option.
1359 %
1360 % ^^X \DescribeOption{delimiter}
1361 % ^^X \DescribeOption{fill}
1362 % ^^X \DescribeOption{align}
1363 % ^^X The commands in this section all accept key-value options as optional argument.
1364 % Valid keys are "delimiter", "fill", and "align",
1365 % their usage is described in section~\ref{sec:options-matrix}.
1366 %
1367 % \begin{function}[
1368 % updated=2024-08-20,
1369 % ]{
1370 % \cvector,
1371 % \rvector
1372 % }
1373 % \begin{syntax}
1374 % \cs{cvector} \oarg{kv opts} \marg{clist}
1375 % \cs{rvector} \oarg{kv opts} \marg{clist}
1376 % \end{syntax}
1377 % The commands \cs{cvector} and \cs{rvector} produce row and column vectors
1378 % respectively. Both of them accept key-value options as optional argument
1379 % \meta{kv opts}. Valid keys and values are described in section~\ref{sec:options-matrix}.
1380 %
1381 % The mandatory argument \meta{clist} is a comma-separated-list,
1382 % whose elements are the entries of the column/row vector.
1383 % If a comma has to appear inside an entry the entire entry has to be wrapped
1384 % in braces.
1385 %
1386 % The delimiter of the row or column vectors depends on the current value of
1387 % the option |delimiter|, by default empty. The option |fill| has no effect
1388 % on the commands and is simply ignored.
1389 %
1390 % \begin{texnote}
1391 % If you were to define your own \env{matrix*}-like environment
1392 % called \env{mymatrix*},
1393 % which has an interface compatible to \pkg{mathtools}'s \env{matrix*}
1394 % family of environments,
1395 % you could make use of it by setting the value of |delimiter| to |my|.
1396 % \end{texnote}
1397 % \end{function}
1398 %
1399 % \medbreak\noindent
1400 % \textbf{Examples:}
1401 % \begin{enumerate}
1402 % \item Column \enquote{vector} without delimiters:
1403 %
1404 % \begin{minipage}{.49\linewidth}
1405 % \begin{verbatim}
1406 % \[
1407 % \cvector{a_{1},a_{2},a_{3}}
1408 % \]
1409 % \end{verbatim}
1410 % \end{minipage}\hfill
1411 % \begin{minipage}{.49\linewidth}
1412 % \[
1413 % \cvector{a_{1},a_{2},a_{3}}
1414 % \]
1415 % \end{minipage}
1416 %
1417 % \item A column vectors delimited with parenthesis and different alignment:
1418 %
1419 % \begin{minipage}{.49\linewidth}
1420 % \begin{verbatim}
1421 % \[
1422 % \cvector[delimiter=p,align=c]{-1,2,3}
1423 % \]
1424 % \end{verbatim}
1425 % \end{minipage}\hfill
1426 % \begin{minipage}{.49\linewidth}
1427 % \[
1428 % \cvector[delimiter=p,align=c]{-1,2,3}
1429 % \]
1430 % \end{minipage}\\[1ex]
1431 % \begin{minipage}{.49\linewidth}
1432 % \begin{verbatim}
1433 % \[
1434 % \cvector[delimiter=p,align=r]{-1,2,3}
1435 % \]
1436 % \end{verbatim}
1437 % \end{minipage}\hfill
1438 % \begin{minipage}{.49\linewidth}
1439 % \[
1440 % \cvector[delimiter=p,align=r]{-1,2,3}
1441 % \]
1442 % \end{minipage}\\[1ex]
1443 % \begin{minipage}{.49\linewidth}
1444 % \begin{verbatim}
1445 % \[
1446 % \cvector[delimiter=p,align=l]{-1,2,3}
1447 % \]
1448 % \end{verbatim}
1449 % \end{minipage}\hfill
1450 % \begin{minipage}{.49\linewidth}
1451 % \[
1452 % \cvector[delimiter=p,align=l]{-1,2,3}
1453 % \]
1454 % \end{minipage}
1455 % \end{enumerate}
1456 %
1457 % \paragraph{Row- and Column Vectors with Predefined Delimiters}
1458 %
1459 % As vectors are commonly delimited by parenthesis, brackets, braces, etc.\
1460 % several shorthands producing delimited vectors are also available.
1461 % \begin{function}[updated=2024-08-20]{
1462 % \pcvector,
1463 % \bcvector,
1464 % \Bcvector,
1465 % \vcvector,
1466 % \Vcvector,
1467 % \prvector,
1468 % \brvector,
1469 % \Brvector,
1470 % \vrvector,
1471 % \Vrvector,
1472 % \prvector,
1473 % \brvector,
1474 % \Brvector,
1475 % \vrvector,
1476 % \Vrvector
1477 % }
1478 % \begin{syntax}
1479 % \cs[no-index]{\meta{delim}cvector} \oarg{kv opts} \marg{clist}
1480 % \cs[no-index]{\meta{delim}rvector} \oarg{kv opts} \marg{clist}
1481 % \end{syntax}
1482 % The \cs[no-index]{\meta{delim}\meta{c or r}vector} family of commands,
1483 % accepts a list of key-value options as optional argument \meta{kv opts}.
1484 % Valid keys are described in section~\ref{sec:options-matrix}.
1485 %
1486 % The mandatory argument \meta{clist} is a comma-separated-list of
1487 % the entries of the vector.
1488 % If a comma needs to appear inside an entry of the vector,
1489 % that entry has to be wrapped in braces.
1490 %
1491 % \meta{delim} may have the value "p" for parenthesis,
1492 % "b" for brackets, "B" for braces, "v" for a single vertical line,
1493 % or "V" for a double vertical line.
1494 % \end{function}
1495 %
1496 % \subparagraph{Example}
1497 % \begin{quote}
1498 % \begin{minipage}{.49\linewidth}
1499 % \begin{verbatim}
1500 % \[
1501 % \pcvector{a_{1},a_{2},a_{3}}
1502 % \]
1503 % \end{verbatim}
1504 % \end{minipage}\hfill
1505 % \begin{minipage}{.49\linewidth}
1506 % \[
1507 % \pcvector{a_{1},a_{2},a_{3}}
1508 % \]
1509 % \end{minipage}
1510 % \end{quote}
1511 %
1512 % \subsection{Small Versions for Inline Math}
1513 % \label{sec:rc-vectors-small}
1514 %
1515 % As the \env{matrix} and \env{matrix*} family of environments is unsuitable,
1516 % for inline math,
1517 % \pkg{mathtools}~\autocite{mathtools} provides the \env{smallmatrix}
1518 % and \env{smallmatrix*} family of environments.
1519 % This package provides analogous commands for row and column vectors
1520 % to be typeset in inline math mode.
1521 %
1522 % \begin{function}[
1523 % updated=2024-08-20,
1524 % ]{
1525 % \smallcvector,
1526 % \smallrvector
1527 % }
1528 % \begin{syntax}
1529 % \cs{smallcvector} \oarg{kv opts} \marg{clist}
1530 % \cs{smallrvector} \oarg{kv opts} \marg{clist}
1531 % \end{syntax}
1532 % \cs{smallcvector} and \cs{smallrvector} produce column and row vectors
1533 % suitable for inline math.
1534 % Both commands accept the same optional key-value arguments as
1535 % \cs{cvector} and \cs{rvector}.
1536 % \end{function}
1537 %
1538 %
1539 % \medbreak\noindent
1540 % \textbf{Example:}
1541 % \begin{quote}
1542 % \begin{verbatim}
1543 % An inline version of \verb|\cvector| looks like this
1544 % \(\smallcvector{1,0}\).
1545 % \end{verbatim}
1546 % An inline version of \verb|\cvector| looks like this
1547 % \(\smallcvector{1,0}\).
1548 % \end{quote}
1549 %
1550 % \begin{function}[updated=2024-08-20]{
1551 % \psmallcvector,
1552 % \bsmallcvector,
1553 % \Bsmallcvector,
1554 % \vsmallcvector,
1555 % \Vsmallcvector,
1556 % \psmallrvector,
1557 % \bsmallrvector,
1558 % \Bsmallrvector,
1559 % \vsmallrvector,
1560 % \Vsmallrvector,
1561 % }
1562 % \begin{syntax}
1563 % \cs{psmallcvector} \oarg{kv opts} \marg{clist}
1564 % \cs[no-index]{psmallrvector} \oarg{kv opts} \marg{clist}
1565 % \cs[no-index]{\meta{delim}small\meta{c or r}vector} \oarg{kv opts} \marg{clist}
1566 % \end{syntax}
1567 % The \cs[no-index]{\meta{delim}small\meta{c or r}vector} family of commands
1568 % like \cs{psmallcvector} produce small inline math version of row and column
1569 % vectors. Their interface is identical to the commands described above.
1570 % \end{function}
1571 %
1572 % \medbreak\noindent
1573 % \textbf{Example:}\nobreak
1574 % \begin{quote}
1575 % \begin{verbatim}
1576 % An inline version of \verb|\pcvector| looks like this
1577 % \(\psmallcvector{1,0}\).
1578 % \end{verbatim}
1579 % An inline version of \verb|\pcvector| looks like this
1580 % \(\psmallcvector{1,0}\).
1581 % \end{quote}
1582 %
1583 %
1584 % \section{Shorthands for Simple Matrices}
1585 % \label{sec:matrices}
1586 %
1587 % \DescribeOption{no-matrix}
1588 % The commands in this section are only defined if the option "no-matrix"
1589 % \emph{has not been given} to the package at load-time.
1590 %
1591 %
1592 % \subsection{(Anti-)diagonal Matrices}
1593 % \label{sec:diagonal-matrices}
1594 %
1595 % \begin{function}{
1596 % \diagmat,
1597 % \antidiagmat,
1598 % }
1599 % \begin{syntax}
1600 % \cs{diagmat} \oarg{kv opts} \marg{diagonal}
1601 % \cs{antidiagmat} \oarg{kv opts} \marg{diagonal}
1602 % \end{syntax}
1603 % \cs{diagmat} and \cs{antidiagmat} produce a diagonal or anti-diagonal matrix
1604 % respectively.
1605 % The optional argument \meta{kv~opts} accepts the key value options
1606 % described in section~\ref{sec:options-matrix}.
1607 %
1608 % The key "fill" determines the contents of the matrix entries
1609 % which are not part of the (anti-)diagonal,
1610 % its default value is |{}| i.e.\ empty.
1611 % The key "align" determines the alignment of the entries inside the
1612 % matrix, valid values are usually "l", "c", and "r",
1613 % the default is "c".
1614 % The key "delimiter" determines the delimiter around the matrix,
1615 % its default value is |{}| (none).
1616 % Valid values for the delimiters are "p" for parenthesis,
1617 % "b" for brackets, "B" for braces, "v" for a single vertical line
1618 % (\enquote{\(\vert\)}), and "V" for a double vertical line (\enquote{\(\Vert\)}).
1619 % See the \pkg{mathtools} manual~\autocite{mathtools} for more information.
1620 %
1621 % \begin{texnote}
1622 % The value of "delimiter" gets inserted inside the |\begin{#1matrix*}|
1623 % and |\end{#1matrix*}| commands.
1624 % Therefore it would be possible to define your own \env{matrix*}
1625 % like environment,
1626 % called for example \env{mymatrix*} and set "delimiter=my"
1627 % to make use of it.
1628 % \end{texnote}
1629 %
1630 % The mandatory argument \meta{diagonal} has to be a comma separated list
1631 % of the entries of the (anti-)diagonal.
1632 % If an entry of the diagonal needs to contain a comma "," the entire entry
1633 % has to be wrapped in braces.
1634 % \end{function}
1635 %
1636 % \medskip\noindent
1637 % \textbf{Examples:}
1638 % \begin{enumerate}
1639 % \item A diagonal and an anti-diagonal matrix without delimiters:
1640 %
1641 % \begin{minipage}{.49\linewidth}
1642 % \begin{verbatim}
1643 % \begin{gather*}
1644 % \diagmat{1,2,3}\\[.5ex]
1645 % \antidiagmat{1,2,3}
1646 % \end{gather*}
1647 % \end{verbatim}
1648 % \end{minipage}\hfill
1649 % \begin{minipage}{.49\linewidth}
1650 % \begin{gather*}
1651 % \diagmat{1,2,3}\\[.5ex]
1652 % \antidiagmat{1,2,3}
1653 % \end{gather*}
1654 % \end{minipage}
1655 % \item A diagonal matrix delimited by parenthesis filled with zeros:
1656 %
1657 % \begin{minipage}{.49\linewidth}
1658 % \begin{verbatim}
1659 % \[
1660 % \diagmat[delimiter=p,fill=0]{1,2,3}
1661 % \]
1662 % \end{verbatim}
1663 % \end{minipage}\hfill
1664 % \begin{minipage}{.49\linewidth}
1665 % \[
1666 % \diagmat[delimiter=p,fill=0]{1,2,3}
1667 % \]
1668 % \end{minipage}
1669 %
1670 % \item A diagonal matrix filled with a symbol:
1671 %
1672 % \begin{minipage}{.49\linewidth}
1673 % \begin{verbatim}
1674 % \[
1675 % \diagmat[fill=\square]{1,2,3}
1676 % \]
1677 % \end{verbatim}
1678 % \end{minipage}\hfill
1679 % \begin{minipage}{.49\linewidth}
1680 % \[\diagmat[fill=\square]{1,2,3}\]
1681 % \end{minipage}
1682 %
1683 % \item Diagonal matrices with different alignment:
1684 %
1685 % \begin{verbatim}
1686 % \[
1687 % \diagmat[delimiter=p,align=c,fill=0]{-1,-2,-3} \qquad
1688 % \diagmat[delimiter=p,align=l,fill=0]{-1,-2,-3} \qquad
1689 % \diagmat[delimiter=p,align=r,fill=0]{-1,-2,-3}
1690 % \]
1691 % \end{verbatim}
1692 % \[
1693 % \diagmat[delimiter=p,align=c,fill=0]{-1,-2,-3} \qquad
1694 % \diagmat[delimiter=p,align=l,fill=0]{-1,-2,-3} \qquad
1695 % \diagmat[delimiter=p,align=r,fill=0]{-1,-2,-3}
1696 % \]
1697 % \end{enumerate}
1698 %
1699 %
1700 % \paragraph{Shorthands for (Anti-)diagonal Matrices with Delimiters}
1701 %
1702 % As matrices are more often than not written inside of delimiters,
1703 % \pkg{moremath} provides several shorthands for producing those matrices
1704 % without having to set the "delimiter" key explicitly.
1705 % \begin{function}{
1706 % \pdiagmat,
1707 % \bdiagmat,
1708 % \Bdiagmat,
1709 % \vdiagmat,
1710 % \Vdiagmat
1711 % }
1712 % \begin{syntax}
1713 % \cs{pdiagmat} \oarg{kv opts} \marg{diagonal}
1714 % \cs{bdiagmat} \oarg{kv opts} \marg{diagonal}
1715 % \cs{Bdiagmat} \oarg{kv opts} \marg{diagonal}
1716 % \cs{vdiagmat} \oarg{kv opts} \marg{diagonal}
1717 % \cs{Vdiagmat} \oarg{kv opts} \marg{diagonal}
1718 % \end{syntax}
1719 % The \cs[no-index]{\meta{delim}diagmat} family of commands provides
1720 % shorthands for producing a delimited (anti-)diagonal matrix
1721 % without having to set the "delimiter" key explicitly every time.
1722 % The pre-set "delimiter" may be overwritten by explicitly passing "delimiter"
1723 % as a key-value option.
1724 %
1725 % The optional argument \meta{kv~opts} accepts the same key-value arguments
1726 % as \cs{diagmat}.
1727 % \end{function}
1728 %
1729 % \medskip\noindent
1730 % \textbf{Example:}
1731 % \begin{quote}
1732 % \begin{minipage}{.49\linewidth}
1733 % \begin{verbatim}
1734 % \[
1735 % \pdiagmat{1,2,3}
1736 % \]
1737 % \end{verbatim}
1738 % \end{minipage}\hfill
1739 % \begin{minipage}{.49\linewidth}
1740 % \[
1741 % \pdiagmat{1,2,3}
1742 % \]
1743 % \end{minipage}
1744 % \end{quote}
1745 %
1746 % \begin{function}{
1747 % \pantidiagmat,
1748 % \bantidiagmat,
1749 % \Bantidiagmat,
1750 % \vantidiagmat,
1751 % \Vantidiagmat
1752 % }
1753 % \begin{syntax}
1754 % \cs{pantidiagmat} \oarg{kv opts} \marg{diagonal}
1755 % \cs{bantidiagmat} \oarg{kv opts} \marg{diagonal}
1756 % \cs{Bantidiagmat} \oarg{kv opts} \marg{diagonal}
1757 % \cs{vantidiagmat} \oarg{kv opts} \marg{diagonal}
1758 % \cs{Vantidiagmat} \oarg{kv opts} \marg{diagonal}
1759 % \end{syntax}
1760 % The \cs[no-index]{\meta{delim}antidiagmat} family of commands behaves
1761 % like the \cs[no-index]{\meta{delim}diagmat} commands described above,
1762 % except they produce anti-diagonal matrices.
1763 % \end{function}
1764 %
1765 % \medskip\noindent
1766 % \textbf{Example:}
1767 % \begin{quote}
1768 % \begin{minipage}{.49\linewidth}
1769 % \begin{verbatim}
1770 % \[
1771 % \pantidiagmat{1,2,3}
1772 % \]
1773 % \end{verbatim}
1774 % \end{minipage}
1775 % \begin{minipage}{.49\linewidth}
1776 % \[
1777 % \pantidiagmat{1,2,3}
1778 % \]
1779 % \end{minipage}
1780 % \end{quote}
1781 %
1782 %
1783 % \subsubsection{Small Versions for Inline Math}
1784 % \label{sec:matrices-small}
1785 %
1786 % \pkg{mathtools} defines special matrix environments for use in
1787 % inline math mode,
1788 % the \env{smallmatrix} and \env{smallmatrix*} family of environments.
1789 % \pkg{moremath} provides for the case of typesetting an (anti-)diagonal
1790 % matrix several commands which utilize these inline math versions.
1791 %
1792 % \begin{function}{
1793 % \smalldiagmat,
1794 % \smallantidiagmat,
1795 % }
1796 % \begin{syntax}
1797 % \cs{smalldiagmat} \oarg{kv opts} \marg{diagonal}
1798 % \cs{smallantidiagmat} \oarg{kv opts} \marg{diagonal}
1799 % \end{syntax}
1800 % The \cs{smalldiagmat} and \cs{smallantidiagmat} commands behave like
1801 % their non-"small" counterpart described above,
1802 % see their description for more information.
1803 % \end{function}
1804 %
1805 % \medskip\noindent
1806 % \textbf{Example:}
1807 % \begin{quote}
1808 % \begin{verbatim}
1809 % An inline version of a diagonal matrix looks like this
1810 % \(\smalldiagmat{1,1}\).
1811 % \end{verbatim}
1812 % An inline version of a diagonal matrix looks like this
1813 % \(\smalldiagmat{1,1}\).
1814 % \end{quote}
1815 %
1816 % \begin{function}{
1817 % \psmalldiagmat,
1818 % \bsmalldiagmat,
1819 % \Bsmalldiagmat,
1820 % \vsmalldiagmat,
1821 % \Vsmalldiagmat,
1822 % }
1823 % \begin{syntax}
1824 % \cs{psmalldiagmat} \oarg{kv opts} \marg{diagonal}
1825 % \cs{bsmalldiagmat} \oarg{kv opts} \marg{diagonal}
1826 % \cs{Bsmalldiagmat} \oarg{kv opts} \marg{diagonal}
1827 % \cs{vsmalldiagmat} \oarg{kv opts} \marg{diagonal}
1828 % \cs{Vsmalldiagmat} \oarg{kv opts} \marg{diagonal}
1829 % \end{syntax}
1830 % Like the \cs[no-index]{\meta{delim}diagmat} commands described above
1831 % there are also shorthand commands for producing an inline math version
1832 % of a diagonal matrix with pre-set delimiters.
1833 % \end{function}
1834 %
1835 % \medbreak\noindent
1836 % \textbf{Example:}
1837 % \begin{quote}
1838 % \begin{verbatim}
1839 % An inline math delimited diagonal matrix looks like this
1840 % \(\psmalldiagmat{1,1}\).
1841 % \end{verbatim}
1842 % An inline math delimited diagonal matrix looks like this
1843 % \(\psmalldiagmat{1,1}\).
1844 % \end{quote}
1845 %
1846 % \begin{function}{
1847 % \psmallantidiagmat,
1848 % \bsmallantidiagmat,
1849 % \Bsmallantidiagmat,
1850 % \vsmallantidiagmat,
1851 % \Vsmallantidiagmat,
1852 % }
1853 % \begin{syntax}
1854 % \cs{psmallantidiagmat} \oarg{kv opts} \marg{diagonal}
1855 % \cs{bsmallantidiagmat} \oarg{kv opts} \marg{diagonal}
1856 % \cs{Bsmallantidiagmat} \oarg{kv opts} \marg{diagonal}
1857 % \cs{vsmallantidiagmat} \oarg{kv opts} \marg{diagonal}
1858 % \cs{Vsmallantidiagmat} \oarg{kv opts} \marg{diagonal}
1859 % \end{syntax}
1860 % Like the \cs[no-index]{\meta{delim}antidiagmat} commands described above
1861 % there are also shorthand commands for producing inline math versions
1862 % of anti-diagonal matrices inside of delimiters.
1863 % \end{function}
1864 %
1865 % \medbreak\noindent
1866 % \textbf{Example:}
1867 % \begin{quote}
1868 % \begin{verbatim}
1869 % A delimited version of an inline math anti-diagonal matrix
1870 % looks like this \(\psmallantidiagmat{1,1}\).
1871 % \end{verbatim}
1872 % A delimited version of an inline math anti-diagonal matrix
1873 % looks like this \(\psmallantidiagmat{1,1}\).
1874 % \end{quote}
1875 %
1876 % \subsection{Identity Matrices}
1877 % \label{sec:id-matrices}
1878 %
1879 % As identity matrices are always quadratic,
1880 % one can further simplify the typesetting of identity matrices to a command,
1881 % which constructs the identity matrix from the number of dimensions.
1882 % The commands in this subsection perform this.
1883 %
1884 % \begin{function}[added = 2024-07-04]{
1885 % \idmat,
1886 % \smallidmat,
1887 % }
1888 % \begin{syntax}
1889 % \cs{idmat} \oarg{kv~opts} \marg{dimension}
1890 % \cs{smallidmat} \oarg{kv~opts} \marg{dimension}
1891 % \end{syntax}
1892 % The \cs{idmat} command produces an identity matrix.
1893 % The optional argument <kv~opts> accepts any valid \emph{matrix} key-value
1894 % arguments,
1895 % which are described in section~\ref{sec:options-matrix}.
1896 % The mandatory argument <dimension> expects a \emph{positive} integer,
1897 % which specifies the dimensions of the identity matrix.
1898 %
1899 % The \cs{smallidmat} command behaves like the \cs{idmat} command,
1900 % except it produces a matrix suitable for inline math mode.
1901 %
1902 % \begin{texnote}
1903 % The maximum number of columns is determined by the \TeX{} counter
1904 % "MaxMatrixCols",
1905 % which has a default value of 10.
1906 % See \textcite{amsmath} for more information.
1907 % \end{texnote}
1908 % \end{function}
1909 %
1910 %
1911 % \begin{function}[added = 2024-07-04]{
1912 % \pidmat,
1913 % \bidmat,
1914 % \Bidmat,
1915 % \vidmat,
1916 % \Vidmat
1917 % }
1918 % \begin{syntax}
1919 % \cs{pidmat} \oarg{kv~opts} \marg{dimension}
1920 % \cs{bidmat} \oarg{kv~opts} \marg{dimension}
1921 % \cs{Bidmat} \oarg{kv~opts} \marg{dimension}
1922 % \cs{vidmat} \oarg{kv~opts} \marg{dimension}
1923 % \cs{Vidmat} \oarg{kv~opts} \marg{dimension}
1924 % \end{syntax}
1925 % Like the \cs[no-index]{\meta{delim}diagmat} commands,
1926 % the \cs[no-index]{\meta{delim}idmat} commands produce an identity matrix
1927 % with a pre-set delimiter around the matrix,
1928 % i.e.\ they behave like \cs{idmat}|[delimiter = |<delim>|]|\marg{dimension}.
1929 % <delim> can be "p" for parenthesis,
1930 % "b" for brackets,
1931 % "B" for braces,
1932 % "v" for a single vertical line (\enquote{\(\vert\)}),
1933 % or "V" for a double vertical line (\enquote{\(\Vert\)}).
1934 %
1935 % Furthermore these commands accept the same <kv~opts> as the \cs{idmat} command.
1936 % \end{function}
1937 %
1938 % \begin{function}[added = 2024-07-04]{
1939 % \psmallidmat,
1940 % \bsmallidmat,
1941 % \Bsmallidmat,
1942 % \vsmallidmat,
1943 % \Vsmallidmat
1944 % }
1945 % \begin{syntax}
1946 % \cs{psmallidmat} \oarg{kv~opts} \marg{dimension}
1947 % \cs{bsmallidmat} \oarg{kv~opts} \marg{dimension}
1948 % \cs{Bsmallidmat} \oarg{kv~opts} \marg{dimension}
1949 % \cs{vsmallidmat} \oarg{kv~opts} \marg{dimension}
1950 % \cs{Vsmallidmat} \oarg{kv~opts} \marg{dimension}
1951 % \end{syntax}
1952 % These commands are provide inline math suitable versions of the
1953 % \cs[no-index]{\meta{delim}idmat} commands described above.
1954 % See their description for more information.
1955 %
1956 % The commands accept any of the key-value options described in section~\ref{sec:options-matrix}
1957 % as optional argument <kv~opts>.
1958 % \end{function}
1959 %
1960 % \paragraph{Examples of Use}
1961 % \begin{enumerate}
1962 % \item Identity matrix without delimiters:
1963 %
1964 % \begin{minipage}{.49\linewidth}
1965 % \begin{verbatim}
1966 % \[
1967 % \idmat{3}
1968 % \]
1969 % \end{verbatim}
1970 % \end{minipage}\hfill
1971 % \begin{minipage}{.49\linewidth}
1972 % \[\idmat{3}\]
1973 % \end{minipage}
1974 %
1975 % \item Identity matrices with different delimiters:
1976 %
1977 % \begin{verbatim}
1978 % \[
1979 % \pidmat{3}\text{,}\quad \bidmat{3}\text{,}\quad
1980 % \Bidmat{3}\text{,}\quad \vidmat{3}\text{,}\quad
1981 % \Vidmat{3}
1982 % \]
1983 % \end{verbatim}
1984 % \[
1985 % \pidmat{3}\text{,}\quad
1986 % \bidmat{3}\text{,}\quad
1987 % \Bidmat{3}\text{,}\quad
1988 % \vidmat{3}\text{,}\quad
1989 % \Vidmat{3}
1990 % \]
1991 %
1992 % \item Inline math versions of identity matrices with delimiters:
1993 %
1994 % \begin{verbatim}
1995 % Inline math mode matrices look like this:
1996 % \(\psmallidmat{2}\), \(\bsmallidmat{2}\), \(\Bsmallidmat{2}\),
1997 % \(\vsmallidmat{2}\), \(\Vsmallidmat{2}\).
1998 % \end{verbatim}
1999 % Inline math mode matrices look like this:
2000 % \(\psmallidmat{2}\), \(\bsmallidmat{2}\), \(\Bsmallidmat{2}\),
2001 % \(\vsmallidmat{2}\), \(\Vsmallidmat{2}\).
2002 %
2003 % \item Identity matrix using the "fill" option for the non-diagonal elements
2004 %
2005 % \begin{minipage}{.49\linewidth}
2006 % \begin{verbatim}
2007 % \[
2008 % \pidmat[fill=\star]{3}
2009 % \]
2010 % \end{verbatim}
2011 % \end{minipage}\hfill
2012 % \begin{minipage}{.49\linewidth}
2013 % \[\pidmat[fill=\star]{3}\]
2014 % \end{minipage}
2015 % \end{enumerate}
2016 %
2017 %
2018 % \section{Shorthands for Absolute Value and Norm}
2019 % \label{sec:shorthands}
2020 %
2021 % \DescribeOption{no-abs-shorthands}
2022 % The commands in this section are only declared if the option "no-abs-shorthands"
2023 % has not been given to the package as a load time option.
2024 %
2025 % \begin{function}{
2026 % \abs,
2027 % \norm
2028 % }
2029 % \begin{syntax}
2030 % \cs{abs} \oarg{size cmd} \marg{content}
2031 % \cs{abs}* \marg{content}
2032 % \cs{norm} \oarg{size cmd} \marg{content}
2033 % \cs{norm}* \marg{content}
2034 % \end{syntax}
2035 % The commands \cs{abs} and \cs{norm}, produce \(\abs{\cdot}\) and
2036 % \(\norm{\cdot}\) respectively.
2037 % These commands are simply paired delimiters defined using \pkg{mathtools}'
2038 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command,
2039 % instruction on their usage can therefore be found in~\textcite{mathtools}.
2040 % \end{function}
2041 %
2042 %
2043 % \section{Vertically Centering Math Along the Math Axis}
2044 % \label{sec:vcenter}
2045 %
2046 % Sometimes it is useful to explicitly center a math symbol along the math axis.
2047 % A prominent example is the case of |\mathop{\boldsymbol\nabla}\nolimits|
2048 % vs.\ |\mathop{\nabla}\nolimits|,
2049 % as displayed below.
2050 % \[
2051 % \mathop{\boldsymbol\nabla}\nolimits f(x)
2052 % \quad \mathop{\nabla}\nolimits f(x)
2053 % \]
2054 % Here the bold nabla is slightly higher up than the non-bold version.
2055 %
2056 % \begin{function}[added=2024-07-08]{\VCenterMath}
2057 % \begin{syntax}
2058 % \cs{VCenterMath} \marg{contents}
2059 % \end{syntax}
2060 % \begin{danger}
2061 % The command \cs{VCenterMath} centers <contents> along the current math axis,
2062 % while adhering to the current math style.
2063 % This command is not in a \TeX{}-sense
2064 % \tn[no-index]{long}, i.e.\ it does not take \tn[no-index]{par} tokens.
2065 %
2066 % This command is somewhat dangerous as it utilizes the \tn{vcenter} primitive,
2067 % which leaves math mode and requires to reenter it.
2068 % \emph{Use at your own responsibility.}
2069 % \end{danger}
2070 % \begin{texnote}
2071 % This command is a wrapper around \tn{vcenter}, \cs{hbox:n}
2072 % and \tn{mathpalette}, it reenters math mode inside the hbox.
2073 % \end{texnote}
2074 % \end{function}
2075 %
2076 % With \cs{VCenterMath} it is possible to fix the above example to:
2077 % \begin{quote}
2078 % \begin{verbatim}
2079 % \[
2080 % \mathop{\VCenterMath{\boldsymbol\nabla}}\nolimits f(x)
2081 % \quad \mathop{\nabla}\nolimits f(x)
2082 % \]
2083 % \end{verbatim}
2084 % \[
2085 % \mathop{\VCenterMath{\boldsymbol\nabla}}\nolimits f(x)
2086 % \quad \mathop{\nabla}\nolimits f(x)
2087 % \]
2088 % \end{quote}
2089 %
2090 %
2091 % \part{Documentation for Class and Package Authors}
2092 % \label{sec:package-auth-doc}
2093 %
2094 % \section{Setting of Options}
2095 % \label{sec:authors-options}
2096 %
2097 % \begin{function}[updated = 2024-07-15]{
2098 % \moremath_setup:n
2099 % }
2100 % \begin{syntax}
2101 % \cs{moremath_setup:n} \marg{kv opts}
2102 % \end{syntax}
2103 % This functions sets the key-value options \meta{kv~opts} in the "moremath" namespace.
2104 % \end{function}
2105 %
2106 % \section{Delimited Operators}
2107 % \label{sec:authors-delim-op}
2108 %
2109 % \begin{function}[updated = 2024-07-15]{
2110 % \moremath_delim_op_noscale:NNnnn,
2111 % \moremath_delim_op_autoscale:NNnnn
2112 % }
2113 % \begin{syntax}
2114 % \cs{moremath_delim_op_noscale:NNnnn} \meta{math~op} \meta{delim}
2115 % \hspace*{2ex} \marg{sup~tl} \marg{sub~tl} \marg{tl}
2116 % \cs{moremath_delim_op_autoscale:NNnnn} \meta{math op} \meta{delim}
2117 % \hspace*{2ex} \marg{sup~tl} \marg{sub~tl} \marg{tl}
2118 % \end{syntax}
2119 % The two functions \cs{moremath_delim_op_noscale:NNnnn} and \cs{moremath_delim_op_autoscale:NNnnn}
2120 % provide a version of a delimited operator with no scaling or automatic scaling respectively.
2121 % The token list arguments \meta{sup~tl} and \meta{sub~tl} take the super- and subscript
2122 % of the operator respectively. Both of those token lists may be empty.
2123 %
2124 % The first argument to the function is a control sequence \meta{math~op},
2125 % which should be an operator declared with
2126 % \cs[module=amsmath,replace=false]{DeclareMathOperator}.
2127 % The second argument \meta{delim} has to be a control sequence of a paired delimiter,
2128 % as defined by \pkg{mathtools}'s
2129 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}.
2130 %
2131 % The final argument \meta{tl} is a list of arbitrary token to put inside the delimiters.
2132 % \end{function}
2133 %
2134 % \begin{function}[updated=2024-07-15]{
2135 % \moremath_delim_op_manuscale:NNnnnn,
2136 % \moremath_delim_op_manuscale:NNVnnn
2137 % }
2138 % \begin{syntax}
2139 % \cs{moremath_delim_op_manuscale:NNnnnn} \meta{math op} \meta{delim} \marg{scale cmd}
2140 % \hspace*{2ex} \marg{sup} \marg{sub} \marg{tl}
2141 % \end{syntax}
2142 % The function \cs{moremath_delim_op_manuscale:NNnnnn} typesets a math operator with
2143 % manual scaling of its delimiters.
2144 % Its arguments are identical to \cs{moremath_delim_op_noscale:NNnnn}
2145 % except for the argument \meta{scale~cmd} which has to be a token list containing
2146 % a \meta{size~cmd} that can be understood by \pkg{mathtools},
2147 % usually \cs{big}, \cs{Big}, \cs{bigg} and \cs{Bigg}.
2148 % \end{function}
2149 %
2150 % \begin{function}[updated=2024-07-15]{
2151 % \moremath_new_delim_op_command:NNN,
2152 % \moremath_new_delim_op_command:cNN,
2153 % }
2154 % \begin{syntax}
2155 % \cs{moremath_new_delim_op_command:NNN} \meta{new~csname} \meta{operator} \meta{delim}
2156 % \end{syntax}
2157 % The function \cs{moremath_new_delim_op_command:NNN} defines a new document level command
2158 % called \meta{new~csname}, utilizing the operator \meta{operator} and the delimiter \meta{delim}.
2159 %
2160 % \meta{operator} has to be a control sequence referring to an operator,
2161 % as declared by \cs{DeclareMathOperator}.
2162 %
2163 % \meta{delim} has to be a paired delimiter as defined by \pkg{mathtools}'
2164 % \cs{DeclarePairedDelimiter}.
2165 % \end{function}
2166 %
2167 % \section{Vector Calculus Typesetting}
2168 % \label{sec:authors-vec-calc}
2169 %
2170 % \subsection{Functions Producing Standalone Operators with Subscripts}
2171 % \label{sec:authors-vec-calc-operators}
2172 %
2173 % \begin{function}[updated=2024-07-15]{
2174 % \moremath_gradient_operator:n,
2175 % \moremath_divergence_operator:n,
2176 % \moremath_curl_operator:n,
2177 % \moremath_laplace_operator:n,
2178 % \moremath_dalembert_operator:n
2179 % }
2180 % \begin{syntax}
2181 % \cs{moremath_gradient_operator:n} \marg{subscript}
2182 % \cs{moremath_divergence_operator:n} \marg{subscript}
2183 % \cs{moremath_curl_operator:n} \marg{subscript}
2184 % \cs{moremath_laplace_operator:n} \marg{subscript}
2185 % \cs{moremath_dalembert_operator:n} \marg{subscript}
2186 % \end{syntax}
2187 % Each of these functions return a vector calculus operator,
2188 % with an (optional) subscript.
2189 % The argument \meta{subscript}, a token list, may be empty,
2190 % in which case no subscript is produced.
2191 %
2192 % The actual operator produced depends on the current settings
2193 % of the key-value options described in section~\ref{sec:pack-opts}
2194 % inside the current group.
2195 % \end{function}
2196 %
2197 % \subsection{Functions Producing Operators with Delimiters}
2198 % \label{sec:authors-vec-calc-delim-ops}
2199 %
2200 % \begin{function}[updated=2024-07-15]{
2201 % \moremath_delim_nabla_op_noscale:NNnn,
2202 % \moremath_delim_nabla_op_autoscale:NNnn,
2203 % }
2204 % \begin{syntax}
2205 % \cs{moremath_delim_nabla_op_noscale:NNnn} \meta{operator} \meta{delim}
2206 % \hspace*{2ex} \marg{sub} \marg{contents}
2207 %
2208 % \cs{moremath_delim_nabla_op_autoscale:NNnn} \meta{operator} \meta{delim}
2209 % \hspace*{2ex} \marg{sub} \marg{contents}
2210 % \end{syntax}
2211 % The usage of these functions is similar to the functions
2212 % \cs{moremath_delim_op_noscale:NNnnn} and \cs{moremath_delim_op_autoscale:NNnnn}
2213 % except for the missing superscript.
2214 %
2215 % The first argument \meta{operator} has to be a function which accepts one argument
2216 % (the subscript).
2217 % This is usually one of the \cs[no-index]{moremath_\meta{op}_operator:n} commands.
2218 %
2219 % The argument \meta{sub}, which may be empty,
2220 % is a token list to pass as the subscript to
2221 % \cs[no-index]{moremath_\meta{op}_operator:n}.
2222 %
2223 % The last argument \meta{contents} is a token list to put inside the delimiters.
2224 %
2225 % \end{function}
2226 %
2227 % \begin{function}[updated=2024-07-15]{
2228 % \moremath_delim_nabla_op_manuscale:NNnnn,
2229 % \moremath_delim_nabla_op_manuscale:NNVnn,
2230 % }
2231 % \begin{syntax}
2232 % \cs{moremath_delim_nabla_op_manuscale:NNnnn} \meta{operator} \meta{delim}
2233 % \hspace*{2ex} \marg{scale~cmd} \marg{sub} \marg{contents}
2234 % \end{syntax}
2235 % The usage of this function is similar to the above functions
2236 % except for the additional argument \meta{scale~cmd} which is a token list
2237 % with a \meta{size~cmd} that should be understood by \pkg{mathtools}
2238 % (e.g.\ \cs{big}, \cs{Big}, etc.).
2239 % \end{function}
2240 %
2241 % \section{Formatting Matrices and Vectors}
2242 % \label{sec:authors-matrix}
2243 %
2244 % \begin{function}[
2245 % updated=2024-07-15,
2246 % updated=2024-08-20,
2247 % ]{
2248 % \moremath_column_vector:nn,
2249 % \moremath_column_vector:Vn,
2250 % \moremath_row_vector:nn,
2251 % \moremath_row_vector:Vn,
2252 % \moremath_column_smallvector:nn,
2253 % \moremath_column_smallvector:Vn,
2254 % \moremath_row_smallvector:nn,
2255 % \moremath_row_smallvector:Vn,
2256 % }
2257 % \begin{syntax}
2258 % \cs{moremath_column_vector:nn} \marg{delim spec tl} \marg{clist}
2259 % \cs{moremath_row_vector:nn} \marg{delim spec tl} \marg{clist}
2260 % \cs{moremath_column_smallvector:nn} \marg{delim spec tl} \marg{clist}
2261 % \cs{moremath_row_smallvector:nn} \marg{delim spec tl} \marg{clist}
2262 % \end{syntax}
2263 % These functions produce a column or row vector.
2264 % The "small"\meta{c~or~r}"vector" versions are intended for inline math mode.
2265 %
2266 % The first argument \meta{delim spec tl} should be the specification of
2267 % a delimiter, as used in the naming of the \env{matrix*} environments
2268 % by \pkg{mathtools}.
2269 %
2270 % The second argument \meta{clist}, is a comma-separated list of entries
2271 % of the vector.
2272 %
2273 % Of this commands the "c" versions produce column vectors, the "r" versions
2274 % produce row vectors.
2275 %
2276 % The alignment of the entries inside the vector depends on the current
2277 % value of the key "align".
2278 % \end{function}
2279 %
2280 % \begin{function}[
2281 % updated = 2024-07-04,
2282 % updated=2024-07-15,
2283 % updated=2024-08-20,
2284 % ]{
2285 % \moremath_diagonal_matrix:nn,
2286 % \moremath_diagonal_matrix:nV,
2287 % \moremath_diagonal_matrix:Vn,
2288 % \moremath_diagonal_matrix:VV,
2289 % \moremath_antidiagonal_matrix:nn,
2290 % \moremath_antidiagonal_matrix:nV,
2291 % \moremath_antidiagonal_matrix:Vn,
2292 % \moremath_antidiagonal_matrix:VV,
2293 % \moremath_diagonal_smallmatrix:nn,
2294 % \moremath_diagonal_smallmatrix:nV,
2295 % \moremath_diagonal_smallmatrix:Vn,
2296 % \moremath_diagonal_smallmatrix:VV,
2297 % \moremath_antidiagonal_smallmatrix:nn,
2298 % \moremath_antidiagonal_smallmatrix:nV,
2299 % \moremath_antidiagonal_smallmatrix:Vn,
2300 % \moremath_antidiagonal_smallmatrix:VV,
2301 % }
2302 % \begin{syntax}
2303 % \cs{moremath_diagonal_matrix:nn} \marg{delim tl} \marg{clist}
2304 % \cs{moremath_antidiagonal_matrix:nn} \marg{delim tl} \marg{clist}
2305 % \cs{moremath_diagonal_smallmatrix:nn} \marg{delim tl} \marg{clist}
2306 % \cs{moremath_antidiagonal_smallmatrix:nn} \marg{delim tl} \marg{clist}
2307 % \end{syntax}
2308 % These functions produce (anti-)diagonal matrices.
2309 % The argument \meta{delim~tl} is a token list,
2310 % intended to specify the delimiter of the matrix or no delimiter if the
2311 % <tl> is empty no delimiters are produced.
2312 %
2313 % The argument <clist> is a list of comma separated values which specify the
2314 % entries of the diagonal.
2315 % Other properties of the matrix to produce like alignment ("align")
2316 % and the tokens to insert for non-diagonal entries ("fill")
2317 % depend on the current setting of the keys described in section~\ref{sec:options-matrix}.
2318 %
2319 % The "smallmatrix" versions are intended for use in inline math mode.
2320 % \end{function}
2321 %
2322 % \begin{function}[
2323 % added = 2024-07-04,
2324 % updated=2024-07-15,
2325 % ]{
2326 % \moremath_id_matrix:n,
2327 % \moremath_id_matrix:V,
2328 % \moremath_id_smallmatrix:n,
2329 % \moremath_id_smallmatrix:V,
2330 % }
2331 % \begin{syntax}
2332 % \cs{moremath_id_matrix:n} \marg{dimensions}
2333 % \cs{moremath_id_smallmatrix:n} \marg{dimensions}
2334 % \end{syntax}
2335 % These functions produce a identity matrix with <dimensions> rows and columns.
2336 % <dimensions> is expected to be a \emph{positive} integer.
2337 % The "smallmatrix" version utilizes \pkg{mathtools}' \env{smallmatrix*} environment,
2338 % which makes it suitable for inline math mode.
2339 %
2340 % The delimiter around the matrix is determined by the current value of the key
2341 % "matrix / delimiter" inside the current group.
2342 %
2343 % As these functions utilize \cs{moremath_diagonal_matrix:VV} or
2344 % \cs{moremath_diagonal_smallmatrix:VV} and make use of temporary variables
2345 % it is advised to put them into their own group,
2346 % i.e.\ surround them by \cs{group_begin:} and \cs{group_end:}.
2347 % \end{function}
2348 %
2349 % \section{Vertically Centering Math Along the Math Axis}
2350 % \label{sec:autors-vcenter}
2351 %
2352 % As already said in section~\ref{sec:vcenter} sometimes it is needed to
2353 % explicitly center some math code.
2354 %
2355 % \begin{function}[
2356 % added=2024-07-08,
2357 % updated=2024-07-15,
2358 % updated=2024-08-20,
2359 % ]{
2360 % \moremath_vcenter:n,
2361 % }
2362 % \begin{syntax}
2363 % \cs{moremath_vcenter:n} \marg{contents}
2364 % \end{syntax}
2365 % The function \cs{moremath_vcenter:n} places <contents> inside a "hbox",
2366 % which is centered along the math axis by \tn{vcenter}.
2367 % The contents inside the "hbox" are set in math mode.
2368 % The function also applies the \enquote{outer} math style
2369 % to the contents of the "hbox".
2370 %
2371 % This function is not \tn[no-index]{long},
2372 % as it sets its contents inside a "hbox".
2373 %
2374 % \begin{texnote}
2375 % This function is a wrapper around \tn{vcenter}, \cs{hbox:n},
2376 % and \tn{mathpalette}.
2377 % Inside the "hbox" math mode is reentered.
2378 % \end{texnote}
2379 % \end{function}
2380 %
2381 % \end{documentation}
2382 %
2383 %
2384 %
2385 %
2386 %
2387 %
2388 %
2389 %
2390 %
2391 %
2392 % \begin{implementation}
2393 % \part{Implementation}
2394 % \label{pt:implementation}
2395 % Start the \pkg{DocStrip} guards.
2396 % \begin{macrocode}
2397 %<*package>
2398 % \end{macrocode}
2399 %
2400 % Set the internal prefix for this package so that \pkg{DocStrip} knows what to
2401 % do.
2402 % \begin{macrocode}
2403 %<@@=moremath>
2404 % \end{macrocode}
2405 %
2406 % \section{Initial Setup}
2407 %
2408 % First set the required version of \LaTeX{},
2409 % we need at least
2410 % \begin{macrocode}
2411 \NeedsTeXFormat{LaTeX2e}[2022-11-01]
2412 % \end{macrocode}
2413 % for key-value option handling, \pkg{xparse}-like document commands
2414 % (especially for using the "=" option specification)
2415 % and hooks.
2416 %
2417 % Afterwards we provide rollback information,
2418 % for the \pkg{latexrelease} rollback mechanism.
2419 % (See \textcite{package-rollback} for more information.)
2420 %
2421 % For the v0.x.x versions I've decided on using the date of the first release
2422 % that was uploaded to CTAN\@.
2423 % \begin{macrocode}
2424 \DeclareCurrentRelease{v0}{2024-07-15}
2425 % \end{macrocode}
2426 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
2427 % Add information for \LaTeX{}'s package rollback mechanism.
2428 % }
2429 %
2430 % Then identify this package as \pkg{moremath}.
2431 % \begin{macrocode}
2432 \ProvidesExplPackage{moremath}
2433 {2024-08-20}{v0.5.0}{More Math Macros}
2434 % \end{macrocode}
2435 %
2436 % ^^X Debugging switch
2437 % \iffalse
2438 % \debug_on:n {all}
2439 % \fi
2440 % \section{Key-value interfaces}
2441 % \label{sec:key-val}
2442 % To make use of key-value interfaces we need to define a few keys.
2443 %
2444 % \subsection{Package load time options}
2445 % \label{sec:load-time-options}
2446 %
2447 % To allow for the conditional definition of macros at load time
2448 % we define a few keys.
2449 %
2450 % But before doing so we define a few messages to write the package options to
2451 % the log file.
2452 % One message to issue if the \texttt{bm} option has been given:
2453 % \begin{macrocode}
2454 \msg_new:nnn { moremath } {load / bm}
2455 {
2456 Option~'bm'~given.\\
2457 Loading~the~bm~package~\msg_line_context:.
2458 }
2459 % \end{macrocode}
2460 % And a more generic message to issue for the other options,
2461 % which all disable certain parts of the library.
2462 % \begin{macrocode}
2463 \msg_new:nnn {moremath} { load / disabling }
2464 {
2465 Option~'#1'~given.\\
2466 Disabling~#2~\msg_line_context:.
2467 }
2468 % \end{macrocode}
2469 %
2470 % \begin{variable}{
2471 % \l_@@_predef_vector_op_bool,
2472 % \l_@@_predef_operators_bool,
2473 % \l_@@_predef_crvector_bool,
2474 % \l_@@_predef_matrix_bool,
2475 % \l_@@_predef_abs_bool,
2476 % }
2477 % To store the values of several switch type key-value options
2478 % we declare several boolean variables.
2479 % \begin{macrocode}
2480 \bool_new:N \l_@@_predef_vector_op_bool
2481 \bool_new:N \l_@@_predef_operators_bool
2482 \bool_new:N \l_@@_predef_crvector_bool
2483 \bool_new:N \l_@@_predef_matrix_bool
2484 \bool_new:N \l_@@_predef_abs_bool
2485 % \end{macrocode}
2486 %
2487 % The variables \cs{l_@@_predef_vector_op_bool}, \cs{l_@@_predef_operators_bool}
2488 % \cs{l_@@_predef_abs_bool}, \cs{l_@@_predef_matrix_bool}
2489 % and \cs{l_@@_predef_crvector_bool}
2490 % control if the predefined macros
2491 % for vector calculus, delimited operators, the matrix shorthands,
2492 % the row and column vectors,
2493 % and the shorthands for absolute value
2494 % and norm shall be defined.
2495 %
2496 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{
2497 % Explicitly declared boolean variables used to store key-value options.
2498 % }
2499 % \end{variable}
2500 %
2501 % \begin{optionenv}{
2502 % bm,
2503 % no-vector,
2504 % no-operators,
2505 % no-abs-shorthands,
2506 % no-matrix,
2507 % no-crvector,
2508 % nopredef,
2509 % }
2510 % Now we define package load time keys:
2511 % \begin{macrocode}
2512 \keys_define:nn { moremath / load }
2513 {
2514 % \end{macrocode}
2515 % We provide an option to conditionally load the \pkg{bm}-package~\autocite{bm}
2516 % to provide better looking bold symbols.
2517 % \begin{macrocode}
2518 bm .code:n = {
2519 \msg_info:nn {moremath} {load / bm}
2520 \RequirePackage{bm}
2521 },
2522 bm .value_forbidden:n = true,
2523 bm. usage:n = load,
2524 % \end{macrocode}
2525 % Then we define options for en-/disabling predefined macros of this package
2526 % to avoid name clashes.
2527 % \begin{macrocode}
2528 no-vector .bool_set_inverse:N = \l_@@_predef_vector_op_bool,
2529 no-vector .default:n = true,
2530 no-vector .initial:n = false,
2531 no-vector .usage:n = load,
2532 no-operators .bool_set_inverse:N = \l_@@_predef_operators_bool,
2533 no-operators .default:n = true,
2534 no-operators .initial:n = false,
2535 no-operators .usage:n = load,
2536 no-abs-shorthands .bool_set_inverse:N = \l_@@_predef_abs_bool,
2537 no-abs-shorthands .default:n = true,
2538 no-abs-shorthands .initial:n = false,
2539 no-abs-shorthands .usage:n = load,
2540 no-matrix .bool_set_inverse:N = \l_@@_predef_matrix_bool,
2541 no-matrix .initial:n = false,
2542 no-matrix .default:n = true,
2543 no-matrix .usage:n =load,
2544 no-crvector .bool_set_inverse:N = \l_@@_predef_crvector_bool,
2545 no-crvector .default:n = true,
2546 no-crvector .initial:n = false,
2547 no-crvector .usage:n = load,
2548 nopredef .multichoice:,
2549 nopredef / operators .meta:nn = { moremath / load }
2550 {
2551 no-operators = true
2552 },
2553 nopredef / vector .meta:nn = { moremath / load }
2554 {
2555 no-vector = true
2556 },
2557 nopredef / abs .meta:nn = { moremath / load }
2558 {
2559 no-abs-shorthands = true,
2560 },
2561 noperdef / matrix .meta:nn = { moremath / load }
2562 {
2563 no-matrix = true,
2564 },
2565 nopredef / crvector .meta:nn = {moremath / load}
2566 {
2567 no-crvector = true,
2568 },
2569 nopredef / all .meta:nn = { moremath / load }
2570 {
2571 no-operators = true,
2572 no-vector = true,
2573 no-abs-shorthands = true
2574 },
2575 nopredef .usage:n = load,
2576 % \end{macrocode}
2577 % Unknown package options get passed to \pkg{mathtools}.
2578 % \begin{macrocode}
2579 unknown .code:n = {\PassOptionsToPackage{\CurrentOption}{mathtools}},
2580 unknown .usage:n = load,
2581 }
2582 % \end{macrocode}
2583 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
2584 % Added package load-time options.
2585 % }
2586 % \end{optionenv}
2587 %
2588 %
2589 % \subsection{Keys controlling appearance}
2590 % \label{sec:keys-appearance}
2591 %
2592 % \begin{variable}{
2593 % \l_@@_nabla_tl,
2594 % \l_@@_nabla_arrow_bool,
2595 % \l_@@_nabla_arrow_bold_bool,
2596 % \l_@@_grad_op_tl,
2597 % \l_@@_laplacian_symb_tl,
2598 % \l_@@_laplacian_delta_bool,
2599 % \l_@@_laplacian_arrow_bool,
2600 % \l_@@_laplacian_tl,
2601 % \l_@@_dalembert_symb_tl,
2602 % }
2603 % We declare several variables to store the values of the keys affecting
2604 % appearance.
2605 % \begin{macrocode}
2606 \tl_new:N \l_@@_nabla_tl
2607 \bool_new:N \l_@@_nabla_arrow_bool
2608 \bool_new:N \l_@@_nabla_arrow_bold_bool
2609 \tl_new:N \l_@@_grad_op_tl
2610 % \end{macrocode}
2611 %
2612 % The symbol to use as \enquote{nabla} is stored in \cs{l_@@_nabla_tl}.
2613 % The variables \cs{l_@@_nabla_arrow_bool} and \cs{l_@@_nabla_bold_bool}
2614 % determine if the nabla-symbol shall have an arrow over itself and/or be bold
2615 % respectively.
2616 %
2617 % The variable \cs{l_@@_grad_op_tl} contains a user provided token list to
2618 % overwrite the built-in gradient operator of the package.
2619 %
2620 % \begin{macrocode}
2621 \tl_new:N \l_@@_laplacian_symb_tl
2622 \bool_new:N \l_@@_laplacian_delta_bool
2623 \bool_new:N \l_@@_laplacian_arrow_bool
2624 \tl_new:N \l_@@_laplacian_tl
2625 % \end{macrocode}
2626 % The token list variable \cs{l_@@_laplacian_symb_tl} stores the tokens to be
2627 % used for the Laplace operator.
2628 % The boolean variable \cs{l_@@_laplacian_delta_bool}
2629 % determines if a delta should be used instead
2630 % of \(\laplacian\) for the laplacian symbol.
2631 % If the boolean variable \cs{l_@@_laplacian_arrow_bool} a small arrow will be
2632 % placed over the Laplace operator symbol.
2633 % If the user wants to overwrite the symbol used for the Laplacian,
2634 % the user provided list of tokens is stored in the variable
2635 % \cs{l_@@_laplacian_tl}.
2636 %
2637 % Finally we define a variable to hold the symbol to use for the
2638 % \foreignlanguage{french}{d'Alembert} operator.
2639 % \begin{macrocode}
2640 \tl_new:N \l_@@_dalembert_symb_tl
2641 % \end{macrocode}
2642 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
2643 % Explicitly declared variables before using them to set keys.
2644 % }
2645 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
2646 % Added: New variable \cs{l_@@_dalembert_symb_tl}
2647 % }
2648 % \end{variable}
2649 %
2650 % \begin{variable}{
2651 % \l_@@_vcenter_bool,
2652 % }
2653 % Additionally we declare a variable to decide if certain math symbols
2654 % shall be centered explicitly along the math axis.
2655 % \begin{macrocode}
2656 \bool_new:N \l_@@_vcenter_bool
2657 % \end{macrocode}
2658 % If \cs{l_@@_vcenter_bool} is true, the symbols of certain math operators,
2659 % should be centered explicitly.
2660 % \end{variable}
2661 %
2662 % \begin{optionenv}{
2663 % nabla,
2664 % arrownabla,
2665 % boldnabla,
2666 % grad-op,
2667 % laplacian-symb,
2668 % delta-laplace,
2669 % arrowlaplace,
2670 % laplacian,
2671 % dalembert-symb,
2672 % }
2673 % First define keys for the vector calculus macros.
2674 % \begin{macrocode}
2675 \keys_define:nn { moremath }
2676 {
2677 % \end{macrocode}
2678 % First we define keys for use with the gradient and gradient based operators.
2679 % \begin{macrocode}
2680 % Symbol to use for the nabla
2681 nabla .tl_set:N = \l_@@_nabla_tl,
2682 nabla .initial:n = {\nabla},
2683 nabla .value_required:n = true,
2684 % shall the nabla have an arrow over it
2685 arrownabla .bool_set:N = \l_@@_nabla_arrow_bool,
2686 arrownabla .default:n = {true},
2687 arrownabla .initial:n = {false},
2688 % shall the nabla be bold
2689 boldnabla .bool_set:N = \l_@@_nabla_bold_bool,
2690 boldnabla .default:n = {true},
2691 boldnabla .initial:n = {false},
2692 % \end{macrocode}
2693 % We also provide an override for the gradient operator
2694 % \begin{macrocode}
2695 % Symbol to use for the gradient operator
2696 grad-op .tl_set:N = \l_@@_grad_op_tl,
2697 grad-op .value_required:n = true,
2698 % \end{macrocode}
2699 %
2700 % Then we define keys for the laplacian.
2701 % \begin{macrocode}
2702 % Symbol to use for the laplacian
2703 laplacian-symb .tl_set:N = \l_@@_laplacian_symb_tl,
2704 laplacian-symb .initial:n = {\l_@@_nabla_tl},
2705 % shall the Laplace operator be a delta
2706 delta-laplace .bool_set:N = \l_@@_laplacian_delta_bool,
2707 delta-laplace .initial:n = {false},
2708 % shall the laplace operator have an arrow over itself
2709 arrowlaplace .bool_set:N = \l_@@_laplacian_arrow_bool,
2710 arrowlaplace .default:n = {true},
2711 arrowlaplace .initial:n = {false},
2712 % overwrite the laplace operator
2713 laplacian .tl_set:N = \l_@@_laplacian_tl,
2714 laplacian .value_required:n = true,
2715 % \end{macrocode}
2716 % And keys for the \foreignlanguage{french}{d'Alembert} operator.
2717 % \begin{macrocode}
2718 dalembert-symb .tl_set:N = \l_@@_dalembert_symb_tl,
2719 dalembert-symb .initial:n = {\square},
2720 % \end{macrocode}
2721 % \begin{optionenv}{
2722 % vcenter,
2723 % }
2724 % The "vcenter" option will control the manual centering of certain math
2725 % operators.
2726 % \begin{macrocode}
2727 vcenter .bool_set:N = \l_@@_vcenter_bool,
2728 vcenter .initial:n = true,
2729 vcenter .value_required:n = true,
2730 }% \keys_define:nn
2731 % \end{macrocode}
2732 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
2733 % Added new option.
2734 % }
2735 % \end{optionenv} ^^X vcenter
2736 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
2737 % Added options controlling appearance.
2738 % }
2739 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
2740 % Added: New option "dalembert-symb".
2741 % }
2742 % \end{optionenv}
2743 %
2744 % \begin{optionenv}{
2745 % delimiter,
2746 % fill,
2747 % align
2748 % }
2749 % Then we define some keys for the matrix based environments:
2750 % \begin{macrocode}
2751 \keys_define:nn { moremath / matrix }
2752 {
2753 % \end{macrocode}
2754 % \begin{variable}{
2755 % \l_@@_matrix_delim_tl,
2756 % \l_@@_matrix_fill_tl,
2757 % \l_@@_matrix_align_tl,
2758 % }
2759 % Every one of the following keys stores its value inside a token list variable.
2760 % \begin{macrocode}
2761 delimiter .tl_set:N = \l_@@_matrix_delim_tl,
2762 delimiter .initial:n = {},
2763 fill .tl_set:N = \l_@@_matrix_fill_tl,
2764 fill .initial:n = {},
2765 align .tl_set:N = \l_@@_matrix_align_tl,
2766 align .initial:n = {c},
2767 align .value_required:n = true,
2768 }
2769 % \end{macrocode}
2770 % The keys \verb|delimiter| and \verb|fill| set the variables
2771 % \cs{l_@@_matrix_delim_tl} and \cs{l_@@_matrix_fill_tl} respectively.
2772 % \cs{l_@@_matrix_delim_tl} determines the delimiter in use to surround
2773 % matrices and \cs{l_@@_matrix_fill_tl} determines the fill values of the
2774 % \cs{diag}, \cs{smalldiag}, \cs[no-index]{Xdiag} and \cs[no-index]{Xsmalldiag}
2775 % commands, which are used for non-diagonal matrix entries.
2776 % The variable \cs{l_@@_matrix_align_tl} contains the alignment specifier
2777 % for use with the \env{matrix*} environment.
2778 %
2779 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
2780 % Added internal variables.
2781 % }
2782 % \end{variable}
2783 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
2784 % Added options for the matrix-based environments of \pkg{mathtools}.
2785 % }
2786 % \end{optionenv}
2787 %
2788 % \subsection{Functions for Setting Options}
2789 % \label{sec:option-setters}
2790 %
2791 %
2792 % Now we define a function for setting the options within the document
2793 % \begin{macro}{\moremath_setup:n}
2794 % \begin{macrocode}
2795 \cs_new_protected:Nn \moremath_setup:n
2796 {
2797 \keys_set:nn {moremath} {#1}
2798 }
2799 % \end{macrocode}
2800 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
2801 % Added function for setting options.
2802 % }
2803 % \end{macro}
2804 %
2805 % Additionally we provide the user with a version of this command.
2806 % \begin{macro}{\moremathsetup}
2807 % \begin{macrocode}
2808 \NewDocumentCommand \moremathsetup {m}
2809 {
2810 \moremath_setup:n {#1}
2811 }
2812 % \end{macrocode}
2813 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
2814 % Added document command for setting package options.
2815 % }
2816 % \end{macro}
2817 % We also need a function for setting the package load time options.
2818 % This function should set all given values for all key families
2819 % and pass unknown options to mathtools.
2820 % \begin{macro}{\@@_load_time_setup:}
2821 % \begin{macrocode}
2822 \cs_new_protected:Nn \@@_load_time_setup:
2823 {
2824 \ProcessKeyOptions[ moremath / load ]
2825 }
2826 % \end{macrocode}
2827 % \end{macro}
2828 %
2829 % ^^X SUBSECTION: Package Initialization
2830 % \section{Package Initialization}
2831 % \label{sec:init}
2832 %
2833 % We now \enquote{initialize} the package by processing the package options,
2834 % all unknown options are passed to \pkg{mathtools}~\autocite{mathtools},
2835 % which is loaded afterwards.
2836 % Because certain \pkg{mathtools}-features are needed by this package,
2837 % we need to require a version of at least 2004/06/05.
2838 % As explained in section~\ref{sec:load-time-options} this may also load \pkg{bm}
2839 % if the \verb|bm| package option has been given.
2840 % \begin{macrocode}
2841 \@@_load_time_setup:
2842 % \end{macrocode}
2843 % If the "no-vector" option has not been given during load time,
2844 % we also need the \pkg{amssymb} package~\autocite{amsfonts} for the
2845 % \cs[module=amssymb,replace=false]{square} command.
2846 % We first define a message to inform the user about this.
2847 % \begin{macrocode}
2848 \msg_new:nnn { moremath } { load / loading-amssymb }
2849 {
2850 Vector~calculus~commands~enabled.\\
2851 Loading~amssymb~package~\msg_line_context:.
2852 }
2853 % \end{macrocode}
2854 % Then we conditionally load the package.
2855 % \begin{macrocode}
2856 \bool_if:NT \l_@@_predef_vector_op_bool
2857 {
2858 \msg_info:nn { moremath } { load / loading-amssymb }
2859 \RequirePackage{amssymb}
2860 }
2861 % \end{macrocode}
2862 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{
2863 % New: Load \pkg{amssymb} if the "no-vector" option has \emph{not} been given.
2864 % }
2865 %
2866 % Finally we load our most important dependency \pkg{mathtools}.
2867 % \begin{macrocode}
2868 \RequirePackage{mathtools}[2004/06/05]
2869 % \end{macrocode}
2870 %
2871 %
2872 % \section{Abstractions for \TeX{}-primitives and \LaTeXe{}-commands}
2873 % \label{sec:impl-abstractions}
2874 %
2875 % As this package makes use of certain \TeX{}-primitives and \LaTeXe{}-commands,
2876 % which are either part of the \LaTeX{}-kernel or of some package.
2877 % It is sensible to provide a (package internal) abstraction for those commands,
2878 % so that they can be switched out once a \LaTeX3{}-command has been defined for them.
2879 %
2880 % \subsection{\TeX{}-primitives}
2881 % \label{sec:impl-tex-abstractions}
2882 %
2883 % \begin{macro}[added=2024-08-20]{
2884 % \@@_tex_vcenter:n,
2885 % }
2886 % \cs{@@_tex_vcenter:n} is an abstraction for \cs{tex_vcenter:D}
2887 % i.e.\ \tn{vcenter}.
2888 % Its single argument is passed to \cs{tex_vcenter:D}.
2889 % \begin{macrocode}
2890 \cs_new_protected:Nn \@@_tex_vcenter:n
2891 {
2892 \tex_vcenter:D {#1}
2893 }
2894 % \end{macrocode}
2895 % \end{macro}
2896 %
2897 % \begin{macro}[added=2024-08-20]{
2898 % \@@_tex_mathpalette:Nn,
2899 % }
2900 % The function \cs{@@_tex_mathpalette:Nn} is an abstraction for the \tn{mathpalette},
2901 % primitive.
2902 % The function takes two arguments
2903 % \begin{arguments}
2904 % \item The \meta{csname} of the macro to pass to \tn{mathpalette}
2905 %
2906 % This macro \textbf{must} accept \textbf{two} arguments:
2907 % The first is a single token containing the current math-style,
2908 % the second is the contents to \enquote{typeset}.
2909 % See \url{https://tex.stackexchange.com/questions/34393/the-mysteries-of-mathpalette/34412#34412}
2910 % for further information.
2911 %
2912 % \item The \meta{tokens} to forward to the macro passed as first argument.
2913 % \end{arguments}
2914 % \begin{macrocode}
2915 \cs_new_protected:Nn \@@_tex_mathpalette:Nn
2916 {
2917 \mathpalette #1 {#2}
2918 }
2919 % \end{macrocode}
2920 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
2921 % Added new function.
2922 % }
2923 % \end{macro}
2924 %
2925 % \begin{macro}[added=2024-08-20]{
2926 % \@@_tex_mathsurround:n
2927 % }
2928 % The function \cs{@@_tex_mathsurround:n} provides (hopefully) a correct abstraction
2929 % for the \tn{mathsurround} primitive.
2930 % It takes one argument
2931 % \begin{arguments}
2932 % \item A \meta{length~expr} for the whitespace surrounding a math switch.
2933 % \end{arguments}
2934 % \begin{macrocode}
2935 \cs_new_protected_nopar:Nn \@@_tex_mathsurround:n
2936 {
2937 \tex_mathsurround:D = #1
2938 }
2939 % \end{macrocode}
2940 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
2941 % Added new function.
2942 % }
2943 % \end{macro}
2944 %
2945 % \begin{macro}[added=2024-08-20]{
2946 % \@@_tex_mathop:n
2947 % }
2948 % The function \cs{@@_tex_mathop:n} provides an abstraction for the \tn{mathop}
2949 % \TeX{}-primitive.
2950 % It accepts a single argument:
2951 % \begin{arguments}
2952 % \item \meta{Tokens} to treat as a math operator.
2953 % \end{arguments}
2954 % \begin{macrocode}
2955 \cs_new_protected_nopar:Nn \@@_tex_mathop:n
2956 {
2957 \tex_mathop:D {#1}
2958 }
2959 % \end{macrocode}
2960 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
2961 % Added new function.
2962 % }
2963 % \end{macro}
2964 %
2965 %
2966 % \subsection{\LaTeXe{}-commands}
2967 % \label{sec:impl-latex-abstractions}
2968 %
2969 % \begin{macro}[EXP,added=2024-08-20]{
2970 % \@@_matrix_star_begin:nn,
2971 % \@@_matrix_star_begin:nV,
2972 % \@@_matrix_star_begin:Vn,
2973 % \@@_matrix_star_begin:VV,
2974 % \@@_matrix_star_end:n,
2975 % \@@_matrix_star_end:V,
2976 % }
2977 % The functions \cs{@@_matrix_star_begin:nn} and \cs{@@_matrix_star_end:n}
2978 % provide an abstraction to the \env{matrix*} family of environments provided
2979 % by \pkg{mathtools}.
2980 % \NB{MI}{These functions need to be expandable,
2981 % as they produce an empty line otherwise.}
2982 %
2983 % \cs{@@_matrix_star_begin:nn} takes two arguments:
2984 % \begin{arguments}
2985 % \item A \meta{tl} determining the type of the matrix.
2986 %
2987 % This is used to further specify which "matrix*" environment to use.
2988 %
2989 % The \meta{tl} may be empty.
2990 %
2991 % \item A \meta{tl} specifying the column type.
2992 % \end{arguments}
2993 % \begin{macrocode}
2994 \cs_new_nopar:Nn \@@_matrix_star_begin:nn
2995 {
2996 \begin{ #1 matrix* } [ #2 ]
2997 }
2998 % \end{macrocode}
2999 % We also create "nV", "Vn", and "VV" variants of this function:
3000 % \begin{macrocode}
3001 \cs_generate_variant:Nn \@@_matrix_star_begin:nn { nV, Vn, VV }
3002 % \end{macrocode}
3003 %
3004 % The function \cs{@@_matrix_star_end:n} takes only one argument
3005 % \begin{arguments}
3006 % \item The \meta{tl} determining the type of the \env{matrix*} environment.
3007 %
3008 % The \meta{tl} \textbf{must} have the same value as used for
3009 % \cs{@@_matrix_star_begin:nn}.
3010 % \end{arguments}
3011 % \begin{macrocode}
3012 \cs_new_nopar:Nn \@@_matrix_star_end:n
3013 {
3014 \end{ #1 matrix* }
3015 }
3016 % \end{macrocode}
3017 % We also provide a "V" type variant of this function.
3018 % \begin{macrocode}
3019 \cs_generate_variant:Nn \@@_matrix_star_end:n {V}
3020 % \end{macrocode}
3021 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3022 % Added new functions and variants.
3023 % }
3024 % \end{macro}
3025 %
3026 %
3027 % \section{Centering Math Symbols Along the Math-Axis}
3028 % \label{sec:impl-vcenter}
3029 %
3030 % Certain math constructs such cause \TeX{}
3031 % to not center the operator along the math axis,
3032 % like case of |\mathop{\nabla}\nolimits| vs.\
3033 % |\mathop{\boldsymbol\nabla}\nolimits|,
3034 % as can be seen below.
3035 % \[
3036 % \mathop{\nabla}\nolimits f(x)
3037 % \quad \text{vs.} \quad
3038 % \mathop{\boldsymbol\nabla}\nolimits f(x)
3039 % \]
3040 % As can be seen the bold nabla symbol is slightly higher up than the non-bold
3041 % version.
3042 % Because of this it is sometimes useful to manually center some math symbols,
3043 % along the math axis.\footnote{%
3044 % The code in this section is inspired by
3045 % \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf}
3046 % }
3047 %
3048 % \begin{macro}[added = 2024-07-08, updated=2024-08-20]{
3049 % \moremath_vcenter:n
3050 % }
3051 % The function \cs{moremath_vcenter:n} is a wrapper around the \tn{vcenter}
3052 % \TeX{} primitive.
3053 % It takes a single argument.
3054 % \begin{arguments}
3055 % \item A \meta{tl} containing math mode material to center along the math axis.
3056 %
3057 % This argument is typeset in math mode.
3058 % \end{arguments}
3059 % The function uses the \tn{mathpalette} primitive to switch to the right
3060 % math style.
3061 % The function is not in a \TeX{}-sense long,
3062 % i.e.\ it does not take \tn{par} tokens.
3063 %
3064 % As this function might be useful not only for internal use by \pkg{moremath},
3065 % we declare it as a public function here.
3066 % \begin{macrocode}
3067 \cs_new_protected_nopar:Nn \moremath_vcenter:n
3068 {
3069 \@@_tex_mathpalette:Nn \@@_vcenter:Nn {#1}
3070 }
3071 % \end{macrocode}
3072 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
3073 % Added new function.
3074 % }
3075 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3076 % Changed: Make use of \cs{@@_tex_mathpalette:Nn}.
3077 % }
3078 % \end{macro}
3079 %
3080 % \begin{macro}[
3081 % added=2024-07-08,
3082 % updated=2024-08-20,
3083 % ]{
3084 % \@@_vcenter:Nn,
3085 % }
3086 % As \tn{mathpalette} needs as its first argument a macro which takes two
3087 % arguments
3088 % (the first is a math style switch and the second the contents).\footnote{%
3089 % See \TeX{}SE answer \url{https://tex.stackexchange.com/a/34412}
3090 % }
3091 % We define an internal helper function for \cs{moremath_vcenter:n} for
3092 % \cs{mathpalette} to call.
3093 %
3094 % The function \cs{@@_vcenter:Nn} takes two arguments:
3095 % \begin{arguments}
3096 % \item The math style macro, which is passed to this function by
3097 % \tn{mathpalette}.
3098 %
3099 % \item The \meta{tl} to typeset inside the \tn{vcenter}.
3100 % \end{arguments}
3101 %
3102 % Because of the properties of \tn{vcenter}, it switches to vertical mode,
3103 % we need to put the contents to typeset inside a horizontal box.
3104 % Because of this we also need to reenter math mode, and because of this
3105 % we need to remove the spacing inserted by entering math mode
3106 % by setting \tn{mathsurround} to zero.
3107 % \begin{macrocode}
3108 \cs_new_protected_nopar:Nn \@@_vcenter:Nn
3109 {
3110 \@@_tex_vcenter:n
3111 {
3112 \hbox:n
3113 {
3114 $
3115 \@@_tex_mathsurround:n {0pt}
3116 #1 {#2}
3117 $
3118 }
3119 }
3120 }
3121 % \end{macrocode}
3122 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3123 % Changed: Now uses \cs{@@_tex_vcenter:n} and \cs{@@_tex_mathsurround:n}
3124 % instead of \TeX-primitives.
3125 % }
3126 % \end{macro}
3127 %
3128 %
3129 % \subsection*{Document Level Command}
3130 %
3131 % Although unlikely there might arise the need for a document author to center
3132 % some math along the math axis.
3133 % For this purpose we are going to define a new document level command.
3134 %
3135 % But first we are going to declare some messages to use by the command.
3136 % The first message informs the user that the command is not available,
3137 % because its \meta{csname} is already taken.
3138 % \begin{macrocode}
3139 \msg_new:nnn { moremath } { csname-already-defined }
3140 {
3141 Control~sequence~' #1 '~is~already~ defined.\\
3142 Skipping~definition~\msg_line_context:
3143 }
3144 % \end{macrocode}
3145 % The second message should be issued if a command that only works in math mode
3146 % was given outside of it.
3147 % \begin{macrocode}
3148 \msg_new:nnnn { moremath } { vcenter / only-in-math-mode }
3149 {
3150 Command~#1~used~outside~math~mode~\msg_line_context:.
3151 }
3152 {
3153 The~command~#1~may~only~be~used~inside~math~mode.
3154 }
3155 % \end{macrocode}
3156 % \begin{macro}{
3157 % \VCenterMath,
3158 % }
3159 % Now to the document level command for centering math along the math axis.
3160 % \begin{macrocode}
3161 \cs_if_free:NTF \VCenterMath
3162 {
3163 \NewDocumentCommand \VCenterMath { m }
3164 {
3165 \mode_if_math:TF
3166 {
3167 \moremath_vcenter:n {#1}
3168 }{% \mode_if_math:TF FALSE BRANCH
3169 \msg_error:nnn { moremath } { vcenter / only-in-math-mode } {\VCenterMath}
3170 }
3171 }
3172 }{% \cs_if_free:NTF \VCenterMath FALSE BRANCH
3173 \msg_warning:nnn { moremath } { csname-already-defined } {\VCenterMath}
3174 }
3175 % \end{macrocode}
3176 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
3177 % Added new document level command.
3178 % }
3179 % \end{macro}
3180 %
3181 %
3182 % ^^X SECTION: Paired Delimiters
3183 % \section{Declaring Paired Delimiters for Internal Use}
3184 % \label{sec:impl-paired-delim}
3185 %
3186 % \begin{macro}{
3187 % \@@_inparent:w,
3188 % \@@_inbrack:w,
3189 % \@@_inbrace:w,
3190 % \@@_in_vert:w,
3191 % \@@_in_Vert:w
3192 % }
3193 % As we are going to use \pkg{mathtools}' \emph{paired delimiters}
3194 % at several places throughout this package,
3195 % we define \emph{paired delimiters} for internal use, as functions with weird
3196 % syntax.
3197 % \begin{macrocode}
3198 \DeclarePairedDelimiter{\@@_inparent:w}{\lparen}{\rparen}
3199 \DeclarePairedDelimiter{\@@_inbrack:w}{\lbrack}{\rbrack}
3200 \DeclarePairedDelimiter{\@@_inbrace:w}{\lbrace}{\rbrace}
3201 \DeclarePairedDelimiter{\@@_in_vert:w}{\lvert}{\rvert}
3202 \DeclarePairedDelimiter{\@@_in_Vert:w}{\lVert}{\rVert}
3203 % \end{macrocode}
3204 % \end{macro}
3205 %
3206 % ^^X SECTION: Delimited Operators
3207 % \section{Delimited Operators}
3208 % \label{sec:impl-delim-op}
3209 %
3210 % We need three different functions for providing the delimited operators.
3211 % But as we share a lot of code between those, we define an additional
3212 % helper function beforehand.
3213 % \begin{macro}{
3214 % \@@_operator:Nnn
3215 % }
3216 % The function \cs{@@_operator:Nnn} takes care of the operator part
3217 % of the new delimiter.
3218 % It allows the operator to have super- and subscripts.
3219 % It takes three arugments.
3220 % \begin{arguments}
3221 % \item The \meta{csname} of the operator to use.
3222 % \item A \meta{token list}, which is used as the superscript operator.
3223 %
3224 % This argument may be empty
3225 % \item A \meta{tl}, which is used as the subscript operator.
3226 %
3227 % The \meta{tl} may be empty.
3228 % \end{arguments}
3229 % \begin{macrocode}
3230 \cs_new_protected:Nn \@@_operator:Nnn
3231 {
3232 #1
3233 % add superscript if present
3234 \tl_if_empty:nF {#2} {^{#2}}
3235 % add subscript if present
3236 \tl_if_empty:nF {#3} { \c_math_subscript_token {#3} }
3237 }
3238 % \end{macrocode}
3239 % \end{macro}
3240 %
3241 % We now define three version of the delimited operators.
3242 % \begin{macro}{
3243 % \moremath_delim_op_noscale:NNnnn,
3244 % \moremath_delim_op_autoscale:NNnnn,
3245 % }
3246 % \cs{moremath_delim_op_noscale:NNnnn} is provides a delimited operator without
3247 % any scaling of the delimiters
3248 % and \cs{moremath_delim_op_autoscale:NNnnn} provides a version with
3249 % automatic scaling of the delimiters.
3250 % Both of them take five arguments:
3251 % \begin{arguments}
3252 % \item The \meta{csname} of the operator to use.
3253 %
3254 % Any operator declared with \pkg{amsmath}'s \cs{operatorname}
3255 % and/or\linebreak[3]
3256 % \cs[module=amsmath,replace=false]{DeclareMathOperator}
3257 % is valid for this.
3258 %
3259 % \item The \meta{csname} of a paired delimiter declared by
3260 % \pkg{mathtools}'~\autocite{mathtools}
3261 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}.
3262 %
3263 % \item A \meta{tl} to use as the superscript of the operator.
3264 %
3265 % \item A \meta{tl} to use as the subscript of the operator.
3266 %
3267 % \item A \meta{tl} to insert inside the delimiters.
3268 % \end{arguments}
3269 % \begin{macrocode}
3270 \cs_new_protected_nopar:Nn \moremath_delim_op_noscale:NNnnn
3271 {
3272 \@@_operator:Nnn #1 {#3} {#4}
3273 % #2 is the paired delimiter
3274 #2 {#5}
3275 }
3276
3277 \cs_new_protected_nopar:Nn \moremath_delim_op_autoscale:NNnnn
3278 {
3279 \@@_operator:Nnn #1 {#3} {#4}
3280 % #2 is the paired delimiter
3281 #2 * {#5}
3282 }
3283 % \end{macrocode}
3284 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
3285 % Added "noscale" and "autoscale" versions.
3286 % }
3287 % \end{macro}
3288 % \begin{macro}{
3289 % \moremath_delim_op_manuscale:NNnnnn,
3290 % \moremath_delim_op_manuscale:NNVnnn
3291 % }
3292 % \cs{moremath_delim_op_manuscale:NNnnnn} provides a delimited operator with
3293 % manual scaling.
3294 % This version takes six arguments:
3295 % \begin{arguments}
3296 % \item The \meta{csname} of the operator to use.
3297 %
3298 % \item The \meta{csname} of the paired delimiter
3299 % declared by \pkg{mathtools}'~\autocite{mathtools}\linebreak[3]
3300 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}.
3301 %
3302 % \item A \meta{tl} containing the scaling macro i.e.\ \cs{big}, \cs{Big},
3303 % \cs{Bigg},\dots
3304 %
3305 % \item A \meta{tl} containing the superscript of the operator.
3306 %
3307 % The \meta{tl} may be empty
3308 %
3309 % \item A \meta{tl} containing the subscript of the operator
3310 %
3311 % The \meta{tl} may be empty.
3312 %
3313 % \item A \meta{tl} to insert inside the delimiters
3314 % \end{arguments}
3315 % \begin{macrocode}
3316 \cs_new_protected_nopar:Nn \moremath_delim_op_manuscale:NNnnnn
3317 {
3318 \@@_operator:Nnn #1 {#4} {#5}
3319 % #2 is the paired delimiter
3320 #2 [ #3 ] {#6}
3321 }
3322 % \end{macrocode}
3323 % We also provide a variant for the scaling macro.
3324 % \begin{macrocode}
3325 \cs_generate_variant:Nn \moremath_delim_op_manuscale:NNnnnn {NNVnnn}
3326 % \end{macrocode}
3327 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
3328 % Function added.
3329 % }
3330 % \end{macro}
3331 %
3332 % For the creation of document level commands we also create a function,
3333 % so that the user is also able to declare new delimited operators.
3334 % But before we do so we create a message to inform the user if a
3335 % \meta{csname} was already taken.
3336 % \begin{macrocode}
3337 \msg_new:nnn { moremath } { delimop / already-defined-skip }
3338 {
3339 Control~sequence~'#1'~is~already~defined.\\
3340 Skipping~definition~of~delimited~operator~'#1'~\msg_line_context:.
3341 }
3342 % \end{macrocode}
3343 %
3344 % We also create a message to inform the user about conflicting options
3345 % given to the command.
3346 % \begin{macrocode}
3347 \msg_new:nnn { moremath } { delimop / auto-manu-scale-conflict }
3348 {
3349 Both~star~and~scale~cmd~given~to~'#1'.\\
3350 Automatic~scaling~will~be~preferred,~the~size~command~will~be~
3351 ignored~\msg_line_context:.
3352 }
3353 % \end{macrocode}
3354 % \begin{macro}{
3355 % \moremath_new_delim_op_command:NNN,
3356 % \moremath_new_delim_op_command:cNN,
3357 %}
3358 % \cs{moremath_new_delim_op_command:NNN} takes three arguments:
3359 % \begin{arguments}
3360 % \item The \meta{csname} to be defined.
3361 %
3362 % \item The \meta{csname} of the operator to use,
3363 % which should be an operator declared with
3364 % \cs[module=amsmath,replace=false]{DeclareMathOperator}.
3365 %
3366 % \item The \meta{csname} of the delimiter to use,
3367 % which should have been declared with
3368 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}.
3369 % \end{arguments}
3370 % \begin{macrocode}
3371 \cs_new_protected:Nn \moremath_new_delim_op_command:NNN
3372 {
3373 \cs_if_free:NTF #1
3374 {
3375 \exp_args:NNe \NewDocumentCommand #1
3376 { s o E{ ^ \char_generate:nn {`_} {8} }{{}{}} m }
3377 {
3378 \tl_if_novalue:nTF {##2}
3379 {
3380 % second argument empty
3381 \bool_if:nTF {##1}
3382 {
3383 % star given
3384 \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5}
3385 }{
3386 % star not given
3387 \moremath_delim_op_noscale:NNnnn #2 #3 {##3} {##4} {##5}
3388 }
3389 }{
3390 % second argument present
3391 % star given?
3392 \bool_if:nTF {##1}
3393 {
3394 % Warn if both star and scaling factor are present
3395 \msg_warning:nnn { moremath } { delimop / auto-manu-scale-conflict }
3396 {#1}
3397 \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5}
3398 }{ % FALSE BRANCH
3399 \moremath_delim_op_manuscale:NNnnnn #2 #3 {##2} {##3} {##4} {##5}
3400 }
3401 }
3402 }
3403 }{ % \cs_if_free:nTF #1 FALSE BRANCH
3404 \msg_warning:nnn { moremath } { delimop / already-defined-skip }
3405 {#1}
3406 }
3407 }
3408
3409 \cs_generate_variant:Nn \moremath_new_delim_op_command:NNN {cNN}
3410 % \end{macrocode}
3411 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
3412 % Added function and variant.
3413 % }
3414 % \end{macro}
3415 %
3416 % \subsection{Document Level Commands}
3417 % \label{sec:impl-delim-op-doc-cmds}
3418 %
3419 % \begin{macro}{\DeclareDelimitedOperator}
3420 % Finally provide the user with a command to declare an additional
3421 % delimited operator.
3422 % \begin{macrocode}
3423 \NewDocumentCommand\DeclareDelimitedOperator { m m m }
3424 {
3425 \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } { error }
3426 \moremath_new_delim_op_command:NNN #1 #2 #3
3427 \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } {}
3428 }
3429 % \end{macrocode}
3430 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Added document level command.}
3431 % \end{macro}
3432 %
3433 % As \pkg{amsmath}~\autocite{amsmath} pre-defines the following operators
3434 % it is only sensible to also define delimited versions of them:\\
3435 % \input{\jobname-ams-op-table.tex}
3436 %
3437 % \begin{macro}{\@@_new_delim_op_cmds:nN}
3438 % \cs{@@_new_delim_op_cmds:nN} creates document level macros of the form
3439 % \cs[no-index]{\meta{prefix}\meta{op name}}.
3440 % It declares fife versions \cs[no-index]{p\meta{op name}},
3441 % \cs[no-index]{b\meta{op name}}, \cs[no-index]{B\meta{op name}},
3442 % \cs[no-index]{v\meta{op name}} and \cs[no-index]{V\meta{op name}}.
3443 %
3444 % The function takes two arguments:
3445 % \begin{arguments}
3446 % \item A token list which contains \meta{op name}
3447 %
3448 % \item The \meta{csname} of the operator to use.
3449 % \end{arguments}
3450 % \begin{macrocode}
3451 \cs_new_protected:Nn \@@_new_delim_op_cmds:nN
3452 {
3453 \moremath_new_delim_op_command:cNN {p #1} #2 \@@_inparent:w
3454 \moremath_new_delim_op_command:cNN {b #1} #2 \@@_inbrack:w
3455 \moremath_new_delim_op_command:cNN {B #1} #2 \@@_inbrace:w
3456 \moremath_new_delim_op_command:cNN {v #1} #2 \@@_in_vert:w
3457 \moremath_new_delim_op_command:cNN {V #1} #2 \@@_in_Vert:w
3458 }
3459 % \end{macrocode}
3460 % \end{macro}
3461 %
3462 % The decision if the following macros are defined depends on a package load
3463 % time option.
3464 % \begin{macrocode}
3465 \bool_if:NTF \l_@@_predef_operators_bool
3466 {
3467 % \end{macrocode}
3468 % We define the commands for the operators already declared by amsmath.
3469 % \begin{macro}[documented-as=\parccos]{
3470 % \parccos, \barccos, \Barccos, \varccos, \Varccos,
3471 % }
3472 % For \cs[module=amsmath,replace=false]{arccos},
3473 % \begin{macrocode}
3474 \@@_new_delim_op_cmds:nN {arccos} \arccos
3475 % \end{macrocode}
3476 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
3477 % Added delimited document commands for all \pkg{amsmath}-defined operators.
3478 % }
3479 % \end{macro}
3480 % \begin{macro}[documented-as=\parccos]{
3481 % \parcsin, \barcsin, \Barcsin, \varcsin, \Varcsin,
3482 % }
3483 % \cs[module=amsmath,replace=false]{arcsin},
3484 % \begin{macrocode}
3485 \@@_new_delim_op_cmds:nN {arcsin} \arcsin
3486 % \end{macrocode}
3487 % \end{macro}
3488 % \begin{macro}[documented-as=\parccos]{
3489 % \parctan, \barctan, \Barctan, \varctan, \Varctan,
3490 % }
3491 % \cs[module=amsmath,replace=false]{arctan},
3492 % \begin{macrocode}
3493 \@@_new_delim_op_cmds:nN {arctan} \arctan
3494 % \end{macrocode}
3495 % \end{macro}
3496 % \begin{macro}[documented-as=\parccos]{
3497 % \Parg, \barg, \Barg, \varg, \Varg,
3498 % }
3499 % \cs[module=amsmath,replace=false]{arg}
3500 % \begin{macrocode}
3501 \@@_new_delim_op_cmds:nN {arg} \arg
3502 % \end{macrocode}
3503 % \end{macro}
3504 % \begin{macro}[documented-as=\parccos]{
3505 % \pcos, \bcos, \Bcos, \vcos, \Vcos,
3506 % }
3507 % \cs[module=amsmath,replace=false]{cos}
3508 % \begin{macrocode}
3509 \@@_new_delim_op_cmds:nN {cos} \cos
3510 % \end{macrocode}
3511 % \end{macro}
3512 % \begin{macro}[documented-as=\parccos]{
3513 % \pcosh, \bcosh, \Bcosh, \vcosh, \Vcosh,
3514 % }
3515 % \cs[module=amsmath,replace=false]{cosh},
3516 % \begin{macrocode}
3517 \@@_new_delim_op_cmds:nN {cosh} \cosh
3518 % \end{macrocode}
3519 % \end{macro}
3520 % \begin{macro}[documented-as=\parccos]{
3521 % \pcot, \bcot, \Bcot, \vcot, \Vcot,
3522 % }
3523 % \cs[module=amsmath,replace=false]{cot},
3524 % \begin{macrocode}
3525 \@@_new_delim_op_cmds:nN {cot} \cot
3526 % \end{macrocode}
3527 % \end{macro}
3528 % \begin{macro}[documented-as=\parccos]{
3529 % \pcoth, \bcoth, \Bcoth, \vcoth, \Vcoth,
3530 % }
3531 % \cs[module=amsmath,replace=false]{coth},
3532 % \begin{macrocode}
3533 \@@_new_delim_op_cmds:nN {coth} \coth
3534 % \end{macrocode}
3535 % \end{macro}
3536 % \begin{macro}[documented-as=\parccos]{
3537 % \pcsc, \bcsc, \Bcsc, \vcsc, \Vcsc,
3538 % }
3539 % \cs[module=amsmath,replace=false]{csc},
3540 % \begin{macrocode}
3541 \@@_new_delim_op_cmds:nN {csc} \csc
3542 % \end{macrocode}
3543 % \end{macro}
3544 % \begin{macro}[documented-as=\parccos]{
3545 % \pdeg, \bdeg, \Bdeg, \vdeg, \Vdeg,
3546 % }
3547 % \cs[module=amsmath,replace=false]{deg},
3548 % \begin{macrocode}
3549 \@@_new_delim_op_cmds:nN {deg} \deg
3550 % \end{macrocode}
3551 % \end{macro}
3552 % \begin{macro}[documented-as=\parccos]{
3553 % \pdet, \bdet, \Bdet, \vdet, \Vdet,
3554 % }
3555 % \cs[module=amsmath,replace=false]{det},
3556 % \begin{macrocode}
3557 \@@_new_delim_op_cmds:nN {det} \det
3558 % \end{macrocode}
3559 % \end{macro}
3560 % \begin{macro}[documented-as=\parccos]{
3561 % \pdim, \bdim, \Bdim, \vdim, \Vdim,
3562 % }
3563 % \cs[module=amsmath,replace=false]{dim},
3564 % \begin{macrocode}
3565 \@@_new_delim_op_cmds:nN {dim} \dim
3566 % \end{macrocode}
3567 % \end{macro}
3568 % \begin{macro}[documented-as=\parccos]{
3569 % \pexp, \bexp, \Bexp, \vexp, \Vexp,
3570 % }
3571 % \cs[module=amsmath,replace=false]{exp},
3572 % \begin{macrocode}
3573 \@@_new_delim_op_cmds:nN {exp} \exp
3574 % \end{macrocode}
3575 % \end{macro}
3576 % \begin{macro}[documented-as=\parccos]{
3577 % \pgcd, \bgcd, \Bgcd, \vgcd, \Vgcd,
3578 % }
3579 % \cs[module=amsmath,replace=false]{gcd},
3580 % \begin{macrocode}
3581 \@@_new_delim_op_cmds:nN {gcd} \gcd
3582 % \end{macrocode}
3583 % \end{macro}
3584 % \begin{macro}[documented-as=\parccos]{
3585 % \phom, \bhom, \Bhom, \vhom, \Vhom,
3586 % }
3587 % \cs[module=amsmath,replace=false]{hom},
3588 % \begin{macrocode}
3589 \@@_new_delim_op_cmds:nN {hom} \hom
3590 % \end{macrocode}
3591 % \end{macro}
3592 % \begin{macro}[documented-as=\parccos]{
3593 % \pinf, \binf, \Binf, \vinf, \Vinf,
3594 % }
3595 % \cs[module=amsmath,replace=false]{inf},
3596 % \begin{macrocode}
3597 \@@_new_delim_op_cmds:nN {inf} \inf
3598 % \end{macrocode}
3599 % \end{macro}
3600 % \begin{macro}[documented-as=\parccos]{
3601 % \pinjlim, \binjlim, \Binjlim, \vinjlim, \Vinjlim,
3602 % }
3603 % \cs[module=amsmath,replace=false]{injlim},
3604 % \begin{macrocode}
3605 \@@_new_delim_op_cmds:nN {injlim} \injlim
3606 % \end{macrocode}
3607 % \end{macro}
3608 % \begin{macro}[documented-as=\parccos]{
3609 % \pker, \bker, \Bker, \vker, \Vker,
3610 % }
3611 % \cs[module=amsmath,replace=false]{ker},
3612 % \begin{macrocode}
3613 \@@_new_delim_op_cmds:nN {ker} \ker
3614 % \end{macrocode}
3615 % \end{macro}
3616 % \begin{macro}[documented-as=\parccos]{
3617 % \plg, \blg, \Blg, \vlg, \Vlg,
3618 % }
3619 % \cs[module=amsmath,replace=false]{lg},
3620 % \begin{macrocode}
3621 \@@_new_delim_op_cmds:nN {lg} \lg
3622 % \end{macrocode}
3623 % \end{macro}
3624 % \begin{macro}[documented-as=\parccos]{
3625 % \plim, \blim, \Blim, \vlim, \Vlim,
3626 % }
3627 % \cs[module=amsmath,replace=false]{lim},
3628 % \begin{macrocode}
3629 \@@_new_delim_op_cmds:nN {lim} \lim
3630 % \end{macrocode}
3631 % \end{macro}
3632 % \begin{macro}[documented-as=\parccos]{
3633 % \pliminf, \bliminf, \Bliminf, \vliminf, \Vliminf,
3634 % }
3635 % \cs[module=amsmath,replace=false]{liminf},
3636 % \begin{macrocode}
3637 \@@_new_delim_op_cmds:nN {liminf} \liminf
3638 % \end{macrocode}
3639 % \end{macro}
3640 % \begin{macro}[documented-as=\parccos]{
3641 % \plimsup, \blimsup, \Blimsup, \vlimsup, \Vlimsup,
3642 % }
3643 % \cs[module=amsmath,replace=false]{limsup},
3644 % \begin{macrocode}
3645 \@@_new_delim_op_cmds:nN {limsup} \limsup
3646 % \end{macrocode}
3647 % \end{macro}
3648 % \begin{macro}[documented-as=\parccos]{
3649 % \pln, \bln, \Bln, \vln, \Vln,
3650 % }
3651 % \cs[module=amsmath,replace=false]{ln}
3652 % \begin{macrocode}
3653 \@@_new_delim_op_cmds:nN {ln} \ln
3654 % \end{macrocode}
3655 % \end{macro}
3656 % \begin{macro}[documented-as=\parccos]{
3657 % \plog, \blog, \Blog, \vlog, \Vlog,
3658 % }
3659 % \cs[module=amsmath,replace=false]{log},
3660 % \begin{macrocode}
3661 \@@_new_delim_op_cmds:nN {log} \log
3662 % \end{macrocode}
3663 % \end{macro}
3664 % \begin{macro}[documented-as=\parccos]{
3665 % \pmax, \bmax, \Bmax, \vmax, \Vmax,
3666 % }
3667 % \cs[module=amsmath,replace=false]{max},
3668 % \begin{macrocode}
3669 \@@_new_delim_op_cmds:nN {max} \max
3670 % \end{macrocode}
3671 % \end{macro}
3672 % \begin{macro}[documented-as=\parccos]{
3673 % \pmin, \bmin, \Bmin, \vmin, \Vmin,
3674 % }
3675 % \cs[module=amsmath,replace=false]{min},
3676 % \begin{macrocode}
3677 \@@_new_delim_op_cmds:nN {min} \min
3678 % \end{macrocode}
3679 % \end{macro}
3680 % \begin{macro}[documented-as=\parccos]{
3681 % \pPr, \bPr, \BPr, \vPr, \VPr,
3682 % }
3683 % \cs[module=amsmath,replace=false]{Pr},
3684 % \begin{macrocode}
3685 \@@_new_delim_op_cmds:nN {Pr} \Pr
3686 % \end{macrocode}
3687 % \end{macro}
3688 % \begin{macro}[documented-as=\parccos]{
3689 % \pprojlim, \bprojlim, \Bprojlim, \vprojlim, \Vprojlim,
3690 % }
3691 % \cs[module=amsmath,replace=false]{projlim},
3692 % \begin{macrocode}
3693 \@@_new_delim_op_cmds:nN {projlim} \projlim
3694 % \end{macrocode}
3695 % \end{macro}
3696 % \begin{macro}[documented-as=\parccos]{
3697 % \psec, \bsec, \Bsec, \vsec, \Vsec,
3698 % }
3699 % \cs[module=amsmath,replace=false]{sec},
3700 % \begin{macrocode}
3701 \@@_new_delim_op_cmds:nN {sec} \sec
3702 % \end{macrocode}
3703 % \end{macro}
3704 % \begin{macro}[documented-as=\parccos]{
3705 % \psin, \bsin, \Bsin, \vsin, \Vsin,
3706 % }
3707 % \cs[module=amsmath,replace=false]{sin},
3708 % \begin{macrocode}
3709 \@@_new_delim_op_cmds:nN {sin} \sin
3710 % \end{macrocode}
3711 % \end{macro}
3712 % \begin{macro}[documented-as=\parccos]{
3713 % \psinh, \bsinh, \Bsinh, \vsinh, \Vsinh,
3714 % }
3715 % \cs[module=amsmath,replace=false]{sinh},
3716 % \begin{macrocode}
3717 \@@_new_delim_op_cmds:nN {sinh} \sinh
3718 % \end{macrocode}
3719 % \end{macro}
3720 % \begin{macro}[documented-as=\parccos]{
3721 % \psup, \bsup, \Bsup, \vsup, \Vsup,
3722 % }
3723 % \cs[module=amsmath,replace=false]{sup},
3724 % \begin{macrocode}
3725 \@@_new_delim_op_cmds:nN {sup} \sup
3726 % \end{macrocode}
3727 % \end{macro}
3728 % \begin{macro}[documented-as=\parccos]{
3729 % \ptan, \btan, \Btan, \vtan, \Vtan,
3730 % }
3731 % \cs[module=amsmath,replace=false]{tan},
3732 % \begin{macrocode}
3733 \@@_new_delim_op_cmds:nN {tan} \tan
3734 % \end{macrocode}
3735 % \end{macro}
3736 % \begin{macro}[documented-as=\parccos]{
3737 % \ptanh, \btanh, \Btanh, \vtanh, \Vtanh
3738 % }
3739 % and \cs[module=amsmath,replace=false]{tanh}.
3740 % \begin{macrocode}
3741 \@@_new_delim_op_cmds:nN {tanh} \tanh
3742 % \end{macrocode}
3743 % \end{macro}
3744 % \begin{macro}[documented-as=\parccos]{
3745 % \pvarinjlim, \bvarinjlim, \Bvarinjlim, \vvarinjlim, \Vvarinjlim,
3746 % \pvarprojlim, \bvarprojlim, \Bvarprojlim, \vvarprojlim, \Vvarprojlim,
3747 % \pvarliminf, \bvarliminf, \Bvarliminf, \vvarliminf, \Vvarliminf,
3748 % \pvarlimsup, \bvarlimsup, \Bvarlimsup, \vvarlimsup, \Vvarlimsup,
3749 % }
3750 % We also provide delimited versions of \cs[module=amsmath,replace=false]{varinjlim},
3751 % \cs[module=amsmath,replace=false]{varprojlim},
3752 % \cs[module=amsmath,replace=false]{varliminf},
3753 % and \cs[module=amsmath,replace=false]{varlimsup}.
3754 % \begin{macrocode}
3755 \@@_new_delim_op_cmds:nN {varinjlim} \varinjlim
3756 \@@_new_delim_op_cmds:nN {varprojlim} \varprojlim
3757 \@@_new_delim_op_cmds:nN {varliminf} \varliminf
3758 \@@_new_delim_op_cmds:nN {varlimsup} \varlimsup
3759 % \end{macrocode}
3760 % \end{macro}
3761 % \begin{macrocode}
3762 }{
3763 \msg_info:nnnn {moremath} {load /disabling} {no-operators}
3764 {
3765 predefined~delimited~operator~macros
3766 }
3767 } % End of the conditional
3768 % \end{macrocode}
3769 %
3770 % ^^X SECTION: Vector Calculus Macros
3771 % \section{Vector Calculus Macros}
3772 % \label{sec:vector-calc}
3773 %
3774 % For providing macros which help with vector differentials,
3775 % we first need some setup functions.
3776 %
3777 % \subsection{Macros Providing Symbols of Operators}
3778 % \label{sec:op-symbols}
3779 %
3780 % \begin{macro}{
3781 % \@@_maybe_vcenter:n,
3782 % }
3783 % Sometimes a symbol should be centered explicitly,
3784 % as this will depend on the current setting of "vcenter",
3785 % i.e.\ the current value of \cs{l_@@_vcenter_bool},
3786 % we provide a helper function which puts its argument
3787 % \begin{arguments}
3788 % \item A list of \meta{tokens}
3789 % \end{arguments}
3790 % inside a \tn{vcenter} by means of \cs{moremath_vcenter:n}
3791 % or not depending on the current value of \cs{l_@@_vcenter_bool}.
3792 % \begin{macrocode}
3793 \cs_new_protected_nopar:Nn \@@_maybe_vcenter:n
3794 {
3795 \bool_if:NTF \l_@@_vcenter_bool
3796 {
3797 \moremath_vcenter:n {#1}
3798 }{
3799 #1
3800 }
3801 }
3802 % \end{macrocode}
3803 % \end{macro}
3804 %
3805 % \begin{macro}[updated=2024-08-20]{\@@_gradient_operator_get:}
3806 % This function returns the gradient operator depending on the current setting
3807 % of the keys.
3808 % \begin{macrocode}
3809 \cs_new_protected:Nn \@@_gradient_operator_get:
3810 {
3811 \tl_if_empty:NTF \l_@@_grad_op_tl
3812 {
3813 \@@_tex_mathop:n
3814 {
3815 % \end{macrocode}
3816 % Otherwise we first need to check if the operator shall have an arrow over it.
3817 % Afterwards if the nabla shall be bold.
3818 % \begin{macrocode}
3819 \bool_if:NTF \l_@@_nabla_arrow_bool
3820 {
3821 \vec
3822 {
3823 % \end{macrocode}
3824 % In case \cs{l_@@_nabla_arrow_bool} is true we should \emph{maybe}
3825 % center the symbol.
3826 % \begin{macrocode}
3827 \@@_maybe_vcenter:n
3828 {
3829 \bool_if:NT \l_@@_nabla_bold_bool
3830 {
3831 \boldsymbol
3832 }
3833 \l_@@_nabla_tl
3834 }
3835 }
3836 }{
3837 % \end{macrocode}
3838 % Like in the case above we should \emph{maybe} center the symbol
3839 % if \cs{l_@@_nabla_bold_bool} is true.
3840 % \begin{macrocode}
3841 \bool_if:NTF \l_@@_nabla_bold_bool
3842 {
3843 \@@_maybe_vcenter:n
3844 {
3845 \boldsymbol
3846 \l_@@_nabla_tl
3847 }
3848 }{
3849 \l_@@_nabla_tl
3850 }
3851 }
3852 }% \@@_tex_mathop:n
3853 \nolimits
3854 }{
3855 % \end{macrocode}
3856 % If the user provided its own implementation of the operator,
3857 % we simply return it.
3858 % \begin{macrocode}
3859 \l_@@_grad_op_tl
3860 }
3861 }
3862 % \end{macrocode}
3863 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3864 % Now uses \cs{@@_tex_mathop:n} instead of \TeX{}-primitives.
3865 % }
3866 % \end{macro}
3867 %
3868 % \begin{macro}[updated=2024-08-20]{\@@_laplace_operator_get:}
3869 % Then we define a function for returning the laplace operator symbol,
3870 % depending on the currently set keys.
3871 % The function wraps the symbol for the operator inside
3872 % \tn{mathop} to provide the right spacing.
3873 % \begin{macrocode}
3874 \cs_new_protected:Nn \@@_laplace_operator_get:
3875 {
3876 \tl_if_empty:NTF \l_@@_laplacian_tl
3877 {
3878 \@@_tex_mathop:n
3879 {
3880 \bool_if:NTF \l_@@_laplacian_delta_bool
3881 {
3882 \Delta
3883 }{
3884 \bool_if:NTF \l_@@_laplacian_arrow_bool
3885 {
3886 \vec{
3887 \@@_maybe_vcenter:n
3888 {
3889 \bool_if:NT \l_@@_nabla_bold_bool {\boldsymbol}
3890 \l_@@_laplacian_symb_tl
3891 }
3892 }
3893 }{
3894 \bool_if:NTF \l_@@_nabla_bold_bool
3895 {
3896 \@@_maybe_vcenter:n
3897 {
3898 \boldsymbol
3899 \l_@@_laplacian_symb_tl
3900 }
3901 }{
3902 \l_@@_laplacian_symb_tl
3903 }
3904 }
3905 }
3906 }\nolimits
3907 \bool_if:NF \l_@@_laplacian_delta_bool
3908 {
3909 \c_math_superscript_token
3910 {
3911 2
3912 }
3913 }
3914 }{
3915 \l_@@_laplacian_tl
3916 }
3917 }
3918 % \end{macrocode}
3919 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3920 % Now uses \cs{@@_tex_mathop:n} instead of \TeX{}-primitives.
3921 % }
3922 % \end{macro}
3923 %
3924 % \begin{macro}[updated=2024-08-20]{
3925 % \@@_dalembert_operator_get:
3926 % }
3927 % This function returns the \foreignlanguage{french}{d'Alembert} operator
3928 % depending on the currently set keys. The symbol for the
3929 % \foreignlanguage{french}{d'Alembert} operator is wrapped inside \tn{mathop}
3930 % to provide proper spacing.
3931 % \begin{macrocode}
3932 \cs_new_protected:Nn \@@_dalembert_operator_get:
3933 {
3934 \@@_tex_mathop:n
3935 {
3936 \l_@@_dalembert_symb_tl
3937 }% \@@_tex_mathop:n
3938 \nolimits
3939 }
3940 % \end{macrocode}
3941 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
3942 % Added function: \cs{@@_dalembert_operator_get:}
3943 % }
3944 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
3945 % Now uses \cs{@@_tex_mathop:n} instead of \TeX{}-primitives.
3946 % }
3947 % \end{macro}
3948 %
3949 % \subsection{Macros Producing an Operator}
3950 % \label{sec:op-macros}
3951 %
3952 % After we have defined the symbols it is now time to provide a function which
3953 % produces the entire gradient operator
3954 % \begin{macro}{
3955 % \moremath_gradient_operator:n,
3956 % \moremath_laplace_operator:n
3957 % }
3958 % This function takes one arguments, the subscript to use with the operator.
3959 % \begin{macrocode}
3960 \cs_new_protected_nopar:Nn \moremath_gradient_operator:n
3961 {
3962 \@@_gradient_operator_get:
3963 \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}}
3964 }
3965 % \end{macrocode}
3966 %
3967 % Like for the gradient operator we do the same for the laplacian
3968 % \begin{macrocode}
3969 \cs_new_protected_nopar:Nn \moremath_laplace_operator:n
3970 {
3971 \@@_laplace_operator_get:
3972 \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}}
3973 }
3974 % \end{macrocode}
3975 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
3976 % Added functions.
3977 % }
3978 % \end{macro}
3979 %
3980 % \begin{macro}{
3981 % \moremath_divergence_operator:n,
3982 % \moremath_curl_operator:n
3983 % }
3984 % Using the already defined gradient operator it is possible to define a
3985 % function which acts as an operator suitable for representing the divergence
3986 % operator and the curl operator.
3987 % Like the gradient operator this functions take one argument
3988 % \begin{arguments}
3989 % \item the subscript of the gradient operator.
3990 % \end{arguments}
3991 % \begin{macrocode}
3992 \cs_new_protected_nopar:Nn \moremath_divergence_operator:n
3993 {
3994 % \end{macrocode}
3995 % The braces around \cs{moremath_gradient_operator:n} are necessary to avoid
3996 % issues with the spacing between \tn{cdot} and the following \tn{mathopen}
3997 % from any braces.\footnote{%
3998 % See: \url{https://tex.stackexchange.com/a/223914}
3999 % }
4000 % Example:
4001 % \[
4002 % \text{With braces:}\quad \pdiv{f(x)} \text{,}
4003 % \qquad\text{without braces: }\quad \mathop{\nabla}\nolimits\cdot(f(x))
4004 % \]
4005 % \begin{macrocode}
4006 {
4007 \moremath_gradient_operator:n {#1}
4008 }
4009 \cdot
4010 }
4011
4012 \cs_new_protected_nopar:Nn \moremath_curl_operator:n
4013 {
4014 {
4015 \moremath_gradient_operator:n {#1}
4016 }
4017 \times
4018 }
4019 % \end{macrocode}
4020 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4021 % Added functions.
4022 % }
4023 % \end{macro}
4024 %
4025 % \begin{macro}{
4026 % \moremath_dalembert_operator:n
4027 % }
4028 % This function produces the \foreignlanguage{french}{d'Alembert} operator,
4029 % including an optional subscript.
4030 % The function takes one argument:
4031 % \begin{arguments}
4032 % \item A \meta{tl} with the contents of the subscript of the operator.
4033 %
4034 % This variable may be empty,
4035 % in this case no subscript (not even an empty one) is produced.
4036 % \end{arguments}
4037 % \begin{macrocode}
4038 \cs_new_protected:Nn \moremath_dalembert_operator:n
4039 {
4040 \@@_dalembert_operator_get:
4041 \tl_if_empty:nF {#1}
4042 {
4043 \c_math_subscript_token {#1}
4044 }
4045 }
4046 % \end{macrocode}
4047 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
4048 % Added new function \cs{moremath_dalembert_operator:n}.
4049 % }
4050 % \end{macro}
4051 %
4052 %
4053 % \subsection{Producing Delimited Vector Calculus Operators}
4054 % \label{sec:delim-vec-ops}
4055 %
4056 % \begin{macro}{
4057 % \moremath_delim_nabla_op_noscale:NNnn,
4058 % \moremath_delim_nabla_op_autoscale:NNnn
4059 % }
4060 % These functions produce a vector calculus operator with \meta{contents}
4061 % inside delimiters.
4062 % The "autoscale" variant scales the delimiters with the size of \meta{contents},
4063 % the "noscale" variant does no scaling at all.
4064 % \begin{arguments}
4065 % \item The \meta{csname} of the operator to use.
4066 %
4067 % This should have the same form as \cs{moremath_gradient_operator:n},
4068 % i.e.\ the function passed as \meta{csname} should accept one argument
4069 % to typeset as subscript.
4070 %
4071 % \item The \meta{csname} of the \emph{paired delimiter} to use.
4072 %
4073 % The paired delimiter has to be one declared using \pkg{mathtools}'
4074 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command.
4075 %
4076 % \item A \meta{tl} with the subscript of the operator.
4077 %
4078 % \item A \meta{tl} with the contents to typeset inside the delimiters
4079 % \end{arguments}
4080 % We begin with the "noscale" version.
4081 % \begin{macrocode}
4082 \cs_new_protected_nopar:Nn \moremath_delim_nabla_op_noscale:NNnn
4083 {
4084 #1 {#3} #2{#4}
4085 }
4086 % \end{macrocode}
4087 % Then we create the version with automatic scaling.
4088 % \begin{macrocode}
4089 \cs_new_protected_nopar:Nn \moremath_delim_nabla_op_autoscale:NNnn
4090 {
4091 #1 {#3} #2 * {#4}
4092 }
4093 % \end{macrocode}
4094 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4095 % Added "noscale" and "autoscale" functions.
4096 % }
4097 % \end{macro}
4098 %
4099 % \begin{macro}{
4100 % \moremath_delim_nabla_op_manuscale:NNnnn
4101 % }
4102 % This function produces a vector calculus operator like
4103 % \cs{moremath_delim_nabla_op_noscale:NNnn}
4104 % and \cs{moremath_delim_nabla_op_autoscale:NNnn},
4105 % but with manual scaling.
4106 % It takes five arguments:
4107 % \begin{arguments}
4108 % \item The \meta{csname} of the operator to use.
4109 %
4110 % \item The \meta{csname} of the paired delimiter.
4111 %
4112 % \item A \meta{token~list} containing the \meta{scale~cmd} like
4113 % \cs{big}, \cs{Big}, \cs{bigg}, etc.
4114 %
4115 % \item A \meta{tl} with the subscript of the operator.
4116 %
4117 % \item A \meta{tl} with the contents to typeset inside the delimiters.
4118 % \end{arguments}
4119 % \begin{macrocode}
4120 \cs_new_protected_nopar:Nn \moremath_delim_nabla_op_manuscale:NNnnn
4121 {
4122 #1 {#4} #2 [#3] {#5}
4123 }
4124 % \end{macrocode}
4125 % \begin{macro}{
4126 % \moremath_delim_nabla_op_manuscale:NNVnn
4127 % }
4128 % We also declare a variant for passing a variable with the \meta{scale~cmd}
4129 % instead of a \meta{token~list}.
4130 % \begin{macrocode}
4131 \cs_generate_variant:Nn \moremath_delim_nabla_op_manuscale:NNnnn {NNVnn}
4132 % \end{macrocode}
4133 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4134 % Add variant.
4135 % }
4136 % \end{macro}
4137 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4138 % Add function.
4139 % }
4140 % \end{macro}
4141 %
4142 % To ease the definition of those macros we define a function for defining
4143 % the delimited versions.
4144 %
4145 % Of course we also need a way to declare a user interface for this functions.
4146 % For this purpose we first need some helpers for setting
4147 % necessary parameters.
4148 % \begin{macro}{\@@_parse_kv_args:nN}
4149 % This helper macro takes two arguments,
4150 % \begin{arguments}
4151 % \item A token list of the key-value arguments.
4152 % \item The \meta{csname} of a token list to put the scale value in.
4153 % \end{arguments}
4154 % The function sets the given keys but before it does so it searches for a
4155 % key named \verb|scale| and puts it into the second argument.
4156 % For this to work it is necessary that all values have \verb|=| in them.
4157 % \begin{macrocode}
4158 \cs_new_protected:Nn \@@_parse_kv_args:nN
4159 {
4160 % \end{macrocode}
4161 % We first put the key-value arguments inside a property list.
4162 % Afterwards we check if the key \verb|scale| has been given.
4163 % If yes we pop it and assign it to the second argument.
4164 % Otherwise we do nothing.
4165 % \NB{MI}{It may be a better idea to use a key instead but I'm not sure.
4166 % If one nests those environments the size of the outer one will propagate into
4167 % the inner scope, which might not be what is wanted.}
4168 % \begin{macrocode}
4169 \prop_set_from_keyval:Nn \l_tmpa_prop {#1}
4170
4171 \prop_pop:NnNT \l_tmpa_prop {scale} #2 {}
4172
4173 \keys_set:ne {moremath} {\prop_to_keyval:N \l_tmpa_prop}
4174 }
4175 % \end{macrocode}
4176 % \end{macro}
4177 %
4178 % We also need a warning message for conflicting arguments,
4179 % to inform the user that one of his options is going to be ignored.
4180 % \begin{macrocode}
4181 \msg_new:nnn { moremath } { vector-calc / scale-star-conflict }
4182 {
4183 Both~star~and~scaling~factor~given~to~'#1'.\\
4184 Automatic~scaling~will~be~preferred,~the~size~command~'#2'~will~be~
4185 ignored~\msg_line_context:.
4186 }
4187 % \end{macrocode}
4188 %
4189 % \begin{macro}{
4190 % \@@_new_delim_nabla_doc_cmd:NNN,
4191 % \@@_new_delim_nabla_doc_cmd:cNN,
4192 % }
4193 % This function takes three arguments:
4194 % \begin{arguments}
4195 % \item The \meta{csname} of the to be defined command
4196 % \item The \meta{csname} of the operator to use.
4197 %
4198 % This should be a function like \cs{moremath_gradient_operator:n}.
4199 % \item The \meta{csname} of the delimiter function to use.
4200 %
4201 % This should be a macro/command created with \pkg{mathtools}
4202 % \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command.
4203 % \end{arguments}
4204 % Its purpose is to create a new document level command,
4205 % for the delimited vector calculus operators.
4206 % \begin{macrocode}
4207 \cs_new_protected:Nn \@@_new_delim_nabla_doc_cmd:NNN
4208 {
4209 \cs_if_free:NTF #1
4210 {
4211 \exp_args:NNe \NewDocumentCommand #1
4212 {
4213 s ={scale} o E{ \char_generate:nn {`_}{8} }{ {} } m
4214 }
4215 { % command code
4216 \group_begin:
4217 % optional arguments given?
4218 \tl_if_novalue:nF {##2}
4219 {
4220 \@@_parse_kv_args:nN {##2} \l_tmpa_tl
4221 }
4222 % star given?
4223 \bool_if:nTF {##1}
4224 {
4225 % scale factor given?
4226 \tl_if_empty:NF \l_tmpa_tl
4227 {
4228 \msg_warning:nnnV { moremath } { vector-calc / scale-star-conflict }
4229 {#1} \l_tmpa_tl
4230 }
4231 \moremath_delim_nabla_op_autoscale:NNnn #2 #3 {##3} {##4}
4232 }{ % \bool_if:nTF {##1} FALSE BRANCH
4233 % scale factor given?
4234 \tl_if_empty:NTF \l_tmpa_tl
4235 {
4236 \moremath_delim_nabla_op_noscale:NNnn #2 #3 {##3} {##4}
4237 }{ % FALSE BRANCH
4238 \moremath_delim_nabla_op_manuscale:NNVnn #2 #3 \l_tmpa_tl {##3} {##4}
4239 }
4240 } % \bool_if:nTF {##1}
4241 \group_end:
4242 }
4243 }{ % \cs_if_free:NTF #1 FALSE BRANCH
4244 \msg_warning:nnn { moremath } { vector-calc / already-defined-skip } {#1}
4245 } % \cs_if_free:NTF #1
4246 }
4247 %
4248 \cs_generate_variant:Nn \@@_new_delim_nabla_doc_cmd:NNN {cNN}
4249 % \end{macrocode}
4250 % \end{macro}
4251 %
4252 % \begin{macro}{\@@_new_nabla_doc_cmds:nN}
4253 % This internal function creates five different document level commands at once,
4254 % using \cs{@@_new_delim_nabla_doc_cmd:cNN}.
4255 % It takes two arguments:
4256 % \begin{arguments}
4257 % \item The a \meta{suffix~tl} for constructing the command names.
4258 %
4259 % The resulting commands will have the form \cs[no-index]{p\meta{suffix}},
4260 % \cs[no-index]{b\meta{suffix}}, \cs[no-index]{B\meta{suffix}},
4261 % \cs[no-index]{v\meta{suffix}} and \cs[no-index]{V\meta{suffix}}.
4262 %
4263 % \item The \meta{csname} of the operator to use
4264 % \end{arguments}
4265 % \begin{macrocode}
4266 \cs_new_protected:Nn \@@_new_nabla_doc_cmds:nN
4267 {
4268 \@@_new_delim_nabla_doc_cmd:cNN { p #1 } #2 \@@_inparent:w
4269 \@@_new_delim_nabla_doc_cmd:cNN { b #1 } #2 \@@_inbrack:w
4270 \@@_new_delim_nabla_doc_cmd:cNN { B #1 } #2 \@@_inbrace:w
4271 \@@_new_delim_nabla_doc_cmd:cNN { v #1 } #2 \@@_in_vert:w
4272 \@@_new_delim_nabla_doc_cmd:cNN { V #1 } #2 \@@_in_Vert:w
4273 }
4274 % \end{macrocode}
4275 % \end{macro}
4276 %
4277 % \subsection{Document Level Commands}
4278 % \label{sec:vec-doc-lvl-commands}
4279 %
4280 % The predefined macros for vector calculus are also guarded by a package
4281 % option to be conditionally disabled by the user.
4282 % \begin{macrocode}
4283 \bool_if:NTF \l_@@_predef_vector_op_bool
4284 {
4285 % \end{macrocode}
4286 % \subsubsection{Standalone Operators}
4287 % \label{par:impl-vector-calc-standalone}
4288 % The user might want to use also a non-delimited version
4289 % of the vector calculus operators,
4290 % we provide them with a standalone version of those.
4291 %
4292 % As the definition of a new document command can fail if the \meta{csname}
4293 % clashes with some already defined macro,
4294 % we define an error message to use when defining document level commands.
4295 % \begin{macrocode}
4296 \msg_new:nnn { moremath } { vector-calc / already-defined-skip }
4297 {
4298 Control~sequence~'#1'~is~already~defined.\\
4299 Skipping~definition~\msg_line_context:.
4300 }
4301 % \end{macrocode}
4302 %
4303 % \begin{macro}{
4304 % \grad,
4305 % \divergence,
4306 % \curl,
4307 % \laplacian
4308 % }
4309 % Now we provide the user with document level commands for
4310 % \cs[no-index]{moremath_\meta{op}_operator:n}.
4311 % \begin{macrocode}
4312 \cs_if_free:NTF \grad
4313 {
4314 \exp_args:NNe \NewDocumentCommand \grad { !o E{ \char_generate:nn {`_}{8} }{{}} }
4315 {
4316 \group_begin:
4317 \tl_if_novalue:nF {#1}
4318 {
4319 \keys_set:nn {moremath} {#1}
4320 }
4321 \moremath_gradient_operator:n {#2}
4322 \group_end:
4323 }
4324 }{
4325 \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\grad}
4326 }
4327
4328 \cs_if_free:NTF \divergence
4329 {
4330 \exp_args:NNe \NewDocumentCommand \divergence
4331 { !o E{ \char_generate:nn {`_} {8} }{{}} }
4332 {
4333 \group_begin:
4334 \tl_if_novalue:nF {#1}
4335 {
4336 \keys_set:nn {moremath} {#1}
4337 }
4338 \moremath_divergence_operator:n {#2}
4339 \group_end:
4340 }
4341 }{
4342 \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\divergence}
4343 }
4344
4345 \cs_if_free:NTF \curl
4346 {
4347 \exp_args:NNe \NewDocumentCommand \curl
4348 { !o E{ \char_generate:nn {`_}{8} }{{}} }
4349 {
4350 \group_begin:
4351 \tl_if_novalue:nF {#1}
4352 {
4353 \keys_set:nn {moremath} {#1}
4354 }
4355 \moremath_curl_operator:n {#2}
4356 \group_end:
4357 }
4358 }{
4359 \msg_warning:nnn {moremath} {vector-calc / already-defined-skip} {\curl}
4360 }
4361
4362 \cs_if_free:NTF \laplacian
4363 {
4364 \exp_args:NNe \NewDocumentCommand \laplacian
4365 { !o E{ \char_generate:nn {`_}{8} }{{}} }
4366 {
4367 \group_begin:
4368 \tl_if_novalue:nF {#1}
4369 {
4370 \keys_set:nn {moremath} {#1}
4371 }
4372 \moremath_laplace_operator:n {#2}
4373 \group_end:
4374 }
4375 }{
4376 \msg_warning:nnn {moremath} { vector-calc / already-defined-skip }
4377 {\laplacian}
4378 }
4379 % \end{macrocode}
4380 % \begin{macro}{\quabla}
4381 % We now also define a command to use as a standalone
4382 % \foreignlanguage{french}{d'Alembert} operator.
4383 % As the name \cs[no-index]{dalembertian} is a bit cumbersome to type out,
4384 % I've decided to use one of its alternate names \cs{quabla}
4385 % \begin{macrocode}
4386 \cs_if_free:NTF \quabla
4387 {
4388 \exp_args:NNe \NewDocumentCommand \quabla
4389 { !o E{ \char_generate:nn {`_} { 8 } }{{}} }
4390 {
4391 \group_begin:
4392 \tl_if_novalue:nF {#1}
4393 {
4394 \keys_set:nn { moremath } {#1}
4395 }
4396 \moremath_dalembert_operator:n {#2}
4397 \group_end:
4398 }
4399 }{ % \cs_if_free:NTF \quabla FALSE BRANCH
4400 \msg_warning:nnn { moremath } { vector-calc / already-defined-skip }
4401 {\quabla}
4402 }
4403 % \end{macrocode}
4404 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{
4405 % Added \cs{quabla} command.
4406 % }
4407 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
4408 % Changed: Spaces between the \meta{csname}
4409 % and the optional argument are now disallowed.
4410 % }
4411 % \end{macro}^^X \quabla
4412 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
4413 % Added \cs{grad}, \cs{divergence}, \cs{curl} and \cs{laplacian}
4414 % commands.
4415 % }
4416 % \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{
4417 % Changed: Spaces between the \meta{csname}
4418 % and the optional argument are now disallowed
4419 % for \cs{grad}, \cs{divergence}, \cs{curl} and \cs{laplacian}.
4420 % }
4421 % \end{macro}
4422 %
4423 % \subsubsection{Operators with Delimiters}
4424 % \label{par:impl-vec-calc-op-delim}
4425 %
4426 % \begin{macro}{
4427 % \pgrad,
4428 % \bgrad,
4429 % \Bgrad,
4430 % \vgrad,
4431 % \Vgrad,
4432 % }
4433 % Now lets declare the delimited gradient operators.
4434 % We provide five versions using parenthesis, brackets, braces, single \tn{vert},
4435 % and double \tn{Vert}.
4436 % \begin{macrocode}
4437 \@@_new_nabla_doc_cmds:nN {grad} \moremath_gradient_operator:n
4438 % \end{macrocode}
4439 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4440 % Added commands for delimited gradient operators.
4441 % }
4442 % \end{macro}
4443 %
4444 % \begin{macro}{
4445 % \pdiv,
4446 % \bdiv,
4447 % \Bdiv,
4448 % \vdiv,
4449 % \Vdiv
4450 % }
4451 % Now we do the same for the divergence operator.
4452 % \begin{macrocode}
4453 \@@_new_nabla_doc_cmds:nN {div} \moremath_divergence_operator:n
4454 % \end{macrocode}
4455 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4456 % Added commands for delimited divergence operators.
4457 % }
4458 % \end{macro}
4459 %
4460 % \begin{macro}{
4461 % \pcurl,
4462 % \bcurl,
4463 % \Bcurl,
4464 % \vcurl,
4465 % \Vcurl
4466 % }
4467 % Now to the curl macros.
4468 % \begin{macrocode}
4469 \@@_new_nabla_doc_cmds:nN {curl} \moremath_curl_operator:n
4470 % \end{macrocode}
4471 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4472 % Added commands for delimited curl operators.
4473 % }
4474 % \end{macro}
4475 %
4476 % \begin{macro}{
4477 % \plaplacian,
4478 % \blaplacian,
4479 % \Blaplacian,
4480 % \vlaplacian,
4481 % \Vlaplacian
4482 % }
4483 % Next we take care of the laplacian
4484 % \begin{macrocode}
4485 \@@_new_nabla_doc_cmds:nN {laplacian} \moremath_laplace_operator:n
4486 % \end{macrocode}
4487 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4488 % Added commands for delimited Laplace operators.
4489 % }
4490 % \end{macro}
4491 %
4492 % \begin{macro}{
4493 % \pquabla,
4494 % \bquabla,
4495 % \Bquabla,
4496 % \vquabla,
4497 % \Vquabla
4498 % }
4499 % Finally we define delimited commands for the
4500 % \foreignlanguage{french}{d'Alembert} operator.
4501 % \begin{macrocode}
4502 \@@_new_nabla_doc_cmds:nN {quabla} \moremath_dalembert_operator:n
4503 % \end{macrocode}
4504 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{
4505 % Added commands for a delimited \foreignlanguage{french}{d'Alembert}
4506 % operator.
4507 % }
4508 % \end{macro}
4509 %
4510 % If the user issued \texttt{no-vector} as a package loading option,
4511 % write this to the log file.
4512 % \begin{macrocode}
4513 }{ % IF NOT \l_@@_predef_vector_op_bool
4514 \msg_info:nnnn {moremath} { load /disabling } {no-vector}
4515 {
4516 predefined~vector~calculus~macros
4517 }
4518 } % END \l_@@_predef_vector_op_bool
4519 % \end{macrocode}
4520 %
4521 % \section{Macros Producing Matrices and Vectors}
4522 % \label{sec:impl-matr-vec}
4523 %
4524 % \subsection{Producing Row and Column Vectors}
4525 %
4526 % The functions in this section are used to generate row and column vectors
4527 % utilizing \pkg{mathtools}~\autocite{mathtools} \env{matrix*} and
4528 % \env{smallmatrix*} environments.
4529 %
4530 % \begin{variable}{\l_@@_vector_entries_seq}
4531 % For generating row or column vectors it is necessary to store the entries
4532 % inside a variable. \cs{l_@@_vector_entries_seq} is used for this purpose.
4533 % \begin{macrocode}
4534 \seq_new:N \l_@@_vector_entries_seq
4535 % \end{macrocode}
4536 % \end{variable}
4537 %
4538 % Then we need a function for formatting the actual entries of the vector.
4539 % We need two version one for the row vector and one for the column vector
4540 % version.
4541 % \begin{macro}{
4542 % \@@_seq_to_column_vector:N,
4543 % \@@_seq_to_row_vector:N
4544 % }
4545 % These functions take one argument
4546 % \begin{arguments}
4547 % \item A sequence which should be converted to the contents of the single
4548 % column/row matrix.
4549 % \end{arguments}
4550 % They format the input suitable to be put inside a \env{matrix*} environment.
4551 % We begin with the column vector version.
4552 % \begin{macrocode}
4553 \cs_new_protected_nopar:Nn \@@_seq_to_column_vector:N
4554 {
4555 \seq_use:Nn #1 {\\}
4556 }
4557 % \end{macrocode}
4558 % Then we get to the row vector.
4559 % \begin{macrocode}
4560 \cs_new_protected_nopar:Nn \@@_seq_to_row_vector:N
4561 {
4562 \seq_use:Nn #1 {&}
4563 }
4564 % \end{macrocode}
4565 % \end{macro}
4566 %
4567 % In the next step we construct the single row/column matrix from the user
4568 % provided input.
4569 % \begin{macro}[updated=2024-08-20]{
4570 % \moremath_column_vector:nn,
4571 % \moremath_column_vector:Vn,
4572 % \moremath_row_vector:nn,
4573 % \moremath_row_vector:Vn,
4574 % }
4575 % The two commands \cs{moremath_column_vector:nn} and \cs{moremath_row_vector:nn}
4576 % construct the matrix, they both take two arguments.
4577 % \begin{arguments}
4578 % \item The delimiter specifier.
4579 %
4580 % This should be one of the prefixes of the \env{\meta{prefix}matrix*},
4581 % environments.
4582 %
4583 % Another possibility is to issue |small| as this parameter to get
4584 % an inline matrix.
4585 %
4586 % \item The comma separated contents of the matrix.
4587 % \end{arguments}
4588 % \begin{macrocode}
4589 \cs_new_protected_nopar:Nn \moremath_column_vector:nn
4590 {
4591 \seq_clear:N \l_@@_vector_entries_seq
4592 \seq_set_from_clist:Nn \l_@@_vector_entries_seq {#2}
4593
4594 \@@_matrix_star_begin:nV {#1} \l_@@_matrix_align_tl
4595 \@@_seq_to_column_vector:N \l_@@_vector_entries_seq
4596 \@@_matrix_star_end:n {#1}
4597 }
4598 %
4599 \cs_new_protected_nopar:Nn \moremath_row_vector:nn
4600 {
4601 \seq_clear:N \l_@@_vector_entries_seq
4602 \seq_set_from_clist:Nn \l_@@_vector_entries_seq {#2}
4603
4604 \@@_matrix_star_begin:nV {#1} \l_@@_matrix_align_tl
4605 \@@_seq_to_row_vector:N \l_@@_vector_entries_seq
4606 \@@_matrix_star_end:n {#1}
4607 }
4608 % \end{macrocode}
4609 % We also provide a "Vn" variant of those functions.
4610 % \begin{macrocode}
4611 \cs_generate_variant:Nn \moremath_column_vector:nn { Vn }
4612 \cs_generate_variant:Nn \moremath_row_vector:nn { Vn }
4613 % \end{macrocode}
4614 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4615 % Added functions producing row- and column vectors.
4616 % }
4617 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
4618 % Changed now uses \cs{@@_matrix_star_begin:nV} instead of raw
4619 % |\begin{#1matrix*}|.
4620 % }
4621 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
4622 % Added new "Vn" variants.
4623 % }
4624 % \end{macro}
4625 %
4626 % \begin{macro}{
4627 % \moremath_column_smallvector:nn,
4628 % \moremath_column_smallvector:Vn,
4629 % \moremath_row_smallvector:nn,
4630 % \moremath_row_smallvector:Vn,
4631 % }
4632 % To make the code more readable, we define functions specifically for
4633 % creating row and column vectors using the \env{smallmatrix*} family of
4634 % environments. These functions take the same arguments as the non-small
4635 % versions above.
4636 % \begin{macrocode}
4637 \cs_new_protected_nopar:Nn \moremath_column_smallvector:nn
4638 {
4639 \moremath_column_vector:nn {#1 small} {#2}
4640 }
4641
4642 \cs_new_protected_nopar:Nn \moremath_row_smallvector:nn
4643 {
4644 \moremath_row_vector:nn {#1 small} {#2}
4645 }
4646 % Variants
4647 \cs_generate_variant:Nn \moremath_column_smallvector:nn { Vn }
4648 \cs_generate_variant:Nn \moremath_row_smallvector:nn { Vn }
4649 % \end{macrocode}
4650 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4651 % Added functions producing inline math row- and column vectors.
4652 % }
4653 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
4654 % Added new "Vn" variants.
4655 % }
4656 % \end{macro}
4657 %
4658 % ^^X SUBSECTION: Shorthands for simple matrices
4659 % \subsection{Shorthands for Simple Matrices}
4660 % \label{sec:impl-matr-shorth}
4661 %
4662 % The construction of several simple matrices like diagonal matrices,
4663 % can be simplified as there is no need to use the \env{matrix} environment.\footnote{%
4664 % The code in this section is heavily inspired by the following answer on
4665 % \TeX{}SE: \url{https://tex.stackexchange.com/a/539741}
4666 % }
4667 %
4668 % \begin{variable}{
4669 % \l_@@_mat_diag_entries_seq,
4670 % \l_@@_mat_row_entries_seq,
4671 % }
4672 % We construct the matrices row by row, therefore we need to store the
4673 % currently constructed row inside a variable.
4674 % The same is true for the diagonal entries which also need to be stored
4675 % somewhere.
4676 % We therefore declare two sequence variables \cs{l_@@_mat_diag_entries_seq}
4677 % and \cs{l_@@_mat_row_seq} for this purpose
4678 % \begin{macrocode}
4679 \seq_clear_new:N \l_@@_mat_diag_entries_seq
4680 \seq_clear_new:N \l_@@_mat_row_entries_seq
4681 % \end{macrocode}
4682 % \end{variable}
4683 %
4684 % \subsubsection{(Anti-)diagonal matrices}
4685 % We split the construction of the matrix into multiple parts,
4686 % utilizing internal helper functions.
4687 % \begin{macro}{
4688 % \@@_constr_diagmat_row:n,
4689 % \@@_constr_antidiagmat_row:n
4690 % }
4691 % \cs{@@_constr_diagmat_row:n} and \cs{@@_constr_antidiagmat_row:n}
4692 % take one integer argument:
4693 % \begin{arguments}
4694 % \item The number of the current row.
4695 % \end{arguments}
4696 % They both construct a matrix row and place it inside the input stream.
4697 % They take the content of the (anti-)diagonal from the variable
4698 % \cs{l_@@_mat_diag_entries_seq}
4699 % and use the variable \cs{l_@@_mat_row_entries_seq}
4700 % to store the current row.
4701 % \begin{macrocode}
4702 \cs_new_protected:Nn \@@_constr_diagmat_row:n
4703 {
4704 \seq_clear:N \l_@@_mat_row_entries_seq
4705 % \end{macrocode}
4706 % As all diagonal matrices \(M \in A^{m \times n}\), where \(A\) is a field,
4707 % are quadratic i.e.\ \(A^{m \times n} \equiv A^{n \times n}\) the length of the
4708 % diagonal sequence equals the number of rows and columns of the matrix.
4709 % We exploit this fact here.
4710 % \begin{macrocode}
4711 \int_step_inline:nn {\seq_count:N \l_@@_mat_diag_entries_seq}
4712 {
4713 \int_compare:nTF { #1 == ##1 }
4714 {
4715 \seq_put_right:Nx \l_@@_mat_row_entries_seq
4716 {
4717 \seq_item:Nn \l_@@_mat_diag_entries_seq { #1 }
4718 }
4719 }{ % false branch
4720 \seq_put_right:NV \l_@@_mat_row_entries_seq \l_@@_matrix_fill_tl
4721 } % \int_compare:nTF { #1 == ##1 }
4722 }
4723 \seq_use:Nn \l_@@_mat_row_entries_seq { & } \\
4724 }
4725
4726 % Anti-diagonal version
4727 \cs_new_protected:Nn \@@_constr_antidiagmat_row:n
4728 {
4729 \seq_clear:N \l_@@_mat_row_entries_seq
4730 \int_step_inline:nn {\seq_count:N \l_@@_mat_diag_entries_seq}
4731 {
4732 \int_compare:nTF { #1 == ##1 }
4733 {
4734 % as this is a anti diagonal matrix we put in the elements from the
4735 % left so that the first entry is the right most entry
4736 \seq_put_left:Nx \l_@@_mat_row_entries_seq
4737 {
4738 \seq_item:Nn \l_@@_mat_diag_entries_seq { #1 }
4739 }
4740 }{ % false branch
4741 \seq_put_left:NV \l_@@_mat_row_entries_seq \l_@@_matrix_fill_tl
4742 } % \int_compare:nTF { #1 == ##1 }
4743 }
4744 \seq_use:Nn \l_@@_mat_row_entries_seq { & } \\
4745 }
4746 % \end{macrocode}
4747 % \end{macro}
4748 %
4749 % \begin{macro}{
4750 % \moremath_diagonal_matrix:nn,
4751 % \moremath_antidiagonal_matrix:nn,
4752 % \moremath_diagonal_smallmatrix:nn,
4753 % \moremath_antidiagonal_smallmatrix:nn,
4754 % }
4755 % The \cs[no-index]{moremath_\meta{a or d}_matrix:nn} and
4756 % \cs[no-index]{moremath_\meta{a or d}_smallmatrix:nn} family of functions
4757 % produce a matrix based on \pkg{mathtools}~\autocite{mathtools}
4758 % \env{matrix*} environment.
4759 % The functions take two arguments.
4760 % \begin{arguments}
4761 % \item The delimiter specifier.
4762 %
4763 % This should be one of the prefixes of the \env{\meta{prefix}matrix*}
4764 % environments.
4765 %
4766 % \item The comma separated contents of the (anti-)diagonal.
4767 % \end{arguments}
4768 % These functions also use the values of the variables
4769 % \cs{l_@@_matrix_fill_tl} and \cs{l_@@_matrix_align_tl}.
4770 % And modifies the variable \cs{l_@@_mat_diag_entries_seq}.
4771 % \begin{macrocode}
4772 \cs_new_protected:Nn \moremath_diagonal_matrix:nn
4773 {
4774 \seq_set_from_clist:Nn \l_@@_mat_diag_entries_seq { #2 }
4775 \@@_matrix_star_begin:nV { #1 } \l_@@_matrix_align_tl
4776 \int_step_function:nN { \seq_count:N \l_@@_mat_diag_entries_seq }
4777 \@@_constr_diagmat_row:n
4778 \@@_matrix_star_end:n { #1 }
4779 }
4780 %
4781 % Anti-diagonal matrix
4782 \cs_new_protected:Nn \moremath_antidiagonal_matrix:nn
4783 {
4784 \seq_set_from_clist:Nn \l_@@_mat_diag_entries_seq { #2 }
4785 \@@_matrix_star_begin:nV { #1 } \l_@@_matrix_align_tl
4786 \int_step_function:nN { \seq_count:N \l_@@_mat_diag_entries_seq }
4787 \@@_constr_antidiagmat_row:n
4788 \@@_matrix_star_end:n { #1 }
4789 }
4790
4791 % Small versions
4792 \cs_new_protected:Nn \moremath_diagonal_smallmatrix:nn
4793 {
4794 \moremath_diagonal_matrix:nn {#1 small} {#2}
4795 }
4796
4797 \cs_new_protected:Nn \moremath_antidiagonal_smallmatrix:nn
4798 {
4799 \moremath_antidiagonal_matrix:nn {#1 small} {#2}
4800 }
4801 % \end{macrocode}
4802 % \begin{macro}{
4803 % \moremath_diagonal_matrix:nV,
4804 % \moremath_diagonal_matrix:Vn,
4805 % \moremath_diagonal_matrix:VV,
4806 % \moremath_antidiagonal_matrix:nV,
4807 % \moremath_antidiagonal_matrix:Vn,
4808 % \moremath_antidiagonal_matrix:VV,
4809 % \moremath_diagonal_smallmatrix:nV,
4810 % \moremath_diagonal_smallmatrix:Vn,
4811 % \moremath_diagonal_smallmatrix:VV,
4812 % \moremath_antidiagonal_smallmatrix:nV,
4813 % \moremath_antidiagonal_smallmatrix:Vn,
4814 % \moremath_antidiagonal_smallmatrix:VV,
4815 % }
4816 % For convenience we also define some variants of the above functions.
4817 % \begin{macrocode}
4818 \cs_generate_variant:Nn \moremath_diagonal_matrix:nn { nV, Vn, VV }
4819 \cs_generate_variant:Nn \moremath_antidiagonal_matrix:nn { nV, Vn, VV }
4820 \cs_generate_variant:Nn \moremath_diagonal_smallmatrix:nn { nV, Vn, VV}
4821 \cs_generate_variant:Nn \moremath_antidiagonal_smallmatrix:nn { nV, Vn, VV }
4822 % \end{macrocode}
4823 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Added variants.}
4824 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{Added "nV" and "VV" variants.}
4825 % \end{macro}
4826 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
4827 % Added functions producing (anti-)diagonal matrices.
4828 % Also added versions for inline math.
4829 % }
4830 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
4831 % Changed now uses \cs{@@_matrix_star_begin:nV} instead of raw
4832 % |\begin{#1matrix*}|.
4833 % }
4834 % \end{macro}
4835 %
4836 %
4837 % \subsubsection{Identity Matrices}
4838 % As we already have functions available for producing diagonal matrices,
4839 % it makes only sense to also provide a shorthand for producing an identity matrix,
4840 % i.e.\ a diagonal matrix with \enquote{1} along the diagonal.
4841 %
4842 %
4843 % \begin{macro}{
4844 % \@@_generate_one_filled_clist:Nn
4845 % }
4846 % The function \cs{@@_generate_one_filled_clist:Nn} produces a \meta{clist},
4847 % consisting only of \enquote{1} as entries.
4848 % This function takes two arguments:
4849 % \begin{arguments}
4850 % \item The \emph{csname} of a \meta{clist~var} to store the \meta{clist}
4851 % into.
4852 %
4853 % \item An \meta{int} to represent the number of entries to produce.
4854 % \end{arguments}
4855 % \begin{macrocode}
4856 \cs_new_protected_nopar:Nn \@@_generate_one_filled_clist:Nn
4857 {
4858 \seq_clear:N \l_tmpa_seq
4859 \int_step_inline:nn {#2}
4860 {
4861 \seq_put_right:NV \l_tmpa_seq \c_one_int
4862 }
4863 \clist_set_from_seq:NN #1 \l_tmpa_seq
4864 }
4865 % \end{macrocode}
4866 % \begin{macro}{
4867 % \@@_generate_one_filled_clist:NV
4868 % }
4869 % We also define a variant accepting an integer variable.
4870 % \begin{macrocode}
4871 \cs_generate_variant:Nn \@@_generate_one_filled_clist:Nn { N V }
4872 % \end{macrocode}
4873 % \end{macro}
4874 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
4875 % Added function.
4876 % }
4877 % \end{macro}
4878 %
4879 % \begin{variable}{
4880 % \l_@@_id_entries_clist
4881 % }
4882 % As we want to utilize the \cs{moremath_diagonal_matrix:VV} and
4883 % \cs{moremath_diagonal_smallmatrix:VV} functions for creating the identity
4884 % matrix we declare an internal \meta{clist~var} called
4885 % \cs{l_@@_id_entries_clist} for passing the \meta{clist} around.
4886 % \begin{macrocode}
4887 \clist_new:N \l_@@_id_entries_clist
4888 % \end{macrocode}
4889 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{Added variable.}
4890 % \end{variable}
4891 %
4892 % \begin{macro}{
4893 % \moremath_id_matrix:n,
4894 % \moremath_id_smallmatrix:n
4895 % }
4896 % These functions are intended to produce an identity matrix from an integer
4897 % expression.
4898 % They take one argument.
4899 % \begin{arguments}
4900 % \item The number of diagonal entries.
4901 % \end{arguments}
4902 % \begin{macrocode}
4903 \cs_new_protected_nopar:Nn \moremath_id_matrix:n
4904 {
4905 \clist_clear:N \l_@@_id_entries_clist
4906 \@@_generate_one_filled_clist:Nn \l_@@_id_entries_clist {#1}
4907 \moremath_diagonal_matrix:VV \l_@@_matrix_delim_tl \l_@@_id_entries_clist
4908 }
4909 % \end{macrocode}
4910 %
4911 % \begin{macrocode}
4912 \cs_new_protected_nopar:Nn \moremath_id_smallmatrix:n
4913 {
4914 \clist_clear:N \l_@@_id_entries_clist
4915 \@@_generate_one_filled_clist:Nn \l_@@_id_entries_clist {#1}
4916 \moremath_diagonal_smallmatrix:VV \l_@@_matrix_delim_tl \l_@@_id_entries_clist
4917 }
4918 % \end{macrocode}
4919 %
4920 % \begin{macro}{
4921 % \moremath_id_matrix:V,
4922 % \moremath_id_smallmatrix:V
4923 % }
4924 % We also provide variants, which accepts a "V"-type argument:
4925 % \begin{macrocode}
4926 \cs_generate_variant:Nn \moremath_id_matrix:n { V }
4927 \cs_generate_variant:Nn \moremath_id_smallmatrix:n { V }
4928 % \end{macrocode}
4929 % \end{macro}
4930 %
4931 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
4932 % Added functions \cs{moremath_id_matrix:n} and \cs{moremath_id_smallmatrix:n}
4933 % and variants.
4934 % }
4935 % \end{macro}
4936 %
4937 % \subsection{Document Level Commands}
4938 % \label{sec:mat-doc-lvl-cmds}
4939 %
4940 % Now we define document level commands for the previously defined
4941 % functions.
4942 %
4943 % But before we do so we define a message to be issued in case the targeted
4944 % \meta{csname} is already defined elsewhere.
4945 % \begin{macrocode}
4946 \msg_new:nnnn { moremath } { matrix / already-defined-doc-cmd-skip }
4947 {
4948 Control~sequence~'#1'~is~already~defined.\\
4949 Skipping~definition~\msg_line_context:.
4950 }
4951 {
4952 The~control~sequence~'#1'~has~already\\
4953 been~defined~by~some~other~package.\\
4954 And~I~am~refusing~to~overwrite~the~existing~definition,\\
4955 therefore~I~am~skipping~the~definition~of~this~command.
4956 }
4957 % \end{macrocode}
4958 %
4959 % \subsubsection{Row and Column Vectors}
4960 % We begin with the row and column vector functions.
4961 % As with the other document level commands, we guard the definitions
4962 % with a key value option, so that the user can disable them.
4963 % \begin{macrocode}
4964 \bool_if:nTF \l_@@_predef_crvector_bool
4965 {
4966 % \end{macrocode}
4967 % \begin{macro}[updated=2024-08-20,]{
4968 % \cvector,
4969 % \rvector,
4970 % \smallcvector,
4971 % \smallrvector
4972 % }
4973 % First we define the document level command for the bare column vector
4974 % \begin{macrocode}
4975 \cs_if_free:NTF \cvector
4976 {
4977 \NewDocumentCommand \cvector { o m }
4978 {
4979 \group_begin:
4980 \tl_if_novalue:nF {#1}
4981 {
4982 \keys_set:nn { moremath / matrix } {#1}
4983 }
4984 \moremath_column_vector:Vn \l_@@_matrix_delim_tl {#2}
4985 \group_end:
4986 }
4987 }{
4988 % issue a warning message if the csname is already taken.
4989 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
4990 {
4991 \cvector
4992 }
4993 } % \cs_if_free:NTF \cvector
4994 % \end{macrocode}
4995 % and the row vector.
4996 % \begin{macrocode}
4997 \cs_if_free:NTF \rvector
4998 {
4999 \NewDocumentCommand \rvector { o m }
5000 {
5001 \group_begin:
5002 \tl_if_novalue:nF {#1}
5003 {
5004 \keys_set:nn { moremath / matrix } {#1}
5005 }
5006 \moremath_row_vector:Vn \l_@@_matrix_delim_tl {#2}
5007 \group_end:
5008 }
5009 }{
5010 % warn if csname is already taken
5011 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip}
5012 {
5013 \rvector
5014 }
5015 } % \cs_if_free:NTF \rvector
5016 % \end{macrocode}
5017 % Then we define the smaller inline versions of those commands.
5018 % \begin{macrocode}
5019 \cs_if_free:NTF \smallcvector
5020 {
5021 \NewDocumentCommand \smallcvector { o m }
5022 {
5023 \group_begin:
5024 \tl_if_novalue:nF {#1}
5025 {
5026 \keys_set:nn {moremath / matrix} {#1}
5027 }
5028 \moremath_column_smallvector:Vn \l_@@_matrix_delim_tl {#2}
5029 \group_end:
5030 }
5031 }{
5032 % Issue a warning message if the csname is already taken
5033 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5034 {
5035 \smallcvector
5036 }
5037 } % \cs_if_free:NTF \smallcvector
5038
5039 \cs_if_free:NTF \smallrvector
5040 {
5041 \NewDocumentCommand \smallrvector { o m }
5042 {
5043 \group_begin:
5044 \tl_if_novalue:nF {#1}
5045 {
5046 \keys_set:nn { moremath / matrix } {#1}
5047 }
5048 \moremath_row_smallvector:Vn \l_@@_matrix_delim_tl {#2}
5049 \group_end:
5050 }
5051 }{
5052 % warn if csname is taken
5053 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5054 {
5055 \smallrvector
5056 }
5057 }
5058 % \end{macrocode}
5059 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
5060 % Added commands producing row and column vectors,
5061 % including inline math versions.
5062 % }
5063 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
5064 % Use "Vn" versions of functions when passing variables around.
5065 % }
5066 % \end{macro}
5067 %
5068 % \paragraph{Commands with Pre-defined Delimiters}
5069 % Next we define several shorthands to for the commonly used delimiters,
5070 % to avoid code duplication, we first create some helper functions which
5071 % define those functions.
5072 % \begin{macro}[updated=2024-08-20]{
5073 % \@@_new_vector_shorth_doc_cmd:NNn
5074 % }
5075 % The function \cs{@@_new_vector_shorth_doc_cmd} creates a new vector shorthand,
5076 % command. It takes three arguments:
5077 % \begin{arguments}
5078 % \item The \meta{csname} to be defined.
5079 % \item The \meta{function} to use for this shorthand.
5080 %
5081 % This should be one of the
5082 % \cs[no-index]{moremath_\meta{type}_\meta{size}vector:Vn}
5083 % like commands.
5084 %
5085 % \item The \meta{delimiter} to use.
5086 %
5087 % Usually one of |p|, |b|, |B|, |v|, |V|.
5088 % \end{arguments}
5089 % \begin{macrocode}
5090 \cs_new_protected:Nn \@@_new_vector_shorth_doc_cmd:NNn
5091 {
5092 \cs_if_free:NTF #1
5093 {
5094 \NewDocumentCommand #1 { o m }
5095 {
5096 \group_begin:
5097 % set the delimiter key pre-set for this function
5098 \keys_set:nn {moremath / matrix } {delimiter = #3}
5099 \tl_if_novalue:nF {##1}
5100 {
5101 \keys_set:nn {moremath / matrix } {##1}
5102 }
5103 #2 \l_@@_matrix_delim_tl {##2}
5104 \group_end:
5105 }
5106 }{
5107 % warn if csname is taken
5108 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5109 {
5110 #1
5111 }
5112 }
5113 }
5114 % \end{macrocode}
5115 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
5116 % Require function with "Vn" signature to pass variable correctly.
5117 % }
5118 % \end{macro}
5119 %
5120 % \begin{macro}[updated=2024-08-20]{
5121 % \pcvector,
5122 % \bcvector,
5123 % \Bcvector,
5124 % \vcvector,
5125 % \Vcvector,
5126 % \prvector,
5127 % \brvector,
5128 % \Brvector,
5129 % \vrvector,
5130 % \Vrvector,
5131 % }
5132 % Now we define shorthands for all of the matrix types so that the user
5133 % does not have to specify |delimiter=|\meta{delim} every time.
5134 % We begin with the column vector.
5135 % \begin{macrocode}
5136 % parenthesis
5137 \@@_new_vector_shorth_doc_cmd:NNn \pcvector \moremath_column_vector:Vn {p}
5138 % brackets
5139 \@@_new_vector_shorth_doc_cmd:NNn \bcvector \moremath_column_vector:Vn {b}
5140 % braces
5141 \@@_new_vector_shorth_doc_cmd:NNn \Bcvector \moremath_column_vector:Vn {B}
5142 % single vert
5143 \@@_new_vector_shorth_doc_cmd:NNn \vcvector \moremath_column_vector:Vn {v}
5144 % double vert
5145 \@@_new_vector_shorth_doc_cmd:NNn \Vcvector \moremath_column_vector:Vn {V}
5146 % \end{macrocode}
5147 % Now to the row vectors.
5148 % \begin{macrocode}
5149 % parenthesis
5150 \@@_new_vector_shorth_doc_cmd:NNn \prvector \moremath_row_vector:Vn {p}
5151 % brackets
5152 \@@_new_vector_shorth_doc_cmd:NNn \brvector \moremath_row_vector:Vn {b}
5153 % braces
5154 \@@_new_vector_shorth_doc_cmd:NNn \Brvector \moremath_row_vector:Vn {B}
5155 % single vert
5156 \@@_new_vector_shorth_doc_cmd:NNn \vrvector \moremath_row_vector:Vn {v}
5157 % double vert
5158 \@@_new_vector_shorth_doc_cmd:NNn \Vrvector \moremath_row_vector:Vn {V}
5159 % \end{macrocode}
5160 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5161 % Added commands for row and column vectors with predefined delimiters.
5162 % }
5163 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
5164 % Use functions with "Vn" signature instead of "nn"
5165 % }
5166 % \end{macro}
5167 %
5168 % \begin{macro}[updated=2024-08-20]{
5169 % \psmallcvector,
5170 % \bsmallcvector,
5171 % \Bsmallcvector,
5172 % \vsmallcvector,
5173 % \Vsmallcvector,
5174 % \psmallrvector,
5175 % \bsmallrvector,
5176 % \Bsmallrvector,
5177 % \vsmallrvector,
5178 % \Vsmallrvector
5179 % }
5180 % We also define shorthands for the \cs{shortcvector} and \cs{shortrvector}
5181 % versions.
5182 % \begin{macrocode}
5183 % column vectors
5184 % parenthesis
5185 \@@_new_vector_shorth_doc_cmd:NNn \psmallcvector \moremath_column_smallvector:Vn
5186 {p}
5187 % brackets
5188 \@@_new_vector_shorth_doc_cmd:NNn \bsmallcvector \moremath_column_smallvector:Vn
5189 {b}
5190 % braces
5191 \@@_new_vector_shorth_doc_cmd:NNn \Bsmallcvector \moremath_column_smallvector:Vn
5192 {B}
5193 % single vert
5194 \@@_new_vector_shorth_doc_cmd:NNn \vsmallcvector \moremath_column_smallvector:Vn
5195 {v}
5196 % double vert
5197 \@@_new_vector_shorth_doc_cmd:NNn \Vsmallcvector \moremath_column_smallvector:Vn
5198 {V}
5199 %
5200 % row vectors
5201 % parenthesis
5202 \@@_new_vector_shorth_doc_cmd:NNn \psmallrvector \moremath_row_smallvector:Vn {p}
5203 % brackets
5204 \@@_new_vector_shorth_doc_cmd:NNn \bsmallrvector \moremath_row_smallvector:Vn {b}
5205 % braces
5206 \@@_new_vector_shorth_doc_cmd:NNn \Bsmallrvector \moremath_row_smallvector:Vn {B}
5207 % single vert
5208 \@@_new_vector_shorth_doc_cmd:NNn \vsmallrvector \moremath_row_smallvector:Vn {v}
5209 % double vert
5210 \@@_new_vector_shorth_doc_cmd:NNn \Vsmallrvector \moremath_row_smallvector:Vn {V}
5211
5212
5213 }{ % \bool_if:nTF \l_@@_predef_crvector_bool FALSE PATH
5214 \msg_info:nnnn {moremath} {load / disabling} {no-crvector}
5215 {
5216 commands~producing~row~and~column~vectors
5217 }
5218 } % \bool_if:nTF \l_@@_predef_crvector_bool
5219 % \end{macrocode}
5220 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5221 % Added commands for inline math row and column vectors
5222 % with predefined delimiters.
5223 % }
5224 % \changes{v0.5.0}{\GetVersionDate{v0.5.0}}{
5225 % Use functions with "Vn" signature instead of "nn"
5226 % }
5227 % \end{macro}
5228 %
5229 %
5230 % \subsubsection{(Anti-)diagonal Matrices}
5231 % Now to the (anti-)diagonal matrix shorthands,
5232 % these are also guarded by a key value option.
5233 % \begin{macrocode}
5234 \bool_if:nTF \l_@@_predef_matrix_bool
5235 {
5236 % \end{macrocode}
5237 % \begin{macro}{
5238 % \diagmat,
5239 % \antidiagmat,
5240 % \smalldiagmat,
5241 % \smallantidiagmat,
5242 % }
5243 % \begin{NOTE}{MI}
5244 % Say something like we begin with some commands producing a matrix that
5245 % is not necessarily delimited.
5246 % \end{NOTE}
5247 % \begin{macrocode}
5248 \cs_if_free:NTF \diagmat
5249 {
5250 \NewDocumentCommand \diagmat { o m }
5251 {
5252 \group_begin:
5253 \tl_if_novalue:nF {#1}
5254 {
5255 \keys_set:nn { moremath / matrix } {#1}
5256 }
5257 \moremath_diagonal_matrix:Vn \l_@@_matrix_delim_tl {#2}
5258 \group_end:
5259 }
5260 }{
5261 \msg_warning:nnn {moremath} {matrix / already-defined-doc-cmd-skip}
5262 {
5263 \diagmat
5264 }
5265 } % \cs_if_free:nTF \diagmat
5266
5267 \cs_if_free:NTF \antidiagmat
5268 {
5269 \NewDocumentCommand \antidiagmat { o m }
5270 {
5271 \group_begin:
5272 \tl_if_novalue:nF {#1}
5273 {
5274 \keys_set:nn { moremath / matrix } {#1}
5275 }
5276 \moremath_antidiagonal_matrix:Vn \l_@@_matrix_delim_tl {#2}
5277 \group_end:
5278 }
5279 }{
5280 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5281 {
5282 \antidiagmat
5283 }
5284 } % \cs_if_free:nTF \antidiagmat
5285
5286 \cs_if_free:NTF \smalldiagmat
5287 {
5288 \NewDocumentCommand \smalldiagmat { o m }
5289 {
5290 \group_begin:
5291 \tl_if_novalue:nF {#1}
5292 {
5293 \keys_set:nn { moremath / matrix } {#1}
5294 }
5295 \moremath_diagonal_smallmatrix:Vn \l_@@_matrix_delim_tl {#2}
5296 \group_end:
5297 }
5298 }{
5299 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5300 {
5301 \smalldiagmat
5302 }
5303 }
5304
5305 \cs_if_free:NTF \smallantidiagmat
5306 {
5307 \NewDocumentCommand \smallantidiagmat { o m }
5308 {
5309 \group_begin:
5310 \tl_if_novalue:nF {#1}
5311 {
5312 \keys_set:nn { moremath / matrix } {#1}
5313 }
5314 \moremath_antidiagonal_smallmatrix:Vn \l_@@_matrix_delim_tl {#2}
5315 \group_end:
5316 }
5317 }{
5318 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5319 {
5320 \smallantidiagmat
5321 }
5322 }
5323 % \end{macrocode}
5324 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
5325 % Added commands producing (anti-)diagonal matrices, including inline math
5326 % versions.
5327 % }
5328 % \end{macro}
5329 %
5330 % \paragraph{(Anti-)diagonal Matrices with Pre-defined Delimiters}
5331 % As it is sort of cumbersome to always specify the delimiter key,
5332 % we also provide commands with pre-defined delimiters.
5333 % \begin{macro}{
5334 % \@@_new_matrix_shorth_doc_cmd:NNn
5335 % }
5336 % To provide several shorthands for delimited matrices,
5337 % we use a helper function to avoid code duplication.
5338 % \cs{@@_new_matrix_shorth_doc_cmd:NNn} takes three arguments:
5339 % \begin{arguments}
5340 % \item The \meta{csname} to define
5341 % \item The \meta{csname} of the matrix function to use,
5342 % which should have the signature |Vn|.
5343 % \item The \enquote{predefined} delimiter of this version
5344 % \end{arguments}
5345 % \begin{macrocode}
5346 \cs_new_protected:Nn \@@_new_matrix_shorth_doc_cmd:NNn
5347 {
5348 \cs_if_free:NTF #1
5349 {
5350 \NewDocumentCommand #1 { o m }
5351 {
5352 \group_begin:
5353 \tl_if_empty:nF {#3}
5354 {
5355 \keys_set:nn { moremath / matrix }
5356 {
5357 delimiter = #3
5358 }
5359 } % \tl_if_empty:nF {#3}
5360 \tl_if_novalue:nF {##1}
5361 {
5362 \keys_set:nn { moremath / matrix } {##1}
5363 }
5364 #2 \l_@@_matrix_delim_tl {##2}
5365 \group_end:
5366 }
5367 }{
5368 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5369 {
5370 #1
5371 }
5372 }
5373 }
5374 % \end{macrocode}
5375 % \end{macro}
5376 %
5377 % We now define the shorthand commands with predefined delimiters.
5378 % \begin{macro}{
5379 % \pdiagmat,
5380 % \bdiagmat,
5381 % \Bdiagmat,
5382 % \vdiagmat,
5383 % \Vdiagmat,
5384 % }
5385 % We begin with the regular diagonal matrix
5386 % \begin{macrocode}
5387 \@@_new_matrix_shorth_doc_cmd:NNn \pdiagmat \moremath_diagonal_matrix:Vn {p}
5388 \@@_new_matrix_shorth_doc_cmd:NNn \bdiagmat \moremath_diagonal_matrix:Vn {b}
5389 \@@_new_matrix_shorth_doc_cmd:NNn \Bdiagmat \moremath_diagonal_matrix:Vn {B}
5390 \@@_new_matrix_shorth_doc_cmd:NNn \vdiagmat \moremath_diagonal_matrix:Vn {v}
5391 \@@_new_matrix_shorth_doc_cmd:NNn \Vdiagmat \moremath_diagonal_matrix:Vn {V}
5392 % \end{macrocode}
5393 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5394 % Added commands for delimited diagonal matrices.
5395 % }
5396 % \end{macro}
5397 % \begin{macro}{
5398 % \pantidiagmat,
5399 % \bantidiagmat,
5400 % \Bantidiagmat,
5401 % \vantidiagmat,
5402 % \Vantidiagmat,
5403 % }
5404 % Now for the anti-diagonal matrix commands.
5405 % \begin{macrocode}
5406 \@@_new_matrix_shorth_doc_cmd:NNn \pantidiagmat
5407 \moremath_antidiagonal_matrix:Vn {p}
5408 \@@_new_matrix_shorth_doc_cmd:NNn \bantidiagmat
5409 \moremath_antidiagonal_matrix:Vn {b}
5410 \@@_new_matrix_shorth_doc_cmd:NNn \Bantidiagmat
5411 \moremath_antidiagonal_matrix:Vn {B}
5412 \@@_new_matrix_shorth_doc_cmd:NNn \vantidiagmat
5413 \moremath_antidiagonal_matrix:Vn {v}
5414 \@@_new_matrix_shorth_doc_cmd:NNn \Vantidiagmat
5415 \moremath_antidiagonal_matrix:Vn {V}
5416 % \end{macrocode}
5417 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5418 % Added commands for delimited antidiagonal matrices.
5419 % }
5420 % \end{macro}
5421 %
5422 % \begin{macro}{
5423 % \psmalldiagmat,
5424 % \bsmalldiagmat,
5425 % \Bsmalldiagmat,
5426 % \vsmalldiagmat,
5427 % \Vsmalldiagmat,
5428 % }
5429 % We continue with the inline math versions based on the \env{smallmatrix*}
5430 % environment.
5431 % \begin{macrocode}
5432 \@@_new_matrix_shorth_doc_cmd:NNn \psmalldiagmat
5433 \moremath_diagonal_smallmatrix:Vn {p}
5434 \@@_new_matrix_shorth_doc_cmd:NNn \bsmalldiagmat
5435 \moremath_diagonal_smallmatrix:Vn {b}
5436 \@@_new_matrix_shorth_doc_cmd:NNn \Bsmalldiagmat
5437 \moremath_diagonal_smallmatrix:Vn {B}
5438 \@@_new_matrix_shorth_doc_cmd:NNn \vsmalldiagmat
5439 \moremath_diagonal_smallmatrix:Vn {v}
5440 \@@_new_matrix_shorth_doc_cmd:NNn \Vsmalldiagmat
5441 \moremath_diagonal_smallmatrix:Vn {V}
5442 % \end{macrocode}
5443 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5444 % Added commands for delimited diagonal matrices suitable for inline math.
5445 % }
5446 % \end{macro}
5447 % \begin{macro}{
5448 % \psmallantidiagmat,
5449 % \bsmallantidiagmat,
5450 % \Bsmallantidiagmat,
5451 % \vsmallantidiagmat,
5452 % \Vsmallantidiagmat,
5453 % }
5454 % We provide also anti-diagonal versions of the small matrices.
5455 % \begin{macrocode}
5456 \@@_new_matrix_shorth_doc_cmd:NNn \psmallantidiagmat
5457 \moremath_antidiagonal_smallmatrix:Vn {p}
5458 \@@_new_matrix_shorth_doc_cmd:NNn \bsmallantidiagmat
5459 \moremath_antidiagonal_smallmatrix:Vn {b}
5460 \@@_new_matrix_shorth_doc_cmd:NNn \Bsmallantidiagmat
5461 \moremath_antidiagonal_smallmatrix:Vn {B}
5462 \@@_new_matrix_shorth_doc_cmd:NNn \vsmallantidiagmat
5463 \moremath_antidiagonal_smallmatrix:Vn {v}
5464 \@@_new_matrix_shorth_doc_cmd:NNn \Vsmallantidiagmat
5465 \moremath_antidiagonal_smallmatrix:Vn {V}
5466 % \end{macrocode}
5467 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{
5468 % Added commands for delimited anti-diagonal matrices suitable for inline math.
5469 % }
5470 % \end{macro}
5471 %
5472 % \subsubsection{Identity Matrices}
5473 % We also provide document level commands for producing an identity matrix.
5474 % These commands are also guarded by the same variable as the other matrix commands
5475 % (\cs{l_@@_predef_matrix_bool}).
5476 %
5477 % \begin{macro}{
5478 % \idmat,
5479 % \smallidmat,
5480 % }
5481 % We provide two document level commands for producing the identiy matrix,
5482 % one for inline math mode and one for display math mode.
5483 %
5484 % We start with the display math mode version.
5485 % \begin{macrocode}
5486 \cs_if_free:NTF \idmat
5487 {
5488 \NewDocumentCommand \idmat { o m }
5489 {
5490 \group_begin:
5491 \tl_if_novalue:nF {#1}
5492 {
5493 \keys_set:nn { moremath / matrix } {#1}
5494 }
5495 \moremath_id_matrix:n {#2}
5496 \group_end:
5497 }
5498 }{ % \cs_if_free:NTF \idmat FALSE BRANCH
5499 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5500 {\idmat}
5501 }
5502 % \end{macrocode}
5503 % Afterwards we continue with the inline math mode version.
5504 % \begin{macrocode}
5505 \cs_if_free:NTF \smallidmat
5506 {
5507 \NewDocumentCommand \smallidmat { o m }
5508 {
5509 \group_begin:
5510 \tl_if_novalue:nF {#1}
5511 {
5512 \keys_set:nn { moremath / matrix } {#1}
5513 }
5514 \moremath_id_smallmatrix:n {#2}
5515 \group_end:
5516 }
5517 }{ % \cs_if_free:NTF \smallidmat FALSE BRANCH
5518 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5519 {\smallidmat}
5520 }
5521 % \end{macrocode}
5522 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
5523 % Added \cs{idmat} and \cs{smallidmat} document level commands.
5524 % }
5525 % \end{macro}
5526 %
5527 % \paragraph{Identity Matrices with Pre-defined Delimiters}
5528 % We also define shorthands for the commonly used delimiters around matrices,
5529 % to avoid code duplication, we first declare a helper function for this.
5530 % \begin{macro}{
5531 % \@@_new_id_matrix_doc_cmd:NNn
5532 % }
5533 % This function creates a new document level command for an identity matrix like
5534 % command.
5535 % It allows pre-setting \meta{kv~opts}.
5536 % The function takes three arguments.
5537 % \begin{arguments}
5538 % \item The \meta{csname} of the document level command to define
5539 %
5540 % \item The \meta{csname} of the function to use
5541 %
5542 % This is indented to be one of \cs{moremath_id_matrix:n} or
5543 % \cs{moremath_id_smallmatrix:n}
5544 %
5545 % \item \meta{kv~opts} to preset in the "moremath / matrix" namespace
5546 % for this command
5547 %
5548 % This is meant to be used for pre-setting the key "delimiter".
5549 % \end{arguments}
5550 % \begin{macrocode}
5551 \cs_new_protected:Nn \@@_new_id_matrix_doc_cmd:NNn
5552 {
5553 \cs_if_free:NTF #1
5554 {
5555 \NewDocumentCommand #1 { o m }
5556 {
5557 \group_begin:
5558 \tl_if_empty:nF {#3}
5559 {
5560 \keys_set:nn { moremath / matrix } {#3}
5561 }
5562 \tl_if_novalue:nF {##1}
5563 {
5564 \keys_set:nn { moremath / matrix } {##1}
5565 }
5566 #2 {##2}
5567 \group_end:
5568 }
5569 }{ % \cs_if_free:NTF #1 FALSE BRANCH
5570 \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip }
5571 {#1}
5572 }
5573 }
5574 % \end{macrocode}
5575 % \end{macro}
5576 %
5577 % \begin{macro}{
5578 % \pidmat,
5579 % \bidmat,
5580 % \Bidmat,
5581 % \vidmat,
5582 % \Vidmat
5583 % }
5584 % We begin with the display math versions,
5585 % starting with the version delimited by parenthesis,
5586 % \begin{macrocode}
5587 \@@_new_id_matrix_doc_cmd:NNn \pidmat \moremath_id_matrix:n { delimiter = p }
5588 % \end{macrocode}
5589 % continue with the bracketed version,
5590 % \begin{macrocode}
5591 \@@_new_id_matrix_doc_cmd:NNn \bidmat \moremath_id_matrix:n { delimiter = b }
5592 % \end{macrocode}
5593 % the version using braces,
5594 % \begin{macrocode}
5595 \@@_new_id_matrix_doc_cmd:NNn \Bidmat \moremath_id_matrix:n { delimiter = B }
5596 % \end{macrocode}
5597 % single vertical lines,
5598 % \begin{macrocode}
5599 \@@_new_id_matrix_doc_cmd:NNn \vidmat \moremath_id_matrix:n { delimiter = v }
5600 % \end{macrocode}
5601 % and finally double vertical lines.
5602 % \begin{macrocode}
5603 \@@_new_id_matrix_doc_cmd:NNn \Vidmat \moremath_id_matrix:n { delimiter = V }
5604 % \end{macrocode}
5605 %
5606 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{
5607 % Added document level commands \cs{pidmat}, \cs{bidmat}, \cs{Bidmat},
5608 % \cs{vidmat}, and \cs{Vidmat}.
5609 % }
5610 % \end{macro}
5611 %
5612 % \begin{macro}{
5613 % \psmallidmat,
5614 % \bsmallidmat,
5615 % \Bsmallidmat,
5616 % \vsmallidmat,
5617 % \Vsmallidmat,
5618 % }
5619 % Now we also define shorthands for inline math mode.
5620 % We start again defining the version using parenthesis,
5621 % \begin{macrocode}
5622 \@@_new_id_matrix_doc_cmd:NNn \psmallidmat \moremath_id_smallmatrix:n
5623 { delimiter = p }
5624 % \end{macrocode}
5625 % then brackets,
5626 % \begin{macrocode}
5627 \@@_new_id_matrix_doc_cmd:NNn \bsmallidmat \moremath_id_smallmatrix:n
5628 { delimiter = b }
5629 % \end{macrocode}
5630 % then braces,
5631 % \begin{macrocode}
5632 \@@_new_id_matrix_doc_cmd:NNn \Bsmallidmat \moremath_id_smallmatrix:n
5633 { delimiter = B }
5634 % \end{macrocode}
5635 % followed by single vertical lines,
5636 % \begin{macrocode}
5637 \@@_new_id_matrix_doc_cmd:NNn \vsmallidmat \moremath_id_smallmatrix:n
5638 { delimiter = v }
5639 % \end{macrocode}
5640 % and finally double vertical lines.
5641 % \begin{macrocode}
5642 \@@_new_id_matrix_doc_cmd:NNn \Vsmallidmat \moremath_id_smallmatrix:n
5643 { delimiter = V }
5644 % \end{macrocode}
5645 % \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{%
5646 % Added document level commands \cs{psmallidmat}, \cs{bsmallidmat},
5647 % \cs{Bsmallidmat}, \cs{vsmallidmat} and \cs{Vsmallidmat}.
5648 % }
5649 % \end{macro}
5650 %
5651 % \begin{macrocode}
5652 }{ % \bool_if:nTF \l_@@_predef_matrix_bool FALSE BRANCH
5653 \msg_info:nnnn {moremath} { load / disabling } { no-matrix }
5654 {
5655 (anti-)diagonal~matrix~commands
5656 }
5657 } % \bool_if:nTF \l_@@_predef_matrix_bool
5658 % \end{macrocode}
5659 %
5660 %
5661 % \section{Shorthand Macros for Absolute Value and Norm}
5662 % \label{sec:impl-abs-shorthands}
5663 %
5664 % We first declare another warning message to inform the user of the case that,
5665 % the \meta{csnames} are already taken.
5666 % \begin{macrocode}
5667 \msg_new:nnnn { moremath } { abs-shorth / csname-already-defined-skip }
5668 {
5669 Control~sequence~'#1'~is~already~defined.\\
5670 Skipping~declaration~of~paired~delimiter~\msg_line_context:.\\
5671 Use~package~option~'no-abs-shorthands'~to~disable~the~paired\\
5672 delimiter~shorthands.
5673 }{
5674 The~control~sequence~'#1'~has~already~been\\
5675 defined~by~something~else.\\
5676 I~am~refusing~to~overwrite~its~existing~definition~and~instead~avoid\\
5677 declaring~a~paired~delimiter.\\
5678 }
5679 % \end{macrocode}
5680 %
5681 %
5682 % As with the other parts these macros may be conditionally disabled.
5683 % \begin{macrocode}
5684 \bool_if:NTF \l_@@_predef_abs_bool
5685 {
5686 % \end{macrocode}
5687 % \begin{macro}{\abs,\norm}
5688 % These macros provide shorthands for \(\abs{\meta{content}}\)
5689 % and \(\norm{\meta{content}}\).
5690 % \begin{macrocode}
5691 \cs_if_free:NTF \abs
5692 {
5693 \DeclarePairedDelimiter \abs {\lvert} {\rvert}
5694 }{
5695 % warn if the csname is taken
5696 \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip }
5697 {\abs}
5698 } % \cs_if_free:NTF \abs
5699
5700 \cs_if_free:NTF \norm
5701 {
5702 \DeclarePairedDelimiter \norm {\lVert} {\rVert}
5703 }{
5704 % warn if csname is already taken
5705 \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip }
5706 {\norm}
5707 } % \cs_if_free:NTF
5708 % \end{macrocode}
5709 % \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{%
5710 % Added shorthands for absolute value and norm.
5711 % }
5712 % \end{macro}
5713 %
5714 % \begin{macrocode}
5715 }{
5716 \msg_info:nnnn {moremath} {load / disabling} {no-abs-shorthands}
5717 {
5718 '\abs'~and~'\norm'~macros
5719 }
5720 } % End of the conditional
5721 % \end{macrocode}
5722 %
5723 % \iffalse debug-switch
5724 %\debug_off:n {all}
5725 % \fi
5726 % \begin{macrocode}
5727 %</package>
5728 % \end{macrocode}
5729 % \end{implementation}
5730 %
5731 % \section*{Copyright and License}
5732 % \addcontentsline{toc}{section}{Copyright and License}
5733 % \label{sec:license}
5734 %
5735 % The following copyright notice applies to the \pkg{moremath} package:
5736 %
5737 % \begin{quote}
5738 % Copyright \textcopyright{} 2024 Marcel Ilg
5739 %
5740 % This work may be distributed and/or modified under the
5741 % conditions of the LaTeX Project Public License, either version 1.3
5742 % of this license or (at your option) any later version.
5743 % The latest version of this license is in
5744 % \url{https://www.latex-project.org/lppl.txt}
5745 % and version 1.3 or later is part of all distributions of LaTeX
5746 % version 2005/12/01 or later.
5747 %
5748 % This work has the LPPL maintenance status \enquote{maintained}.
5749 %
5750 % The Current Maintainer of this work is Marcel Ilg.
5751 %
5752 % This work consists of the files listed in \file{MANIFEST.md}.
5753 % \end{quote}
5754 %
5755 % \noindent The file \file{MANIFEST.md} has to be distributed together with the
5756 % package.
5757 %
5758 %
5759 % \printbibliography[heading=bibintoc]
5760 % \PrintChanges
5761 % \PrintIndex