diff options
author | Karl Berry <karl@freefriends.org> | 2024-07-15 21:37:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-07-15 21:37:23 +0000 |
commit | 4320a78558317d5c6c80ce26a11d9bd30c6164aa (patch) | |
tree | 6f1cedc886a3734df0b7a5d7cac79230ab449290 /Master/texmf-dist/source/latex/moremath | |
parent | 1ba9a729a2fc1b85eb84c0db01a471753d6ceb90 (diff) |
moremath (15jul24)
git-svn-id: svn://tug.org/texlive/trunk@71810 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/moremath')
-rw-r--r-- | Master/texmf-dist/source/latex/moremath/moremath.dtx | 5515 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/moremath/moremath.ins | 66 |
2 files changed, 5581 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/moremath/moremath.dtx b/Master/texmf-dist/source/latex/moremath/moremath.dtx new file mode 100644 index 00000000000..3b520f4ac21 --- /dev/null +++ b/Master/texmf-dist/source/latex/moremath/moremath.dtx @@ -0,0 +1,5515 @@ +% \iffalse meta-comment +% +% Copyright (C) 2024 Marcel Ilg +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% +% https://www.latex-project.org/lppl.txt +% +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status ‘maintained’. +% +% The Current Maintainer of this work is Marcel Ilg. +% +% This work consists of the files listed in MANIFEST.md. +% \fi +% +% \iffalse +% +%<*driver> +% Generated by ctanbib +\begin{filecontents*}[overwrite]{\jobname.bib} +@preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" } +@manual{amsfonts, + title = {The \ctanbibpkgname{amsfonts} package}, + subtitle = {TeX fonts from the American Mathematical Society}, + author = {{The American Mathematical Society}}, + url = {https://ctan.org/pkg/amsfonts}, + urldate = {2024-07-04}, + date = {}, + version = {3.04}, +} + +@preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" } +@manual{amsmath, + title = {The \ctanbibpkgname{amsmath} package}, + subtitle = {AMS mathematical facilities for LaTeX}, + author = {{The LaTeX Project Team}}, + url = {https://ctan.org/pkg/amsmath}, + urldate = {2024-07-04}, + date = {2023-05-13}, + version = {2.17o}, +} + +@preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" } +@manual{bm, + title = {The \ctanbibpkgname{bm} package}, + subtitle = {Access bold symbols in maths mode}, + author = {Carlisle, David and Mittelbach, Frank and {The LaTeX Project Team}}, + url = {https://ctan.org/pkg/bm}, + urldate = {2024-07-04}, + date = {2023-12-19}, + version = {1.2f}, +} + +@preamble{ "\providecommand\ctanbibpkgname[1]{\textsl{#1}}" } +@manual{mathtools, + title = {The \ctanbibpkgname{mathtools} package}, + subtitle = {Mathematical tools to use with amsmath}, + author = {Høgholm, Morten and Madsen, Lars and Robertson, Will and Wright, Joseph and {The LaTeX Project Team}}, + url = {https://ctan.org/pkg/mathtools}, + urldate = {2024-07-04}, + date = {2024-03-11}, + version = {1.30}, +} +\end{filecontents*} +\begin{filecontents*}[overwrite]{\jobname-ams-op-table.tex} +\begin{tabular}{rlrlrlrl} + \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 \)\\ + \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 \)\\ + \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 \)\\ + \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 \)\\ + \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 \)\\ + \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 \)\\ + \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 \)\\ + \cs[module=amsmath,replace=false]{coth} &\(\coth\) &\cs[module=amsmath,replace=false]{injlim} &\(\injlim\) &\cs[module=amsmath,replace=false]{min} &\( \min \) & &\\ + \cs[module=amsmath,replace=false]{csc} &\(\csc\) &\cs[module=amsmath,replace=false]{ker} &\(\ker\) &\cs[module=amsmath,replace=false]{Pr} &\( \Pr \) & &\\ +\end{tabular} +\begin{center} + \begin{tabular}{rlrl} + \cs[module=amsmath,replace=false]{varinjlim} &\(\varinjlim\) &\cs[module=amsmath,replace=false]{varliminf} &\(\varliminf\)\\ + \cs[module=amsmath,replace=false]{varprojlim} &\(\varprojlim\) &\cs[module=amsmath,replace=false]{varlimsup} &\(\varlimsup\)\\ + \end{tabular} +\end{center} +\end{filecontents*} + + +% custom commands for use inside the documentation +\ExplSyntaxOn +% Property list storing version date information +\prop_new:N \l__moremathdoc_version_date_prop + +\cs_new_protected:Nn \moremathdoc_add_version:nn +{ + \prop_put_if_new:Nnn \l__moremathdoc_version_date_prop {#1} {#2} +} + +\cs_new_protected:Nn \moremathdoc_get_version:n +{ + \group_begin: + \prop_get:NnNT \l__moremathdoc_version_date_prop {#1} \l_tmpa_tl + { + \tl_use:N \l_tmpa_tl + } + \group_end: +} + +\NewDocumentCommand \AddVersion { m m } +{ + \moremathdoc_add_version:nn {#1} {#2} +} + +\NewDocumentCommand \GetVersionDate { m } +{ + \moremathdoc_get_version:n {#1} +} +\ExplSyntaxOff + +\documentclass[% +%show-notes,% +]{l3doc} + +\SetupDoc{reportchangedates=true} +\RecordChanges + +\usepackage[american]{babel} +\AddBabelHook[american]{nofrench}{afterextras}{\frenchspacing} + +\usepackage[style=alphabetic]{biblatex} +\addbibresource{\jobname.bib} + +\usepackage{csquotes} +\SetCiteCommand{\autocite} + +\usepackage{amssymb} +\usepackage[bm]{moremath} + +% renew the ctanbibpkgname command +\NewDocumentCommand\ctanbibpkgname{m}{\pkg{#1}} + +% Example operators and commands +\DeclareMathOperator{\glorb}{glorb} +\DeclarePairedDelimiter{\inparen}{\lparen}{\rparen} +\DeclareDelimitedOperator{\pglorb}{\glorb}{\inparen} + +\begin{document} + \DocInput{moremath.dtx} +\end{document} +%</driver> +% \fi +% +% ^^X Get the package version name etc. +% \GetFileInfo{moremath.sty} +% +% ^^X Register changes here +% \AddVersion{v0.1.0}{2024-06-28} +% \AddVersion{v0.2.0}{2024-07-04} +% \AddVersion{v0.3.0}{2024-07-08} +% \AddVersion{v0.4.0}{2024-07-15} +% +% ^^X Placeholder for unreleased versions +% \AddVersion{vUNRELEASED}{UNRELEASED} +% +% \begin{documentation} +% +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Initial development release} +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Split the documentation into several parts. +% } +% \changes{v0.4.0}{\GetVersionDate{v0.4.0}}{ +% \textbf{Breaking Change:} Rename the package +% and the \meta{prefix} used for function names from +% "conmath" to "moremath". +% } +% +% \title{The \pkg{moremath} package\thanks{This document coresponds to +% \textsf{moremath}~\fileversion, dated \filedate.}} +% +% \author{Marcel Ilg\thanks{\texttt{mister01x (at) web (dot) de}}} +% +% \date{Released \filedate} +% +% \maketitle +% +% \begin{abstract} +% The \pkg{moremath} package provides several document level commands +% to ease the typesetting +% and \LaTeX{} code readability of certain mathematical constructs. +% It provides complementary commands to all operators defined by \pkg{amsmath}, +% the commands typeset delimiters that may be automatically, manually or +% not scaled at all. +% The commands also accept optional sub- and superscripts to the operators. +% +% Furthermore it provides several commands to typeset gradient, divergence, +% curl, and Laplace operators, +% for which there are also versions with delimiters. +% Those commands also accept an optional subscript +% and their appearance can be modified using key-value options. +% +% Additionally commands are provided for producing row and column vectors, +% as well as (anti-)diagonal matrices, +% utilizing \pkg{mathtools} \env{matrix*} family of environments. +% +% Most of the document level commands defined by this package can also +% be disabled using a package load-time option to avoid clashes with +% commands defined by other packages. +% \end{abstract} +% +% \section*{Note: This Package is Still in its Initial Development Phase} +% Do not expect a stable interface until version 1.0.0 has been reached! +% While I try to keep the interface stable and backwards compatible, +% I am unable to promise this. +% +% \tableofcontents +% +% \part{Document Author Documentation} +% \label{pt:doc-auth} +% +% \section{Introduction} +% \label{sec:intro} +% +% When typesetting mathematics in \LaTeX{} it is very common to often encounter, +% code patterns such as |\sin \left( \frac{x}{2} \right)|. +% While this above code works as expected its not especially easy for human +% readers of this code to immediately understand what that code is going to +% do. +% +% This package tries to ease readability of such commonly used constructs +% by providing commands that (hopefully) increase readability, +% as well as speeding up writing math in \LaTeX{}. +% Using \pkg{moremath} the above code can be simplified to |\psin*{\frac{x}{2}}|, +% which is shorter and better \enquote{human readable}. +% The package also provides the possibility for users to define such delimited operators, +% on their own. +% +% There are also other things that can be improved when typesetting math. +% One prominent example is the typsetting of row and column vectors, +% which require the use of a \env{matrix} environment. +% For this case \pkg{moremath} provides commands which accept a comma separated +% list of vector entries, +% obliterating the need for a \env{matrix} environment to typeset vectors. +% +% The same goes for (anti-)diagonal matrices, +% only the elements of the diagonal are of importance here. +% Therefore the production of those matrices may also be simplified into a single command, +% which again improves readability of the code compared to a mostly empty \env{matrix} environment. +% +% Another feature of this package is the definition of several (delimited) +% vector calculus operators such as gradient, divergence and curl operators, +% this does not only improve the semantics of the math code +% (|\mathop{\nabla} f| vs.\ |\grad f|), +% but also tries to provide the correct spacing between the operator and its +% arguments. +% +% The \pkg{moremath} package is written using \LaTeX{}3 +% and provides a small \LaTeX{}3 interface for class and package writers. +% +% The source code for \pkg{moremath} is hosted on GitHub at +% \begin{center} +% \url{https://github.com/Mister00X/moremath} +% \end{center} +% If you have any issues or found a bug, feel free to register an issue there. +% +% \section{Dependencies} +% \label{sec:deps} +% +% The main dependency of this package is \pkg{mathtools}~\autocite{mathtools}. +% Optionally the \pkg{bm}~\autocite{bm} may be loaded. +% +% If the option "no-vector" has \emph{not} been given as a package load time option, +% this package also loads the \pkg{amssymb}~\autocite{amsfonts} package. +% +% \section{Package Options} +% \label{sec:pack-opts} +% +% ^^X SUBSECTION: Package Load Time Options +% \subsection{Package Load Time Options} +% \label{sec:pkg-load-time-opts} +% The options described in this section \emph{must} be given +% at package load time i.e.\ as package options. +% All options which are not described below will be passed to +% \pkg{mathtools}~\autocite{mathtools}, +% see its documentation for more information. +% +% \DescribeOption{bm} The \verb|bm| option +% loads the \pkg{bm}~\autocite{bm} package which provides a better version of +% the \cs{boldsymbol} command. +% +% +% +% +% The options +% \DescribeOption{no-vector} "no-vector", +% \DescribeOption{no-abs-shorthands} "no-abs-shorthands", +% \DescribeOption{no-operators} "no-operators", +% \DescribeOption{no-crvector} "no-crvector", +% and \DescribeOption{no-matrix} "no-matrix" +% disable the definition of the predefined commands described in sections~\ref{sec:vector-calculus}, +% \ref{sec:shorthands}, +% \ref{sec:delim-ops}, +% \ref{sec:rc-vectors}, +% and~\ref{sec:matrices} +% respectively. +% +% \DescribeOption{nopredef} +% The option |nopredef| achieves the same as the three +% |no-|\meta{functionality} options above. +% It accepts multiple values, valid option values are: +% |vector|, +% |abs|, +% |operators|, +% |crvector|, +% |matrix|, +% and |all|. +% The values +% |abs|, +% |operators|, +% and |vector| +% disable the predefined +% document level commands for +% delimited operators, +% vector calculus +% and the shorthands for absolute value and norm respectively. +% The values "crvector" and "matrix" disable the shorthand commands +% for row and column vectors, and simple matrices respectively. +% The special value |all| disables all of them. +% +% The option accepts multiple values which can be given as a comma separated +% list, or as multiple key-value options, like in the examples below: +% \begin{verbatim} +% \usepackage[nopredef={vector,abs,operators}]{moremath} +% \end{verbatim} +% This is equivalent to +% \begin{verbatim} +% \usepackage[nopredef=all]{moremath} +% \end{verbatim} +% and to: +% \begin{verbatim} +% \usepackage[nopredef=vector,nopredef=abs,nopredef=operators]{moremath} +% \end{verbatim} +% +% The command \cs{NewDelimitedOperator} is not affected by any of the above +% settings. +% +% ^^X SUBSECTION: General Options +% \subsection{General Options} +% \label{sec:pkg-general-options} +% +% The options described in this section +% \emph{must not} be given as package options, +% instead they should be set using \cs{moremathsetup} +% or given as optional argument to the commands described later. +% \begin{function}[updated = 2024-07-15]{\moremathsetup} +% \begin{syntax} +% \cs{moremathsetup}\marg{kv~list} +% \end{syntax} +% Sets the options specified in the \meta{key-value list}, +% the assignment is local to the current group. +% If a \meta{value} contains a comma it needs to be wrapped in braces. +% This command may be used anywhere in the document after \pkg{moremath} +% has been loaded. +% \end{function} +% +% \subsubsection{Options Affecting Vector Calculus Operators} +% \label{sec:options-vec-calc} +% +% \DescribeOption{nabla} +% The option |nabla| sets the symbol to use by the document level commands +% described in section~\ref{sec:vector-calculus} to use for the nabla. +% It accepts a list of \meta{tokens}. Its default value is |\nabla|. +% +% \DescribeOption{arrownabla} +% The option |arrownabla| puts a small arrow over the gradient operator symbol. +% Its default value is |false|. +% +% \DescribeOption{boldnabla} +% The option |boldnabla| makes the nabla symbol bold. +% If the |bm| package option has been given the |\boldsymbol| command from +% the \pkg{bm} package is used for the bold symbol, +% otherwise the \pkg{amsmath}~\autocite{amsmath} version is used. +% +% \DescribeOption{grad-op} +% The option |grad-op| may be used to overwrite, +% the built in version of the gradient operator, it accepts a \meta{token list}. +% Use at your own responsibility. +% +% \DescribeOption{laplacian-symb} +% The option |laplacian-symb| sets the symbol to use by the document level +% commands described in section~\ref{sec:vector-calculus} to use for the +% Laplace operator. It accepts a list of \meta{tokens}. +% +% \DescribeOption{delta-laplace} +% The option |delta-laplace| replaces the Laplace operator symbol +% (by default \(\laplacian\)) with a uppercase delta +% (\(\laplacian[delta-laplace=true]\)). +% Its default value is |false|. +% +% \DescribeOption{arrowlaplace} +% The option |arrowlaplace| if set to |true| makes the Laplace operator look +% like this: \(\laplacian[arrowlaplace=true]\). +% +% \DescribeOption{laplacian} +% Like the option |grad-op| above the option |laplacian| may be used to +% overwrite the built-in version of the Laplace operator. +% Use at your own responsibility. +% +% \DescribeOption{dalembert-symb} +% Like the option "nabla" this sets the symbol to use by the document level +% commands described in section~\ref{sec:dalembert-op-cmds} to use as symbol +% for the \foreignlanguage{french}{d'Alembert} operator. It accepts a list of +% \meta{tokens}. It's default value is \cs[module=amssymb,replace=false]{square}. +% +% \DescribeOption{vcenter} +% The option "vcenter" controls if certain mathematical symbols +% of the operators described in section~\ref{sec:vector-calculus} should be +% vertically centered along the math-axis. +% The default value of this option is "true". +% +% +% +% \subsubsection{Options Affecting Matrices and Vectors} +% \label{sec:options-matrix} +% +% The options in this section only affect the commands described in sections~\ref{sec:rc-vectors} +% and~\ref{sec:matrices}. To set them with \cs{moremathsetup} it is necessary +% to add the prefix |matrix / | to these options, +% so that the resulting command looks like \cs{moremathsetup}\texttt{\{matrix / \meta{option}\}}. +% When using these options inside the optional argument of the commands described +% in sections~\ref{sec:rc-vectors} and~\ref{sec:matrices}, the prefix "matrix /" +% must be omitted. +% +% \DescribeOption{delimiter} +% The option |delimiter| determines the delimiters used for the matrices, +% valid values are "p" for parenthesis, "b" for brackets, "B" for braces, +% "v" for single vertical lines (\enquote{\(\vert\)}), +% "V" for double vertical lines (\enquote{\(\Vert\)}) or empty for no delimiters. +% The default value is "{}" (empty). +% +% \DescribeOption{fill} +% The fill option determines the values an (anti-)diagonal matrix is filled with, +% outside the diagonal. The default is again empty. +% +% \DescribeOption{align} +% This option determines the alignment of the numbers inside the matrix. +% The value of this option gets passed to the optional argument of the \env{matrix*} +% or \env{smallmatrix*} family of environments defined by \pkg{mathtools}~\autocite{mathtools}. +% Valid values for both types of those environments are |l| for left alignment, +% |r| for right alignment and |c| for centered alignment. The default is |c|. +% +% \begin{texnote} +% The non-"small" versions of the commands described in the sections~\ref{sec:rc-vectors} +% and~\ref{sec:matrices}, accept \textcquote{mathtools}{\textelp{} +% any column type valid in the usual \env{array} environment.} +% \end{texnote} +% +% +% \section{Delimited Operators} +% \label{sec:delim-ops} +% +% \subsection{Delimited Operators Predefined by \pkg{moremath}} +% \label{sec:delim-op-predef} +% +% \DescribeOption{no-operators} +% If the package load time option |no-operators| is not given this package defines several +% delimited mathematical operators. +% +% \begin{table} +% \caption{% +% Operator commands defined by the \pkg{amsmath}~\autocite{amsmath} +% package.} +% \label{tab:amsmath-operators} +% \vspace{.5\baselineskip} +% \input{\jobname-ams-op-table.tex} +% \end{table} +% +% \begin{function}{ +% \parccos, \barccos, \Barccos, \varccos, \Varccos, +% } +% \begin{syntax} +% \cs{parccos} \oarg{size cmd} \marg{contents} + +% \cs{parccos} \oarg{size cmd} \textasciicircum\marg{superscript} \marg{contents} +% +% \cs{parccos} \oarg{size cmd} \_\marg{subscript} \marg{contents} +% +% \cs{parccos} \oarg{size cmd} \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents} +% +% \cs{parccos}* \marg{contents} +% +% \cs{parccos}* \textasciicircum\marg{superscript} \marg{contents} +% +% \cs{parccos}* \_\marg{subscript} \marg{contents} +% \cs{parccos}* \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents} +% +% +% \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \textasciicircum\marg{superscript} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \_\marg{subscript} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}} \oarg{size cmd} \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}}* \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}}* \textasciicircum\marg{superscript} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}}* \_\marg{subscript} \marg{contents} +% \cs[no-index]{\meta{prefix}\meta{op name}}* \textasciicircum\marg{superscript} \_\marg{subscript} \marg{contents} +% \end{syntax} +% For all of the operators predefined by \pkg{amsmath}~\autocite{amsmath}, +% which are shown in table~\ref{tab:amsmath-operators}, +% \pkg{moremath} declares delimited versions. +% The name of those commands follows the scheme \cs[no-index]{\meta{prefix}\meta{op}}, +% where \meta{prefix} is one of |p|, |b|, |B|, |v|, or |V| +% and \meta{op} is the name of one of the operators shown in table~\ref{tab:amsmath-operators}. +% +% The \meta{prefix}es |p|, |b|, |B|, |v|, and |V| stand for +% parenthesis, brackets, braces, single vertical lines (\enquote{\(\vert\)}), and double vertical lines +% (\enquote{\(\Vert\)}) respectively. +% +% The commands accept a \meta{size cmd} optional argument, which is usually one of +% \cs{big}, \cs{Big}, \cs{bigg} and \cs{Bigg}. +% These \meta{size cmd}s are used to change the size of the delimiters. +% +% The commands also accept sub- and superscripts, +% which have to be issued \emph{after} the optional argument (if present), +% but before the mandatory argument \meta{contents}. +% +% The starred variant uses automatic scaling for the delimiters depending on the height of its contents. +% \end{function} +% +% \paragraph{Examples} +% +% The following examples showcase the use of those predefined delimited operators: +% \begin{enumerate} +% \item Different delimited operators without any scaling: +% +% \begin{verbatim} +% \[ +% \pcos{x} \times \bcos{y} +% \times \Bcos{z} \times \vcos{a} +% \times \Vcos{b} +% \] +% \end{verbatim} +% \[ +% \pcos{x} \times \bcos{y} +% \times \Bcos{z} \times \vcos{a} +% \times \Vcos{b} +% \] +% +% \item Delimited operator with automatic scaling: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcos*{\frac{x^{2}}{2}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pcos*{\frac{x^{2}}{2}} +% \] +% \end{minipage} +% +% \item Delimited operator with manual scaling: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcos[\Big]{\frac{x^{2}}{2}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pcos[\Big]{\frac{x^{2}}{2}} +% \] +% \end{minipage} +% +% \item Delimited operator with subscript: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \plog_{10}{1+x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% ^^X XXX: Using an underscore is broken here (because of l3doc???) therefore I +% ^^X use "\sb" instead. +% \[ +% \plog\sb{10}{1+x} +% \] +% \end{minipage} +% +% \item Delimited operator with superscript: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcos^{2}{x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pcos^{2}{x} +% \] +% \end{minipage} +% +% \item Delimited operator with both sub- and superscript and manual scaling: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcos[\Big]^{2}_{x}{\frac{x}{2}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% ^^X XXX: Again use "\sb" instead of "_" because of l3doc +% \[ +% \pcos[\Big]^{2}\sb{x}{\frac{x}{2}} +% \] +% \end{minipage} +% \end{enumerate} +% +% +% \subsection{Declaring New Delimited Operators} +% \label{sec:delim-op-new} +% +% \begin{function}{\DeclareDelimitedOperator} +% \begin{syntax} +% \cs{DeclareDelimitedOperator}\marg{new op}\marg{op}\marg{delim} +% \end{syntax} +% Creates a new delimited operator, +% the name of the new command will be \meta{new op}. +% The \meta{op} is the command of the operator to use, +% which is usually a command declared with +% \cs[module=amsmath,replace=false]{DeclareMathOperator}. +% \meta{delim} is the command to use as paired delimiter, +% it is expected to behave like a paired delimiter declared by +% \pkg{mathtools}~\autocite{mathtools} +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}. +% \end{function} +% +% \paragraph{Example: Creating a New Delimited Operator} +% The following code creates a new operator and a paired delimiter +% and uses it afterwards to declare a paired operator. +% \begin{verbatim} +% \documentclass{scrartcl} +% +% \DeclareMathOperator{\glorb}{glorb} +% \DeclarePairedDelimiter{\inparen}{\lparen}{\rparen} +% \DeclarePairedOperator{\pglorb}{\glorb}{\inparen} +% +% \begin{document} +% \[ +% \pglorb{a} +% \] +% \end{document} +% \end{verbatim} +% The result then looks like this: +% \[ +% \pglorb{a} +% \] +% +% +% \section{Vector Calculus Operators} +% \label{sec:vector-calculus} +% +% \DescribeOption{no-vector} +% The commands in this section are only declared if the option |no-vector| +% has not been given to the package as a load time option. +% +% \DescribeOption{vcenter} +% The option "vcenter" controls if the symbols for the operators described below +% should be vertically centered along the math axis. Its default value is "true". +% +% This option only shows its effects if other options like "arrownabla", +% "arrowlaplace", or "boldnabla" are set to "true". +% Like in the example below: +% \begin{quote} +% \begin{verbatim} +% \begin{gather*} +% \grad f(x) \quad \grad[arrownabla,vcenter=false] f(x) +% \quad \grad[arrownabla,vcenter=true] f(x)\\ +% \laplacian f(x) \quad \laplacian[arrowlaplace,vcenter=false] f(x) +% \quad \laplacian[arrowlaplace,vcenter=true] f(x) +% \end{gather*} +% \end{verbatim} +% \begin{gather*} +% \grad f(x) \quad \grad[arrownabla,vcenter=false] f(x) +% \quad \grad[arrownabla,vcenter=true] f(x)\\ +% \laplacian f(x) \quad \laplacian[arrowlaplace,vcenter=false] f(x) +% \quad \laplacian[arrowlaplace,vcenter=true] f(x) +% \end{gather*} +% \end{quote} +% +% All of the commands described in this section take key-value options +% as optional argument, which are described in section~\ref{sec:options-vec-calc} +% +% \subsection{Gradient Operator Commands} +% \label{sec:grad-op-cmds} +% +% \subsubsection{Standalone Operator Command} +% \label{sec:grad-op-standalone} +% +% \begin{function}[updated=2024-07-08]{ +% \grad, +% } +% \begin{syntax} +% \cs{grad} \oarg{kv opts} +% \cs{grad} \oarg{kv opts} \_\marg{subscript} +% \end{syntax} +% The \cs{grad} command produces a gradient operator +% looking like this \enquote{\(\grad\)} by default. +% The optional argument \meta{kv opts} accepts the key-value options +% described in section~\ref{sec:options-vec-calc}, +% whitespace between the command name +% and \oarg{kv~opts} is \emph{not allowed}. +% An optional subscript using "_" may be given after the optional argument. +% \end{function} +% +% \paragraph{Examples of Use} +% \begin{enumerate} +% \item Standalone gradient operator (with and without subscript): +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \grad f(x), \quad \grad_{x} f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \grad f(x), \quad \grad\sb{x} f(x) +% \] +% \end{minipage} +% +% \item Bold version of the gradient operator: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \grad[boldnabla] f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \grad[boldnabla] f(x) +% \] +% \end{minipage} +% +% \item Gradient operator with an arrow: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \grad[arrownabla] f(x) +% \] +% \end{verbatim} +% \end{minipage} +% \begin{minipage}{.49\linewidth} +% \[ +% \grad[arrownabla] f(x) +% \] +% \end{minipage} +% \end{enumerate} +% +% \subsubsection{Operators with Delimiters} +% \label{sec:grad-op-delim} +% +% \begin{function}{ +% \pgrad, +% \bgrad, +% \Bgrad, +% \vgrad, +% \Vgrad +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}grad} \oarg{size cmd} \marg{content} +% \cs[no-index]{\meta{delim}grad} \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}grad} \oarg{size cmd} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}grad} \oarg{kv opts} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}grad}* \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}grad}* \oarg{kv opts} \_\marg{subscript} \marg{content} +% \end{syntax} +% The \cs[no-index]{\meta{delim}grad} family of commands produces +% gradient operator which is followed by \meta{contents} inside delimiters. +% The delimiter is determined by the first letter of the command \meta{delim}, +% which may be "p" for parenthesis, "b" for brackets, "B" for braces, +% "v" for a single vertical line (\enquote{\(\vert\)}), or "V" for a double +% vertical line (\enquote{\(\Vert\)}). +% +% The commands accept either a \meta{size command} as optional argument, +% which gets passed to \pkg{mathtools}~\autocite{mathtools} paired delimiter +% or a list of \meta{key-value option}s, +% the \meta{kv opts} \emph{must} be given using the complete syntax, +% i.e.\ \meta{key}"="\meta{value}, +% shorthands for options with an implicit default value (|arrownabla|), +% will not work here. +% The \meta{size~command} is usually one of \cs{big}, \cs{Big}, \cs{bigg} and +% \cs{Bigg}. +% Valid \meta{kv opts} are all options described in section~\ref{sec:options-vec-calc} +% and the key "scale" which accepts a \meta{size cmd}. +% +% \begin{quote} +% \textbf{Note:}\\ +% Do not mix \meta{kv opts} and \meta{size cmd}, +% use either |\pgrad[\big]{f(x)}| or |\pgrad[arrownabla=true,scale=\big]{f(x)}|. +% \end{quote} +% +% \medskip\noindent +% An optional \meta{subscript} may be given between the optional argument, +% and \meta{contents}. One use case for this subscript is to write formulae +% using the so called Feynman-notation, where the gradient operator acts +% only on one variable. +% +% The starred version of the commands automatically scale the delimiters +% with its contents. +% \end{function} +% +% \paragraph{Examples:} +% \begin{enumerate} +% \item Gradient operator with non-scaled delimiters: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pgrad{1+\vec{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pgrad{1+\vec{x}} +% \] +% \end{minipage} +% +% \item Bold version: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pgrad[boldnabla=true]{1+\vec{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pgrad[boldnabla=true]{1+\vec{x}} +% \] +% \end{minipage} +% +% \item Gradient operator with automatically scaled delimiters: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pgrad*{\frac{1}{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pgrad*{\frac{1}{x}} +% \] +% \end{minipage} +% +% \item Manually scaled version: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \begin{gather*} +% \pgrad[\Big]{\frac{1}{x}}\\[.5ex] +% \pgrad[scale=\Big]{\frac{1}{x}} +% \end{gather*} +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \begin{gather*} +% \pgrad[\Big]{\frac{1}{x}}\\[.5ex] +% \pgrad[scale=\Big]{\frac{1}{x}} +% \end{gather*} +% \end{minipage} +% +% \item Feynman-Notation: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pgrad_{x}{x+y+z} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pgrad\sb{x}{x+y+z} +% \] +% \end{minipage} +% \end{enumerate} +% +% \subsection{Divergence Operator Commands} +% \label{sec:div-op-cmds} +% +% \subsubsection{Standalone Operator Command} +% \label{sec:div-op-standalone} +% +% \begin{function}[updated=2024-07-08]{\divergence} +% \begin{syntax} +% \cs{divergence} \oarg{kv opts} +% \cs{divergence} \oarg{kv opts} \_\marg{subscript} +% \end{syntax} +% The \cs{divergence} command produces the divergence operator +% \enquote{\(\divergence\)}, +% its usage is analogous to the use of the \cs{grad} command, +% which is described in section~\ref{sec:grad-op-standalone}. +% \end{function} +% +% \paragraph{Examples} +% \begin{enumerate} +% \item Standalone divergence operator +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \divergence f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\divergence f\] +% \end{minipage} +% +% \item Standalone divergence operator +% with an arrow over the gradient operator +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \divergence[arrownabla] f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\divergence[arrownabla] f(x)\] +% \end{minipage} +% +% \item Standalone divergence operator with subscript +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \divergence_{x} f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% ^^X We need to use \sb because of the subscript package +% \begin{minipage}{.49\linewidth} +% \[\divergence\sb{x} f(x)\] +% \end{minipage} +% \end{enumerate} +% \subsubsection{Operators with Delimiters} +% \label{sec:div-op-delim} +% +% \begin{function}{ +% \pdiv, +% \bdiv, +% \Bdiv, +% \vdiv, +% \Vdiv +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}div} \oarg{size cmd} \marg{content} +% \cs[no-index]{\meta{delim}div} \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}div} \oarg{size cmd} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}div} \oarg{kv opts} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}div}* \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}div}* \oarg{kv opts} \_\marg{subscript} \marg{content} +% \end{syntax} +% The \cs[no-index]{\meta{delim}div} family of commands produces the divergence +% operator with its arguments placed inside delimiters. +% The usage of these commands is analogous to the \cs[no-index]{\meta{delim}grad} +% family of commands described in section~\ref{sec:grad-op-delim}. +% \end{function} +% +% \paragraph{Examples} +% +% \begin{enumerate} +% \item Divergence operator with parenthesis and no scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pdiv{1+x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\pdiv{1+x}\] +% \end{minipage} +% \item Bold version with manual scaling and subscript +% +% \begin{verbatim} +% \[ +% \pdiv[boldnabla=true,scale=\Big]_{x}{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \[\pdiv[boldnabla=true,scale=\Big]\sb{x}{1+\frac{1}{x}}\] +% +% \item Automatic scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pdiv*{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\pdiv*{1 + \frac{1}{x}}\] +% \end{minipage} +% \end{enumerate} +% +% \subsection{Curl Operator Commands} +% \label{sec:curl-op-cmds} +% +% \subsubsection{Standalone Operator Command} +% \label{sec:curl-op-standalone} +% +% \begin{function}[updated=2024-07-08]{\curl} +% \begin{syntax} +% \cs{curl} \oarg{kv opts} +% \cs{curl} \oarg{kv opts} \_\marg{subscript} +% \end{syntax} +% The \cs{curl} command produces the curl operator \enquote{\(\curl\)}, +% its usage is analogous to the use of the \cs{grad} command +% described in section~\ref{sec:grad-op-standalone}. +% \end{function} +% +% \paragraph{Examples} +% \begin{enumerate} +% \item Standalone curl operator +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \curl f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\curl f(x)\] +% \end{minipage} +% +% \item Standalone curl operator with an arrow over the gradient operator +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \curl[arrownabla] f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\curl[arrownabla] f(x)\] +% \end{minipage} +% +% \item Standalone curl operator with subscript +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \curl_{x} f(x,y) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\curl\sb{x} f(x,y)\] +% \end{minipage} +% \end{enumerate} +% +% \subsubsection{Operators with Delimiters} +% \label{sec:curl-op-delim} +% +% \begin{function}{ +% \pcurl, +% \bcurl, +% \Bcurl, +% \vcurl, +% \Vcurl +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}curl} \oarg{size cmd} \marg{content} +% \cs[no-index]{\meta{delim}curl} \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}curl} \oarg{size cmd} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}curl} \oarg{kv opts} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}curl}* \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}curl}* \oarg{kv opts} \_\marg{subscript} \marg{content} +% \end{syntax} +% The \cs[no-index]{\meta{delim}curl} family of commands produce the curl operator +% with its arguments placed inside delimiters. +% The usage of these commands is analogous to the \cs[no-index]{\meta{delim}grad} +% family of commmands described in section~\ref{sec:grad-op-delim}. +% \end{function} +% +% \paragraph{Examples} +% \begin{enumerate} +% \item Curl operator with parenthesis without scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcurl{1+x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\pcurl{1+x}\] +% \end{minipage} +% +% \item Bold version with manual scaling and subscript +% +% \begin{verbatim} +% \[ +% \pcurl[boldnabla=true,scale=\Big]_{x}{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \[ +% \pcurl[boldnabla=true,scale=\Big]\sb{x}{1 + \frac{1}{x}} +% \] +% +% \item Automatic scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcurl*{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\pcurl*{1 + \frac{1}{x}}\] +% \end{minipage} +% \end{enumerate} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Fixed example to match description. +% } +% +% +% \subsection{Laplace Operator Commands} +% \label{sec:laplace-op-cmds} +% +% This section describes commands which can be used to typeset a Laplace +% operator. +% +% +% Like the commands described in sections~\ref{sec:grad-op-cmds}, +% \ref{sec:div-op-cmds}, and~\ref{sec:curl-op-cmds} +% the commands in this section accept key-value options via an optional +% argument. +% There is some deviation from the options compared to the above commands: +% The "arrownabla" option is ignored, +% instead the "arrowlaplace" option produces an arrow over the operator. +% The "boldnabla" option on the other hand is not ignored. +% Finally the "delta-laplace" option replaces the symbol used +% for the operator from \(\laplacian\) to \(\laplacian[delta-laplace]\) +% +% \subsubsection{Standalone Operator Command} +% \label{sec:laplace-op-standalone} +% +% +% \begin{function}[updated=2024-07-08]{\laplacian} +% \begin{syntax} +% \cs{laplacian} \oarg{kv opts} +% \cs{laplacian} \oarg{kv opts} \_\marg{subscript} +% \end{syntax} +% The \cs{laplacian} command produces a Laplace operator, +% which looks by default like this: \(\laplacian\). +% +% Its interface is analogous to the \cs{grad}, \cs{divergence}, +% and \cs{curl} commands described above, +% with the difference in key-value options described at the start of this +% subsection. +% \end{function} +% +% +% \subsubsection{Operators with Delimiters} +% \label{sec:laplace-op-delim} +% +% \begin{function}{ +% \plaplacian, +% \blaplacian, +% \Blaplacian, +% \vlaplacian, +% \Vlaplacian +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}laplacian} \oarg{size cmd} \marg{content} +% \cs[no-index]{\meta{delim}laplacian} \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}laplacian} \oarg{size cmd} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}laplacian} \oarg{kv opts} \_\marg{subscript} \marg{content} +% \cs[no-index]{\meta{delim}laplacian}* \oarg{kv opts} \marg{content} +% \cs[no-index]{\meta{delim}laplacian}* \oarg{kv opts} \_\marg{subscript} \marg{content} +% \end{syntax} +% \end{function} +% +% \paragraph{Examples} +% \begin{enumerate} +% \item Laplace operator delimited by parenthesis without scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \plaplacian{1+x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\plaplacian{1+x}\] +% \end{minipage} +% +% \item Version with arrow, manual scaling and subscript +% +% \begin{verbatim} +% \[ +% \plaplacian[arrowlaplace=true,scale=\Big]_{x}{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \[ +% \plaplacian[arrowlaplace=true,scale=\Big]\sb{x}{1 + \frac{1}{x}} +% \] +% +% \item Version with automatic scaling +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \plaplacian*{1 + \frac{1}{x}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\plaplacian*{1 + \frac{1}{x}}\] +% \end{minipage} +% +% \item Using a delta as symbol for the Laplacian +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \plaplacian[delta-laplace=true]{1+x} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\plaplacian[delta-laplace=true]{1+x}\] +% \end{minipage} +% \end{enumerate} +% +% +% \subsection{^^X +% Commands Producing a \foreignlanguage{french}{d'Alembert} operator +% } +% \label{sec:dalembert-op-cmds} +% +% \subsubsection{Standalone Operator Command} +% \label{sec:dalembert-op-standalone} +% +% \begin{function}[ +% added = 2024-07-04, +% updated=2024-07-08, +% ]{\quabla} +% \begin{syntax} +% \cs{quabla} \oarg{kv~opts} +% \cs{quabla} \oarg{kv~opts} \_\marg{subscript} +% \end{syntax} +% The \cs{quabla} command produces +% the \foreignlanguage{french}{d'Alembert} operator \enquote{\(\quabla\)}. +% This command accepts an optional subscript. +% \end{function} +% +% The command is called \cs{quabla} because thats shorter and easier to type than +% \cs[no-index]{dalembertian}. +% If you want to have a command called \cs[no-index]{dalembertian}, +% put the following in your documents preamble. +% \begin{verbatim} +% \NewCommandCopy\quabla\dalembertian +% \end{verbatim} +% +% \paragraph{Example of Use:} +% \begin{quote} +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \quabla f(x) +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\quabla f(x)\] +% \end{minipage} +% \end{quote} +% +% +% \subsubsection{Operators with Delimiters} +% \label{sec:dalembert-op-delim} +% +% \begin{function}[added = 2024-07-04]{ +% \pquabla, +% \bquabla, +% \Bquabla, +% \vquabla, +% \Vquabla, +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}quabla} \oarg{size~cmd} \marg{contents} +% \cs[no-index]{\meta{delim}quabla} \oarg{kv~opts} \marg{contents} +% \cs[no-index]{\meta{delim}quabla} \oarg{size~cmd} \_\marg{subscript} \marg{contents} +% \cs[no-index]{\meta{delim}quabla} \oarg{kv~opts} \_\marg{subscript} \marg{contents} +% \cs[no-index]{\meta{delim}quabla}* \oarg{kv~opts} \marg{contents} +% \cs[no-index]{\meta{delim}quabla}* \oarg{kv~opts} \_\marg{subscript} \marg{contents} +% \end{syntax} +% The \cs[no-index]{\meta{delim}quabla} family of commands produce a +% \foreignlanguage{french}{d'Alembert} operator with <contents> placed inside +% delimiters. +% Their usage is analogous to the \cs[no-index]{\meta{delim}grad} family of +% commands described in section~\ref{sec:grad-op-delim}. +% \end{function} +% +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Fixed syntax description of standalone operators not matching reality. +% } +% +% +% \section{Row- and Column Vectors} +% \label{sec:rc-vectors} +% +% \DescribeOption{no-crvector} +% The command in this section are only declared if the option |no-crvector| +% has not been given as a package option. +% +% ^^X \DescribeOption{delimiter} +% ^^X \DescribeOption{fill} +% ^^X \DescribeOption{align} +% ^^X The commands in this section all accept key-value options as optional argument. +% Valid keys are "delimiter", "fill", and "align", +% their usage is described in section~\ref{sec:options-matrix}. +% +% \begin{function}{ +% \cvector, +% \rvector +% } +% \begin{syntax} +% \cs{cvector} \oarg{kv opts} \marg{clist} +% \cs{rvector} \oarg{kv opts} \marg{clist} +% \end{syntax} +% The commands \cs{cvector} and \cs{rvector} produce row and column vectors +% respectively. Both of them accept key-value options as optional argument +% \meta{kv opts}. Valid keys and values are described in section~\ref{sec:options-matrix}. +% +% The mandatory argument \meta{clist} is a comma-separated-list, +% whose elements are the entries of the column/row vector. +% If a comma has to appear inside an entry the entire entry has to be wrapped +% in braces. +% +% The delimiter of the row or column vectors depends on the current value of +% the option |delimiter|, by default empty. The option |fill| has no effect +% on the commands and is simply ignored. +% +% \begin{texnote} +% If you were to define your own \env{matrix*}-like environment +% called \env{mymatrix*}, +% which has an interface compatible to \pkg{mathtools}'s \env{matrix*} +% family of environments, +% you could make use of it by setting the value of |delimiter| to |my|. +% \end{texnote} +% \end{function} +% +% \medbreak\noindent +% \textbf{Examples:} +% \begin{enumerate} +% \item Column \enquote{vector} without delimiters: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \cvector{a_{1},a_{2},a_{3}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \cvector{a_{1},a_{2},a_{3}} +% \] +% \end{minipage} +% +% \item A column vectors delimited with parenthesis and different alignment: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \cvector[delimiter=p,align=c]{-1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \cvector[delimiter=p,align=c]{-1,2,3} +% \] +% \end{minipage}\\[1ex] +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \cvector[delimiter=p,align=r]{-1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \cvector[delimiter=p,align=r]{-1,2,3} +% \] +% \end{minipage}\\[1ex] +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \cvector[delimiter=p,align=l]{-1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \cvector[delimiter=p,align=l]{-1,2,3} +% \] +% \end{minipage} +% \end{enumerate} +% +% \paragraph{Row- and Column Vectors with Predefined Delimiters} +% +% As vectors are commonly delimited by parenthesis, brackets, braces, etc.\ +% several shorthands producing delimited vectors are also available. +% \begin{function}{ +% \pcvector, +% \bcvector, +% \Bcvector, +% \vcvector, +% \Vcvector, +% \prvector, +% \brvector, +% \Brvector, +% \vrvector, +% \Vrvector, +% \prvector, +% \brvector, +% \Brvector, +% \vrvector, +% \Vrvector +% } +% \begin{syntax} +% \cs[no-index]{\meta{delim}cvector} \oarg{kv opts} \marg{clist} +% \cs[no-index]{\meta{delim}rvector} \oarg{kv opts} \marg{clist} +% \end{syntax} +% The \cs[no-index]{\meta{delim}\meta{c or r}vector} family of commands, +% accepts a list of key-value options as optional argument \meta{kv opts}. +% Valid keys are described in section~\ref{sec:options-matrix}. +% +% The mandatory argument \meta{clist} is a comma-separated-list of +% the entries of the vector. +% If a comma needs to appear inside an entry of the vector, +% that entry has to be wrapped in braces. +% +% \meta{delim} may have the value "p" for parenthesis, +% "b" for brackets, "B" for braces, "v" for a single vertical line, +% or "V" for a double vertical line. +% \end{function} +% +% \subparagraph{Example} +% \begin{quote} +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pcvector{a_{1},a_{2},a_{3}} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pcvector{a_{1},a_{2},a_{3}} +% \] +% \end{minipage} +% \end{quote} +% +% \subsection{Small Versions for Inline Math} +% \label{sec:rc-vectors-small} +% +% As the \env{matrix} and \env{matrix*} family of environments is unsuitable, +% for inline math, +% \pkg{mathtools}~\autocite{mathtools} provides the \env{smallmatrix} +% and \env{smallmatrix*} family of environments. +% This package provides analogous commands for row and column vectors +% to be typeset in inline math mode. +% +% \begin{function}{ +% \smallcvector, +% \smallrvector +% } +% \begin{syntax} +% \cs{smallcvector} \oarg{kv opts} \marg{clist} +% \cs{smallrvector} \oarg{kv opts} \marg{clist} +% \end{syntax} +% \cs{smallcvector} and \cs{smallrvector} produce column and row vectors +% suitable for inline math. +% Both commands accept the same optional key-value arguments as +% \cs{cvector} and \cs{rvector}. +% \end{function} +% +% +% \medbreak\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{verbatim} +% An inline version of \verb|\cvector| looks like this +% \(\smallcvector{1,0}\). +% \end{verbatim} +% An inline version of \verb|\cvector| looks like this +% \(\smallcvector{1,0}\). +% \end{quote} +% +% \begin{function}{ +% \psmallcvector, +% \bsmallcvector, +% \Bsmallcvector, +% \vsmallcvector, +% \Vsmallcvector, +% \psmallrvector, +% \bsmallrvector, +% \Bsmallrvector, +% \vsmallrvector, +% \Vsmallrvector, +% } +% \begin{syntax} +% \cs{psmallcvector} \oarg{kv opts} \marg{clist} +% \cs[no-index]{psmallrvector} \oarg{kv opts} \marg{clist} +% \cs[no-index]{\meta{delim}small\meta{c or r}vector} \oarg{kv opts} \marg{clist} +% \end{syntax} +% The \cs[no-index]{\meta{delim}small\meta{c or r}vector} family of commands +% like \cs{psmallcvector} produce small inline math version of row and column +% vectors. Their interface is identical to the commands described above. +% \end{function} +% +% \medbreak\noindent +% \textbf{Example:}\nobreak +% \begin{quote} +% \begin{verbatim} +% An inline version of \verb|\pcvector| looks like this +% \(\psmallcvector{1,0}\). +% \end{verbatim} +% An inline version of \verb|\pcvector| looks like this +% \(\psmallcvector{1,0}\). +% \end{quote} +% +% +% \section{Shorthands for Simple Matrices} +% \label{sec:matrices} +% +% \DescribeOption{no-matrix} +% The commands in this section are only defined if the option "no-matrix" +% \emph{has not been given} to the package at load-time. +% +% +% \subsection{(Anti-)diagonal Matrices} +% \label{sec:diagonal-matrices} +% +% \begin{function}{ +% \diagmat, +% \antidiagmat, +% } +% \begin{syntax} +% \cs{diagmat} \oarg{kv opts} \marg{diagonal} +% \cs{antidiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% \cs{diagmat} and \cs{antidiagmat} produce a diagonal or anti-diagonal matrix +% respectively. +% The optional argument \meta{kv~opts} accepts the key value options +% described in section~\ref{sec:options-matrix}. +% +% The key "fill" determines the contents of the matrix entries +% which are not part of the (anti-)diagonal, +% its default value is |{}| i.e.\ empty. +% The key "align" determines the alignment of the entries inside the +% matrix, valid values are usually "l", "c", and "r", +% the default is "c". +% The key "delimiter" determines the delimiter around the matrix, +% its default value is |{}| (none). +% Valid values for the delimiters are "p" for parenthesis, +% "b" for brackets, "B" for braces, "v" for a single vertical line +% (\enquote{\(\vert\)}), and "V" for a double vertical line (\enquote{\(\Vert\)}). +% See the \pkg{mathtools} manual~\autocite{mathtools} for more information. +% +% \begin{texnote} +% The value of "delimiter" gets inserted inside the |\begin{#1matrix*}| +% and |\end{#1matrix*}| commands. +% Therefore it would be possible to define your own \env{matrix*} +% like environment, +% called for example \env{mymatrix*} and set "delimiter=my" +% to make use of it. +% \end{texnote} +% +% The mandatory argument \meta{diagonal} has to be a comma separated list +% of the entries of the (anti-)diagonal. +% If an entry of the diagonal needs to contain a comma "," the entire entry +% has to be wrapped in braces. +% \end{function} +% +% \medskip\noindent +% \textbf{Examples:} +% \begin{enumerate} +% \item A diagonal and an anti-diagonal matrix without delimiters: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \begin{gather*} +% \diagmat{1,2,3}\\[.5ex] +% \antidiagmat{1,2,3} +% \end{gather*} +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \begin{gather*} +% \diagmat{1,2,3}\\[.5ex] +% \antidiagmat{1,2,3} +% \end{gather*} +% \end{minipage} +% \item A diagonal matrix delimited by parenthesis filled with zeros: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \diagmat[delimiter=p,fill=0]{1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \diagmat[delimiter=p,fill=0]{1,2,3} +% \] +% \end{minipage} +% +% \item A diagonal matrix filled with a symbol: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \diagmat[fill=\square]{1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\diagmat[fill=\square]{1,2,3}\] +% \end{minipage} +% +% \item Diagonal matrices with different alignment: +% +% \begin{verbatim} +% \[ +% \diagmat[delimiter=p,align=c,fill=0]{-1,-2,-3} \qquad +% \diagmat[delimiter=p,align=l,fill=0]{-1,-2,-3} \qquad +% \diagmat[delimiter=p,align=r,fill=0]{-1,-2,-3} +% \] +% \end{verbatim} +% \[ +% \diagmat[delimiter=p,align=c,fill=0]{-1,-2,-3} \qquad +% \diagmat[delimiter=p,align=l,fill=0]{-1,-2,-3} \qquad +% \diagmat[delimiter=p,align=r,fill=0]{-1,-2,-3} +% \] +% \end{enumerate} +% +% +% \paragraph{Shorthands for (Anti-)diagonal Matrices with Delimiters} +% +% As matrices are more often than not written inside of delimiters, +% \pkg{moremath} provides several shorthands for producing those matrices +% without having to set the "delimiter" key explicitly. +% \begin{function}{ +% \pdiagmat, +% \bdiagmat, +% \Bdiagmat, +% \vdiagmat, +% \Vdiagmat +% } +% \begin{syntax} +% \cs{pdiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{bdiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Bdiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{vdiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Vdiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% The \cs[no-index]{\meta{delim}diagmat} family of commands provides +% shorthands for producing a delimited (anti-)diagonal matrix +% without having to set the "delimiter" key explicitly every time. +% The pre-set "delimiter" may be overwritten by explicitly passing "delimiter" +% as a key-value option. +% +% The optional argument \meta{kv~opts} accepts the same key-value arguments +% as \cs{diagmat}. +% \end{function} +% +% \medskip\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pdiagmat{1,2,3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[ +% \pdiagmat{1,2,3} +% \] +% \end{minipage} +% \end{quote} +% +% \begin{function}{ +% \pantidiagmat, +% \bantidiagmat, +% \Bantidiagmat, +% \vantidiagmat, +% \Vantidiagmat +% } +% \begin{syntax} +% \cs{pantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{bantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Bantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{vantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Vantidiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% The \cs[no-index]{\meta{delim}antidiagmat} family of commands behaves +% like the \cs[no-index]{\meta{delim}diagmat} commands described above, +% except they produce anti-diagonal matrices. +% \end{function} +% +% \medskip\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pantidiagmat{1,2,3} +% \] +% \end{verbatim} +% \end{minipage} +% \begin{minipage}{.49\linewidth} +% \[ +% \pantidiagmat{1,2,3} +% \] +% \end{minipage} +% \end{quote} +% +% +% \subsubsection{Small Versions for Inline Math} +% \label{sec:matrices-small} +% +% \pkg{mathtools} defines special matrix environments for use in +% inline math mode, +% the \env{smallmatrix} and \env{smallmatrix*} family of environments. +% \pkg{moremath} provides for the case of typesetting an (anti-)diagonal +% matrix several commands which utilize these inline math versions. +% +% \begin{function}{ +% \smalldiagmat, +% \smallantidiagmat, +% } +% \begin{syntax} +% \cs{smalldiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{smallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% The \cs{smalldiagmat} and \cs{smallantidiagmat} commands behave like +% their non-"small" counterpart described above, +% see their description for more information. +% \end{function} +% +% \medskip\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{verbatim} +% An inline version of a diagonal matrix looks like this +% \(\smalldiagmat{1,1}\). +% \end{verbatim} +% An inline version of a diagonal matrix looks like this +% \(\smalldiagmat{1,1}\). +% \end{quote} +% +% \begin{function}{ +% \psmalldiagmat, +% \bsmalldiagmat, +% \Bsmalldiagmat, +% \vsmalldiagmat, +% \Vsmalldiagmat, +% } +% \begin{syntax} +% \cs{psmalldiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{bsmalldiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Bsmalldiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{vsmalldiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Vsmalldiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% Like the \cs[no-index]{\meta{delim}diagmat} commands described above +% there are also shorthand commands for producing an inline math version +% of a diagonal matrix with pre-set delimiters. +% \end{function} +% +% \medbreak\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{verbatim} +% An inline math delimited diagonal matrix looks like this +% \(\psmalldiagmat{1,1}\). +% \end{verbatim} +% An inline math delimited diagonal matrix looks like this +% \(\psmalldiagmat{1,1}\). +% \end{quote} +% +% \begin{function}{ +% \psmallantidiagmat, +% \bsmallantidiagmat, +% \Bsmallantidiagmat, +% \vsmallantidiagmat, +% \Vsmallantidiagmat, +% } +% \begin{syntax} +% \cs{psmallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{bsmallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Bsmallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{vsmallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \cs{Vsmallantidiagmat} \oarg{kv opts} \marg{diagonal} +% \end{syntax} +% Like the \cs[no-index]{\meta{delim}antidiagmat} commands described above +% there are also shorthand commands for producing inline math versions +% of anti-diagonal matrices inside of delimiters. +% \end{function} +% +% \medbreak\noindent +% \textbf{Example:} +% \begin{quote} +% \begin{verbatim} +% A delimited version of an inline math anti-diagonal matrix +% looks like this \(\psmallantidiagmat{1,1}\). +% \end{verbatim} +% A delimited version of an inline math anti-diagonal matrix +% looks like this \(\psmallantidiagmat{1,1}\). +% \end{quote} +% +% \subsection{Identity Matrices} +% \label{sec:id-matrices} +% +% As identity matrices are always quadratic, +% one can further simplify the typesetting of identity matrices to a command, +% which constructs the identity matrix from the number of dimensions. +% The commands in this subsection perform this. +% +% \begin{function}[added = 2024-07-04]{ +% \idmat, +% \smallidmat, +% } +% \begin{syntax} +% \cs{idmat} \oarg{kv~opts} \marg{dimension} +% \cs{smallidmat} \oarg{kv~opts} \marg{dimension} +% \end{syntax} +% The \cs{idmat} command produces an identity matrix. +% The optional argument <kv~opts> accepts any valid \emph{matrix} key-value +% arguments, +% which are described in section~\ref{sec:options-matrix}. +% The mandatory argument <dimension> expects a \emph{positive} integer, +% which specifies the dimensions of the identity matrix. +% +% The \cs{smallidmat} command behaves like the \cs{idmat} command, +% except it produces a matrix suitable for inline math mode. +% +% \begin{texnote} +% The maximum number of columns is determined by the \TeX{} counter +% "MaxMatrixCols", +% which has a default value of 10. +% See \textcite{amsmath} for more information. +% \end{texnote} +% \end{function} +% +% +% \begin{function}[added = 2024-07-04]{ +% \pidmat, +% \bidmat, +% \Bidmat, +% \vidmat, +% \Vidmat +% } +% \begin{syntax} +% \cs{pidmat} \oarg{kv~opts} \marg{dimension} +% \cs{bidmat} \oarg{kv~opts} \marg{dimension} +% \cs{Bidmat} \oarg{kv~opts} \marg{dimension} +% \cs{vidmat} \oarg{kv~opts} \marg{dimension} +% \cs{Vidmat} \oarg{kv~opts} \marg{dimension} +% \end{syntax} +% Like the \cs[no-index]{\meta{delim}diagmat} commands, +% the \cs[no-index]{\meta{delim}idmat} commands produce an identity matrix +% with a pre-set delimiter around the matrix, +% i.e.\ they behave like \cs{idmat}|[delimiter = |<delim>|]|\marg{dimension}. +% <delim> can be "p" for parenthesis, +% "b" for brackets, +% "B" for braces, +% "v" for a single vertical line (\enquote{\(\vert\)}), +% or "V" for a double vertical line (\enquote{\(\Vert\)}). +% +% Furthermore these commands accept the same <kv~opts> as the \cs{idmat} command. +% \end{function} +% +% \begin{function}[added = 2024-07-04]{ +% \psmallidmat, +% \bsmallidmat, +% \Bsmallidmat, +% \vsmallidmat, +% \Vsmallidmat +% } +% \begin{syntax} +% \cs{psmallidmat} \oarg{kv~opts} \marg{dimension} +% \cs{bsmallidmat} \oarg{kv~opts} \marg{dimension} +% \cs{Bsmallidmat} \oarg{kv~opts} \marg{dimension} +% \cs{vsmallidmat} \oarg{kv~opts} \marg{dimension} +% \cs{Vsmallidmat} \oarg{kv~opts} \marg{dimension} +% \end{syntax} +% These commands are provide inline math suitable versions of the +% \cs[no-index]{\meta{delim}idmat} commands described above. +% See their description for more information. +% +% The commands accept any of the key-value options described in section~\ref{sec:options-matrix} +% as optional argument <kv~opts>. +% \end{function} +% +% \paragraph{Examples of Use} +% \begin{enumerate} +% \item Identity matrix without delimiters: +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \idmat{3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\idmat{3}\] +% \end{minipage} +% +% \item Identity matrices with different delimiters: +% +% \begin{verbatim} +% \[ +% \pidmat{3}\text{,}\quad \bidmat{3}\text{,}\quad +% \Bidmat{3}\text{,}\quad \vidmat{3}\text{,}\quad +% \Vidmat{3} +% \] +% \end{verbatim} +% \[ +% \pidmat{3}\text{,}\quad +% \bidmat{3}\text{,}\quad +% \Bidmat{3}\text{,}\quad +% \vidmat{3}\text{,}\quad +% \Vidmat{3} +% \] +% +% \item Inline math versions of identity matrices with delimiters: +% +% \begin{verbatim} +% Inline math mode matrices look like this: +% \(\psmallidmat{2}\), \(\bsmallidmat{2}\), \(\Bsmallidmat{2}\), +% \(\vsmallidmat{2}\), \(\Vsmallidmat{2}\). +% \end{verbatim} +% Inline math mode matrices look like this: +% \(\psmallidmat{2}\), \(\bsmallidmat{2}\), \(\Bsmallidmat{2}\), +% \(\vsmallidmat{2}\), \(\Vsmallidmat{2}\). +% +% \item Identity matrix using the "fill" option for the non-diagonal elements +% +% \begin{minipage}{.49\linewidth} +% \begin{verbatim} +% \[ +% \pidmat[fill=\star]{3} +% \] +% \end{verbatim} +% \end{minipage}\hfill +% \begin{minipage}{.49\linewidth} +% \[\pidmat[fill=\star]{3}\] +% \end{minipage} +% \end{enumerate} +% +% +% \section{Shorthands for Absolute Value and Norm} +% \label{sec:shorthands} +% +% \DescribeOption{no-abs-shorthands} +% The commands in this section are only declared if the option "no-abs-shorthands" +% has not been given to the package as a load time option. +% +% \begin{function}{ +% \abs, +% \norm +% } +% \begin{syntax} +% \cs{abs} \oarg{size cmd} \marg{content} +% \cs{abs}* \marg{content} +% \cs{norm} \oarg{size cmd} \marg{content} +% \cs{norm}* \marg{content} +% \end{syntax} +% The commands \cs{abs} and \cs{norm}, produce \(\abs{\cdot}\) and +% \(\norm{\cdot}\) respectively. +% These commands are simply paired delimiters defined using \pkg{mathtools}' +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command, +% instruction on their usage can therefore be found in~\textcite{mathtools}. +% \end{function} +% +% +% \section{Vertically Centering Math Along the Math Axis} +% \label{sec:vcenter} +% +% Sometimes it is useful to explicitly center a math symbol along the math axis. +% A prominent example is the case of |\mathop{\boldsymbol\nabla}\nolimits| +% vs.\ |\mathop{\nabla}\nolimits|, +% as displayed below. +% \[ +% \mathop{\boldsymbol\nabla}\nolimits f(x) +% \quad \mathop{\nabla}\nolimits f(x) +% \] +% Here the bold nabla is slightly higher up than the non-bold version. +% +% \begin{function}[added=2024-07-08]{\VCenterMath} +% \begin{syntax} +% \cs{VCenterMath} \marg{contents} +% \end{syntax} +% \begin{danger} +% The command \cs{VCenterMath} centers <contents> along the current math axis, +% while adhering to the current math style. +% This command is not in a \TeX{}-sense +% \tn[no-index]{long}, i.e.\ it does not take \tn[no-index]{par} tokens. +% +% This command is somewhat dangerous as it utilizes the \tn{vcenter} primitive, +% which leaves math mode and requires to reenter it. +% \emph{Use at your own responsibility.} +% \end{danger} +% \begin{texnote} +% This command is a wrapper around \tn{vcenter}, \cs{hbox:n} +% and \tn{mathpalette}, it reenters math mode inside the hbox. +% \end{texnote} +% \end{function} +% +% With \cs{VCenterMath} it is possible to fix the above example to: +% \begin{quote} +% \begin{verbatim} +% \[ +% \mathop{\VCenterMath{\boldsymbol\nabla}}\nolimits f(x) +% \quad \mathop{\nabla}\nolimits f(x) +% \] +% \end{verbatim} +% \[ +% \mathop{\VCenterMath{\boldsymbol\nabla}}\nolimits f(x) +% \quad \mathop{\nabla}\nolimits f(x) +% \] +% \end{quote} +% +% +% \part{Documentation for Class and Package Authors} +% \label{sec:package-auth-doc} +% +% \section{Setting of Options} +% \label{sec:authors-options} +% +% \begin{function}[updated = 2024-07-15]{ +% \moremath_setup:n +% } +% \begin{syntax} +% \cs{moremath_setup:n} \marg{kv opts} +% \end{syntax} +% This functions sets the key-value options \meta{kv~opts} in the "moremath" namespace. +% \end{function} +% +% \section{Delimited Operators} +% \label{sec:authors-delim-op} +% +% \begin{function}[updated = 2024-07-15]{ +% \moremath_delim_op_noscale:NNnnn, +% \moremath_delim_op_autoscale:NNnnn +% } +% \begin{syntax} +% \cs{moremath_delim_op_noscale:NNnnn} \meta{math~op} \meta{delim} +% \hspace*{2ex} \marg{sup~tl} \marg{sub~tl} \marg{tl} +% \cs{moremath_delim_op_autoscale:NNnnn} \meta{math op} \meta{delim} +% \hspace*{2ex} \marg{sup~tl} \marg{sub~tl} \marg{tl} +% \end{syntax} +% The two functions \cs{moremath_delim_op_noscale:NNnnn} and \cs{moremath_delim_op_autoscale:NNnnn} +% provide a version of a delimited operator with no scaling or automatic scaling respectively. +% The token list arguments \meta{sup~tl} and \meta{sub~tl} take the super- and subscript +% of the operator respectively. Both of those token lists may be empty. +% +% The first argument to the function is a control sequence \meta{math~op}, +% which should be an operator declared with +% \cs[module=amsmath,replace=false]{DeclareMathOperator}. +% The second argument \meta{delim} has to be a control sequence of a paired delimiter, +% as defined by \pkg{mathtools}'s +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}. +% +% The final argument \meta{tl} is a list of arbitrary token to put inside the delimiters. +% \end{function} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_delim_op_manuscale:NNnnnn, +% \moremath_delim_op_manuscale:NNVnnn +% } +% \begin{syntax} +% \cs{moremath_delim_op_manuscale:NNnnnn} \meta{math op} \meta{delim} \marg{scale cmd} +% \hspace*{2ex} \marg{sup} \marg{sub} \marg{tl} +% \end{syntax} +% The function \cs{moremath_delim_op_manuscale:NNnnnn} typesets a math operator with +% manual scaling of its delimiters. +% Its arguments are identical to \cs{moremath_delim_op_noscale:NNnnn} +% except for the argument \meta{scale~cmd} which has to be a token list containing +% a \meta{size~cmd} that can be understood by \pkg{mathtools}, +% usually \cs{big}, \cs{Big}, \cs{bigg} and \cs{Bigg}. +% \end{function} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_new_delim_op_command:NNN, +% \moremath_new_delim_op_command:cNN, +% } +% \begin{syntax} +% \cs{moremath_new_delim_op_command:NNN} \meta{new~csname} \meta{operator} \meta{delim} +% \end{syntax} +% The function \cs{moremath_new_delim_op_command:NNN} defines a new document level command +% called \meta{new~csname}, utilizing the operator \meta{operator} and the delimiter \meta{delim}. +% +% \meta{operator} has to be a control sequence referring to an operator, +% as declared by \cs{DeclareMathOperator}. +% +% \meta{delim} has to be a paired delimiter as defined by \pkg{mathtools}' +% \cs{DeclarePairedDelimiter}. +% \end{function} +% +% \section{Vector Calculus Typesetting} +% \label{sec:authors-vec-calc} +% +% \subsection{Functions Producing Standalone Operators with Subscripts} +% \label{sec:authors-vec-calc-operators} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_gradient_operator:n, +% \moremath_divergence_operator:n, +% \moremath_curl_operator:n, +% \moremath_laplace_operator:n, +% \moremath_dalembert_operator:n +% } +% \begin{syntax} +% \cs{moremath_gradient_operator:n} \marg{subscript} +% \cs{moremath_divergence_operator:n} \marg{subscript} +% \cs{moremath_curl_operator:n} \marg{subscript} +% \cs{moremath_laplace_operator:n} \marg{subscript} +% \cs{moremath_dalembert_operator:n} \marg{subscript} +% \end{syntax} +% Each of these functions return a vector calculus operator, +% with an (optional) subscript. +% The argument \meta{subscript}, a token list, may be empty, +% in which case no subscript is produced. +% +% The actual operator produced depends on the current settings +% of the key-value options described in section~\ref{sec:pack-opts} +% inside the current group. +% \end{function} +% +% \subsection{Functions Producing Operators with Delimiters} +% \label{sec:authors-vec-calc-delim-ops} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_delim_nabla_op_noscale:NNnn, +% \moremath_delim_nabla_op_autoscale:NNnn, +% } +% \begin{syntax} +% \cs{moremath_delim_nabla_op_noscale:NNnn} \meta{operator} \meta{delim} +% \hspace*{2ex} \marg{sub} \marg{contents} +% +% \cs{moremath_delim_nabla_op_autoscale:NNnn} \meta{operator} \meta{delim} +% \hspace*{2ex} \marg{sub} \marg{contents} +% \end{syntax} +% The usage of these functions is similar to the functions +% \cs{moremath_delim_op_noscale:NNnnn} and \cs{moremath_delim_op_autoscale:NNnnn} +% except for the missing superscript. +% +% The first argument \meta{operator} has to be a function which accepts one argument +% (the subscript). +% This is usually one of the \cs[no-index]{moremath_\meta{op}_operator:n} commands. +% +% The argument \meta{sub}, which may be empty, +% is a token list to pass as the subscript to +% \cs[no-index]{moremath_\meta{op}_operator:n}. +% +% The last argument \meta{contents} is a token list to put inside the delimiters. +% +% \end{function} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_delim_nabla_op_manuscale:NNnnn, +% \moremath_delim_nabla_op_manuscale:NNVnn, +% } +% \begin{syntax} +% \cs{moremath_delim_nabla_op_manuscale:NNnnn} \meta{operator} \meta{delim} +% \hspace*{2ex} \marg{scale~cmd} \marg{sub} \marg{contents} +% \end{syntax} +% The usage of function is similar to the above functions +% except for the additional argument \meta{scale~cmd} which is a token list +% with a \meta{size~cmd} that should be understood by \pkg{mathtools} +% (e.g.\ \cs{big}, \cs{Big}, etc.). +% \end{function} +% +% \section{Formatting Matrices and Vectors} +% \label{sec:authors-matrix} +% +% \begin{function}[updated=2024-07-15]{ +% \moremath_column_vector:nn, +% \moremath_row_vector:nn, +% \moremath_column_smallvector:nn, +% \moremath_row_smallvector:nn +% } +% \begin{syntax} +% \cs{moremath_column_vector:nn} \marg{delim spec tl} \marg{clist} +% \cs{moremath_row_vector:nn} \marg{delim spec tl} \marg{clist} +% \cs{moremath_column_smallvector:nn} \marg{delim spec tl} \marg{clist} +% \cs{moremath_row_smallvector:nn} \marg{delim spec tl} \marg{clist} +% \end{syntax} +% These functions produce a column or row vector. +% The "small"\meta{c~or~r}"vector" versions are intended for inline math mode. +% +% The first argument \meta{delim spec tl} should be the specification of +% a delimiter, as used in the naming of the \env{matrix*} environments +% by \pkg{mathtools}. +% +% The second argument \meta{clist}, is a comma-separated list of entries +% of the vector. +% +% Of this commands the "c" versions produce column vectors, the "r" versions +% produce row vectors. +% +% The alignment of the entries inside the vector depends on the current +% value of the key "align". +% \end{function} +% +% \begin{function}[ +% updated = 2024-07-04, +% updated=2024-07-15, +% ]{ +% \moremath_diagonal_matrix:nn, +% \moremath_diagonal_matrix:nV, +% \moremath_diagonal_matrix:Vn, +% \moremath_diagonal_matrix:VV, +% \moremath_antidiagonal_matrix:nn, +% \moremath_antidiagonal_matrix:nV, +% \moremath_antidiagonal_matrix:Vn, +% \moremath_antidiagonal_matrix:VV, +% \moremath_diagonal_smallmatrix:nn, +% \moremath_diagonal_smallmatrix:nV, +% \moremath_diagonal_smallmatrix:Vn, +% \moremath_diagonal_smallmatrix:VV, +% \moremath_antidiagonal_smallmatrix:nn, +% \moremath_antidiagonal_smallmatrix:nV, +% \moremath_antidiagonal_smallmatrix:Vn, +% \moremath_antidiagonal_smallmatrix:VV, +% } +% \begin{syntax} +% \cs{moremath_diagonal_matrix:nn} \marg{delim tl} \marg{clist} +% \cs{moremath_antidiagonal_matrix:nn} \marg{delim tl} \marg{clist} +% \cs{moremath_diagonal_smallmatrix:nn} \marg{delim tl} \marg{clist} +% \cs{moremath_antidiagonal_smallmatrix:nn} \marg{delim tl} \marg{clist} +% \end{syntax} +% These functions produce (anti-)diagonal matrices. +% The argument \meta{delim~tl} is a token list, +% intended to specify the delimiter of the matrix or no delimiter if the +% <tl> is empty no delimiters are produced. +% +% The argument <clist> is a list of comma separated values which specify the +% entries of the diagonal. +% Other properties of the matrix to produce like alignment ("align") +% and the tokens to insert for non-diagonal entries ("fill") +% depend on the current setting of the keys described in section~\ref{sec:options-matrix}. +% +% The "smallmatrix" versions are intended for use in inline math mode. +% \end{function} +% +% \begin{function}[ +% added = 2024-07-04, +% updated=2024-07-15, +% ]{ +% \moremath_id_matrix:n, +% \moremath_id_matrix:V, +% \moremath_id_smallmatrix:n, +% \moremath_id_smallmatrix:V, +% } +% \begin{syntax} +% \cs{moremath_id_matrix:n} \marg{dimensions} +% \cs{moremath_id_smallmatrix:n} \marg{dimensions} +% \end{syntax} +% These functions produce a identity matrix with <dimensions> rows and columns. +% <dimensions> is expected to be a \emph{positive} integer. +% The "smallmatrix" version utilizes \pkg{mathtools}' \env{smallmatrix*} environment, +% which makes it suitable for inline math mode. +% +% The delimiter around the matrix is determined by the current value of the key +% "matrix / delimiter" inside the current group. +% +% As these functions utilize \cs{moremath_diagonal_matrix:VV} or +% \cs{moremath_diagonal_smallmatrix:VV} and make use of temporary variables +% it is advised to put them into their own group, +% i.e.\ surround them by \cs{group_begin:} and \cs{group_end:}. +% \end{function} +% +% \section{Vertically Centering Math Along the Math Axis} +% \label{sec:autors-vcenter} +% +% As already said in section~\ref{sec:vcenter} sometimes it is needed to +% explicitly center some math code. +% +% \begin{function}[ +% added=2024-07-08, +% updated=2024-07-15, +% ]{ +% \moremath_vcenter:n, +% } +% \begin{syntax} +% \cs{moremath_vcenter:n} \marg{contents} +% \end{syntax} +% The function \cs{moremath_vcenter:n} places <contents> inside a "hbox", +% which is centered along the math axis by \tn{vcenter}. +% The contents inside the "hbox" are set in math mode. +% The function also applies the \enquote{outer} math style +% to the contents of the "hbox". +% +% This function is not \tn[no-index]{long}, +% as it sets its contents inside a "hbox". +% +% \begin{texnote} +% This function is a wrapper around \tn{vcenter}, \cs{hbox:n}, +% and \tn{mathpalette}. +% Inside the "hbox" math mode is reentered. +% \end{texnote} +% \end{function} +% +% \end{documentation} +% +% +% +% +% +% +% +% +% +% +% \begin{implementation} +% \part{Implementation} +% \label{pt:implementation} +% Start the \pkg{DocStrip} guards. +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% Set the internal prefix for this package so that \pkg{DocStrip} knows what to +% do. +% \begin{macrocode} +%<@@=moremath> +% \end{macrocode} +% +% \section{Initial Setup} +% +% First set the required version of \LaTeX{}, +% we need at least +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[2022-11-01] +% \end{macrocode} +% for key-value option handling, \pkg{xparse}-like document commands +% (especially for using the "=" option specification) +% and hooks. +% +% Then identify this package as \pkg{moremath}. +% \begin{macrocode} +\ProvidesExplPackage{moremath} + {2024-07-15}{v0.4.0}{More Math Macros} +% \end{macrocode} +% +% ^^X Debugging switch +% \iffalse +% \debug_on:n {all} +% \fi +% \section{Key-value interfaces} +% \label{sec:key-val} +% To make use of key-value interfaces we need to define a few keys. +% +% \subsection{Package load time options} +% \label{sec:load-time-options} +% +% To allow for the conditional definition of macros at load time +% we define a few keys. +% +% But before doing so we define a few messages to write the package options to +% the log file. +% One message to issue if the \texttt{bm} option has been given: +% \begin{macrocode} +\msg_new:nnn { moremath } {load / bm} +{ + Option~'bm'~given.\\ + Loading~the~bm~package~\msg_line_context:. +} +% \end{macrocode} +% And a more generic message to issue for the other options, +% which all disable certain parts of the library. +% \begin{macrocode} +\msg_new:nnn {moremath} { load / disabling } +{ + Option~'#1'~given.\\ + Disabling~#2~\msg_line_context:. +} +% \end{macrocode} +% +% \begin{variable}{ +% \l_@@_predef_vector_op_bool, +% \l_@@_predef_operators_bool, +% \l_@@_predef_crvector_bool, +% \l_@@_predef_matrix_bool, +% \l_@@_predef_abs_bool, +% } +% To store the values of several switch type key-value options +% we declare several boolean variables. +% \begin{macrocode} +\bool_new:N \l_@@_predef_vector_op_bool +\bool_new:N \l_@@_predef_operators_bool +\bool_new:N \l_@@_predef_crvector_bool +\bool_new:N \l_@@_predef_matrix_bool +\bool_new:N \l_@@_predef_abs_bool +% \end{macrocode} +% +% The variables \cs{l_@@_predef_vector_op_bool}, \cs{l_@@_predef_operators_bool} +% \cs{l_@@_predef_abs_bool}, \cs{l_@@_predef_matrix_bool} +% and \cs{l_@@_predef_crvector_bool} +% control if the predefined macros +% for vector calculus, delimited operators, the matrix shorthands, +% the row and column vectors, +% and the shorthands for absolute value +% and norm shall be defined. +% +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{ +% Explicitly declared boolean variables used to store key-value options. +% } +% \end{variable} +% +% \begin{optionenv}{ +% bm, +% no-vector, +% no-operators, +% no-abs-shorthands, +% no-matrix, +% no-crvector, +% nopredef, +% } +% Now we define package load time keys: +% \begin{macrocode} +\keys_define:nn { moremath / load } +{ +% \end{macrocode} +% We provide an option to conditionally load the \pkg{bm}-package~\autocite{bm} +% to provide better looking bold symbols. +% \begin{macrocode} + bm .code:n = { + \msg_info:nn {moremath} {load / bm} + \RequirePackage{bm} + }, + bm .value_forbidden:n = true, + bm. usage:n = load, +% \end{macrocode} +% Then we define options for en-/disabling predefined macros of this package +% to avoid name clashes. +% \begin{macrocode} + no-vector .bool_set_inverse:N = \l_@@_predef_vector_op_bool, + no-vector .default:n = true, + no-vector .initial:n = false, + no-vector .usage:n = load, + no-operators .bool_set_inverse:N = \l_@@_predef_operators_bool, + no-operators .default:n = true, + no-operators .initial:n = false, + no-operators .usage:n = load, + no-abs-shorthands .bool_set_inverse:N = \l_@@_predef_abs_bool, + no-abs-shorthands .default:n = true, + no-abs-shorthands .initial:n = false, + no-abs-shorthands .usage:n = load, + no-matrix .bool_set_inverse:N = \l_@@_predef_matrix_bool, + no-matrix .initial:n = false, + no-matrix .default:n = true, + no-matrix .usage:n =load, + no-crvector .bool_set_inverse:N = \l_@@_predef_crvector_bool, + no-crvector .default:n = true, + no-crvector .initial:n = false, + no-crvector .usage:n = load, + nopredef .multichoice:, + nopredef / operators .meta:nn = { moremath / load } + { + no-operators = true + }, + nopredef / vector .meta:nn = { moremath / load } + { + no-vector = true + }, + nopredef / abs .meta:nn = { moremath / load } + { + no-abs-shorthands = true, + }, + noperdef / matrix .meta:nn = { moremath / load } + { + no-matrix = true, + }, + nopredef / crvector .meta:nn = {moremath / load} + { + no-crvector = true, + }, + nopredef / all .meta:nn = { moremath / load } + { + no-operators = true, + no-vector = true, + no-abs-shorthands = true + }, + nopredef .usage:n = load, +% \end{macrocode} +% Unknown package options get passed to \pkg{mathtools}. +% \begin{macrocode} + unknown .code:n = {\PassOptionsToPackage{\CurrentOption}{mathtools}}, + unknown .usage:n = load, +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added package load-time options. +% } +% \end{optionenv} +% +% +% \subsection{Keys controlling appearance} +% \label{sec:keys-appearance} +% +% \begin{variable}{ +% \l_@@_nabla_tl, +% \l_@@_nabla_arrow_bool, +% \l_@@_nabla_arrow_bold_bool, +% \l_@@_grad_op_tl, +% \l_@@_laplacian_symb_tl, +% \l_@@_laplacian_delta_bool, +% \l_@@_laplacian_arrow_bool, +% \l_@@_laplacian_tl, +% \l_@@_dalembert_symb_tl, +% } +% We declare several variables to store the values of the keys affecting +% appearance. +% \begin{macrocode} +\tl_new:N \l_@@_nabla_tl +\bool_new:N \l_@@_nabla_arrow_bool +\bool_new:N \l_@@_nabla_arrow_bold_bool +\tl_new:N \l_@@_grad_op_tl +% \end{macrocode} +% +% The symbol to use as \enquote{nabla} is stored in \cs{l_@@_nabla_tl}. +% The variables \cs{l_@@_nabla_arrow_bool} and \cs{l_@@_nabla_bold_bool} +% determine if the nabla-symbol shall have an arrow over itself and/or be bold +% respectively. +% +% The variable \cs{l_@@_grad_op_tl} contains a user provided token list to +% overwrite the built-in gradient operator of the package. +% +% \begin{macrocode} +\tl_new:N \l_@@_laplacian_symb_tl +\bool_new:N \l_@@_laplacian_delta_bool +\bool_new:N \l_@@_laplacian_arrow_bool +\tl_new:N \l_@@_laplacian_tl +% \end{macrocode} +% The token list variable \cs{l_@@_laplacian_symb_tl} stores the tokens to be +% used for the Laplace operator. +% The boolean variable \cs{l_@@_laplacian_delta_bool} +% determines if a delta should be used instead +% of \(\laplacian\) for the laplacian symbol. +% If the boolean variable \cs{l_@@_laplacian_arrow_bool} a small arrow will be +% placed over the Laplace operator symbol. +% If the user wants to overwrite the symbol used for the Laplacian, +% the user provided list of tokens is stored in the variable +% \cs{l_@@_laplacian_tl}. +% +% Finally we define a variable to hold the symbol to use for the +% \foreignlanguage{french}{d'Alembert} operator. +% \begin{macrocode} +\tl_new:N \l_@@_dalembert_symb_tl +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Explicitly declared variables before using them to set keys. +% } +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added: New variable \cs{l_@@_dalembert_symb_tl} +% } +% \end{variable} +% +% \begin{variable}{ +% \l_@@_vcenter_bool, +% } +% Additionally we declare a variable to decide if certain math symbols +% shall be centered explicitly along the math axis. +% \begin{macrocode} +\bool_new:N \l_@@_vcenter_bool +% \end{macrocode} +% If \cs{l_@@_vcenter_bool} is true, the symbols of certain math operators, +% should be centered explicitly. +% \end{variable} +% +% \begin{optionenv}{ +% nabla, +% arrownabla, +% boldnabla, +% grad-op, +% laplacian-symb, +% delta-laplace, +% arrowlaplace, +% laplacian, +% dalembert-symb, +% } +% First define keys for the vector calculus macros. +% \begin{macrocode} +\keys_define:nn { moremath } +{ +% \end{macrocode} +% First we define keys for use with the gradient and gradient based operators. +% \begin{macrocode} + % Symbol to use for the nabla + nabla .tl_set:N = \l_@@_nabla_tl, + nabla .initial:n = {\nabla}, + nabla .value_required:n = true, + % shall the nabla have an arrow over it + arrownabla .bool_set:N = \l_@@_nabla_arrow_bool, + arrownabla .default:n = {true}, + arrownabla .initial:n = {false}, + % shall the nabla be bold + boldnabla .bool_set:N = \l_@@_nabla_bold_bool, + boldnabla .default:n = {true}, + boldnabla .initial:n = {false}, +% \end{macrocode} +% We also provide an override for the gradient operator +% \begin{macrocode} + % Symbol to use for the gradient operator + grad-op .tl_set:N = \l_@@_grad_op_tl, + grad-op .value_required:n = true, +% \end{macrocode} +% +% Then we define keys for the laplacian. +% \begin{macrocode} + % Symbol to use for the laplacian + laplacian-symb .tl_set:N = \l_@@_laplacian_symb_tl, + laplacian-symb .initial:n = {\l_@@_nabla_tl}, + % shall the Laplace operator be a delta + delta-laplace .bool_set:N = \l_@@_laplacian_delta_bool, + delta-laplace .initial:n = {false}, + % shall the laplace operator have an arrow over itself + arrowlaplace .bool_set:N = \l_@@_laplacian_arrow_bool, + arrowlaplace .default:n = {true}, + arrowlaplace .initial:n = {false}, + % overwrite the laplace operator + laplacian .tl_set:N = \l_@@_laplacian_tl, + laplacian .value_required:n = true, +% \end{macrocode} +% And keys for the \foreignlanguage{french}{d'Alembert} operator. +% \begin{macrocode} + dalembert-symb .tl_set:N = \l_@@_dalembert_symb_tl, + dalembert-symb .initial:n = {\square}, +% \end{macrocode} +% \begin{optionenv}{ +% vcenter, +% } +% The "vcenter" option will control the manual centering of certain math +% operators. +% \begin{macrocode} + vcenter .bool_set:N = \l_@@_vcenter_bool, + vcenter .initial:n = true, + vcenter .value_required:n = true, +}% \keys_define:nn +% \end{macrocode} +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Added new option. +% } +% \end{optionenv} ^^X vcenter +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added options controlling appearance. +% } +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added: New option "dalembert-symb". +% } +% \end{optionenv} +% +% \begin{optionenv}{ +% delimiter, +% fill, +% align +% } +% Then we define some keys for the matrix based environments: +% \begin{macrocode} +\keys_define:nn { moremath / matrix } +{ +% \end{macrocode} +% \begin{variable}{ +% \l_@@_matrix_delim_tl, +% \l_@@_matrix_fill_tl, +% \l_@@_matrix_align_tl, +% } +% Every one of the following keys stores its value inside a token list variable. +% \begin{macrocode} + delimiter .tl_set:N = \l_@@_matrix_delim_tl, + delimiter .initial:n = {}, + fill .tl_set:N = \l_@@_matrix_fill_tl, + fill .initial:n = {}, + align .tl_set:N = \l_@@_matrix_align_tl, + align .initial:n = {c}, + align .value_required:n = true, +} +% \end{macrocode} +% The keys \verb|delimiter| and \verb|fill| set the variables +% \cs{l_@@_matrix_delim_tl} and \cs{l_@@_matrix_fill_tl} respectively. +% \cs{l_@@_matrix_delim_tl} determines the delimiter in use to surround +% matrices and \cs{l_@@_matrix_fill_tl} determines the fill values of the +% \cs{diag}, \cs{smalldiag}, \cs[no-index]{Xdiag} and \cs[no-index]{Xsmalldiag} +% commands, which are used for non-diagonal matrix entries. +% The variable \cs{l_@@_matrix_align_tl} contains the alignment specifier +% for use with the \env{matrix*} environment. +% +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added internal variables. +% } +% \end{variable} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added options for the matrix-based environments of \pkg{mathtools}. +% } +% \end{optionenv} +% +% \subsection{Functions for Setting Options} +% \label{sec:option-setters} +% +% +% Now we define a function for setting the options within the document +% \begin{macro}{\moremath_setup:n} +% \begin{macrocode} +\cs_new_protected:Nn \moremath_setup:n +{ + \keys_set:nn {moremath} {#1} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added function for setting options. +% } +% \end{macro} +% +% Additionally we provide the user with a version of this command. +% \begin{macro}{\moremathsetup} +% \begin{macrocode} +\NewDocumentCommand \moremathsetup {m} +{ + \moremath_setup:n {#1} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added document command for setting package options. +% } +% \end{macro} +% We also need a function for setting the package load time options. +% This function should set all given values for all key families +% and pass unknown options to mathtools. +% \begin{macro}{\@@_load_time_setup:} +% \begin{macrocode} +\cs_new_protected:Nn \@@_load_time_setup: +{ + \ProcessKeyOptions[ moremath / load ] +} +% \end{macrocode} +% \end{macro} +% +% ^^X SUBSECTION: Package Initialization +% \section{Package Initialization} +% \label{sec:init} +% +% We now \enquote{initialize} the package by processing the package options, +% all unknown options are passed to \pkg{mathtools}~\autocite{mathtools}, +% which is loaded afterwards. +% Because certain \pkg{mathtools}-features are needed by this package, +% we need to require a version of at least 2004/06/05. +% As explained in section~\ref{sec:load-time-options} this may also load \pkg{bm} +% if the \verb|bm| package option has been given. +% \begin{macrocode} +\@@_load_time_setup: +% \end{macrocode} +% If the "no-vector" option has not been given during load time, +% we also need the \pkg{amssymb} package~\autocite{amsfonts} for the +% \cs[module=amssymb,replace=false]{square} command. +% We first define a message to inform the user about this. +% \begin{macrocode} +\msg_new:nnn { moremath } { load / loading-amssymb } +{ + Vector~calculus~commands~enabled.\\ + Loading~amssymb~package~\msg_line_context:. +} +% \end{macrocode} +% Then we conditionally load the package. +% \begin{macrocode} +\bool_if:NT \l_@@_predef_vector_op_bool +{ + \msg_info:nn { moremath } { load / loading-amssymb } + \RequirePackage{amssymb} +} +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{ +% New: Load \pkg{amssymb} if the "no-vector" option has \emph{not} been given. +% } +% +% Finally we load our most important dependency \pkg{mathtools}. +% \begin{macrocode} +\RequirePackage{mathtools}[2004/06/05] +% \end{macrocode} +% +% +% \section{Centering Math Symbols Along the Math-Axis} +% \label{sec:impl-vcenter} +% +% Certain math constructs such cause \TeX{} +% to not center the operator along the math axis, +% like case of |\mathop{\nabla}\nolimits| vs.\ +% |\mathop{\boldsymbol\nabla}\nolimits|, +% as can be seen below. +% \[ +% \mathop{\nabla}\nolimits f(x) +% \quad \text{vs.} \quad +% \mathop{\boldsymbol\nabla}\nolimits f(x) +% \] +% As can be seen the bold nabla symbol is slightly higher up than the non-bold +% version. +% Because of this it is sometimes useful to manually center some math symbols, +% along the math axis.\footnote{% +% The code in this section is inspired by +% \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf} +% } +% +% \begin{macro}[added = 2024-07-08]{ +% \moremath_vcenter:n +% } +% The function \cs{moremath_vcenter:n} is a wrapper around the \tn{vcenter} +% \TeX{} primitive. +% It takes a single argument. +% \begin{arguments} +% \item A \meta{tl} containing math mode material to center along the math axis. +% +% This argument is typeset in math mode. +% \end{arguments} +% The function uses the \tn{mathpalette} primitive to switch to the right +% math style. +% The function is not in a \TeX{}-sense long, +% i.e.\ it does not take \tn{par} tokens. +% +% As this function might be useful not only for internal use by \pkg{moremath}, +% we declare it as a public function here. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_vcenter:n +{ + \mathpalette \@@_vcenter:Nn {#1} +} +% \end{macrocode} +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Added new function. +% } +% \end{macro} +% +% \begin{macro}[added=2024-07-08]{ +% \@@_vcenter:Nn, +% } +% As \tn{mathpalette} needs as its first argument a macro which takes two +% arguments +% (the first is a math style switch and the second the contents).\footnote{% +% See \TeX{}SE answer \url{https://tex.stackexchange.com/a/34412} +% } +% We define an internal helper function for \cs{moremath_vcenter:n} for +% \cs{mathpalette} to call. +% +% The function \cs{@@_vcenter:Nn} takes two arguments: +% \begin{arguments} +% \item The math style macro, which is passed to this function by +% \tn{mathpalette}. +% +% \item The \meta{tl} to typeset inside the \tn{vcenter}. +% \end{arguments} +% +% Because of the properties of \tn{vcenter}, it switches to vertical mode, +% we need to put the contents to typeset inside a horizontal box. +% Because of this we also need to reenter math mode, and because of this +% we need to remove the spacing inserted by entering math mode +% by setting \tn{mathsurround} to zero. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_vcenter:Nn +{ + \vcenter + { + \hbox:n + { + $ + \mathsurround=0pt + #1 {#2} + $ + } + } +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection*{Document Level Command} +% +% Although unlikely there might arise the need for a document author to center +% some math along the math axis. +% For this purpose we are going to define a new document level command. +% +% But first we are going to declare some messages to use by the command. +% The first message informs the user that the command is not available, +% because its \meta{csname} is already taken. +% \begin{macrocode} +\msg_new:nnn { moremath } { csname-already-defined } +{ + Control~sequence~' #1 '~is~already~ defined.\\ + Skipping~definition~\msg_line_context: +} +% \end{macrocode} +% The second message should be issued if a command that only works in math mode +% was given outside of it. +% \begin{macrocode} +\msg_new:nnnn { moremath } { vcenter / only-in-math-mode } +{ + Command~#1~used~outside~math~mode~\msg_line_context:. +} +{ + The~command~#1~may~only~be~used~inside~math~mode. +} +% \end{macrocode} +% \begin{macro}{ +% \VCenterMath, +% } +% Now to the document level command for centering math along the math axis. +% \begin{macrocode} +\cs_if_free:NTF \VCenterMath +{ + \NewDocumentCommand \VCenterMath { m } + { + \mode_if_math:TF + { + \moremath_vcenter:n {#1} + }{% \mode_if_math:TF FALSE BRANCH + \msg_error:nnn { moremath } { vcenter / only-in-math-mode } {\VCenterMath} + } + } +}{% \cs_if_free:NTF \VCenterMath FALSE BRANCH + \msg_warning:nnn { moremath } { csname-already-defined } {\VCenterMath} +} +% \end{macrocode} +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Added new document level command. +% } +% \end{macro} +% +% +% ^^X SECTION: Paired Delimiters +% \section{Declaring Paired Delimiters for Internal Use} +% \label{sec:impl-paired-delim} +% +% \begin{macro}{ +% \@@_inparent:w, +% \@@_inbrack:w, +% \@@_inbrace:w, +% \@@_in_vert:w, +% \@@_in_Vert:w +% } +% As we are going to use \pkg{mathtools}' \emph{paired delimiters} +% at several places throughout this package, +% we define \emph{paired delimiters} for internal use, as functions with weird +% syntax. +% \begin{macrocode} +\DeclarePairedDelimiter{\@@_inparent:w}{\lparen}{\rparen} +\DeclarePairedDelimiter{\@@_inbrack:w}{\lbrack}{\rbrack} +\DeclarePairedDelimiter{\@@_inbrace:w}{\lbrace}{\rbrace} +\DeclarePairedDelimiter{\@@_in_vert:w}{\lvert}{\rvert} +\DeclarePairedDelimiter{\@@_in_Vert:w}{\lVert}{\rVert} +% \end{macrocode} +% \end{macro} +% +% ^^X SECTION: Delimited Operators +% \section{Delimited Operators} +% \label{sec:impl-delim-op} +% +% We need three different functions for providing the delimited operators. +% But as we share a lot of code between those, we define an additional +% helper function beforehand. +% \begin{macro}{ +% \@@_operator:Nnn +% } +% The function \cs{@@_operator:Nnn} takes care of the operator part +% of the new delimiter. +% It allows the operator to have super- and subscripts. +% It takes three arugments. +% \begin{arguments} +% \item The \meta{csname} of the operator to use. +% \item A \meta{token list}, which is used as the superscript operator. +% +% This argument may be empty +% \item A \meta{tl}, which is used as the subscript operator. +% +% The \meta{tl} may be empty. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_operator:Nnn +{ + #1 + % add superscript if present + \tl_if_empty:nF {#2} {^{#2}} + % add subscript if present + \tl_if_empty:nF {#3} { \c_math_subscript_token {#3} } +} +% \end{macrocode} +% \end{macro} +% +% We now define three version of the delimited operators. +% \begin{macro}{ +% \moremath_delim_op_noscale:NNnnn, +% \moremath_delim_op_autoscale:NNnnn, +% } +% \cs{moremath_delim_op_noscale:NNnnn} is provides a delimited operator without +% any scaling of the delimiters +% and \cs{moremath_delim_op_autoscale:NNnnn} provides a version with +% automatic scaling of the delimiters. +% Both of them take five arguments: +% \begin{arguments} +% \item The \meta{csname} of the operator to use. +% +% Any operator declared with \pkg{amsmath}'s \cs{operatorname} +% and/or\linebreak[3] +% \cs[module=amsmath,replace=false]{DeclareMathOperator} +% is valid for this. +% +% \item The \meta{csname} of a paired delimiter declared by +% \pkg{mathtools}'~\autocite{mathtools} +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}. +% +% \item A \meta{tl} to use as the superscript of the operator. +% +% \item A \meta{tl} to use as the subscript of the operator. +% +% \item A \meta{tl} to insert inside the delimiters. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_delim_op_noscale:NNnnn +{ + \@@_operator:Nnn #1 {#3} {#4} + % #2 is the paired delimiter + #2 {#5} +} + +\cs_new_protected_nopar:Nn \moremath_delim_op_autoscale:NNnnn +{ + \@@_operator:Nnn #1 {#3} {#4} + % #2 is the paired delimiter + #2 * {#5} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added "noscale" and "autoscale" versions. +% } +% \end{macro} +% \begin{macro}{ +% \moremath_delim_op_manuscale:NNnnnn, +% \moremath_delim_op_manuscale:NNVnnn +% } +% \cs{moremath_delim_op_manuscale:NNnnnn} provides a delimited operator with +% manual scaling. +% This version takes six arguments: +% \begin{arguments} +% \item The \meta{csname} of the operator to use. +% +% \item The \meta{csname} of the paired delimiter +% declared by \pkg{mathtools}'~\autocite{mathtools}\linebreak[3] +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}. +% +% \item A \meta{tl} containing the scaling macro i.e.\ \cs{big}, \cs{Big}, +% \cs{Bigg},\dots +% +% \item A \meta{tl} containing the superscript of the operator. +% +% The \meta{tl} may be empty +% +% \item A \meta{tl} containing the subscript of the operator +% +% The \meta{tl} may be empty. +% +% \item A \meta{tl} to insert inside the delimiters +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_delim_op_manuscale:NNnnnn +{ + \@@_operator:Nnn #1 {#4} {#5} + % #2 is the paired delimiter + #2 [ #3 ] {#6} +} +% \end{macrocode} +% We also provide a variant for the scaling macro. +% \begin{macrocode} +\cs_generate_variant:Nn \moremath_delim_op_manuscale:NNnnnn {NNVnnn} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Function added. +% } +% \end{macro} +% +% For the creation of document level commands we also create a function, +% so that the user is also able to declare new delimited operators. +% But before we do so we create a message to inform the user if a +% \meta{csname} was already taken. +% \begin{macrocode} +\msg_new:nnn { moremath } { delimop / already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~of~delimited~operator~'#1'~\msg_line_context:. +} +% \end{macrocode} +% +% We also create a message to inform the user about conflicting options +% given to the command. +% \begin{macrocode} +\msg_new:nnn { moremath } { delimop / auto-manu-scale-conflict } +{ + Both~star~and~scale~cmd~given~to~'#1'.\\ + Automatic~scaling~will~be~preferred,~the~size~command~will~be~ + ignored~\msg_line_context:. +} +% \end{macrocode} +% \begin{macro}{ +% \moremath_new_delim_op_command:NNN, +% \moremath_new_delim_op_command:cNN, +%} +% \cs{moremath_new_delim_op_command:NNN} takes three arguments: +% \begin{arguments} +% \item The \meta{csname} to be defined. +% +% \item The \meta{csname} of the operator to use, +% which should be an operator declared with +% \cs[module=amsmath,replace=false]{DeclareMathOperator}. +% +% \item The \meta{csname} of the delimiter to use, +% which should have been declared with +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter}. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \moremath_new_delim_op_command:NNN +{ + \cs_if_free:NTF #1 + { + \exp_args:NNe \NewDocumentCommand #1 + { s o E{ ^ \char_generate:nn {`_} {8} }{{}{}} m } + { + \tl_if_novalue:nTF {##2} + { + % second argument empty + \bool_if:nTF {##1} + { + % star given + \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5} + }{ + % star not given + \moremath_delim_op_noscale:NNnnn #2 #3 {##3} {##4} {##5} + } + }{ + % second argument present + % star given? + \bool_if:nTF {##1} + { + % Warn if both star and scaling factor are present + \msg_warning:nnn { moremath } { delimop / auto-manu-scale-conflict } + {#1} + \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5} + }{ % FALSE BRANCH + \moremath_delim_op_manuscale:NNnnnn #2 #3 {##2} {##3} {##4} {##5} + } + } + } + }{ % \cs_if_free:nTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { delimop / already-defined-skip } + {#1} + } +} + +\cs_generate_variant:Nn \moremath_new_delim_op_command:NNN {cNN} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added function and variant. +% } +% \end{macro} +% +% \subsection{Document Level Commands} +% \label{sec:impl-delim-op-doc-cmds} +% +% \begin{macro}{\DeclareDelimitedOperator} +% Finally provide the user with a command to declare an additional +% delimited operator. +% \begin{macrocode} +\NewDocumentCommand\DeclareDelimitedOperator { m m m } +{ + \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } { error } + \moremath_new_delim_op_command:NNN #1 #2 #3 + \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } {} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Added document level command.} +% \end{macro} +% +% As \pkg{amsmath}~\autocite{amsmath} pre-defines the following operators +% it is only sensible to also define delimited versions of them:\\ +% \input{\jobname-ams-op-table.tex} +% +% \begin{macro}{\@@_new_delim_op_cmds:nN} +% \cs{@@_new_delim_op_cmds:nN} creates document level macros of the form +% \cs[no-index]{\meta{prefix}\meta{op name}}. +% It declares fife versions \cs[no-index]{p\meta{op name}}, +% \cs[no-index]{b\meta{op name}}, \cs[no-index]{B\meta{op name}}, +% \cs[no-index]{v\meta{op name}} and \cs[no-index]{V\meta{op name}}. +% +% The function takes two arguments: +% \begin{arguments} +% \item A token list which contains \meta{op name} +% +% \item The \meta{csname} of the operator to use. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_delim_op_cmds:nN +{ + \moremath_new_delim_op_command:cNN {p #1} #2 \@@_inparent:w + \moremath_new_delim_op_command:cNN {b #1} #2 \@@_inbrack:w + \moremath_new_delim_op_command:cNN {B #1} #2 \@@_inbrace:w + \moremath_new_delim_op_command:cNN {v #1} #2 \@@_in_vert:w + \moremath_new_delim_op_command:cNN {V #1} #2 \@@_in_Vert:w +} +% \end{macrocode} +% \end{macro} +% +% The decision if the following macros are defined depends on a package load +% time option. +% \begin{macrocode} +\bool_if:NTF \l_@@_predef_operators_bool +{ +% \end{macrocode} +% We define the commands for the operators already declared by amsmath. +% \begin{macro}[documented-as=\parccos]{ +% \parccos, \barccos, \Barccos, \varccos, \Varccos, +% } +% For \cs[module=amsmath,replace=false]{arccos}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {arccos} \arccos +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added delimited document commands for all \pkg{amsmath}-defined operators. +% } +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \parcsin, \barcsin, \Barcsin, \varcsin, \Varcsin, +% } +% \cs[module=amsmath,replace=false]{arcsin}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {arcsin} \arcsin +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \parctan, \barctan, \Barctan, \varctan, \Varctan, +% } +% \cs[module=amsmath,replace=false]{arctan}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {arctan} \arctan +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \Parg, \barg, \Barg, \varg, \Varg, +% } +% \cs[module=amsmath,replace=false]{arg} +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {arg} \arg +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pcos, \bcos, \Bcos, \vcos, \Vcos, +% } +% \cs[module=amsmath,replace=false]{cos} +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {cos} \cos +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pcosh, \bcosh, \Bcosh, \vcosh, \Vcosh, +% } +% \cs[module=amsmath,replace=false]{cosh}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {cosh} \cosh +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pcot, \bcot, \Bcot, \vcot, \Vcot, +% } +% \cs[module=amsmath,replace=false]{cot}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {cot} \cot +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pcoth, \bcoth, \Bcoth, \vcoth, \Vcoth, +% } +% \cs[module=amsmath,replace=false]{coth}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {coth} \coth +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pcsc, \bcsc, \Bcsc, \vcsc, \Vcsc, +% } +% \cs[module=amsmath,replace=false]{csc}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {csc} \csc +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pdeg, \bdeg, \Bdeg, \vdeg, \Vdeg, +% } +% \cs[module=amsmath,replace=false]{deg}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {deg} \deg +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pdet, \bdet, \Bdet, \vdet, \Vdet, +% } +% \cs[module=amsmath,replace=false]{det}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {det} \det +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pdim, \bdim, \Bdim, \vdim, \Vdim, +% } +% \cs[module=amsmath,replace=false]{dim}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {dim} \dim +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pexp, \bexp, \Bexp, \vexp, \Vexp, +% } +% \cs[module=amsmath,replace=false]{exp}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {exp} \exp +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pgcd, \bgcd, \Bgcd, \vgcd, \Vgcd, +% } +% \cs[module=amsmath,replace=false]{gcd}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {gcd} \gcd +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \phom, \bhom, \Bhom, \vhom, \Vhom, +% } +% \cs[module=amsmath,replace=false]{hom}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {hom} \hom +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pinf, \binf, \Binf, \vinf, \Vinf, +% } +% \cs[module=amsmath,replace=false]{inf}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {inf} \inf +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pinjlim, \binjlim, \Binjlim, \vinjlim, \Vinjlim, +% } +% \cs[module=amsmath,replace=false]{injlim}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {injlim} \injlim +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pker, \bker, \Bker, \vker, \Vker, +% } +% \cs[module=amsmath,replace=false]{ker}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {ker} \ker +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \plg, \blg, \Blg, \vlg, \Vlg, +% } +% \cs[module=amsmath,replace=false]{lg}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {lg} \lg +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \plim, \blim, \Blim, \vlim, \Vlim, +% } +% \cs[module=amsmath,replace=false]{lim}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {lim} \lim +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pliminf, \bliminf, \Bliminf, \vliminf, \Vliminf, +% } +% \cs[module=amsmath,replace=false]{liminf}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {liminf} \liminf +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \plimsup, \blimsup, \Blimsup, \vlimsup, \Vlimsup, +% } +% \cs[module=amsmath,replace=false]{limsup}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {limsup} \limsup +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pln, \bln, \Bln, \vln, \Vln, +% } +% \cs[module=amsmath,replace=false]{ln} +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {ln} \ln +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \plog, \blog, \Blog, \vlog, \Vlog, +% } +% \cs[module=amsmath,replace=false]{log}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {log} \log +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pmax, \bmax, \Bmax, \vmax, \Vmax, +% } +% \cs[module=amsmath,replace=false]{max}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {max} \max +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pmin, \bmin, \Bmin, \vmin, \Vmin, +% } +% \cs[module=amsmath,replace=false]{min}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {min} \min +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pPr, \bPr, \BPr, \vPr, \VPr, +% } +% \cs[module=amsmath,replace=false]{Pr}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {Pr} \Pr +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pprojlim, \bprojlim, \Bprojlim, \vprojlim, \Vprojlim, +% } +% \cs[module=amsmath,replace=false]{projlim}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {projlim} \projlim +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \psec, \bsec, \Bsec, \vsec, \Vsec, +% } +% \cs[module=amsmath,replace=false]{sec}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {sec} \sec +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \psin, \bsin, \Bsin, \vsin, \Vsin, +% } +% \cs[module=amsmath,replace=false]{sin}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {sin} \sin +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \psinh, \bsinh, \Bsinh, \vsinh, \Vsinh, +% } +% \cs[module=amsmath,replace=false]{sinh}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {sinh} \sinh +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \psup, \bsup, \Bsup, \vsup, \Vsup, +% } +% \cs[module=amsmath,replace=false]{sup}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {sup} \sup +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \ptan, \btan, \Btan, \vtan, \Vtan, +% } +% \cs[module=amsmath,replace=false]{tan}, +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {tan} \tan +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \ptanh, \btanh, \Btanh, \vtanh, \Vtanh +% } +% and \cs[module=amsmath,replace=false]{tanh}. +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {tanh} \tanh +% \end{macrocode} +% \end{macro} +% \begin{macro}[documented-as=\parccos]{ +% \pvarinjlim, \bvarinjlim, \Bvarinjlim, \vvarinjlim, \Vvarinjlim, +% \pvarprojlim, \bvarprojlim, \Bvarprojlim, \vvarprojlim, \Vvarprojlim, +% \pvarliminf, \bvarliminf, \Bvarliminf, \vvarliminf, \Vvarliminf, +% \pvarlimsup, \bvarlimsup, \Bvarlimsup, \vvarlimsup, \Vvarlimsup, +% } +% We also provide delimited versions of \cs[module=amsmath,replace=false]{varinjlim}, +% \cs[module=amsmath,replace=false]{varprojlim}, +% \cs[module=amsmath,replace=false]{varliminf}, +% and \cs[module=amsmath,replace=false]{varlimsup}. +% \begin{macrocode} +\@@_new_delim_op_cmds:nN {varinjlim} \varinjlim +\@@_new_delim_op_cmds:nN {varprojlim} \varprojlim +\@@_new_delim_op_cmds:nN {varliminf} \varliminf +\@@_new_delim_op_cmds:nN {varlimsup} \varlimsup +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +}{ + \msg_info:nnnn {moremath} {load /disabling} {no-operators} + { + predefined~delimited~operator~macros + } +} % End of the conditional +% \end{macrocode} +% +% ^^X SECTION: Vector Calculus Macros +% \section{Vector Calculus Macros} +% \label{sec:vector-calc} +% +% For providing macros which help with vector differentials, +% we first need some setup functions. +% +% \subsection{Macros Providing Symbols of Operators} +% \label{sec:op-symbols} +% +% \begin{macro}{ +% \@@_maybe_vcenter:n, +% } +% Sometimes a symbol should be centered explicitly, +% as this will depend on the current setting of "vcenter", +% i.e.\ the current value of \cs{l_@@_vcenter_bool}, +% we provide a helper function which puts its argument +% \begin{arguments} +% \item A list of \meta{tokens} +% \end{arguments} +% inside a \tn{vcenter} by means of \cs{moremath_vcenter:n} +% or not depending on the current value of \cs{l_@@_vcenter_bool}. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_maybe_vcenter:n +{ + \bool_if:NTF \l_@@_vcenter_bool + { + \moremath_vcenter:n {#1} + }{ + #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_gradient_operator_get:} +% This function returns the gradient operator depending on the current setting +% of the keys. +% \begin{macrocode} +\cs_new_protected:Nn \@@_gradient_operator_get: +{ + \tl_if_empty:NTF \l_@@_grad_op_tl + { + \mathop + { +% \end{macrocode} +% Otherwise we first need to check if the operator shall have an arrow over it. +% Afterwards if the nabla shall be bold. +% \begin{macrocode} + \bool_if:NTF \l_@@_nabla_arrow_bool + { + \vec + { +% \end{macrocode} +% In case \cs{l_@@_nabla_arrow_bool} is true we should \emph{maybe} +% center the symbol. +% \begin{macrocode} + \@@_maybe_vcenter:n + { + \bool_if:NT \l_@@_nabla_bold_bool + { + \boldsymbol + } + \l_@@_nabla_tl + } + } + }{ +% \end{macrocode} +% Like in the case above we should \emph{maybe} center the symbol +% if \cs{l_@@_nabla_bold_bool} is true. +% \begin{macrocode} + \bool_if:NTF \l_@@_nabla_bold_bool + { + \@@_maybe_vcenter:n + { + \boldsymbol + \l_@@_nabla_tl + } + }{ + \l_@@_nabla_tl + } + } + }% \mathop + \nolimits + }{ +% \end{macrocode} +% If the user provided its own implementation of the operator, +% we simply return it. +% \begin{macrocode} + \l_@@_grad_op_tl + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_laplace_operator_get:} +% Then we define a function for returning the laplace operator symbol, +% depending on the currently set keys. +% The function wraps the symbol for the operator inside +% \tn{mathop} to provide the right spacing. +% \begin{macrocode} +\cs_new_protected:Nn \@@_laplace_operator_get: +{ + \tl_if_empty:NTF \l_@@_laplacian_tl + { + \mathop + { + \bool_if:NTF \l_@@_laplacian_delta_bool + { + \Delta + }{ + \bool_if:NTF \l_@@_laplacian_arrow_bool + { + \vec{ + \@@_maybe_vcenter:n + { + \bool_if:NT \l_@@_nabla_bold_bool {\boldsymbol} + \l_@@_laplacian_symb_tl + } + } + }{ + \bool_if:NTF \l_@@_nabla_bold_bool + { + \@@_maybe_vcenter:n + { + \boldsymbol + \l_@@_laplacian_symb_tl + } + }{ + \l_@@_laplacian_symb_tl + } + } + } + }\nolimits + \bool_if:NF \l_@@_laplacian_delta_bool + { + \c_math_superscript_token + { + 2 + } + } + }{ + \l_@@_laplacian_tl + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{ +% \@@_dalembert_operator_get: +% } +% This function returns the \foreignlanguage{french}{d'Alembert} operator +% depending on the currently set keys. The symbol for the +% \foreignlanguage{french}{d'Alembert} operator is wrapped inside \tn{mathop} +% to provide proper spacing. +% \begin{macrocode} +\cs_new_protected:Nn \@@_dalembert_operator_get: +{ + \mathop + { + \l_@@_dalembert_symb_tl + }% \mathop + \nolimits +} +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added function: \cs{@@_dalembert_operator_get:} +% } +% \end{macro} +% +% \subsection{Macros Producing an Operator} +% \label{sec:op-macros} +% +% After we have defined the symbols it is now time to provide a function which +% produces the entire gradient operator +% \begin{macro}{ +% \moremath_gradient_operator:n, +% \moremath_laplace_operator:n +% } +% This function takes one arguments, the subscript to use with the operator. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_gradient_operator:n +{ + \@@_gradient_operator_get: + \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}} +} +% \end{macrocode} +% +% Like for the gradient operator we do the same for the laplacian +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_laplace_operator:n +{ + \@@_laplace_operator_get: + \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added functions. +% } +% \end{macro} +% +% \begin{macro}{ +% \moremath_divergence_operator:n, +% \moremath_curl_operator:n +% } +% Using the already defined gradient operator it is possible to define a +% function which acts as an operator suitable for representing the divergence +% operator and the curl operator. +% Like the gradient operator this functions take one argument +% \begin{arguments} +% \item the subscript of the gradient operator. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_divergence_operator:n +{ +% \end{macrocode} +% The braces around \cs{moremath_gradient_operator:n} are necessary to avoid +% issues with the spacing between \tn{cdot} and the following \tn{mathopen} +% from any braces.\footnote{% +% See: \url{https://tex.stackexchange.com/a/223914} +% } +% Example: +% \[ +% \text{With braces:}\quad \pdiv{f(x)} \text{,} +% \qquad\text{without braces: }\quad \mathop{\nabla}\nolimits\cdot(f(x)) +% \] +% \begin{macrocode} + { + \moremath_gradient_operator:n {#1} + } + \cdot +} + +\cs_new_protected_nopar:Nn \moremath_curl_operator:n +{ + { + \moremath_gradient_operator:n {#1} + } + \times +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added functions. +% } +% \end{macro} +% +% \begin{macro}{ +% \moremath_dalembert_operator:n +% } +% This function produces the \foreignlanguage{french}{d'Alembert} operator, +% including an optional subscript. +% The function takes one argument: +% \begin{arguments} +% \item A \meta{tl} with the contents of the subscript of the operator. +% +% This variable may be empty, +% in this case no subscript (not even an empty one) is produced. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \moremath_dalembert_operator:n +{ + \@@_dalembert_operator_get: + \tl_if_empty:nF {#1} + { + \c_math_subscript_token {#1} + } +} +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added new function \cs{moremath_dalembert_operator:n}. +% } +% \end{macro} +% +% +% \subsection{Producing Delimited Vector Calculus Operators} +% \label{sec:delim-vec-ops} +% +% \begin{macro}{ +% \moremath_delim_nabla_op_noscale:NNnn, +% \moremath_delim_nabla_op_autoscale:NNnn +% } +% These functions produce a vector calculus operator with \meta{contents} +% inside delimiters. +% The "autoscale" variant scales the delimiters with the size of \meta{contents}, +% the "noscale" variant does no scaling at all. +% \begin{arguments} +% \item The \meta{csname} of the operator to use. +% +% This should have the same form as \cs{moremath_gradient_operator:n}, +% i.e.\ the function passed as \meta{csname} should accept one argument +% to typeset as subscript. +% +% \item The \meta{csname} of the \emph{paired delimiter} to use. +% +% The paired delimiter has to be one declared using \pkg{mathtools}' +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command. +% +% \item A \meta{tl} with the subscript of the operator. +% +% \item A \meta{tl} with the contents to typeset inside the delimiters +% \end{arguments} +% We begin with the "noscale" version. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_noscale:NNnn +{ + #1 {#3} #2{#4} +} +% \end{macrocode} +% Then we create the version with automatic scaling. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_autoscale:NNnn +{ + #1 {#3} #2 * {#4} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added "noscale" and "autoscale" functions. +% } +% \end{macro} +% +% \begin{macro}{ +% \moremath_delim_nabla_op_manuscale:NNnnn +% } +% This function produces a vector calculus operator like +% \cs{moremath_delim_nabla_op_noscale:NNnn} +% and \cs{moremath_delim_nabla_op_autoscale:NNnn}, +% but with manual scaling. +% It takes five arguments: +% \begin{arguments} +% \item The \meta{csname} of the operator to use. +% +% \item The \meta{csname} of the paired delimiter. +% +% \item A \meta{token~list} containing the \meta{scale~cmd} like +% \cs{big}, \cs{Big}, \cs{bigg}, etc. +% +% \item A \meta{tl} with the subscript of the operator. +% +% \item A \meta{tl} with the contents to typeset inside the delimiters. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_manuscale:NNnnn +{ + #1 {#4} #2 [#3] {#5} +} +% \end{macrocode} +% \begin{macro}{ +% \moremath_delim_nabla_op_manuscale:NNVnn +% } +% We also declare a variant for passing a variable with the \meta{scale~cmd} +% instead of a \meta{token~list}. +% \begin{macrocode} +\cs_generate_variant:Nn \moremath_delim_nabla_op_manuscale:NNnnn {NNVnn} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Add variant. +% } +% \end{macro} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Add function. +% } +% \end{macro} +% +% To ease the definition of those macros we define a function for defining +% the delimited versions. +% +% Of course we also need a way to declare a user interface for this functions. +% For this purpose we first need some helpers for setting +% necessary parameters. +% \begin{macro}{\@@_parse_kv_args:nN} +% This helper macro takes two arguments, +% \begin{arguments} +% \item A token list of the key-value arguments. +% \item The \meta{csname} of a token list to put the scale value in. +% \end{arguments} +% The function sets the given keys but before it does so it searches for a +% key named \verb|scale| and puts it into the second argument. +% For this to work it is necessary that all values have \verb|=| in them. +% \begin{macrocode} +\cs_new_protected:Nn \@@_parse_kv_args:nN +{ +% \end{macrocode} +% We first put the key-value arguments inside a property list. +% Afterwards we check if the key \verb|scale| has been given. +% If yes we pop it and assign it to the second argument. +% Otherwise we do nothing. +% \begin{macrocode} + \prop_set_from_keyval:Nn \l_tmpa_prop {#1} + + \prop_pop:NnNT \l_tmpa_prop {scale} #2 {} + + \keys_set:ne {moremath} {\prop_to_keyval:N \l_tmpa_prop} +} +% \end{macrocode} +% \end{macro} +% +% We also need a warning message for conflicting arguments, +% to inform the user that one of his options is going to be ignored. +% \begin{macrocode} +\msg_new:nnn { moremath } { vector-calc / scale-star-conflict } +{ + Both~star~and~scaling~factor~given~to~'#1'.\\ + Automatic~scaling~will~be~preferred,~the~size~command~'#2'~will~be~ + ignored~\msg_line_context:. +} +% \end{macrocode} +% +% \begin{macro}{ +% \@@_new_delim_nabla_doc_cmd:NNN, +% \@@_new_delim_nabla_doc_cmd:cNN, +% } +% This function takes three arguments: +% \begin{arguments} +% \item The \meta{csname} of the to be defined command +% \item The \meta{csname} of the operator to use. +% +% This should be a function like \cs{moremath_gradient_operator:n}. +% \item The \meta{csname} of the delimiter function to use. +% +% This should be a macro/command created with \pkg{mathtools} +% \cs[module=mathtools,replace=false]{DeclarePairedDelimiter} command. +% \end{arguments} +% Its purpose is to create a new document level command, +% for the delimited vector calculus operators. +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_delim_nabla_doc_cmd:NNN +{ + \cs_if_free:NTF #1 + { + \exp_args:NNe \NewDocumentCommand #1 + { + s ={scale} o E{ \char_generate:nn {`_}{8} }{ {} } m + } + { % command code + \group_begin: + % optional arguments given? + \tl_if_novalue:nF {##2} + { + \@@_parse_kv_args:nN {##2} \l_tmpa_tl + } + % star given? + \bool_if:nTF {##1} + { + % scale factor given? + \tl_if_empty:NF \l_tmpa_tl + { + \msg_warning:nnnV { moremath } { vector-calc / scale-star-conflict } + {#1} \l_tmpa_tl + } + \moremath_delim_nabla_op_autoscale:NNnn #2 #3 {##3} {##4} + }{ % \bool_if:nTF {##1} FALSE BRANCH + % scale factor given? + \tl_if_empty:NTF \l_tmpa_tl + { + \moremath_delim_nabla_op_noscale:NNnn #2 #3 {##3} {##4} + }{ % FALSE BRANCH + \moremath_delim_nabla_op_manuscale:NNVnn #2 #3 \l_tmpa_tl {##3} {##4} + } + } % \bool_if:nTF {##1} + \group_end: + } + }{ % \cs_if_free:NTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { vector-calc / already-defined-skip } {#1} + } % \cs_if_free:NTF #1 +} +% +\cs_generate_variant:Nn \@@_new_delim_nabla_doc_cmd:NNN {cNN} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_new_nabla_doc_cmds:nN} +% This internal function creates five different document level commands at once, +% using \cs{@@_new_delim_nabla_doc_cmd:cNN}. +% It takes two arguments: +% \begin{arguments} +% \item The a \meta{suffix~tl} for constructing the command names. +% +% The resulting commands will have the form \cs[no-index]{p\meta{suffix}}, +% \cs[no-index]{b\meta{suffix}}, \cs[no-index]{B\meta{suffix}}, +% \cs[no-index]{v\meta{suffix}} and \cs[no-index]{V\meta{suffix}}. +% +% \item The \meta{csname} of the operator to use +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_nabla_doc_cmds:nN +{ + \@@_new_delim_nabla_doc_cmd:cNN { p #1 } #2 \@@_inparent:w + \@@_new_delim_nabla_doc_cmd:cNN { b #1 } #2 \@@_inbrack:w + \@@_new_delim_nabla_doc_cmd:cNN { B #1 } #2 \@@_inbrace:w + \@@_new_delim_nabla_doc_cmd:cNN { v #1 } #2 \@@_in_vert:w + \@@_new_delim_nabla_doc_cmd:cNN { V #1 } #2 \@@_in_Vert:w +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Document Level Commands} +% \label{sec:vec-doc-lvl-commands} +% +% The predefined macros for vector calculus are also guarded by a package +% option to be conditionally disabled by the user. +% \begin{macrocode} +\bool_if:NTF \l_@@_predef_vector_op_bool +{ +% \end{macrocode} +% \subsubsection{Standalone Operators} +% \label{par:impl-vector-calc-standalone} +% The user might want to use also a non-delimited version +% of the vector calculus operators, +% we provide them with a standalone version of those. +% +% As the definition of a new document command can fail if the \meta{csname} +% clashes with some already defined macro, +% we define an error message to use when defining document level commands. +% \begin{macrocode} +\msg_new:nnn { moremath } { vector-calc / already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~\msg_line_context:. +} +% \end{macrocode} +% +% \begin{macro}{ +% \grad, +% \divergence, +% \curl, +% \laplacian +% } +% Now we provide the user with document level commands for +% \cs[no-index]{moremath_\meta{op}_operator:n}. +% \begin{macrocode} +\cs_if_free:NTF \grad +{ + \exp_args:NNe \NewDocumentCommand \grad { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_gradient_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\grad} +} + +\cs_if_free:NTF \divergence +{ + \exp_args:NNe \NewDocumentCommand \divergence + { !o E{ \char_generate:nn {`_} {8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_divergence_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\divergence} +} + +\cs_if_free:NTF \curl +{ + \exp_args:NNe \NewDocumentCommand \curl + { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_curl_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} {vector-calc / already-defined-skip} {\curl} +} + +\cs_if_free:NTF \laplacian +{ + \exp_args:NNe \NewDocumentCommand \laplacian + { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_laplace_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } + {\laplacian} +} +% \end{macrocode} +% \begin{macro}{\quabla} +% We now also define a command to use as a standalone +% \foreignlanguage{french}{d'Alembert} operator. +% As the name \cs[no-index]{dalembertian} is a bit cumbersome to type out, +% I've decided to use one of its alternate names \cs{quabla} +% \begin{macrocode} +\cs_if_free:NTF \quabla +{ + \exp_args:NNe \NewDocumentCommand \quabla + { !o E{ \char_generate:nn {`_} { 8 } }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath } {#1} + } + \moremath_dalembert_operator:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \quabla FALSE BRANCH + \msg_warning:nnn { moremath } { vector-calc / already-defined-skip } + {\quabla} +} +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{ +% Added \cs{quabla} command. +% } +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Changed: Spaces between the \meta{csname} +% and the optional argument are now disallowed. +% } +% \end{macro}^^X \quabla +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added \cs{grad}, \cs{divergence}, \cs{curl} and \cs{laplacian} +% commands. +% } +% \changes{v0.3.0}{\GetVersionDate{v0.3.0}}{ +% Changed: Spaces between the \meta{csname} +% and the optional argument are now disallowed +% for \cs{grad}, \cs{divergence}, \cs{curl} and \cs{laplacian}. +% } +% \end{macro} +% +% \subsubsection{Operators with Delimiters} +% \label{par:impl-vec-calc-op-delim} +% +% \begin{macro}{ +% \pgrad, +% \bgrad, +% \Bgrad, +% \vgrad, +% \Vgrad, +% } +% Now lets declare the delimited gradient operators. +% We provide five versions using parenthesis, brackets, braces, single \tn{vert}, +% and double \tn{Vert}. +% \begin{macrocode} +\@@_new_nabla_doc_cmds:nN {grad} \moremath_gradient_operator:n +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands for delimited gradient operators. +% } +% \end{macro} +% +% \begin{macro}{ +% \pdiv, +% \bdiv, +% \Bdiv, +% \vdiv, +% \Vdiv +% } +% Now we do the same for the divergence operator. +% \begin{macrocode} +\@@_new_nabla_doc_cmds:nN {div} \moremath_divergence_operator:n +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands for delimited divergence operators. +% } +% \end{macro} +% +% \begin{macro}{ +% \pcurl, +% \bcurl, +% \Bcurl, +% \vcurl, +% \Vcurl +% } +% Now to the curl macros. +% \begin{macrocode} +\@@_new_nabla_doc_cmds:nN {curl} \moremath_curl_operator:n +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands for delimited curl operators. +% } +% \end{macro} +% +% \begin{macro}{ +% \plaplacian, +% \blaplacian, +% \Blaplacian, +% \vlaplacian, +% \Vlaplacian +% } +% Next we take care of the laplacian +% \begin{macrocode} +\@@_new_nabla_doc_cmds:nN {laplacian} \moremath_laplace_operator:n +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands for delimited Laplace operators. +% } +% \end{macro} +% +% \begin{macro}{ +% \pquabla, +% \bquabla, +% \Bquabla, +% \vquabla, +% \Vquabla +% } +% Finally we define delimited commands for the +% \foreignlanguage{french}{d'Alembert} operator. +% \begin{macrocode} +\@@_new_nabla_doc_cmds:nN {quabla} \moremath_dalembert_operator:n +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{ +% Added commands for a delimited \foreignlanguage{french}{d'Alembert} +% operator. +% } +% \end{macro} +% +% If the user issued \texttt{no-vector} as a package loading option, +% write this to the log file. +% \begin{macrocode} +}{ % IF NOT \l_@@_predef_vector_op_bool + \msg_info:nnnn {moremath} { load /disabling } {no-vector} + { + predefined~vector~calculus~macros + } +} % END \l_@@_predef_vector_op_bool +% \end{macrocode} +% +% \section{Macros Producing Matrices and Vectors} +% \label{sec:impl-matr-vec} +% +% \subsection{Producing Row and Column Vectors} +% +% The functions in this section are used to generate row and column vectors +% utilizing \pkg{mathtools}~\autocite{mathtools} \env{matrix*} and +% \env{smallmatrix*} environments. +% +% \begin{variable}{\l_@@_vector_entries_seq} +% For generating row or column vectors it is necessary to store the entries +% inside a variable. \cs{l_@@_vector_entries_seq} is used for this purpose. +% \begin{macrocode} +\seq_new:N \l_@@_vector_entries_seq +% \end{macrocode} +% \end{variable} +% +% Then we need a function for formatting the actual entries of the vector. +% We need two version one for the row vector and one for the column vector +% version. +% \begin{macro}{ +% \@@_seq_to_column_vector:N, +% \@@_seq_to_row_vector:N +% } +% These functions take one argument +% \begin{arguments} +% \item A sequence which should be converted to the contents of the single +% column/row matrix. +% \end{arguments} +% They format the input suitable to be put inside a \env{matrix*} environment. +% We begin with the column vector version. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_seq_to_column_vector:N +{ + \seq_use:Nn #1 {\\} +} +% \end{macrocode} +% Then we get to the row vector. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_seq_to_row_vector:N +{ + \seq_use:Nn #1 {&} +} +% \end{macrocode} +% \end{macro} +% +% In the next step we construct the single row/column matrix from the user +% provided input. +% \begin{macro}{ +% \moremath_column_vector:nn, +% \moremath_row_vector:nn, +% } +% The two commands \cs{moremath_column_vector:n} and \cs{moremath_row_vector:n} +% construct the matrix, they both take two arguments. +% \begin{arguments} +% \item The delimiter specifier. +% +% This should be one of the prefixes of the \env{\meta{prefix}matrix*}, +% environments. +% +% Another possibility is to issue |small| as this parameter to get +% an inline matrix. +% +% \item The comma separated contents of the matrix. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_column_vector:nn +{ + \seq_clear:N \l_@@_vector_entries_seq + \seq_set_from_clist:Nn \l_@@_vector_entries_seq {#2} + + \exp_args:NnNV \begin{#1 matrix*} [ \l_@@_matrix_align_tl ] + \@@_seq_to_column_vector:N \l_@@_vector_entries_seq + \end{#1 matrix*} +} + +\cs_new_protected_nopar:Nn \moremath_row_vector:nn +{ + \seq_clear:N \l_@@_vector_entries_seq + \seq_set_from_clist:Nn \l_@@_vector_entries_seq {#2} + + \exp_args:NnNV \begin{#1matrix*} [ \l_@@_matrix_align_tl ] + \@@_seq_to_row_vector:N \l_@@_vector_entries_seq + \end{#1matrix*} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added functions producing row- and column vectors. +% } +% \end{macro} +% +% \begin{macro}{ +% \moremath_column_smallvector:nn, +% \moremath_row_smallvector:nn +% } +% To make the code more readable, we define functions specifically for +% creating row and column vectors using the \env{smallmatrix*} family of +% environments. These functions take the same arguments as the non-small +% versions above. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_column_smallvector:nn +{ + \moremath_column_vector:nn {#1 small} {#2} +} + +\cs_new_protected_nopar:Nn \moremath_row_smallvector:nn +{ + \moremath_row_vector:nn {#1 small} {#2} +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added functions producing inline math row- and column vectors. +% } +% \end{macro} +% +% ^^X SUBSECTION: Shorthands for simple matrices +% \subsection{Shorthands for Simple Matrices} +% \label{sec:impl-matr-shorth} +% +% The construction of several simple matrices like diagonal matrices, +% can be simplified as there is no need to use the \env{matrix} environment.\footnote{% +% The code in this section is heavily inspired by the following answer on +% \TeX{}SE: \url{https://tex.stackexchange.com/a/539741} +% } +% +% \begin{variable}{ +% \l_@@_mat_diag_entries_seq, +% \l_@@_mat_row_entries_seq, +% } +% We construct the matrices row by row, therefore we need to store the +% currently constructed row inside a variable. +% The same is true for the diagonal entries which also need to be stored +% somewhere. +% We therefore declare two sequence variables \cs{l_@@_mat_diag_entries_seq} +% and \cs{l_@@_mat_row_seq} for this purpose +% \begin{macrocode} +\seq_clear_new:N \l_@@_mat_diag_entries_seq +\seq_clear_new:N \l_@@_mat_row_entries_seq +% \end{macrocode} +% \end{variable} +% +% \subsubsection{(Anti-)diagonal matrices} +% We split the construction of the matrix into multiple parts, +% utilizing internal helper functions. +% \begin{macro}{ +% \@@_constr_diagmat_row:n, +% \@@_constr_antidiagmat_row:n +% } +% \cs{@@_constr_diagmat_row:n} and \cs{@@_constr_antidiagmat_row:n} +% take one integer argument: +% \begin{arguments} +% \item The number of the current row. +% \end{arguments} +% They both construct a matrix row and place it inside the input stream. +% They take the content of the (anti-)diagonal from the variable +% \cs{l_@@_mat_diag_entries_seq} +% and use the variable \cs{l_@@_mat_row_entries_seq} +% to store the current row. +% \begin{macrocode} +\cs_new_protected:Nn \@@_constr_diagmat_row:n +{ + \seq_clear:N \l_@@_mat_row_entries_seq +% \end{macrocode} +% As all diagonal matrices \(M \in A^{m \times n}\), where \(A\) is a field, +% are quadratic i.e.\ \(A^{m \times n} \equiv A^{n \times n}\) the length of the +% diagonal sequence equals the number of rows and columns of the matrix. +% We exploit this fact here. +% \begin{macrocode} + \int_step_inline:nn {\seq_count:N \l_@@_mat_diag_entries_seq} + { + \int_compare:nTF { #1 == ##1 } + { + \seq_put_right:Nx \l_@@_mat_row_entries_seq + { + \seq_item:Nn \l_@@_mat_diag_entries_seq { #1 } + } + }{ % false branch + \seq_put_right:NV \l_@@_mat_row_entries_seq \l_@@_matrix_fill_tl + } % \int_compare:nTF { #1 == ##1 } + } + \seq_use:Nn \l_@@_mat_row_entries_seq { & } \\ +} + +% Anti-diagonal version +\cs_new_protected:Nn \@@_constr_antidiagmat_row:n +{ + \seq_clear:N \l_@@_mat_row_entries_seq + \int_step_inline:nn {\seq_count:N \l_@@_mat_diag_entries_seq} + { + \int_compare:nTF { #1 == ##1 } + { + % as this is a anti diagonal matrix we put in the elements from the + % left so that the first entry is the right most entry + \seq_put_left:Nx \l_@@_mat_row_entries_seq + { + \seq_item:Nn \l_@@_mat_diag_entries_seq { #1 } + } + }{ % false branch + \seq_put_left:NV \l_@@_mat_row_entries_seq \l_@@_matrix_fill_tl + } % \int_compare:nTF { #1 == ##1 } + } + \seq_use:Nn \l_@@_mat_row_entries_seq { & } \\ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{ +% \moremath_diagonal_matrix:nn, +% \moremath_antidiagonal_matrix:nn, +% \moremath_diagonal_smallmatrix:nn, +% \moremath_antidiagonal_smallmatrix:nn, +% } +% The \cs[no-index]{moremath_\meta{a or d}_matrix:nn} and +% \cs[no-index]{moremath_\meta{a or d}_smallmatrix:nn} family of functions +% produce a matrix based on \pkg{mathtools}~\autocite{mathtools} +% \env{matrix*} environment. +% The functions take two arguments. +% \begin{arguments} +% \item The delimiter specifier. +% +% This should be one of the prefixes of the \env{\meta{prefix}matrix*} +% environments. +% +% \item The comma separated contents of the (anti-)diagonal. +% \end{arguments} +% These functions also use the values of the variables +% \cs{l_@@_matrix_fill_tl} and \cs{l_@@_matrix_align_tl}. +% And modifies the variable \cs{l_@@_mat_diag_entries_seq}. +% \begin{macrocode} +\cs_new_protected:Nn \moremath_diagonal_matrix:nn +{ + \seq_set_from_clist:Nn \l_@@_mat_diag_entries_seq { #2 } + \exp_args:NnNV \begin{#1 matrix*} [ \l_@@_matrix_align_tl ] + \int_step_function:nN { \seq_count:N \l_@@_mat_diag_entries_seq } + \@@_constr_diagmat_row:n + \end{#1 matrix*} +} + +% Anti-diagonal matrix +\cs_new_protected:Nn \moremath_antidiagonal_matrix:nn +{ + \seq_set_from_clist:Nn \l_@@_mat_diag_entries_seq { #2 } + \exp_args:NnNV \begin{ #1 matrix* } [ \l_@@_matrix_align_tl ] + \int_step_function:nN { \seq_count:N \l_@@_mat_diag_entries_seq } + \@@_constr_antidiagmat_row:n + \end{ #1 matrix* } +} + +% Small versions +\cs_new_protected:Nn \moremath_diagonal_smallmatrix:nn +{ + \moremath_diagonal_matrix:nn {#1 small} {#2} +} + +\cs_new_protected:Nn \moremath_antidiagonal_smallmatrix:nn +{ + \moremath_antidiagonal_matrix:nn {#1 small} {#2} +} +% \end{macrocode} +% \begin{macro}{ +% \moremath_diagonal_matrix:nV, +% \moremath_diagonal_matrix:Vn, +% \moremath_diagonal_matrix:VV, +% \moremath_antidiagonal_matrix:nV, +% \moremath_antidiagonal_matrix:Vn, +% \moremath_antidiagonal_matrix:VV, +% \moremath_diagonal_smallmatrix:nV, +% \moremath_diagonal_smallmatrix:Vn, +% \moremath_diagonal_smallmatrix:VV, +% \moremath_antidiagonal_smallmatrix:nV, +% \moremath_antidiagonal_smallmatrix:Vn, +% \moremath_antidiagonal_smallmatrix:VV, +% } +% For convenience we also define some variants of the above functions. +% \begin{macrocode} +\cs_generate_variant:Nn \moremath_diagonal_matrix:nn { n V } +\cs_generate_variant:Nn \moremath_diagonal_matrix:nn { V n } +\cs_generate_variant:Nn \moremath_diagonal_matrix:nn { V V } +\cs_generate_variant:Nn \moremath_antidiagonal_matrix:nn { n V } +\cs_generate_variant:Nn \moremath_antidiagonal_matrix:nn { V n } +\cs_generate_variant:Nn \moremath_antidiagonal_matrix:nn { V V } +\cs_generate_variant:Nn \moremath_diagonal_smallmatrix:nn { n V } +\cs_generate_variant:Nn \moremath_diagonal_smallmatrix:nn { V n } +\cs_generate_variant:Nn \moremath_diagonal_smallmatrix:nn { V V } +\cs_generate_variant:Nn \moremath_antidiagonal_smallmatrix:nn { n V } +\cs_generate_variant:Nn \moremath_antidiagonal_smallmatrix:nn { V n } +\cs_generate_variant:Nn \moremath_antidiagonal_smallmatrix:nn { V V } +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{Added variants.} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{Added "nV" and "VV" variants.} +% \end{macro} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added functions producing (anti-)diagonal matrices. +% Also added versions for inline math. +% } +% \end{macro} +% +% +% \subsubsection{Identity Matrices} +% As we already have functions available for producing diagonal matrices, +% it makes only sense to also provide a shorthand for producing an identity matrix, +% i.e.\ a diagonal matrix with \enquote{1} along the diagonal. +% +% +% \begin{macro}{ +% \@@_generate_one_filled_clist:Nn +% } +% The function \cs{@@_generate_one_filled_clist:Nn} produces a \meta{clist}, +% consisting only of \enquote{1} as entries. +% This function takes two arguments: +% \begin{arguments} +% \item The \emph{csname} of a \meta{clist~var} to store the \meta{clist} +% into. +% +% \item An \meta{int} to represent the number of entries to produce. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_generate_one_filled_clist:Nn +{ + \seq_clear:N \l_tmpa_seq + \int_step_inline:nn {#2} + { + \seq_put_right:NV \l_tmpa_seq \c_one_int + } + \clist_set_from_seq:NN #1 \l_tmpa_seq +} +% \end{macrocode} +% \begin{macro}{ +% \@@_generate_one_filled_clist:NV +% } +% We also define a variant accepting an integer variable. +% \begin{macrocode} +\cs_generate_variant:Nn \@@_generate_one_filled_clist:Nn { N V } +% \end{macrocode} +% \end{macro} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added function. +% } +% \end{macro} +% +% \begin{variable}{ +% \l_@@_id_entries_clist +% } +% As we want to utilize the \cs{moremath_diagonal_matrix:VV} and +% \cs{moremath_diagonal_smallmatrix:VV} functions for creating the identity +% matrix we declare an internal \meta{clist~var} called +% \cs{l_@@_id_entries_clist} for passing the \meta{clist} around. +% \begin{macrocode} +\clist_new:N \l_@@_id_entries_clist +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{Added variable.} +% \end{variable} +% +% \begin{macro}{ +% \moremath_id_matrix:n, +% \moremath_id_smallmatrix:n +% } +% These functions are intended to produce an identity matrix from an integer +% expression. +% They take one argument. +% \begin{arguments} +% \item The number of diagonal entries. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_id_matrix:n +{ + \clist_clear:N \l_@@_id_entries_clist + \@@_generate_one_filled_clist:Nn \l_@@_id_entries_clist {#1} + \moremath_diagonal_matrix:VV \l_@@_matrix_delim_tl \l_@@_id_entries_clist +} +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected_nopar:Nn \moremath_id_smallmatrix:n +{ + \clist_clear:N \l_@@_id_entries_clist + \@@_generate_one_filled_clist:Nn \l_@@_id_entries_clist {#1} + \moremath_diagonal_smallmatrix:VV \l_@@_matrix_delim_tl \l_@@_id_entries_clist +} +% \end{macrocode} +% +% \begin{macro}{ +% \moremath_id_matrix:V, +% \moremath_id_smallmatrix:V +% } +% We also provide variants, which accepts a "V"-type argument: +% \begin{macrocode} +\cs_generate_variant:Nn \moremath_id_matrix:n { V } +\cs_generate_variant:Nn \moremath_id_smallmatrix:n { V } +% \end{macrocode} +% \end{macro} +% +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added functions \cs{moremath_id_matrix:n} and \cs{moremath_id_smallmatrix:n} +% and variants. +% } +% \end{macro} +% +% \subsection{Document Level Commands} +% \label{sec:mat-doc-lvl-cmds} +% +% Now we define document level commands for the previously defined +% functions. +% +% But before we do so we define a message to be issued in case the targeted +% \meta{csname} is already defined elsewhere. +% \begin{macrocode} +\msg_new:nnnn { moremath } { matrix / already-defined-doc-cmd-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~\msg_line_context:. +} +{ + The~control~sequence~'#1'~has~already\\ + been~defined~by~some~other~package.\\ + And~I~am~refusing~to~overwrite~the~existing~definition,\\ + therefore~I~am~skipping~the~definition~of~this~command. +} +% \end{macrocode} +% +% \subsubsection{Row and Column Vectors} +% We begin with the row and column vector functions. +% As with the other document level commands, we guard the definitions +% with a key value option, so that the user can disable them. +% \begin{macrocode} +\bool_if:nTF \l_@@_predef_crvector_bool +{ +% \end{macrocode} +% \begin{macro}{ +% \cvector, +% \rvector, +% \smallcvector, +% \smallrvector +% } +% First we define the document level command for the bare column vector +% \begin{macrocode} +\cs_if_free:NTF \cvector +{ + \NewDocumentCommand \cvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_column_vector:nn {\l_@@_matrix_delim_tl} {#2} + \group_end: + } +}{ + % issue a warning message if the csname is already taken. + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \cvector + } +} % \cs_if_free:NTF \cvector +% \end{macrocode} +% and the row vector. +% \begin{macrocode} +\cs_if_free:NTF \rvector +{ + \NewDocumentCommand \rvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_row_vector:nn {\l_@@_matrix_delim_tl} {#2} + \group_end: + } +}{ + % warn if csname is already taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip} + { + \rvector + } +} % \cs_if_free:NTF \rvector +% \end{macrocode} +% Then we define the smaller inline versions of those commands. +% \begin{macrocode} +\cs_if_free:NTF \smallcvector +{ + \NewDocumentCommand \smallcvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath / matrix} {#1} + } + \moremath_column_smallvector:nn {\l_@@_matrix_delim_tl} {#2} + \group_end: + } +}{ + % Issue a warning message if the csname is already taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallcvector + } +} % \cs_if_free:NTF \smallcvector + +\cs_if_free:NTF \smallrvector +{ + \NewDocumentCommand \smallrvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_row_smallvector:nn {\l_@@_matrix_delim_tl} {#2} + \group_end: + } +}{ + % warn if csname is taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallrvector + } +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands producing row and column vectors, +% including inline math versions. +% } +% \end{macro} +% +% \paragraph{Commands with Pre-defined Delimiters} +% Next we define several shorthands to for the commonly used delimiters, +% to avoid code duplication, we first create some helper functions which +% define those functions. +% \begin{macro}{ +% \@@_new_vector_shorth_doc_cmd:NNn +% } +% The function \cs{@@_new_vector_shorth_doc_cmd} creates a new vector shorthand, +% command. It takes three arguments: +% \begin{arguments} +% \item The \meta{csname} to be defined. +% \item The \meta{function} to use for this shorthand. +% +% This should be one of the +% \cs[no-index]{moremath_\meta{type}_\meta{size}vector:nn} +% like commands. +% +% \item The \meta{delimiter} to use. +% +% Usually one of |p|, |b|, |B|, |v|, |V|. +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_vector_shorth_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + % set the delimiter key pre-set for this function + \keys_set:nn {moremath / matrix } {delimiter = #3} + \tl_if_novalue:nF {##1} + { + \keys_set:nn {moremath / matrix } {##1} + } + #2 {\l_@@_matrix_delim_tl} {##2} + \group_end: + } + }{ + % warn if csname is taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + #1 + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{ +% \pcvector, +% \bcvector, +% \Bcvector, +% \vcvector, +% \Vcvector, +% \prvector, +% \brvector, +% \Brvector, +% \vrvector, +% \Vrvector, +% } +% Now we define shorthands for all of the matrix types so that the user +% does not have to specify |delimiter=|\meta{delim} every time. +% We begin with the column vector. +% \begin{macrocode} +% parenthesis +\@@_new_vector_shorth_doc_cmd:NNn \pcvector \moremath_column_vector:nn {p} +% brackets +\@@_new_vector_shorth_doc_cmd:NNn \bcvector \moremath_column_vector:nn {b} +% braces +\@@_new_vector_shorth_doc_cmd:NNn \Bcvector \moremath_column_vector:nn {B} +% single vert +\@@_new_vector_shorth_doc_cmd:NNn \vcvector \moremath_column_vector:nn {v} +% double vert +\@@_new_vector_shorth_doc_cmd:NNn \Vcvector \moremath_column_vector:nn {V} +% \end{macrocode} +% Now to the row vectors. +% \begin{macrocode} +% parenthesis +\@@_new_vector_shorth_doc_cmd:NNn \prvector \moremath_row_vector:nn {p} +% brackets +\@@_new_vector_shorth_doc_cmd:NNn \brvector \moremath_row_vector:nn {b} +% braces +\@@_new_vector_shorth_doc_cmd:NNn \Brvector \moremath_row_vector:nn {B} +% single vert +\@@_new_vector_shorth_doc_cmd:NNn \vrvector \moremath_row_vector:nn {v} +% double vert +\@@_new_vector_shorth_doc_cmd:NNn \Vrvector \moremath_row_vector:nn {V} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for row and column vectors with predefined delimiters. +% } +% \end{macro} +% +% \begin{macro}{ +% \psmallcvector, +% \bsmallcvector, +% \Bsmallcvector, +% \vsmallcvector, +% \Vsmallcvector, +% \psmallrvector, +% \bsmallrvector, +% \Bsmallrvector, +% \vsmallrvector, +% \Vsmallrvector +% } +% We also define shorthands for the \cs{shortcvector} and \cs{shortrvector} +% versions. +% \begin{macrocode} +% column vectors +% parenthesis +\@@_new_vector_shorth_doc_cmd:NNn \psmallcvector \moremath_column_smallvector:nn + {p} +% brackets +\@@_new_vector_shorth_doc_cmd:NNn \bsmallcvector \moremath_column_smallvector:nn + {b} +% braces +\@@_new_vector_shorth_doc_cmd:NNn \Bsmallcvector \moremath_column_smallvector:nn + {B} +% single vert +\@@_new_vector_shorth_doc_cmd:NNn \vsmallcvector \moremath_column_smallvector:nn + {v} +% double vert +\@@_new_vector_shorth_doc_cmd:NNn \Vsmallcvector \moremath_column_smallvector:nn + {V} +% +% row vectors +% parenthesis +\@@_new_vector_shorth_doc_cmd:NNn \psmallrvector \moremath_row_smallvector:nn {p} +% brackets +\@@_new_vector_shorth_doc_cmd:NNn \bsmallrvector \moremath_row_smallvector:nn {b} +% braces +\@@_new_vector_shorth_doc_cmd:NNn \Bsmallrvector \moremath_row_smallvector:nn {B} +% single vert +\@@_new_vector_shorth_doc_cmd:NNn \vsmallrvector \moremath_row_smallvector:nn {v} +% double vert +\@@_new_vector_shorth_doc_cmd:NNn \Vsmallrvector \moremath_row_smallvector:nn {V} + + +}{ % \bool_if:nTF \l_@@_predef_crvector_bool FALSE PATH + \msg_info:nnnn {moremath} {load / disabling} {no-crvector} + { + commands~producing~row~and~column~vectors + } +} % \bool_if:nTF \l_@@_predef_crvector_bool +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for inline math row and column vectors +% with predefined delimiters. +% } +% \end{macro} +% +% +% \subsubsection{(Anti-)diagonal Matrices} +% Now to the (anti-)diagonal matrix shorthands, +% these are also guarded by a key value option. +% \begin{macrocode} +\bool_if:nTF \l_@@_predef_matrix_bool +{ +% \end{macrocode} +% \begin{macro}{ +% \diagmat, +% \antidiagmat, +% \smalldiagmat, +% \smallantidiagmat, +% } +% \begin{NOTE}{MI} +% Say something like we begin with some commands producing a matrix that +% is not necessarily delimited. +% \end{NOTE} +% \begin{macrocode} +\cs_if_free:NTF \diagmat +{ + \NewDocumentCommand \diagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_diagonal_matrix:Vn \l_@@_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} {matrix / already-defined-doc-cmd-skip} + { + \diagmat + } +} % \cs_if_free:nTF \diagmat + +\cs_if_free:NTF \antidiagmat +{ + \NewDocumentCommand \antidiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_antidiagonal_matrix:Vn \l_@@_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \antidiagmat + } +} % \cs_if_free:nTF \antidiagmat + +\cs_if_free:NTF \smalldiagmat +{ + \NewDocumentCommand \smalldiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_diagonal_smallmatrix:Vn \l_@@_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smalldiagmat + } +} + +\cs_if_free:NTF \smallantidiagmat +{ + \NewDocumentCommand \smallantidiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_antidiagonal_smallmatrix:Vn \l_@@_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallantidiagmat + } +} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added commands producing (anti-)diagonal matrices, including inline math +% versions. +% } +% \end{macro} +% +% \paragraph{(Anti-)diagonal Matrices with Pre-defined Delimiters} +% As it is sort of cumbersome to always specify the delimiter key, +% we also provide commands with pre-defined delimiters. +% \begin{macro}{ +% \@@_new_matrix_shorth_doc_cmd:NNn +% } +% To provide several shorthands for delimited matrices, +% we use a helper function to avoid code duplication. +% \cs{@@_new_matrix_shorth_doc_cmd:NNn} takes three arguments: +% \begin{arguments} +% \item The \meta{csname} to define +% \item The \meta{csname} of the matrix function to use, +% which should have the signature |Vn|. +% \item The \enquote{predefined} delimiter of this version +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_matrix_shorth_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + \tl_if_empty:nF {#3} + { + \keys_set:nn { moremath / matrix } + { + delimiter = #3 + } + } % \tl_if_empty:nF {#3} + \tl_if_novalue:nF {##1} + { + \keys_set:nn { moremath / matrix } {##1} + } + #2 \l_@@_matrix_delim_tl {##2} + \group_end: + } + }{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + #1 + } + } +} +% \end{macrocode} +% \end{macro} +% +% We now define the shorthand commands with predefined delimiters. +% \begin{macro}{ +% \pdiagmat, +% \bdiagmat, +% \Bdiagmat, +% \vdiagmat, +% \Vdiagmat, +% } +% We begin with the regular diagonal matrix +% \begin{macrocode} +\@@_new_matrix_shorth_doc_cmd:NNn \pdiagmat \moremath_diagonal_matrix:Vn {p} +\@@_new_matrix_shorth_doc_cmd:NNn \bdiagmat \moremath_diagonal_matrix:Vn {b} +\@@_new_matrix_shorth_doc_cmd:NNn \Bdiagmat \moremath_diagonal_matrix:Vn {B} +\@@_new_matrix_shorth_doc_cmd:NNn \vdiagmat \moremath_diagonal_matrix:Vn {v} +\@@_new_matrix_shorth_doc_cmd:NNn \Vdiagmat \moremath_diagonal_matrix:Vn {V} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for delimited diagonal matrices. +% } +% \end{macro} +% \begin{macro}{ +% \pantidiagmat, +% \bantidiagmat, +% \Bantidiagmat, +% \vantidiagmat, +% \Vantidiagmat, +% } +% Now for the anti-diagonal matrix commands. +% \begin{macrocode} +\@@_new_matrix_shorth_doc_cmd:NNn \pantidiagmat + \moremath_antidiagonal_matrix:Vn {p} +\@@_new_matrix_shorth_doc_cmd:NNn \bantidiagmat + \moremath_antidiagonal_matrix:Vn {b} +\@@_new_matrix_shorth_doc_cmd:NNn \Bantidiagmat + \moremath_antidiagonal_matrix:Vn {B} +\@@_new_matrix_shorth_doc_cmd:NNn \vantidiagmat + \moremath_antidiagonal_matrix:Vn {v} +\@@_new_matrix_shorth_doc_cmd:NNn \Vantidiagmat + \moremath_antidiagonal_matrix:Vn {V} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for delimited antidiagonal matrices. +% } +% \end{macro} +% +% \begin{macro}{ +% \psmalldiagmat, +% \bsmalldiagmat, +% \Bsmalldiagmat, +% \vsmalldiagmat, +% \Vsmalldiagmat, +% } +% We continue with the inline math versions based on the \env{smallmatrix*} +% environment. +% \begin{macrocode} +\@@_new_matrix_shorth_doc_cmd:NNn \psmalldiagmat + \moremath_diagonal_smallmatrix:Vn {p} +\@@_new_matrix_shorth_doc_cmd:NNn \bsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {b} +\@@_new_matrix_shorth_doc_cmd:NNn \Bsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {B} +\@@_new_matrix_shorth_doc_cmd:NNn \vsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {v} +\@@_new_matrix_shorth_doc_cmd:NNn \Vsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {V} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for delimited diagonal matrices suitable for inline math. +% } +% \end{macro} +% \begin{macro}{ +% \psmallantidiagmat, +% \bsmallantidiagmat, +% \Bsmallantidiagmat, +% \vsmallantidiagmat, +% \Vsmallantidiagmat, +% } +% We provide also anti-diagonal versions of the small matrices. +% \begin{macrocode} +\@@_new_matrix_shorth_doc_cmd:NNn \psmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {p} +\@@_new_matrix_shorth_doc_cmd:NNn \bsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {b} +\@@_new_matrix_shorth_doc_cmd:NNn \Bsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {B} +\@@_new_matrix_shorth_doc_cmd:NNn \vsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {v} +\@@_new_matrix_shorth_doc_cmd:NNn \Vsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {V} +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{ +% Added commands for delimited anti-diagonal matrices suitable for inline math. +% } +% \end{macro} +% +% \subsubsection{Identity Matrices} +% We also provide document level commands for producing an identity matrix. +% These commands are also guarded by the same variable as the other matrix commands +% (\cs{l_@@_predef_matrix_bool}). +% +% \begin{macro}{ +% \idmat, +% \smallidmat, +% } +% We provide two document level commands for producing the identiy matrix, +% one for inline math mode and one for display math mode. +% +% We start with the display math mode version. +% \begin{macrocode} +\cs_if_free:NTF \idmat +{ + \NewDocumentCommand \idmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_id_matrix:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \idmat FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {\idmat} +} +% \end{macrocode} +% Afterwards we continue with the inline math mode version. +% \begin{macrocode} +\cs_if_free:NTF \smallidmat +{ + \NewDocumentCommand \smallidmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_id_smallmatrix:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \smallidmat FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {\smallidmat} +} +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added \cs{idmat} and \cs{smallidmat} document level commands. +% } +% \end{macro} +% +% \paragraph{Identity Matrices with Pre-defined Delimiters} +% We also define shorthands for the commonly used delimiters around matrices, +% to avoid code duplication, we first declare a helper function for this. +% \begin{macro}{ +% \@@_new_id_matrix_doc_cmd:NNn +% } +% This function creates a new document level command for an identity matrix like +% command. +% It allows pre-setting \meta{kv~opts}. +% The function takes three arguments. +% \begin{arguments} +% \item The \meta{csname} of the document level command to define +% +% \item The \meta{csname} of the function to use +% +% This is indented to be one of \cs{moremath_id_matrix:n} or +% \cs{moremath_id_smallmatrix:n} +% +% \item \meta{kv~opts} to preset in the "moremath / matrix" namespace +% for this command +% +% This is meant to be used for pre-setting the key "delimiter". +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \@@_new_id_matrix_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + \tl_if_empty:nF {#3} + { + \keys_set:nn { moremath / matrix } {#3} + } + \tl_if_novalue:nF {##1} + { + \keys_set:nn { moremath / matrix } {##1} + } + #2 {##2} + \group_end: + } + }{ % \cs_if_free:NTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {#1} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{ +% \pidmat, +% \bidmat, +% \Bidmat, +% \vidmat, +% \Vidmat +% } +% We begin with the display math versions, +% starting with the version delimited by parenthesis, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \pidmat \moremath_id_matrix:n { delimiter = p } +% \end{macrocode} +% continue with the bracketed version, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \bidmat \moremath_id_matrix:n { delimiter = b } +% \end{macrocode} +% the version using braces, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \Bidmat \moremath_id_matrix:n { delimiter = B } +% \end{macrocode} +% single vertical lines, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \vidmat \moremath_id_matrix:n { delimiter = v } +% \end{macrocode} +% and finally double vertical lines. +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \Vidmat \moremath_id_matrix:n { delimiter = V } +% \end{macrocode} +% +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{ +% Added document level commands \cs{pidmat}, \cs{bidmat}, \cs{Bidmat}, +% \cs{vidmat}, and \cs{Vidmat}. +% } +% \end{macro} +% +% \begin{macro}{ +% \psmallidmat, +% \bsmallidmat, +% \Bsmallidmat, +% \vsmallidmat, +% \Vsmallidmat, +% } +% Now we also define shorthands for inline math mode. +% We start again defining the version using parenthesis, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \psmallidmat \moremath_id_smallmatrix:n + { delimiter = p } +% \end{macrocode} +% then brackets, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \bsmallidmat \moremath_id_smallmatrix:n + { delimiter = b } +% \end{macrocode} +% then braces, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \Bsmallidmat \moremath_id_smallmatrix:n + { delimiter = B } +% \end{macrocode} +% followed by single vertical lines, +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \vsmallidmat \moremath_id_smallmatrix:n + { delimiter = v } +% \end{macrocode} +% and finally double vertical lines. +% \begin{macrocode} +\@@_new_id_matrix_doc_cmd:NNn \Vsmallidmat \moremath_id_smallmatrix:n + { delimiter = V } +% \end{macrocode} +% \changes{v0.2.0}{\GetVersionDate{v0.2.0}}{% +% Added document level commands \cs{psmallidmat}, \cs{bsmallidmat}, +% \cs{Bsmallidmat}, \cs{vsmallidmat} and \cs{Vsmallidmat}. +% } +% \end{macro} +% +% \begin{macrocode} +}{ % \bool_if:nTF \l_@@_predef_matrix_bool FALSE BRANCH + \msg_info:nnnn {moremath} { load / disabling } { no-matrix } + { + (anti-)diagonal~matrix~commands + } +} % \bool_if:nTF \l_@@_predef_matrix_bool +% \end{macrocode} +% +% +% \section{Shorthand Macros for Absolute Value and Norm} +% \label{sec:impl-abs-shorthands} +% +% We first declare another warning message to inform the user of the case that, +% the \meta{csnames} are already taken. +% \begin{macrocode} +\msg_new:nnnn { moremath } { abs-shorth / csname-already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~declaration~of~paired~delimiter~\msg_line_context:.\\ + Use~package~option~'no-abs-shorthands'~to~disable~the~paired\\ + delimiter~shorthands. +}{ + The~control~sequence~'#1'~has~already~been\\ + defined~by~something~else.\\ + I~am~refusing~to~overwrite~its~existing~definition~and~instead~avoid\\ + declaring~a~paired~delimiter.\\ +} +% \end{macrocode} +% +% +% As with the other parts these macros may be conditionally disabled. +% \begin{macrocode} +\bool_if:NTF \l_@@_predef_abs_bool +{ +% \end{macrocode} +% \begin{macro}{\abs,\norm} +% These macros provide shorthands for \(\abs{\meta{content}}\) +% and \(\norm{\meta{content}}\). +% \begin{macrocode} +\cs_if_free:NTF \abs +{ + \DeclarePairedDelimiter \abs {\lvert} {\rvert} +}{ + % warn if the csname is taken + \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip } + {\abs} +} % \cs_if_free:NTF \abs + +\cs_if_free:NTF \norm +{ + \DeclarePairedDelimiter \norm {\lVert} {\rVert} +}{ + % warn if csname is already taken + \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip } + {\norm} +} % \cs_if_free:NTF +% \end{macrocode} +% \changes{v0.1.0}{\GetVersionDate{v0.1.0}}{% +% Added shorthands for absolute value and norm. +% } +% \end{macro} +% +% \begin{macrocode} +}{ + \msg_info:nnnn {moremath} {load / disabling} {no-abs-shorthands} + { + '\abs'~and~'\norm'~macros + } +} % End of the conditional +% \end{macrocode} +% +% \iffalse debug-switch +%\debug_off:n {all} +% \fi +% \begin{macrocode} +%</package> +% \end{macrocode} +% \end{implementation} +% +% \section*{Copyright and License} +% \addcontentsline{toc}{section}{Copyright and License} +% \label{sec:license} +% +% The following copyright notice applies to the \pkg{moremath} package: +% +% \begin{quote} +% Copyright \textcopyright{} 2024 Marcel Ilg +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% \url{https://www.latex-project.org/lppl.txt} +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status \enquote{maintained}. +% +% The Current Maintainer of this work is Marcel Ilg. +% +% This work consists of the files listed in \file{MANIFEST.md}. +% \end{quote} +% +% \noindent The file \file{MANIFEST.md} has to be distributed together with the +% package. +% +% +% \printbibliography[heading=bibintoc] +% \PrintChanges +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/moremath/moremath.ins b/Master/texmf-dist/source/latex/moremath/moremath.ins new file mode 100644 index 00000000000..f04f2b04b20 --- /dev/null +++ b/Master/texmf-dist/source/latex/moremath/moremath.ins @@ -0,0 +1,66 @@ +%% +%% Copyright (C) 2024 Marcel Ilg +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% +%% https://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status ‘maintained’. +%% +%% The Current Maintainer of this work is Marcel Ilg. +%% +%% This work consists of the files listed in MANIFEST.md. + +\input docstrip + +\usedir{tex/latex/moremath} + +\keepsilent + +\preamble + +This is a generated file. + + +Copyright (C) 2024 Marcel Ilg + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3 +of this license or (at your option) any later version. +The latest version of this license is in + + https://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status ‘maintained’. + +The Current Maintainer of this work is Marcel Ilg. + +This work consists of the files listed in MANIFEST.md. + +\endpreamble + +\generate{\file{moremath.sty}{\from{moremath.dtx}{package}}} + +\obeyspaces +\Msg{***************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following file into a} +\Msg{* directory searched by TeX:} +\Msg{*} +\Msg{* moremath.sty} +\Msg{*} +\Msg{* To produce the documentation run the file moremath.dtx through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{***************************************************************************} +\endbatchfile |