%
% \iffalse meta-comment
%
% mathfixs.dtx Copyright (C) 2018-2026 Niklas Beisert
%
% 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.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Niklas Beisert.
%
% This work consists of the files mathfixs.dtx and mathfixs.ins
% and the derived files mathfixs.sty and mathfixs-samp.tex.
%
%<package|sample>\NeedsTeXFormat{LaTeX2e}[1996-12-01]
%<package>\ProvidesPackage{mathfixs}[2026-04-08 v1.2.1 various fixes for math mode]
%<sample>\ProvidesFile{mathfixs-samp.tex}[2026-04-08 v1.2.1 sample for mathfixs]
%<source>\ProvidesFile{mathfixs-src.tex}[2026-04-08 v1.2.1 mathfixs source code documentation]
%<manual>\ProvidesFile{mathfixs.tex}[2026-04-08 v1.2.1 mathfixs reference manual]
%<*main|manual|source>
\def\thepkg/{mathfixs}\def\thedate/{2026-04-08}\def\theversion/{v1.2.1}
\def\thecopyright/{2018\texorpdfstring{--}{-}2026 Niklas Beisert}
%<*main>
\ProvidesFile{\thepkg/.dtx}[\thedate/ \theversion/ \thepkg/ package main file]
%</main>
\PassOptionsToClass{10pt,a4paper}{article}
\documentclass{ltxdoc}

\usepackage[margin=35mm]{geometry}
\usepackage[hyperindex=false]{hyperref}
\usepackage{hyperxmp}
\usepackage[usenames]{color}
\usepackage{longtable}

\usepackage{amssymb,bbm,dsfont}
\IfFileExists{bbold.sty}{}{\GenericWarning{please install package `bbold'}}
\DeclareMathAlphabet{\mathbbold}{U}{bbold}{m}{n}
\DeclareMathAlphabet{\mathdss}{U}{dsss}{m}{n}
\IfFileExists{upgreek.sty}{\usepackage[Symbolsmallscale]{upgreek}}{%
  \def\uppi{\mathrm{\pi}}}

%<*main>
\title{The \markpkg{\thepkg/} Package}
\hypersetup{pdftitle={The \thepkg/ Package}}
\hypersetup{pdfsubject={Documentation for the LaTeX2e Package \thepkg/}}
%</main>
%<manual>\title{The \markpkg{\thepkg/} Package\\Reference Manual}
%<manual>\hypersetup{pdftitle={The \thepkg/ Package -- Reference Manual}}
%<manual>\hypersetup{pdfsubject={Reference Manual for the LaTeX2e Package \thepkg/}}
%<source>\title{The \markpkg{\thepkg/} Package\\Source Code Documentation}
%<source>\hypersetup{pdftitle={The \thepkg/ Package -- Source Code Documentation}}
%<source>\hypersetup{pdfsubject={Documented Source for the LaTeX2e Package \thepkg/}}
\author{Niklas Beisert\\[2ex]
  Institut f\"ur Theoretische Physik\\
  Eidgen\"ossische Technische Hochschule Z\"urich\\
  Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex]
  \href{mailto:nbeisert@itp.phys.ethz.ch}
  {\texttt{nbeisert@itp.phys.ethz.ch}}}
\hypersetup{pdfauthor={Niklas Beisert}}
\date{\theversion/: \markdate{\thedate/}\\[1ex]
\url{https://ctan.org/pkg/\thepkg/}\\[0.5ex]
\url{https://github.com/nbeisert/latex-pkg-nb}}

\hypersetup{pdflang={en-UK}}
\hypersetup{pdfurl={https://ctan.org/pkg/\thepkg/}}
\hypersetup{pdfcopyright={Copyright \thecopyright/.
  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.}}
\hypersetup{pdflicenseurl={https://www.latex-project.org/lppl.txt}}
\hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K,
  Wolfgang-Pauli-Strasse 27}}
\hypersetup{pdfcontactpostcode={8093}}
\hypersetup{pdfcontactcity={Zurich}}
\hypersetup{pdfcontactcountry={Switzerland}}
\hypersetup{pdfcontactemail={nbeisert@itp.phys.ethz.ch}}
\hypersetup{pdfcontacturl={https://people.phys.ethz.ch/\xmptilde nbeisert/}}

\hypersetup{keeppdfinfo=true}
\hypersetup{pdfsource={}}
\AddToHook{begindocument/before}{\hypersetup{colorlinks=false}}
\hypersetup{urlbordercolor={.5 1 1}}
\hypersetup{linkbordercolor={1 .7 .7}}
\AddToHook{begindocument/before}{\hypersetup{pdfstartview=FitH}}

\parskip1ex
\parindent0pt
\edef\itemize{\unexpanded\expandafter{\itemize}\parskip0pt}

\newcommand{\markpkg}[1]{\textsf{#1}}
\newcommand{\markdate}[1]{\textsf{#1}}
\newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}
\newcommand{\ctanref}[2]{\href{https://ctan.org/#1}{#2}}
\newcommand{\ctanpkg}[1]{\ctanref{pkg/#1}{\markpkg{#1}}}

\def\verbbar{\texttt{\char"7C}}
\def\verbpkg{\texttt{\thepkg/}}
\def\thepkgctan/{\ctanpkg{\thepkg/}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle

\begin{abstract}\noindent
\markpkg{mathfixs} is a \LaTeXe{} package
to fix some odd behaviour in math mode such as
spacing around fractions and roots,
math symbols within bold text
as well as
capital Greek letters.
It also adds some related macros.
\end{abstract}

\begingroup
\parskip0ex
\tableofcontents
\endgroup


%<*main|manual>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}

Undoubtedly, \TeX{} and \LaTeX{} are excellent at
producing visually appealing mathematical expressions.
However, some commonly used macros produce output which
sometimes appears unbalanced under certain conditions.
Depending on the level of sophistication, such artefacts
are typically either ignored or fixed by some manual adjustments
wherever they appear.
This package addresses some of the issues
encountered commonly (by the author),
and provides fixes or additional macros to handle such situations.
At present the package is mainly concerned with:
%
\begin{itemize}
\item
spacing of fractions, roots and symbols
\item
alternative versions of fractions
\item
representation of (capital) Greek letters
\item
math symbols within bold text
\end{itemize}
%
Additional fixes and features may be added
to the package in later versions.
All of these features can be selected and customised
to some extent to accommodate for the desired style.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Usage}

To use the package \ctanpkg{mathfixs} add the command
%
\begin{center}
|\usepackage{mathfixs}|
\end{center}
%
to the preamble of your \LaTeX{} document.
Furthermore you must select the desired features explicitly
as described below, otherwise the package will have no effect.
This is to avoid having to agree on
all the provided features and to allow for forward compatibility:
the package should remain open for future extensions
which may modify the default behaviour in an unintended fashion.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Package Features}

\DescribeMacro{\ProvideMathFix}
Features and options can be selected by the commands:
%
\begin{longtable}{rl}
&|\usepackage[|\textit{opts}|]{mathfixs}|
\\
or&|\PassOptionsToPackage{|\textit{opts}|}{mathfixs}|
\\
or&|\ProvideMathFix{|\textit{opts}|}|
\end{longtable}
%
|\PassOptionsToPackage| must be used before |\usepackage|;
|\ProvideMathFix| must be used afterwards.
Note that if |\ProvideMathFix| is invoked within a block,
its definitions are valid only locally within the block.
\textit{opts} is a comma-separated list of features or options.
The available features and options are described below.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Fractions}

The package offers some improvements for the spacing of fractions
as well as definitions to typeset small rational numbers.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{frac}.}
\DescribeMacro{frac}
%
In many situations, \LaTeX{} typesets fractions with an
insufficient amount of surrounding space.
For example, the space between two consecutive fractions
almost make them appear as a single one:
%
\begin{center}
|x\frac{a+b}{c+d}\frac{e}{f}.|
\quad$\longrightarrow$\quad
$\displaystyle x\frac{a+b}{c+d}\frac{e}{f}.$
\end{center}
%
Also the space towards other symbols and punctuation marks
arguably is too small.
To make expressions more legible, sequences of fractions
are often coded with various custom spaces
(`|\,|', `|\:|', `|\;|', `|\ |', `|~|', etc.)
inserted, e.g.
%
\begin{center}
|x\,\frac{a+b}{c+d}\;\frac{e}{f}\ .|
\quad$\longrightarrow$\quad
$\displaystyle x\,\frac{a+b}{c+d}\;\frac{e}{f}\ .$
\end{center}
%
This looks better, but requires a lot of intervention
and depends very much on personal conventions.

The underlying technical reason for the shortcoming in spacing
around fractions
is that the latter are defined
to have the math class of ordinary objects (|\mathord|)
which results in no surrounding space.
A simple resolution is to assign the math class
of inner objects (|\mathinner|) to fractions
as described in the \markpkg{\TeX{}book}, e.g.
%
\begin{center}
|x\mathinner{\frac{a+b}{c+d}}\mathinner{\frac{e}{f}}.|
\end{center}
%
Inner objects behave almost like ordinary objects,
but some space is added between them and
other inner or ordinary objects, e.g.:
%
\[
x\mathinner{\frac{a+b}{c+d}}\mathinner{\frac{e}{f}}.
\]
%
Importantly, no space is added between inner objects
and the ends of the math expression or subexpression in parentheses.
Also, no space is generated
in the script styles (|\|[|script|]|scriptstyle|).

\DescribeMacro{\frac}
The feature |frac| redefines the macro |\frac|
such that all fractions have the inner math class
producing some surrounding space in selected situations, e.g.:
%
\begin{center}
|x\frac{a+b}{c+d}\frac{e}{f}.|
\quad$\longrightarrow$\quad
$\displaystyle x\mathinner{\frac{a+b}{c+d}}\mathinner{\frac{e}{f}}.$
\end{center}
%
This makes adding custom space around fractions
unnecessary in almost all situations,
and leads to a rather uniform appearance
without further adjustments.

\DescribeMacro{\genfrac}
\DescribeMacro{\dfrac}
\DescribeMacro{\tfrac}
The macro |\genfrac| of the package \ctanpkg{amsmath}
is modified suitably when the latter is loaded.
This also affects the macros |\dfrac| and |\tfrac| for fractions
in styles |\displaystyle| and |\textstyle|, respectively.
For |\genfrac| fractions with delimiters,
the inner math class is not applied
because the default math class is appropriate.

Note that when the |frac| feature is used,
spaces around fractions can be eliminated by using:
%
\begin{center}
|\mathord{\frac{|\textit{num}|}{|\textit{denom}|}}|
\end{center}
%
or simply (a block enclosed by braces |{|\ldots|}|
is considered an object with ordinary math class):
%
\begin{center}
|{\frac{|\textit{num}|}{|\textit{denom}|}}|
\end{center}
%
Furthermore, note that unlike the original macro |\frac|,
the redefined macro must be enclosed in a block
when passed as an argument. For example, |x^\frac{1}{2}|
produces an error and must be written as |x^{\frac{1}{2}}|.

\DescribeMacro{fracclass}
\DescribeMacro{fracdelimclass}
The option |fracclass=|\textit{class}
can be used to customise the math class of fractions
to any desired command \textit{class} accepting
the expression for the fraction as its single parameter.
Likewise, the option |fracdelimclass=|\textit{class}
customises the math class of fractions with delimiters
generated by |\genfrac| such as |\|[|d|\verbbar|t|]|binom|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{rfrac}.}
\DescribeMacro{rfrac}
%
Rational numbers as coefficients to
some simple terms often stick out visually
from displayed math expressions, e.g.:
%
\[
\frac{1}{2}x^2 + \frac{1}{6} y^3 + \frac{1}{4} x^2 y^2
\]
%
Arguably, typesetting such fractions in text style
has a more uniform appearance:
%
\[
{\textstyle\frac{1}{2}}x^2
+ {\textstyle\frac{1}{6}} y^3
+ {\textstyle\frac{1}{4}} x^2 y^2
\]
%

\DescribeMacro{\rfrac}
The feature |rfrac| defines the macro |\rfrac|
to typeset a fraction in text style or smaller.
It is similar to |\tfrac| of the package \ctanpkg{amsmath},
but it will not choose text style when in the script styles
and it will not produce surrounding space
when the feature |frac| is used.
The optional argument |rfrac={\|\textit{cmd}|}| specifies
an alternative command name |\|\textit{cmd} for |\rfrac|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{vfrac}.}
\DescribeMacro{vfrac}
\DescribeMacro{\vfrac}
%
Common or vulgar fractions such as $^1\!/\!_2$
can be typeset in a simple fashion
as a superscript numerator followed by a slash
and a subscript denominator.
The spacing around the slash should be reduced
to join the expression.
The package provides this representation
as the feature |vfrac| defining the macro |\vfrac|.
It is similar to |\nicefrac| of the package \ctanpkg{nicefrac}
or the more advanced implementation |\sfrac| of the package \ctanpkg{xfrac}.
As vulgar fractions are often (mainly) used within plain text,
the macro |\vfrac| also works in text mode.
The optional argument |vfrac={\|\textit{cmd}|}| specifies
an alternative command name |\|\textit{cmd} for |\vfrac|.

\DescribeMacro{vfracclass}
\DescribeMacro{vfracskippre}
\DescribeMacro{vfracskippost}
The option |vfracclass=|\textit{class}
can be used to customise the math class of the vulgar fraction.
The options |vfracskippre=|\textit{muskip}
and |vfracskippost=|\textit{muskip}
defines the (negative) skip around the slash
(must be given in math units |mu|).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Roots}

The \TeX{} implementations of radicals, mostly those with exponents,
have some uneven spacing, e.g.:
%
\[
y\sqrt{x}z,\qquad
y\sqrt[]{x}z,\qquad
y\sqrt[i]{x}z,\qquad
y\sqrt[n]{x}z,\qquad
y\sqrt[3]{x}z,\qquad
y\sqrt[123]{x}z
\]
%
They work best if no exponent is specified
or if the exponent is a single numerical digit.
The spacing is slightly different if the exponent is $n$ or $i$.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{root}.}
\DescribeMacro{root}
\DescribeMacro{\sqrt}
\DescribeMacro{\root}
%
The package provides an alternative mechanism for the
placement of the exponent next to the radical.
It first measures the extents of the exponent
and the radical sign and then places them accordingly.
It also adds some space at the end of the radicand.
The refined definition produces the following representation
without further spacing adjustments
%
\[
y\sqrt{x\mskip2mu}z,\qquad
y\sqrt{x\mskip2mu}z,\qquad
y\mskip5mu
  \sqrt[{\makebox[0pt][r]{$\scriptscriptstyle i$}}]{x\mskip2mu}z,\qquad
y\mskip5mu
  \sqrt[{\makebox[0pt][r]{$\scriptscriptstyle n$}}]{x\mskip2mu}z,\qquad
y\mskip5mu
  \sqrt[{\makebox[0pt][r]{$\scriptscriptstyle 3$}}]{x\mskip2mu}z,\qquad
y\mskip-5mu
  \sqrt[123]{x\mskip2mu}z
\]
%

\DescribeMacro{rootclass}
\DescribeMacro{rootskipend}
\DescribeMacro{rootskippre}
\DescribeMacro{rootskippost}
The option |rootclass=|\textit{class}
can be used to customise the math class of the root.
The option |rootskipend=|\textit{muskip}
defines the additional skip at the end of the radicand
within the radical (must be given in math units |mu|).
The options |rootskippre=|\textit{muskip}
and |rootskippost=|\textit{muskip}
define additional skip around the radical.

\DescribeMacro{rootclose}
The option |rootclose| adds a closing mark
to the end of the top bar of radicals:
%
\[
\setbox0\hbox{$\sqrt{a\mskip2mu}$}\copy0\lower\fontdimen8\textfont3
\hbox{\vrule width\fontdimen8\textfont3 height \ht0 depth -0.8\ht0}
\]
%
The optional argument |rootclose=|\textit{height}
specifies the starting height with a default value of $0.8$.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Space Representing Multiplication Signs}

Mathematical expressions regularly omit explicit multiplication signs
between factors, e.g.\ $x^2yz$. All is well unless
some of the factors are compound expressions such as
$\Delta x$ or differentials $dx$ (or $\mathrm{d}x$)
where additional space is typically inserted by
commands like `|\,|'.

A simple method to declare (or define) compound expressions
with a suitable amount of surrounding space
is to encapsulate them in a |\mathinner| block, e.g.
%
\begin{center}
|12c\mathinner{\Delta x}\mathinner{\Delta y}z|
\quad$\longrightarrow$\quad
$12c\mathinner{\Delta x}\mathinner{\Delta y}$
\\
|\int x\mathinner{dx}|
\quad$\longrightarrow$\quad
$\displaystyle\int x\mathinner{dx}$
\end{center}
%
Importantly, |\mathinner| will not add any space
at the ends of an expression
(or a subexpression in parentheses).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{multskip}.}
\DescribeMacro{multskip}
\DescribeMacro{\.}
%
Furthermore, the package provides the feature |multskip|
to encode a space representing an omitted multiplication sign
by the short command `|\.|', e.g.:
%
\begin{center}
|12c\.\Delta x\.\Delta y\.z|
\qquad or\qquad
|\int x\.dx|
\end{center}
%
The macro `|\.|' produces some amount of space in math mode
(while retaining its original definition as an accent in text mode)
and by default it is equivalent to `|\,|'.
However, the macro `|\.|' is intended to describe this space unambiguously
as a multiplication sign.
In particular, the amount of space can be configured by
the option |multskip=|\textit{muskip} (given in math units |mu|),
or the command could be customised further
to a visually different representation.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Greek Letters}

\TeX{} defines Greek letters in math mode somewhat differently
from Latin letters. The following two features redefine
to the standard \TeX{} Greek letters.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{greekcaps}.}
\DescribeMacro{greekcaps}
%
Capital Greek letters are declared as operators instead of plain letters,
and therefore they are typeset in an upright shape.
To typeset them in italic shape
(as all the other letters representing variables)
one can use |\mathnormal|,
but this may be tedious if most capital Greek letters in a document
actually represent variables.

The feature |greekcaps| redefines the 11 capital Greek letters
|\Gamma|, |\Delta|, |\Theta|, |\Lambda|, |\Xi|, |\Pi|,
|\Sigma|, |\Upsilon|, |\Phi|, |\Psi| and |\Omega|
provided by \TeX{} to have a default italic shape.
Upright capital Greek letters remain accessible
by switching to the upright shape using |\mathrm|
or by declaring them as part of an operator,
e.g.\ |\operatorname| or |\DeclareMathOperator|
(package \ctanpkg{amsopt} within \ctanpkg{amsmath}).

The optional argument |greekcaps=|\textit{pre} will
instead define the macros |\|\textit{pre}|Gamma|, etc.,
and keep the original definitions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{greeklower}.}
\DescribeMacro{greeklower}
%
Lowercase Greek letters are fixed to the default math italic
font because (unfortunately) no upright counterparts exist
in the Compute Modern family of fonts.

The feature |greeklower| redefines the 23 lowercase Greek letters
|\alpha|, \ldots, |\omega|
as well as their 6 variants
|\varepsilon|, |\vartheta|, |\varpi|, |\varphi|, |\varrho| and |\varsigma|
defined by \TeX{}
to be elements of the regular math alphabet.
This allows them to be typeset in different font series
such as |\mathbold| described below.
However, when trying to cast them in upright shape
they will be typeset as altogether different symbols,
e.g.\ |\mathrm{\alpha}| becomes the ligature `ff'
which occupies the same slot in the \TeX{} font encodings OML vs.\ OT1.
Hence, some caution is needed when this feature is used.
Note that math font redefinitions may clash with this feature.

The optional argument |greeklower=|\textit{pre} will
instead define the macros |\|\textit{pre}|alpha|, etc.,
and keep the original definitions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Bold Fonts}

Combining bold fonts and math mode in \LaTeX\ sometimes
yields unintuitive results.
The following two features assist
the intuitive use of bold fonts in math mode.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{autobold}.}
\DescribeMacro{autobold}
%
Sectioning commands such as |\chapter|, |\section|, |\paragraph|,
etc., but also |\maketitle| often change the font series to bold.
However, any math symbols contained in the titles
are typeset in the regular, non-bold series by default leading to
a non-uniform appearance or calling for further manual adjustments
using |\boldmath|.
One might argue that it is bad practice to have math symbols in titles
in the first place,
but this point of view perhaps does not apply universally.

\DescribeMacro{\bfseries}
\DescribeMacro{\mdseries}
The feature |autobold| overwrites the \LaTeX{} font commands
|\bfseries|, |\mdseries| as well as |\normalfont|
to automatically switch the math fonts to their bold version.
Derived commands such as |\section|, etc., will also
switch the math fonts to the bold series.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{mathbold}.}
\DescribeMacro{mathbold}
\DescribeMacro{\mathbold}
%
The feature |mathbold| defines a bold italic math font |\mathbold|.
To typeset bold italic letters simply use |\mathbold{abc}|.
To make this work for lowercase Greek letters as well,
the feature |greeklower| must be activated.
The optional argument |mathbold={\|\textit{cmd}|}| specifies
an alternative command name |\|\textit{cmd} for |\mathbold|,
e.g.\ |mathbold={\mathbit}|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Mathematical Functions and Operators}

\LaTeX\ defines many basic standard mathematical functions and operators,
see below.
The following features fill some gaps in the collection of functions
and they provide worthwhile alternative representations for some
functions and operators. All of the following features require
that the package \ctanpkg{amsopn} (part of \ctanpkg{amsmath})
is loaded \emph{before} \ctanpkg{mathfixs}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Native \LaTeX{} Functions and Operators.}

As a reference, \LaTeX{} supplies the following functions and operators.
All of them are overwritten by \ctanpkg{amsopn} within \ctanpkg{amsmath}.

Exponential and logarithm functions:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\exp| & $\exp$ & exponential function \\
|\log| & $\log$ & logarithm function \\
|\lg| & $\lg$ & common logarithm function \\
|\ln| & $\ln$ & natural logarithm function \\
\end{longtable}

Trigonometric functions:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\sin| & $\sin$ & sine function \\
|\cos| & $\cos$ & cosine function \\
|\tan| & $\tan$ & tangent function \\
|\cot| & $\cot$ & cotangent function \\
|\sec| & $\sec$ & secant function \\
|\csc| & $\csc$ & cosecant function \\
|\arcsin| & $\arcsin$ & inverse sine function \\
|\arccos| & $\arccos$ & inverse cosine function \\
|\arctan| & $\arctan$ & inverse tangent function \\
\end{longtable}

Hyperbolic functions:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\sinh| & $\sinh$ & hyperbolic sine function \\
|\cosh| & $\cosh$ & hyperbolic cosine function \\
|\tanh| & $\tanh$ & hyperbolic tangent function \\
|\coth| & $\coth$ & hyperbolic cotangent function \\
\end{longtable}

Extremal values:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\max| & $\max$ & maximum of a set \\
|\min| & $\min$ & minimum of a set \\
|\sup| & $\sup$ & supremum of a set \\
|\inf| & $\inf$ & infimum of a set \\
\end{longtable}

Limits:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\lim| & $\lim$ & limit operator \\
|\limsup| & $\limsup$ & limit superior operator \\
|\liminf| & $\liminf$ & limit inferior operator \\
|\injlim| & inj\,lim & ? (\ctanpkg{amsopn}/\ctanpkg{amsmath} only) \\
|\projlim| & proj\,lim & ? (\ctanpkg{amsopn}/\ctanpkg{amsmath} only) \\
\end{longtable}

Assorted functions and operators:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\arg| & $\arg$ & argument of a complex number \\
|\det| & $\det$ & determinant of a matrix \\
|\ker| & $\ker$ & kernel of a map \\
|\dim| & $\dim$ & dimension of \ldots \\
|\deg| & $\deg$ & degree of \ldots \\
|\gcd| & $\gcd$ & greatest common divisor \\
|\hom| & $\hom$ & ? \\
|\Pr| & $\Pr$ & ? \\
\end{longtable}

Modulo statements:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\bmod| & $X \bmod Y$ & modulo statement \\
|\pmod| & $X \pmod Y$ & modulo statement in parentheses \\
|\mod| & $X\mkern18mu \bmod Y$ & modulo statement with space
(\ctanpkg{amsmath} only) \\
\end{longtable}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{genop}.}
\DescribeMacro{genop}
\DescribeMacro{...}
%
The package defines several
additional mathematical functions, operators and symbols
which are not included in the \LaTeX\ macro library.
These may be provided by other packages as well,
or they can easily be defined by |\DeclareMathOperator|
or used by |\operatorname|.
Nevertheless, it is convenient to have these objects declared
by a simple switch rather than by issuing a formal \LaTeX{} clause.

The additional macros are grouped by category
and each category is included as a feature.
The first category describes
assorted mathematical functions, operators and symbols.
Further categories are provided in the following paragraphs.

In order to evade clashes, the package allows to
individually select the desired definitions
from the assorted section
with optionally defined macro names:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|sgn| & |\sgn| & sgn & signum function \\
|res| & |\res| & res & residue operator \\
|lcm| & |\lcm| & lcm & least common multiple \\
|span| & |\Span| & span & span \\
|diag| & |\diag| & diag & diagonal matrix \\
|spec| & |\spec| & spec & spectrum \\
|const| & |\const| & const & anything constant \\
\hline
|genop| & & & all of the above
\end{longtable}
%
The following two-letter operators
and some additional ones
are not included in the above class
and must be implemented individually:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|id| & |\id| & id & identity map \\
|tr| & |\tr| & tr & trace \\
|ad| & |\ad| & ad & adjoint (action) \\
|Vol| & |\Vol| & Vol & Volume \\
\end{longtable}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{reim}.}
\DescribeMacro{reim}
\DescribeMacro{\Re}
\DescribeMacro{\Im}
%
\LaTeX{} assigns the symbols `$\Re$' and `$\Im$' to projectors
to the real and imaginary parts of complex numbers.
Another established representation for these projectors is given by
`Re' and `Im'.
The feature |reim| overwrites the predefined macros |\Re| and |\Im|
with a textual representation:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\Re| & Re & real part of a complex number \\
|\Im| & Im & imaginary part of a complex number \\
\end{longtable}
%
The optional argument |reim={\|\textit{cmdr}|\|\textit{cmdi}|}| specifies
alternative command names |\|\textit{cmdr} and |\|\textit{cmdi}
for |\Re| and |\Im|.
The feature |reim*| restores the predefined representation for |\Re| and |\Im|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{trig}.}
\DescribeMacro{trig}
\DescribeMacro{\arccot}
\DescribeMacro{\arcsec}
\DescribeMacro{\arccsc}
%
\LaTeX{} defines most trigonometric functions and their inverses
like $\sin$, $\cos$ and $\arctan$, but three of their inverses are omitted.
The feature |trig| supplies the remaining
three inverse trigonometric functions:
\begin{longtable}{lll}
macro & output & description \\
\hline
|\arccot| & arccot & inverse cotangent function \\
|\arcsec| & arcsec & inverse secant function \\
|\arccsc| & arccsc & inverse cosecant function \\
\end{longtable}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{hyp}.}
\DescribeMacro{hyp}
\DescribeMacro{\sech}
\DescribeMacro{\csch}
\DescribeMacro{\ar...h}
%
\LaTeX{} defines four hyperbolic functions $\sinh$, $\cosh$ and $\tanh$,
but two of them and all inverses are omitted.
The feature |hyp| supplies the remaining two hyperbolic functions
along with all inverse hypberbolic functions:
\begin{longtable}{lll}
macro & output & description \\
\hline
|\sech| & sech & hyperbolic secant function \\
|\csch| & csch & hyperbolic cosecant function \\
|\arsinh| & arsinh & inverse hyperbolic sine function \\
|\arcosh| & arcosh & inverse hyperbolic cosine function \\
|\artanh| & artanh & inverse hyperbolic tangent function \\
|\arcoth| & arcoth & inverse hyperbolic cotangent function \\
|\arsech| & arsech & inverse hyperbolic secant function \\
|\arcsch| & arcsch & inverse hyperbolic cosecant function \\
\end{longtable}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{mapchar}.}
\DescribeMacro{mapchar}
%
The feature |mapchar| supplies further characteristics of maps:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\dom| & dom & domain \\
|\codom| & codom & codomain \\
|\supp| & supp & support \\
|\im| & im & image \\
|\coker| & coker & cokernel \\
|\rank| & rank & rank \\
\end{longtable}
%
The optional argument |mapchar={\|\textit{cmdim}|}| specifies
an alternative command name |\|\textit{cmdim} for |\im|
which has only two letters and might easily clash with other definitions.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{mapclass}.}
\DescribeMacro{mapclass}
%
The feature |mapclass| supplies symbols for the sets of
homomorphisms, endomorphisms, isomorphisms and automorphisms
as classes/categories of structure-preserving maps:
%
\begin{longtable}{lll}
macro & output & description \\
\hline
|\Hom| & Hom & homomorphisms \\
|\End| & End & endomorphisms \\
|\Isom| & Isom & isomorphisms \\
|\Aut| & Aut & automorphisms
\end{longtable}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Feature \texttt{vecdiff}.}
\DescribeMacro{vecdiff}
\DescribeMacro{vecrot}
%
The feature |vecdiff| supplies the three common differential operators
gradient, divergence and curl for vectors:
%
\begin{longtable}{llll}
macro & output & description \\
\hline
|\grad| & grad & gradient \\
|\div| & div & divergence \\
|\curl| & curl & curl \\
|\curl| & rot & curl (alternative form using |vecdiff*| or |vecrot|) \\
\end{longtable}
%
The feature |vecrot|[|={\|\textit{cmd}|}|]
supplies the alternative form `rot' for curl/rotor on top of |\curl|
with the option to specify an alternative command name.
The feature |lapl|, see below, supplies the Laplace operator.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Particular Symbols}

The package provides a couple of standard mathematical symbols.
Of course, users can be trusted to define these symbols themselves
or, more likely, use them straight away.
Nevertheless, here we go \ldots

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Mathematical Constants.}
\DescribeMacro{econst}
\DescribeMacro{iunit}
\DescribeMacro{piconst}
\DescribeMacro{unitel}
%
Three of the most relevant mathematical constants are Euler's number $e$,
the imaginary unit $i$ and the circle's constant $\pi$
(with the relation $e^{i\pi}=-1$).
The unit element of some algebraic structure similarly deserves mention
as it could be typeset in various forms.
The package provides macros for these
with diverse representations:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|econst| & |\econst| & e & Euler's number (upright) \\
|econst*| & & $e$ & \quad (math italic) \\
|iunit| & |\iunit|   & i & imaginary unit (upright) \\
|iunit*| & & $i$ & \quad (math italic) \\
|iunit*nb| & & $\mathring{\imath}$ & \quad  (NB's silly circle version) \\
|piconst| & |\piconst| & $\uppi$ & circle constant $\pi$
                         (upright, if only \ldots) \\
|piconst*| & & $\pi$ & \quad (math italic) \\
|unitel1| & |\unitel| & $\mathds{1}$ & unit element (doublestroke `1')\\
|unitel1*| & & $1$ & \quad (plain `1') \\
|unitel|\textit{var} &  &  & \quad (variants, see table below) \\
\end{longtable}
%
Each macro and representation is provided as an individual feature
\textit{feature}[|={\|\textit{cmd}|}|]
which offers the option to customise the macro name to |\|\textit{cmd}
(or use several representations side-by-side).
The following table lists variants for the unit element representation.
%
\begin{longtable}{l@{\hspace{2em}}c@{\hspace{0.5em}}l@%
  {\hspace{2em}}c@{\hspace{0.5em}}l@{\hspace{2em}}c@{\hspace{0.5em}}l}
& \multicolumn{2}{l}{output/\textit{var}}
& \multicolumn{2}{l}{output/\textit{var}}
& \multicolumn{2}{l}{output/\textit{var}}
\\\hline
\markpkg{dsfont} `$\mathds{1}$' &
$\mathds{1}$ & |1ds| (default) &
$\mathds{1}$ & |1dsr| (serif) &
$\mathdss{1}$ & |1dss| (sans)
\\
\markpkg{bbm} `$\mathbbm{1}$' &
$\mathbbm{1}$ & |1bbm| (serif) &
$\mathbbmss{1}$ & |1bbmss| (sans) &
$\mathbbmtt{1}$ & |1bbmtt| (typewriter)
\\
\markpkg{bbold} `$\mathbbold{1}$' &
$\mathbbold{1}$ & |1bbold| (sans)
\\
bold `1' &
$\mathbf{1}$ & |1bf| (extended) &
\def\bfdefault{b}\textbf{1} & |1bfb| (narrower) &
\def\bfdefault{bx}\textbf{1} & |1bfbx| (extended)
\\
letter `e' &
$\mathrm{e}$ & |e| &
$e$ & |e*|
\\
letter `E' &
$\mathrm{E}$ & |E| &
$E$ & |E*|
\\
`I' / `id' &
$\mathrm{I}$ & |I| &
$I$ & |I*| &
id & |id|
\end{longtable}
%
The doublestroke/blackboard bold representations
require installation of the further packages
\markpkg{dsfont}/\ctanpkg{doublestroke},
\ctanpkg{bbm}/\ctanpkg{bbm-macros} and/or \ctanpkg{bbold}.
Inclusion of the packages in your document is not required,
as \ctanpkg{mathfixs} will try to include the fonts anyway.
The default form |unitel1| will pick the first available form
from the above packages and resort to the bold form otherwise.

\DescribeMacro{econstclass}
As Euler's number is commonly used within exponentiation
which looks dense in compound expressions
(e.g.\ $2e^{\sin x}F$),
|\econst| is defined as |\mathinner|
which adds some space around the exponentiation in such a situation
(e.g.\ $2\mathinner{e}^{\sin x}F$).
Use |{\econst}| if such spacing is undesired.
The option |econstclass=|\textit{class}
can be used to customise the math class of |\econst|.

An upright version of |\pi| needs to be supplied
for the feature |piconst| to work properly.
If the macro |\uppi| from the package \ctanpkg{upgreek}
in the bundle \ctanpkg{was} is available
at the time of loading, it will be used.
Otherwise an upright |\pi| can be supplied by package \ctanpkg{unicode-math}.
Note that the feature |piconst| (without |*|) may interfere
with the feature |greeklower|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Derivative Symbols.}
\DescribeMacro{der}
\DescribeMacro{diff}
%
The package provides some assorted elementary symbols and compounds:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|der| & |\der| & d & derivative symbol (upright) \\
|der*| & |\der| & $d$ & derivative symbol (math italic) \\
|diff| & |\diff{|$x$|}| & d$x$ & coordinate differential (upright) \\
|diff*| & |\diff{|$x$|}| & $dx$ & coordinate differential (math italic) \\
\end{longtable}
%
Each macro and representation is provided as an individual feature
\textit{feature}[|={\|\textit{cmd}|}|]
which offers the option to customise the macro name to |\|\textit{cmd}.

The coordinate differential |\diff| is meant to be used
within integrals and as a differential form,
and it can be used in the denominator of differentiation expressions.
In all of these, it is understood as a compound which should be
separated from surrounding symbols.
Therefore |\diff{|$x$|}| is declared as |\mathinner|
which adds spacing where needed.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Conjugation Operations.}
\DescribeMacro{trans}
\DescribeMacro{hconj}
\DescribeMacro{conj}
%
The package provides macros for the matrix and vector operations
transposition, hermitian conjugation, complex conjugation and dualisation
in various representations:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|trans|   & |\trans| & $^\top{}$ & transposition (|\top|) \\
|trans*|  &          & $^\intercal$ &
  \quad alternate symbol (|\intercal|, requires \markpkg{amssymb})\\
|transT|  &          & $^\mathsf{T}$ & \quad letter `T' \\
|transT*| &          & $^\mathsf{\scriptscriptstyle T}$ &
  \quad letter `T' (|\scriptscriptsize|) \\
|transt|  &          & $^\mathsf{t}$ & \quad letter `t' \\
|hconj|   & |\hconj| & $^\dagger$ & hermitian conjugation (|\dagger|) \\
|hconjH|  &          & $^\mathsf{H}$ & \quad letter `H' \\
|hconjH*| &          & $^\mathsf{\scriptscriptstyle H}$ &
   \quad letter `H' (|\scriptscriptsize|) \\
|hconjh|  &          & $^\mathsf{h}$ & \quad letter `h' \\
|conj|    & |\conj|  & $^*$ & complex conjugation (|\ast|) \\
|dual|    & |\dual|  & $^*$ & dualisation (|\ast|) \\
\end{longtable}
%
The macros are intended to be used within superscripts.
Each macro and representation is provided as an individual feature
\textit{feature}[|={\|\textit{cmd}|}|]
which offers the option to customise the macro name to |\|\textit{cmd}.

\DescribeMacro{transfont}
The default font for letter representations of transposition
and hermitian conjugation is |\mathsf|;
it can be adjusted by |transfont={|\textit{mathfont}|}|.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Assorted Symbols.}
%
The package provides some assorted elementary symbols and compounds:
%
\begin{longtable}{llll}
feature & macro & output & description \\
\hline
|order| & |\order| & $o$ & anything of order less than \\
|Order| & |\Order| & $O$ & anything of order at most \\
|Order*| & |\Order| & $\mathcal{O}$ & anything of order at most
                                      (calligraphic) \\
|lapl| & |\lapl| & $\mathnormal{\Delta}$ & Laplace operator \\
|defeq| & |\defeq| & $\mathrel{\mathop:}=$ & is defined as \\
|eqdef| & |\eqdef| & $=\mathrel{\mathop:}$ & defines \\
|dualop| & |\dualop| & $\star$ & dual operator (e.g.\ Hodge) \\
|dualop*| & |\dualop| & $\ast$ & dual operator (alternative form) \\
\end{longtable}
%
Each macro and representation is provided as an individual feature
\textit{feature}[|={\|\textit{cmd}|}|]
which offers the option to customise the macro name to |\|\textit{cmd}.

The defining symbols |\defeq| and |\eqdef| both typeset
the colon to be vertically aligned with the equation sign.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Number Sets.}
\DescribeMacro{numset}
\DescribeMacro{numsetfont}
%
The feature |numset| provides the macro |\numset|
to typeset a number set such as the integers
which is commonly denoted by a (blackboard) bold letter
such as $\mathbb{Z}$ or $\mathbf{Z}$.
The feature |numset={\|\textit{cmd}|}|
offers the option to customise the macro name to |\|\textit{cmd}.
The default font for this feature is |\mathbb| of \ctanpkg{amssymb}
if available at the time of loading, otherwise |\mathbf|;
it can be adjusted by |numsetfont={|\textit{mathfont}|}|.

\DescribeMacro{numsets}
The standard number fields are provided by the feature |numsets|
as follows:
%
\begin{longtable}{llll}
macro & output & description \\
\hline
|\Natural| & $\mathbb{N}$ & set of natural numbers \\
|\Integer| & $\mathbb{Z}$ & field of integer numbers \\
|\Rational| & $\mathbb{Q}$ & field of rational numbers \\
|\Real| & $\mathbb{R}$ & field of real numbers \\
|\Complex| & $\mathbb{C}$ & field of complex numbers \\
|\Quaternion| & $\mathbb{H}$ & skew field of quaternions \\
|\Octonion| & $\mathbb{O}$ & division algebra of octonions \\
\end{longtable}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{Standard Groups.}
\DescribeMacro{grp}
%
The feature |grp| provides the macro |\grp|
to typeset a group name
which is commonly denoted by upright (mostly capital) letters
such as $\mathrm{GL}$ or $\mathrm{SO}$.
The feature |grp={\|\textit{cmd}|}|
offers the option to customise the macro name to |\|\textit{cmd}.
The feature |groups| defines a couple of common group names.

\DescribeMacro{grpfin}
The basic finite groups are provided by the feature |grpfin|
as follows:
%
\begin{longtable}{llll}
macro & output & description \\
\hline
|\grpcyc| & Z & cyclic group \\
|\grpcyc| & C & cyclic group (alternative form using |grpcycC| or |grpfin*|) \\
|\grpdih| & D & dihedral group \\
|\grpperm| & S & permutation group \\
|\grpalt| & A & alternating group \\
\end{longtable}
%
\DescribeMacro{grplie}
The basic groups of Lie type are provided by the feature |grplie|
as follows:
%
\begin{longtable}{llll}
macro & output & description \\
\hline
|\grpGL| & GL & general linear group \\
|\grpSL| & SL & special linear group \\
|\grpPGL| & PGL & projective linear group \\
|\grpPSL| & PSL & projective special linear group \\
|\grpU| & U & unitary group \\
|\grpSU| & SU & special unitary group \\
|\grpPU| & PU & projective unitary group \\
|\grpPSU| & PSU & projective special unitary group \\
|\grpO| & O & orthogonal group \\
|\grpSO| & SO & special orthogonal group \\
|\grpPSO| & PSO & projective special orthogonal group \\
|\grpSpin| & Spin & spin group \\
|\grpPin| & Pin & pin group \\
|\grpSp| & Sp & symplectic group \\
|\grpMp| & Mp & metaplectic group \\
\end{longtable}
%
\DescribeMacro{grpdynkin}
The seven classes of groups associated to Dynkin diagrams
are provided by the feature |grpdynkin|
as follows:
%
\begin{longtable}{llll}
macro & output & description \\
\hline
|\grpA| & A & group of type A \\
|\grpB| & B & group of type B \\
|\grpC| & C & group of type C \\
|\grpD| & D & group of type D \\
|\grpE| & E & group of (exceptional) type E \\
|\grpF| & F & group of (exceptional) type F \\
|\grpG| & G & group of (exceptional) type G \\
\end{longtable}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Information}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Copyright}

Copyright \copyright{} \thecopyright/

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.3c or later is part of all distributions of \LaTeX{}
version 2008 or later.

This work has the LPPL maintenance status `maintained'.

The Current Maintainer of this work is Niklas Beisert.

This work consists of the files
|README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|
as well as the derived files listed below.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Files and Installation}

The package consists of the files:
%
\begin{longtable}{ll}
    |README.txt|   & readme file \\
    \verbpkg|.ins| & installation file \\
    \verbpkg|.dtx| & source file \\
    \verbpkg|.sty| & package file \\
    \verbpkg|-samp.tex| & sample file \\
    \verbpkg|.pdf| & documentation \\
\end{longtable}
%
The distribution consists of the files
|README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|.
%
\begin{itemize}
\item
Run \LaTeX{} on \verbpkg|.ins| to create the package \verbpkg|.sty|
and further documentation files.
\item
Copy the file \verbpkg|.sty| to an appropriate directory of your \LaTeX{}
distribution, e.g.\ \textit{texmf-root}|/tex/latex/|\verbpkg.
\item
Alternatively, you may copy \verbpkg|.sty| to your project directory.
\item
Run (pdf)\LaTeX{} on \verbpkg|.dtx|
to compile the documentation \verbpkg|.pdf| (this file).
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Related CTAN Packages}

The package is related to other packages available at CTAN:
%
\begin{itemize}
\item
This package uses the package \ctanpkg{keyval}
to process the options for the package, environments and macros.
Compatibility with the \ctanpkg{keyval} package
has been tested with v1.15 (\markdate{2014-10-28}).
\item
This package is designed to be compatible with
the package \ctanpkg{amsmath}.
To prevent \ctanpkg{amsmath} from overwriting some features,
it should be loaded \emph{before} the present package.
Compatibility with the \ctanpkg{amsmath} package
has been tested with v2.17a (\markdate{2017-09-02}).
\item
This package reproduces the functionality of the
package \ctanpkg{fixmath} v0.9 (\markdate{2000-04-11})
from the bundle \ctanpkg{was}.
\item
Functionality to typeset common fractions is also provided by
the packages \ctanpkg{nicefrac}
from the bundle \ctanpkg{units}
and \ctanpkg{xfrac}
offering a more advanced implementation.
\item
This package cooperates with the package \ctanpkg{beamer}
in not changing colours for the root exponent.
Compatibility with the \ctanpkg{beamer} package
has been tested with v3.77 (\markdate{2026-01-22}).
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\iffalse
\subsection{Feature Suggestions}

The following is a list of features which may be useful for future
versions of this package:
%
\begin{itemize}
\item
 set of elliptic functions and constants
\item
 improvement for vector accent plancement
\item
 \mathup: no need as \mathrm does just that in whatever font
\item
 alternative representations for some operators
\end{itemize}

\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Revision History}

\iffalse

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{vN.N.N+:} \markdate{20YY-MM-DD}

\begin{itemize}
\item
\ldots
\end{itemize}

\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.2.1:} \markdate{2026-04-08}

\begin{itemize}
\item
catch upright pi at end of preamble
\item
fixed error due to open conditional statements
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.2:} \markdate{2026-03-23}

\begin{itemize}
\item
added unit element |\unitel| in various representations
\item
adjoint action |\ad|, volume |\Vol| and dual operator |\dualop|
\item
added transposition |\trans|, hermitian conjugation |\hconj|,
complex conjugation |\conj| and dualisation |\dual|
\item
added standard finite and Lie groups |\grp|\ldots
\item
fix for not applying |math text| colour for root exponent in \ctanpkg{beamer}
\item
use |\muexpr| to protect muskip expressions
\item
use elementary register manipulations
\item
package maintenance
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1.3:} \markdate{2025-03-25}

\begin{itemize}
\item
declared more features as robust commands (for use in titles, captions, etc.;
thanks to Jon\'a\v{s} Dujava for bug report)
\item
maintenance and manual update
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.12:} \markdate{2024-11-18}

\begin{itemize}
\item
fixed loading without \ctanpkg{amsmath}
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.11:} \markdate{2024-10-25}

\begin{itemize}
\item
fixed misspelled definition |\End|
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.1:} \markdate{2024-10-23}

\begin{itemize}
\item
added feature |genop| for additional functions, operators and symbols
\item
added feature |reim| to change the definitions
of |\Re| and |\Im| to `Re' and `Im'
\item
added features |trig| and |hyp| to complete the definitions
of trigonometric and hypberbolic functions
\item
added feature |mapchar| to represent characteristics of maps
\item
added feature |mapclass| to represent structure-preserving maps
\item
added feature |vecdiff| to represent vector differential operators
\item
added representation for mathematical constants $e$, $i$, $\pi$
\item
added features |der| and |diff| to represent derivative symbols
\item
added assorted symbols
\item
added feature |numset| and |numset| to represent number sets
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.01:} \markdate{2018-12-30}

\begin{itemize}
\item
fix for |\vfrac| in aligned math
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{v1.0:} \markdate{2018-01-17}

\begin{itemize}
\item
first version published on CTAN
\end{itemize}

%</main|manual>
%<*main>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\appendix
%</main>
%<*main|source>
\raggedright
\settowidth\MacroIndent{\rmfamily\scriptsize 000\ }

\DocInput{\thepkg/.dtx}
%</main|source>

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</main|manual|source>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Sample}
% \iffalse
%<*sample>
% \fi
%
% In this section we provide an example of how to use
% some of the \ctanpkg{mathfixs} features.
% We also test the behaviour in some special cases.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Preamble.}
%
% Standard document class:
%    \begin{macrocode}
\documentclass[12pt]{article}
%    \end{macrocode}

% Use package \ctanpkg{geometry} to adjust the page layout,
% adjust the paragraph shape:
%    \begin{macrocode}
\usepackage{geometry}
\geometry{layout=a4paper}
\geometry{paper=a4paper}
\geometry{margin=3cm}
\parindent0pt
%    \end{macrocode}

% Include \ctanpkg{amsmath}, \ctanpkg{amssymb}
% and the \ctanpkg{mathfixs} package:
%    \begin{macrocode}
\RequirePackage{amsmath,amssymb}
\RequirePackage[autobold]{mathfixs}
%    \end{macrocode}

% Declare features to be implemented globally:
%    \begin{macrocode}
\ProvideMathFix{greekcaps,mathbold}
\ProvideMathFix{frac,rfrac,vfrac}
\ProvideMathFix{multskip}
\ProvideMathFix{der,diff}
%    \end{macrocode}

% Start document body:
%    \begin{macrocode}
\begin{document}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Fractions.}
%    \begin{macrocode}
\paragraph{Fractions.}
%    \end{macrocode}

% Fraction spacing:
%    \begin{macrocode}
\[
x\frac{a+b}{c+d}\frac{e}{f}.
\]
%    \end{macrocode}

% Vulgar fractions:
%    \begin{macrocode}
Recipe for $\approx 3$ pancakes (scale accordingly):
Whisk together one large egg, $\vfrac{1}{8} \ell$ milk,
$50\mathinner{\mathrm{g}}$ flour
(mix \vfrac{2}{3} wholemeal flour and \vfrac{1}{3} white flour); fry in pan.
Feel free to use more flour than indicated.
%    \end{macrocode}

% Rational numbers:
%    \begin{macrocode}
\[
\rfrac{1}{2}x^2 + \rfrac{1}{6} y^3 + \rfrac{1}{4} x^2 y^2
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Radicals.}
%    \begin{macrocode}
\paragraph{Radicals.}
%    \end{macrocode}

% Original radicals spacing:
%    \begin{macrocode}
\[
y\sqrt{x}z,\qquad
y\sqrt[]{x}z,\qquad
y\sqrt[i]{x}z,\qquad
y\sqrt[n]{x}z,\qquad
y\sqrt[3]{x}z,\qquad
y\sqrt[123]{x}z
\]
%    \end{macrocode}

% Radicals spacing
% (feature introduced in document body):
%    \begin{macrocode}
\ProvideMathFix{root}
\[
y\sqrt{x}z,\qquad
y\sqrt[]{x}z,\qquad
y\sqrt[i]{x}z,\qquad
y\sqrt[n]{x}z,\qquad
y\sqrt[3]{x}z,\qquad
y\sqrt[123]{x}z
\]
%    \end{macrocode}

% Radicals with closing mark
% (using a locally defined option):
%    \begin{macrocode}
\[
\ProvideMathFix{rootclose}
y\sqrt{x}z,\qquad
y\sqrt[]{x}z,\qquad
y\sqrt[i]{x}z,\qquad
y\sqrt[n]{x}z,\qquad
y\sqrt[3]{x}z,\qquad
y\sqrt[123]{x}z
\]
%    \end{macrocode}

% Radicals with class |\mathinner|:
%    \begin{macrocode}
\[
\ProvideMathFix{rootclass={\mathinner}}
y\sqrt{x}z,\qquad
y\sqrt[]{x}z,\qquad
y\sqrt[i]{x}z,\qquad
y\sqrt[n]{x}z,\qquad
y\sqrt[3]{x}z,\qquad
y\sqrt[123]{x}z
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Spaces Representing Multiplication and Derivative Symbols.}
%    \begin{macrocode}
\paragraph{Spaces Representing Multiplication and Derivative Symbols.}
%    \end{macrocode}

% Explicit spacing:
%    \begin{macrocode}
\[
\int x\.\der x
\]
%    \end{macrocode}

% Implicit spacing:
%    \begin{macrocode}
\[
\int x\diff{x}
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Greek Letters.}
%    \begin{macrocode}
\paragraph{Greek Letters.}
%    \end{macrocode}

% Capital letters:
%    \begin{macrocode}
\[
\Gamma \qquad
\mathrm{\Gamma} \qquad
c\operatorname{\Gamma}(x)
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Bold Text with Math Symbols.}
%    \begin{macrocode}
\paragraph{Bold Text with Math Symbols: $abc123\alpha\Gamma$.}
%    \end{macrocode}

% Bold text:
%    \begin{macrocode}
\[
aG\alpha\Gamma
\qquad\mathbold{aG\alpha\Gamma}
\qquad\ProvideMathFix{greeklower}\mathbold{aG\alpha\Gamma}
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Real and Imaginary Parts.}
%    \begin{macrocode}
\paragraph{Real and Imaginary Parts.}
%    \end{macrocode}

% Change representation for |\Re| and |\Im|:
%    \begin{macrocode}
\[
\Re(z),\Im(z)
\qquad\ProvideMathFix{reim}
\Re(z),\Im(z)
\qquad\ProvideMathFix{reim={\nRe\nIm}}
\nRe(z),\nIm(z)
\]
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Functions, Operators, Symbols.}
%    \begin{macrocode}
\paragraph{Functions, Operators, Symbols.}
%    \end{macrocode}

% Some examples of vector differential operators:
%    \begin{macrocode}
\[
\ProvideMathFix{vecdiff,lapl,defeq}
\lapl f=\div\grad f,
\qquad
\lapl v=\grad\div v-\curl\curl v,
\]
%    \end{macrocode}
% Some examples of mathematical constants:
%    \begin{macrocode}
\[
\ProvideMathFix{econst,iunit,piconst}
\econst^{\iunit\piconst}=-1,
\qquad
\ProvideMathFix{econst*,iunit*,piconst*}
\econst^{\iunit\piconst}=-1,
\qquad
\ProvideMathFix{econst,defeq,iunit*nb,numsets}
z\defeq x+\iunit y=r\econst^{\iunit\theta}\in\Complex,
\quad x,y,r,\theta\in\Real
\]
%    \end{macrocode}
% Some examples of operators and symbols:
%    \begin{macrocode}
\[
\ProvideMathFix{res,hyp,iunit*,piconst*}
\res_{z=\iunit \piconst n} \csch(z)=(-1)^n
\]
%    \end{macrocode}

% End of document body:
%    \begin{macrocode}
\end{document}
%    \end{macrocode}
% \iffalse
%</sample>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Implementation}
% \iffalse
%<*package>
% \fi
%
% In this section we describe the package \verbpkg|.sty|.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Required Packages.}
%
% The package loads the package
% \ctanpkg{keyval}
% if not yet present.
% \ctanpkg{keyval} is used for extended options processing:
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{General Definitions.}
%
% \macro{\mafx@letcs}
% \macro{\mafx@mathopfont}
% Define some auxiliary macros for the package.
% |\mafx@letcs| makes a |\let| assignment on the csname |#1|.
% |\mafx@mathopfont| encapsules |\operator@font| within a block.
%    \begin{macrocode}
\def\mafx@letcs#1{\expandafter\let\csname#1\endcsname}
\DeclareRobustCommand{\mafx@mathopfont}[1]{{\operator@font#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Automatically Bold Maths.}
%
% \macro{\bfseries}
% \macro{\mdseries}
% \macro{\normalfont}
% Define replacements for |\bfseries|, |\mdseries| and |\normalfont|
% by appending |\boldmath| or |\unboldmath|
% (if not already in math mode where font selection works differently).
% The chain of |\expandafter| directives fills in the original definition:
%    \begin{macrocode}
\expandafter\DeclareRobustCommand\expandafter\mafx@bfseries\expandafter
  {\bfseries\ifmmode\else\boldmath\fi}
\expandafter\DeclareRobustCommand\expandafter\mafx@mdseries\expandafter
  {\mdseries\ifmmode\else\unboldmath\fi}
\expandafter\DeclareRobustCommand\expandafter\mafx@normalfont\expandafter
  {\normalfont\ifmmode\else\unboldmath\fi}
%    \end{macrocode}

% \macro{autobold}
% Implement the |autobold| fix:
%    \begin{macrocode}
\define@key{mafx@}{autobold}[]{%
  \let\bfseries=\mafx@bfseries
  \let\mdseries=\mafx@mdseries
  \let\normalfont=\mafx@normalfont
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Bold Italic Math.}
%
% \macro{mathbold}
% \macro{\mathbold}
% Define a new math alphabet |\mathbold|
% as the bold series and italic shape
% of the standard computer modern math font
% (see package \ctanpkg{fixmath}):
%
%    \begin{macrocode}
\DeclareMathAlphabet{\mafx@mathbold}{OML}{cmm}{b}{it}
%    \end{macrocode}

% \macro{autobold}
% Implement |\mathbold| (or alterantive macro name):
%    \begin{macrocode}
\define@key{mafx@}{mathbold}[\mathbold]{\let#1=\mafx@mathbold}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Spacing Adjustment for Fractions.}
%
% Save primitive definition of |\over| into |\@@over|
% (compatible with \ctanpkg{amsmath}):
%
%    \begin{macrocode}
\ifdefined\@@over\else\let\@@over=\over\fi
%    \end{macrocode}

% Define math class selectors for fractions (without/with delimiters):
%    \begin{macrocode}
\let\mafx@frac@class=\mathinner
\def\mafx@frac@delimclass{\mathopen{}\mathclose}
%    \end{macrocode}

% \macro{\frac}
% Define replacement for |\frac| which uses a configurable
% math class selector:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@frac}[2]{%
  \mafx@frac@class{\begingroup#1\endgroup\@@over#2}}
%    \end{macrocode}

% \macro{\genfrac}
% Define replacement for |\@genfrac| (called by |\genfrac|)
% which uses the appropriate math class selector.
% If the package \ctanpkg{amsmath} is not loaded, this definition will
% have no impact:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@@genfrac}[5]{\begingroup
  \ifx#2\@@overwithdelims\let\mafx@frac@class\mafx@frac@delimclass\fi
  \ifx#2\@@abovewithdelims\let\mafx@frac@class\mafx@frac@delimclass\fi
  \ifx#2\@@atopwithdelims\let\mafx@frac@class\mafx@frac@delimclass\fi
  \mafx@frac@class{#1{\begingroup#4\endgroup#2#3\relax#5}}%
  \endgroup}
%    \end{macrocode}

% \macro{frac}
% Implement the replacement for |\frac| and |\genfrac|:
%    \begin{macrocode}
\define@key{mafx@}{frac}[]{%
  \let\frac=\mafx@frac
  \let\@genfrac=\mafx@@genfrac
}
%    \end{macrocode}

% \macro{fracclass}
% \macro{fracdelimclass}
% Configure the math classes for fractions (without/with delimiters):
%    \begin{macrocode}
\define@key{mafx@}{fracclass}{\def\mafx@frac@class{#1}}
\define@key{mafx@}{fracdelimclass}{\def\mafx@frac@delimclass{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Small Fractions.}
%
% \macro{\rfrac}
% Define a fraction in text style or smaller
% using the ordinary math class (no surrounding space), e.g.: $\frac{1}{2}$:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@rfrac}[2]{{\mathchoice
  {\textstyle{\begingroup#1\endgroup\@@over#2}}%
  {\begingroup#1\endgroup\@@over#2}%
  {\begingroup#1\endgroup\@@over#2}%
  {\begingroup#1\endgroup\@@over#2}}}
%    \end{macrocode}

% \macro{rfrac}
% Implement |\rfrac| (or alternative macro name):
%    \begin{macrocode}
\define@key{mafx@}{rfrac}[\rfrac]{\let#1=\mafx@rfrac}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Vulgar Fractions.}
%
% Define the math class and spacing parameters as (negative) spaces
% around the dividing slash:
%    \begin{macrocode}
\let\mafx@vfrac@class=\mathinner
\def\mafx@vfrac@preskip{\thinmuskip}
\def\mafx@vfrac@postskip{0.6667\thinmuskip}
%    \end{macrocode}
%
% \macro{\vfrac}
% Define a vulgar representation of a rational number, e.g.: $^1\!/\!_2$.
% Automatically switch to math mode if in text mode:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@vfrac}[2]{\ifmmode
  \mafx@vfrac@class{\textstyle
    ^{#1}\mkern-\muexpr\mafx@vfrac@preskip\relax
    /\mkern-\muexpr\mafx@vfrac@postskip\relax_{#2}}%
  \else$\mafx@vfrac{#1}{#2}$\fi}
%    \end{macrocode}

% \macro{vfrac}
% Implement |\vfrac| (or alternative macro name):
%    \begin{macrocode}
\define@key{mafx@}{vfrac}[\vfrac]{\let#1=\mafx@vfrac}
%    \end{macrocode}

% \macro{vfracclass}
% \macro{vfracskippre}
% \macro{vfracskippost}
% Define configurable skip parameters for |\vfrac|:
%    \begin{macrocode}
\define@key{mafx@}{vfracclass}{\def\mafx@vfrac@class{#1}}
\define@key{mafx@}{vfracskippre}{\def\mafx@vfrac@preskip{#1}}
\define@key{mafx@}{vfracskippost}{\def\mafx@vfrac@postskip{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Interaction with \markpkg{beamerbasecolor}.}
%
% Suppress changing colors in inner math structures
% when \ctanpkg{beamer} class is loaded:
%    \begin{macrocode}
\let\mafx@beamerbasecolor@fix\@empty
\AddToHook{package/beamerbasecolor/after}{%
  \def\mafx@beamerbasecolor@fix{\donotcoloroutermaths}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Spacing Adjustment for Roots.}
%
% Define some parameters for the improved root macros.
% |\mafx@root@close| stores the relative height
% where the closing bar for the radical starts;
% empty disables the closing bar.
% |\mafx@root@class| stores the math class for a root.
% |\mafx@root@endskip| stores space to be added after the radicant
% but within the radical in math units.
% |\mafx@root@preskip| and |\mafx@root@postskip| store space to be added
% before or after the radical sign:
%    \begin{macrocode}
\let\mafx@root@close=\@empty
\def\mafx@root@class{}
\def\mafx@root@endskip{0.6667\thinmuskip}
\def\mafx@root@preskip{0mu}
\def\mafx@root@postskip{0.3333\thinmuskip}
%    \end{macrocode}

% \macro{\sqrt}
% Replacement for |\sqrt| which passes an
% empty first argument instead of calling |\sqrtsign|:
%    \begin{macrocode}
\DeclareRobustCommand\mafx@sqrt{\@ifnextchar[\@sqrt{\@sqrt[]}}
\def\mafx@@sqrt[#1]{\root#1\of}
%    \end{macrocode}

% \macro{\root}
% Replacement for |\root| \ldots|\of|
% which stores the |\leftroot| and |\uproot| parameters
% specified in the exponent (see package \ctanpkg{amsmath}).
% It does so by first storing them in global parameters
% and then converting them to local ones to avoid
% interference with nested radicals.
% As usual, the macro then passes on to |\r@@t|
% with |\mathpalette|:
%    \begin{macrocode}
\def\mafx@root#1\of{%
  \setbox\rootbox\hbox{\mafx@beamerbasecolor@fix$\m@th\scriptscriptstyle{%
    \gdef\mafx@gleftroot{0}\gdef\mafx@guproot{0}%
    \def\leftroot##1{\gdef\mafx@gleftroot{##1}}%
    \def\uproot##1{\gdef\mafx@guproot{##1}}%
    #1}$}%
  \let\mafx@leftroot=\mafx@gleftroot
  \let\mafx@uproot=\mafx@guproot
  \mathpalette\r@@t}
%    \end{macrocode}

% The replacement for |\r@@t| typesets the radical by
% placing the exponent in an elevated box.
% First, select desirect math class:
%    \begin{macrocode}
\def\mafx@r@@t#1#2{\mafx@root@class{%
%    \end{macrocode}
% Determine the font selector for the current style:
%    \begin{macrocode}
  \ifx#1\scriptstyle\let\mafx@tmp@fontsel=\scriptfont\else
  \ifx#1\scriptscriptstyle\let\mafx@tmp@fontsel=\scriptscriptfont\else
  \let\mafx@tmp@fontsel=\textfont\fi\fi
%    \end{macrocode}
% Generate a radical with empty radicand in cramped style
% (see package \ctanpkg{mathtools})
% at the desired height and depth and store in a box
% for subsequent measurements:
%    \begin{macrocode}
  \sbox\z@{$\m@th#1\nulldelimiterspace=\z@\radical\z@{#2}$}%
  \dimen@\ht\z@
  \ifx#1\displaystyle
    \advance\dimen@-\fontdimen8\textfont3\relax
    \advance\dimen@-0.25\fontdimen5\textfont2\relax
  \else
    \advance\dimen@-1.25\fontdimen8\mafx@tmp@fontsel3\relax
  \fi
  \setbox\z@=\hbox{$\m@th#1\sqrtsign{%
    \vrule width\z@ height\dimen@ depth\dp\z@}$}%
%    \end{macrocode}
% Shift to start of exponent box such that end
% will reside at 60\% of radical sign.
% Do not shift if exponent box is sufficiently wide:
%    \begin{macrocode}
  \dimen@\dimexpr0.6\wd\z@-\wd\rootbox\relax
  \ifdim\dimen@>\z@\else\dimen@\z@\fi
  \kern\dimen@
%    \end{macrocode}
% Compute elevation of exponent box as 60\% of radical sign.
% Add length specified by |\uproot|:
%    \begin{macrocode}
  \setbox\@ne=\hbox{$\m@th#1\mskip\muexpr\mafx@uproot mu\relax$}%
  \dimen@\dimexpr0.6\ht\z@-0.6\dp\z@+\wd\@ne\relax
%    \end{macrocode}
% Place exponent box and return to intended start of radical sign:
%    \begin{macrocode}
  \mkern-\muexpr\mafx@leftroot mu\relax
  \raise\dimen@\copy\rootbox
  \mkern\muexpr\mafx@leftroot mu\relax
  \kern-0.6\wd\z@
%    \end{macrocode}
% Place radical adding extra kernings |\mafx@root@preskip| and
% |\mafx@root@endskip|:
%    \begin{macrocode}
  \mkern\muexpr\mafx@root@preskip\relax
  \sqrtsign{#2\mskip\muexpr\mafx@root@endskip\relax}%
%    \end{macrocode}
% Add a closing bar to the radical,
% see \url{http://en.wikibooks.org/wiki/LaTeX/Mathematics}.
% If |\mafx@root@close| is empty, ignore.
% Determine the thickness of the rule as font dimension x8.
% Draw a vertical rule starting from relative height |\mafx@root@close|
% of the radical:
%    \begin{macrocode}
  \ifx\mafx@root@close\@empty\else
  \dimen@\fontdimen8\mafx@tmp@fontsel3\relax
  \lower\dimen@\hbox{%
    \vrule width\dimen@ height\ht\z@ depth -\mafx@root@close\ht\z@}%
  \fi
%    \end{macrocode}
% Finally, add kerning |\mafx@root@postskip|:
%    \begin{macrocode}
  \mkern\mafx@root@postskip}}
%    \end{macrocode}

% \macro{root}
% Implement replacement |\sqrt| and |\root|:
%    \begin{macrocode}
\define@key{mafx@}{root}[]{%
  \let\sqrt=\mafx@sqrt
  \let\@sqrt=\mafx@@sqrt
  \let\root=\mafx@root
  \let\r@@t=\mafx@r@@t
}
%    \end{macrocode}

% \macro{rootclose}
% \macro{rootclass}
% \macro{rootskipend}
% \macro{rootskippre}
% \macro{rootskipbefore}
% Define configurable parameters for alternative root:
%    \begin{macrocode}
\define@key{mafx@}{rootclose}[0.8]{\def\mafx@root@close{#1}}
\define@key{mafx@}{rootclass}{\let\mafx@root@class=#1}
\define@key{mafx@}{rootskipend}{\def\mafx@root@endskip{#1}}
\define@key{mafx@}{rootskippre}{\def\mafx@root@preskip{#1}}
\define@key{mafx@}{rootskippost}{\def\mafx@root@postskip{#1}}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Space Representing Multiplication.}
%
% \macro{\.}
% Define |\.| to represent a thin math skip when in math mode.
% Retain original definition as an accent in text mode.
% Switch is performed by temporarily storing the appropriate macro
% which is subsequently issued so that the correct number of
% arguments are fetched:
%    \begin{macrocode}
\let\mafx@old@dot=\.
\def\mafx@dot@skip{\thinmuskip}
\def\mafx@dot{\mskip\muexpr\mafx@dot@skip\relax}
\DeclareRobustCommand{\mafx@per@dot}{%
  \ifmmode\expandafter\mafx@dot\else\expandafter\mafx@old@dot\fi}
%    \end{macrocode}

% \macro{multskip}
% Implement definition of |\.|:
%    \begin{macrocode}
\define@key{mafx@}{multskip}[\thinmuskip]{%
  \let\.=\mafx@per@dot
  \def\mafx@dot@skip{#1}%
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Italic Capital Greek Letters.}
%
% \macro{\Gamma}
% \macro{...}
% Define capital Greek letters as letters
% (instead of the default assignment as operators).
% This implementation follows the package \ctanpkg{fixmath}:
%    \begin{macrocode}
\DeclareMathSymbol{\mafx@Gamma}{\mathalpha}{letters}{0}
\DeclareMathSymbol{\mafx@Delta}{\mathalpha}{letters}{1}
\DeclareMathSymbol{\mafx@Theta}{\mathalpha}{letters}{2}
\DeclareMathSymbol{\mafx@Lambda}{\mathalpha}{letters}{3}
\DeclareMathSymbol{\mafx@Xi}{\mathalpha}{letters}{4}
\DeclareMathSymbol{\mafx@Pi}{\mathalpha}{letters}{5}
\DeclareMathSymbol{\mafx@Sigma}{\mathalpha}{letters}{6}
\DeclareMathSymbol{\mafx@Upsilon}{\mathalpha}{letters}{7}
\DeclareMathSymbol{\mafx@Phi}{\mathalpha}{letters}{8}
\DeclareMathSymbol{\mafx@Psi}{\mathalpha}{letters}{9}
\DeclareMathSymbol{\mafx@Omega}{\mathalpha}{letters}{10}
%    \end{macrocode}

% \macro{greekcaps}
% Implement italic capital Greek letters.
% The optional argument is used as a prefix for the definitions:
%    \begin{macrocode}
\define@key{mafx@}{greekcaps}[]{%
  \mafx@letcs{#1Gamma}=\mafx@Gamma
  \mafx@letcs{#1Delta}=\mafx@Delta
  \mafx@letcs{#1Theta}=\mafx@Theta
  \mafx@letcs{#1Lambda}=\mafx@Lambda
  \mafx@letcs{#1Xi}=\mafx@Xi
  \mafx@letcs{#1Pi}=\mafx@Pi
  \mafx@letcs{#1Sigma}=\mafx@Sigma
  \mafx@letcs{#1Upsilon}=\mafx@Upsilon
  \mafx@letcs{#1Phi}=\mafx@Phi
  \mafx@letcs{#1Psi}=\mafx@Psi
  \mafx@letcs{#1Omega}=\mafx@Omega
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Lowercase Greek Letters in Standard Math Type.}
%
% \macro{\alpha}
% \macro{...}
% Define lowercase Greek letters in standard type |\mathalpha|
% (instead of the default assiment |\mathord|).
% This implementation follows the package \ctanpkg{fixmath}:
%    \begin{macrocode}
\DeclareMathSymbol{\mafx@alpha}{\mathalpha}{letters}{11}
\DeclareMathSymbol{\mafx@beta}{\mathalpha}{letters}{12}
\DeclareMathSymbol{\mafx@gamma}{\mathalpha}{letters}{13}
\DeclareMathSymbol{\mafx@delta}{\mathalpha}{letters}{14}
\DeclareMathSymbol{\mafx@epsilon}{\mathalpha}{letters}{15}
\DeclareMathSymbol{\mafx@zeta}{\mathalpha}{letters}{16}
\DeclareMathSymbol{\mafx@eta}{\mathalpha}{letters}{17}
\DeclareMathSymbol{\mafx@theta}{\mathalpha}{letters}{18}
\DeclareMathSymbol{\mafx@iota}{\mathalpha}{letters}{19}
\DeclareMathSymbol{\mafx@kappa}{\mathalpha}{letters}{20}
\DeclareMathSymbol{\mafx@lambda}{\mathalpha}{letters}{21}
\DeclareMathSymbol{\mafx@mu}{\mathalpha}{letters}{22}
\DeclareMathSymbol{\mafx@nu}{\mathalpha}{letters}{23}
\DeclareMathSymbol{\mafx@xi}{\mathalpha}{letters}{24}
\DeclareMathSymbol{\mafx@pi}{\mathalpha}{letters}{25}
\DeclareMathSymbol{\mafx@rho}{\mathalpha}{letters}{26}
\DeclareMathSymbol{\mafx@sigma}{\mathalpha}{letters}{27}
\DeclareMathSymbol{\mafx@tau}{\mathalpha}{letters}{28}
\DeclareMathSymbol{\mafx@upsilon}{\mathalpha}{letters}{29}
\DeclareMathSymbol{\mafx@phi}{\mathalpha}{letters}{30}
\DeclareMathSymbol{\mafx@chi}{\mathalpha}{letters}{31}
\DeclareMathSymbol{\mafx@psi}{\mathalpha}{letters}{32}
\DeclareMathSymbol{\mafx@omega}{\mathalpha}{letters}{33}
\DeclareMathSymbol{\mafx@varepsilon}{\mathalpha}{letters}{34}
\DeclareMathSymbol{\mafx@vartheta}{\mathalpha}{letters}{35}
\DeclareMathSymbol{\mafx@varpi}{\mathalpha}{letters}{36}
\DeclareMathSymbol{\mafx@varphi}{\mathalpha}{letters}{39}
\DeclareMathSymbol{\mafx@varrho}{\mathalpha}{letters}{37}
\DeclareMathSymbol{\mafx@varsigma}{\mathalpha}{letters}{38}
%    \end{macrocode}

% \macro{greeklower}
% Implement standard type lowercase Greek letters.
% The optional argument is used as a prefix for the definitions:
%    \begin{macrocode}
\define@key{mafx@}{greeklower}[]{%
  \mafx@letcs{#1alpha}=\mafx@alpha
  \mafx@letcs{#1beta}=\mafx@beta
  \mafx@letcs{#1gamma}=\mafx@gamma
  \mafx@letcs{#1delta}=\mafx@delta
  \mafx@letcs{#1epsilon}=\mafx@epsilon
  \mafx@letcs{#1zeta}=\mafx@zeta
  \mafx@letcs{#1eta}=\mafx@eta
  \mafx@letcs{#1theta}=\mafx@theta
  \mafx@letcs{#1iota}=\mafx@iota
  \mafx@letcs{#1kappa}=\mafx@kappa
  \mafx@letcs{#1lambda}=\mafx@lambda
  \mafx@letcs{#1mu}=\mafx@mu
  \mafx@letcs{#1nu}=\mafx@nu
  \mafx@letcs{#1xi}=\mafx@xi
  \mafx@letcs{#1pi}=\mafx@pi
  \mafx@letcs{#1rho}=\mafx@rho
  \mafx@letcs{#1sigma}=\mafx@sigma
  \mafx@letcs{#1tau}=\mafx@tau
  \mafx@letcs{#1upsilon}=\mafx@upsilon
  \mafx@letcs{#1phi}=\mafx@phi
  \mafx@letcs{#1chi}=\mafx@chi
  \mafx@letcs{#1psi}=\mafx@psi
  \mafx@letcs{#1omega}=\mafx@omega
  \mafx@letcs{#1varepsilon}=\mafx@varepsilon
  \mafx@letcs{#1vartheta}=\mafx@vartheta
  \mafx@letcs{#1varpi}=\mafx@varpi
  \mafx@letcs{#1varphi}=\mafx@varphi
  \mafx@letcs{#1varrho}=\mafx@varrho
  \mafx@letcs{#1varsigma}=\mafx@varsigma
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Assorted Functions, Operators, Symbols.}
%
% The following definitions require \ctanpkg{amsopn}:
%    \begin{macrocode}
\ifdefined\DeclareMathOperator
%    \end{macrocode}

% Define macros for assorted functions, operators, symbols:
%    \begin{macrocode}
\DeclareMathOperator{\mafx@sgn}{sgn}
\DeclareMathOperator*{\mafx@res}{res}
\DeclareMathOperator{\mafx@lcm}{lcm}
\DeclareMathOperator{\mafx@span}{span}
\DeclareMathOperator{\mafx@diag}{diag}
\DeclareMathOperator{\mafx@spec}{spec}
\DeclareMathOperator{\mafx@const}{const}
\DeclareMathOperator{\mafx@id}{id}
\DeclareMathOperator{\mafx@tr}{tr}
\DeclareMathOperator{\mafx@ad}{ad}
\DeclareMathOperator{\mafx@Vol}{Vol}
%    \end{macrocode}

% Implement assorted functions, operators and symbols individually
% with the option to adjust their macro names:
%    \begin{macrocode}
\define@key{mafx@}{sgn}[\sgn]{\let#1=\mafx@sgn}
\define@key{mafx@}{res}[\res]{\let#1=\mafx@res}
\define@key{mafx@}{lcm}[\lcm]{\let#1=\mafx@lcm}
\define@key{mafx@}{diag}[\diag]{\let#1=\mafx@diag}
\define@key{mafx@}{span}[\Span]{\let#1=\mafx@span}
\define@key{mafx@}{spec}[\spec]{\let#1=\mafx@spec}
\define@key{mafx@}{const}[\const]{\let#1=\mafx@const}
\define@key{mafx@}{id}[\id]{\let#1=\mafx@id}
\define@key{mafx@}{tr}[\tr]{\let#1=\mafx@tr}
\define@key{mafx@}{ad}[\ad]{\let#1=\mafx@ad}
\define@key{mafx@}{Vol}[\Vol]{\let#1=\mafx@Vol}
%    \end{macrocode}
%
% \macro{genop}
% Implement all assorted functions, operators and symbols:
%    \begin{macrocode}
\define@key{mafx@}{genop}[]{%
  \ProvideMathFix{sgn,res,lcm,diag,span,spec,const}%
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Real and Imaginary Part Projectors in Text Form.}
%
% \macro{\Re}
% \macro{\Im}
% Define a different notation for real and imaginary part projectors are the
% textual symbols `Re' and `Im':
%    \begin{macrocode}
\let\mafx@orgRe=\Re
\let\mafx@orgIm=\Im
\DeclareMathOperator{\mafx@Re}{Re}
\DeclareMathOperator{\mafx@Im}{Im}
%    \end{macrocode}

% \macro{reim}
% Implement textual notation for \verb+\Re+ and \verb+\Im+:
%    \begin{macrocode}
\define@key{mafx@}{reim}[\Re\Im]{%
  \expandafter\let\@firstoftwo#1=\mafx@Re
  \expandafter\let\@secondoftwo#1=\mafx@Im
}
\define@key{mafx@}{reim*}[\Re\Im]{%
  \expandafter\let\@firstoftwo#1=\mafx@orgRe
  \expandafter\let\@secondoftwo#1=\mafx@orgIm
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Remaining Inverse Trigonometric Functions.}
%
% \macro{\arccot}
% \macro{\arcsec}
% \macro{\arccsc}
% Define remaining inverse trigonometric functions
% and their inverses:
%    \begin{macrocode}
\DeclareMathOperator{\mafx@arccot}{arccot}
\DeclareMathOperator{\mafx@arcsec}{arcsec}
\DeclareMathOperator{\mafx@arccsc}{arccsc}
%    \end{macrocode}

% \macro{trig}
% Implement remaining trigonometric functions:
%    \begin{macrocode}
\define@key{mafx@}{trig}[]{%
  \let\arccot=\mafx@arccot
  \let\arcsec=\mafx@arcsec
  \let\arccsc=\mafx@arccsc
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Remaining Hyperbolic Functions.}
%
% \macro{\sech}
% \macro{\csch}
% \macro{\ar...h}
% Define remaining hyperbolic functions
% and their inverses:
%    \begin{macrocode}
\DeclareMathOperator{\mafx@sech}{sech}
\DeclareMathOperator{\mafx@csch}{csch}
\DeclareMathOperator{\mafx@arsinh}{arsinh}
\DeclareMathOperator{\mafx@arcosh}{arcosh}
\DeclareMathOperator{\mafx@artanh}{artanh}
\DeclareMathOperator{\mafx@arcoth}{arcoth}
\DeclareMathOperator{\mafx@arsech}{arsech}
\DeclareMathOperator{\mafx@arcsch}{arcsch}
%    \end{macrocode}

% \macro{hyp}
% Implement remaining hyperbolic functions:
%    \begin{macrocode}
\define@key{mafx@}{hyp}[]{%
  \let\sech=\mafx@sech
  \let\csch=\mafx@csch
  \let\arsinh=\mafx@arsinh
  \let\arcosh=\mafx@arcosh
  \let\artanh=\mafx@artanh
  \let\arcoth=\mafx@arcoth
  \let\arsech=\mafx@arsech
  \let\arcsch=\mafx@arcsch
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Characteristics of Maps.}
%
% Define macros for characteristics of maps:
%    \begin{macrocode}
\DeclareMathOperator{\mafx@dom}{dom}
\DeclareMathOperator{\mafx@supp}{supp}
\DeclareMathOperator{\mafx@codom}{codom}
\DeclareMathOperator{\mafx@im}{im}
\DeclareMathOperator{\mafx@rank}{rank}
\DeclareMathOperator{\mafx@coker}{coker}
%    \end{macrocode}

% Implement characteristics of maps
% with the option to adjust the macro name for |\im|
% to evade potential clashes for two letter definition:
%    \begin{macrocode}
\define@key{mafx@}{mapchar}[\im]{%
  \let\dom=\mafx@dom
  \let\supp=\mafx@supp
  \let\codom=\mafx@codom
  \let#1=\mafx@im
  \let\rank=\mafx@rank
  \let\coker=\mafx@coker
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Classes of Structure-Preserving Maps.}
%
% \macro{\Hom}
% \macro{\End}
% \macro{\Isom}
% \macro{\Aut}
% Define classes of structure-preserving maps:
%    \begin{macrocode}
\DeclareMathOperator{\mafx@Hom}{Hom}
\DeclareMathOperator{\mafx@End}{End}
\DeclareMathOperator{\mafx@Isom}{Isom}
\DeclareMathOperator{\mafx@Aut}{Aut}
%    \end{macrocode}

% \macro{mapclass}
% Implement classes of structure-preserving maps:
%    \begin{macrocode}
\define@key{mafx@}{mapclass}[]{%
  \let\Hom=\mafx@Hom
  \let\End=\mafx@End
  \let\Isom=\mafx@Isom
  \let\Aut=\mafx@Aut
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Differential Operators for Vectors.}
%
% \macro{\grad}
% \macro{\div}
% \macro{\curl}
% Define differential operators gradient, divergence and curl
% (alternative form rot):
%    \begin{macrocode}
\DeclareMathOperator{\mafx@grad}{grad}
\DeclareMathOperator{\mafx@div}{div}
\DeclareMathOperator{\mafx@curl}{curl}
\DeclareMathOperator{\mafx@rot}{rot}
%    \end{macrocode}

% \macro{vecdiff}
% \macro{vecdiff*}
% \macro{vecrot}
% Implement differential operators for vectors individually
% with the option to adjust their macro names.
% Implement alternative rot for curl/rotor
% with the option to adjust its macro name:
%    \begin{macrocode}
\define@key{mafx@}{vecdiff}[]{%
  \let\grad=\mafx@grad
  \let\div=\mafx@div
  \let\curl=\mafx@curl
}
\define@key{mafx@}{vecdiff*}[]{%
  \let\grad=\mafx@grad
  \let\div=\mafx@div
  \let\curl=\mafx@rot
}
\define@key{mafx@}{vecrot}[\curl]{\let#1=\mafx@rot}
%    \end{macrocode}

% The above definitions required \ctanpkg{amsopn}:
%    \begin{macrocode}
\fi
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Mathematical Constants.}
%
% Try to declare upright and italic lowercase pi.
% Use |\uppi| for upright |\pi| if available,
% otherwise use plain |\pi| hoping for availability of an upright version:
%    \begin{macrocode}
\def\mafx@piup{\operator@font\pi}
\def\mafx@piit{\mathnormal{\pi}}
\AddToHook{begindocument/end}{%
  \ifdefined\uppi\def\mafx@piup{\uppi}%
  \else\ifdefined\symup\def\mafx@piup{\symup{\pi}}\fi\fi
  \ifdefined\symit\def\mafx@piit{\symit{\pi}}\fi
}
%    \end{macrocode}
%
% Declare some math alphabets for blackboard bold unit element:
%    \begin{macrocode}
\DeclareMathAlphabet{\mafx@mathbfb}{OT1}{cmr}{b}{n}
\DeclareMathAlphabet{\mafx@mathbfbx}{OT1}{cmr}{bx}{n}
\ifdefined\bbfamily\let\mafx@mathbbold=\mathbb\else\IfFileExists{bbold.sty}{%
  \DeclareMathAlphabet{\mafx@mathbbold}{U}{bbold}{m}{n}}{}\fi
\ifdefined\mathds\let\mafx@mathds=\mathds\else\IfFileExists{dsfont.sty}{%
  \DeclareMathAlphabet{\mafx@mathds}{U}{dsrom}{m}{n}}{}\fi
\IfFileExists{dsfont.sty}{%
  \DeclareMathAlphabet{\mafx@mathdsr}{U}{dsrom}{m}{n}
  \DeclareMathAlphabet{\mafx@mathdss}{U}{dsss}{m}{n}
}{}
\ifdefined\mathbbm\let\mafx@mathds=\mathds\else\IfFileExists{bbm.sty}{%
  \DeclareMathAlphabet{\mafx@mathbbm}{U}{bbm}{m}{n}
  \SetMathAlphabet\mafx@mathbbm{bold}{U}{bbm}{bx}{n}
  \DeclareMathAlphabet{\mafx@mathbbmss}{U}{bbmss}{m}{n}
  \SetMathAlphabet\mafx@mathbbmss{bold}{U}{bbmss}{bx}{n}
  \DeclareMathAlphabet{\mafx@mathbbmtt}{U}{bbmtt}{m}{n}
}{}\fi
\ifdefined\mafx@mathds\let\mafx@mathbb=\mafx@mathds
\else\ifdefined\mafx@mathbbm\let\mafx@mathbb=\mafx@mathbbm
\else\ifdefined\mafx@mathbbold\let\mafx@mathbb=\mafx@mathbold
\else\let\mafx@mathbb=\mathbf\fi\fi\fi
%    \end{macrocode}

% \macro{\econst}
% \macro{\iunit}
% \macro{\piconst}
% \macro{\unitel}
% Define macros for mathematical constants:
%    \begin{macrocode}
\let\mafx@econst@class=\mathinner
\DeclareRobustCommand{\mafx@econstup}{\mafx@econst@class{\operator@font e}}
\DeclareRobustCommand{\mafx@econstit}{\mafx@econst@class{\mathnormal{e}}}
\DeclareRobustCommand{\mafx@iunitup}{{\operator@font i}}
\DeclareRobustCommand{\mafx@iunitit}{{\mathnormal{i}}}
\DeclareRobustCommand{\mafx@iunitnb}{{\mathnormal{\mathring\imath}}}
\DeclareRobustCommand{\mafx@piconstup}{{\mafx@piup}}
\DeclareRobustCommand{\mafx@piconstit}{{\mafx@piit}}
\DeclareRobustCommand{\mafx@unitelbb}{{\mafx@mathbb{1}}}
\DeclareRobustCommand{\mafx@unitelds}{{\mafx@mathds{1}}}
\DeclareRobustCommand{\mafx@uniteldsr}{{\mafx@mathdsr{1}}}
\DeclareRobustCommand{\mafx@uniteldss}{{\mafx@mathdss{1}}}
\DeclareRobustCommand{\mafx@unitelbbold}{{\mafx@mathbbold{1}}}
\DeclareRobustCommand{\mafx@unitelbbm}{{\mafx@mathbbm{1}}}
\DeclareRobustCommand{\mafx@unitelbbmss}{{\mafx@mathbbmss{1}}}
\DeclareRobustCommand{\mafx@unitelbbmtt}{{\mafx@mathbbmtt{1}}}
\DeclareRobustCommand{\mafx@unitelbf}{{\mathbf{1}}}
\DeclareRobustCommand{\mafx@unitelbfb}{{\mafx@mathbfb{1}}}
\DeclareRobustCommand{\mafx@unitelbfbx}{{\mafx@mathbfbx{1}}}
\DeclareRobustCommand{\mafx@uniteleup}{{\operator@font e}}
\DeclareRobustCommand{\mafx@uniteleit}{{\mathnormal{e}}}
\DeclareRobustCommand{\mafx@unitelEup}{{\operator@font E}}
\DeclareRobustCommand{\mafx@unitelEit}{{\mathnormal{E}}}
\DeclareRobustCommand{\mafx@unitelIup}{{\operator@font I}}
\DeclareRobustCommand{\mafx@unitelIit}{{\mathnormal{I}}}
\DeclareRobustCommand{\mafx@unitelid}{{\operator@font id}}
\DeclareRobustCommand{\mafx@unitels}{{\operator@font1}}
%    \end{macrocode}

% \macro{econst}
% \macro{numsetclass}
% \macro{iunit}
% \macro{piconst}
% \macro{unitel}
% Implement mathematical constants individually
% with the option to adjust their macro names:
%    \begin{macrocode}
\define@key{mafx@}{econst}[\econst]{\let#1=\mafx@econstup}
\define@key{mafx@}{econst*}[\econst]{\let#1=\mafx@econstit}
\define@key{mafx@}{econstclass}{\let\mafx@econst@class=#1}
\define@key{mafx@}{iunit}[\iunit]{\let#1=\mafx@iunitup}
\define@key{mafx@}{iunit*}[\iunit]{\let#1=\mafx@iunitit}
\define@key{mafx@}{iunit*nb}[\iunit]{\let#1=\mafx@iunitnb}
\define@key{mafx@}{piconst}[\piconst]{\let#1=\mafx@piconstup}
\define@key{mafx@}{piconst*}[\piconst]{\let#1=\mafx@piconstit}
\define@key{mafx@}{unitel1}[\unitel]{\let#1=\mafx@unitelbb}
\define@key{mafx@}{unitel1ds}[\unitel]{\let#1=\mafx@unitelds}
\define@key{mafx@}{unitel1dsr}[\unitel]{\let#1=\mafx@uniteldsr}
\define@key{mafx@}{unitel1dss}[\unitel]{\let#1=\mafx@uniteldss}
\define@key{mafx@}{unitel1bbm}[\unitel]{\let#1=\mafx@unitelbbm}
\define@key{mafx@}{unitel1bbmss}[\unitel]{\let#1=\mafx@unitelbbmss}
\define@key{mafx@}{unitel1bbmtt}[\unitel]{\let#1=\mafx@unitelbbmtt}
\define@key{mafx@}{unitel1bbold}[\unitel]{\let#1=\mafx@unitelbbold}
\define@key{mafx@}{unitel1bf}[\unitel]{\let#1=\mafx@unitelbf}
\define@key{mafx@}{unitel1bfb}[\unitel]{\let#1=\mafx@unitelbfb}
\define@key{mafx@}{unitel1bfbx}[\unitel]{\let#1=\mafx@unitelbfbx}
\define@key{mafx@}{unitel1*}[\unitel]{\let#1=\mafx@unitels}
\define@key{mafx@}{unitele}[\unitel]{\let#1=\mafx@uniteleup}
\define@key{mafx@}{unitele*}[\unitel]{\let#1=\mafx@uniteleit}
\define@key{mafx@}{unitelE}[\unitel]{\let#1=\mafx@unitelEup}
\define@key{mafx@}{unitelE*}[\unitel]{\let#1=\mafx@unitelEit}
\define@key{mafx@}{unitelI}[\unitel]{\let#1=\mafx@unitelIup}
\define@key{mafx@}{unitelI*}[\unitel]{\let#1=\mafx@unitelIit}
\define@key{mafx@}{unitelid}[\unitel]{\let#1=\mafx@unitelid}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Derivative Symbols.}
%
% Define macros for derivative symbols:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@derup}{{\operator@font d}}
\DeclareRobustCommand{\mafx@derit}{{\mathnormal{d}}}
\DeclareRobustCommand{\mafx@diffup}[1]{\mathinner{\mafx@derup#1}}
\DeclareRobustCommand{\mafx@diffit}[1]{\mathinner{\mafx@derit#1}}
%    \end{macrocode}

% Implement derivative symbols individually
% with the option to adjust their macro names:
%    \begin{macrocode}
\define@key{mafx@}{der}[\der]{\let#1=\mafx@derup}
\define@key{mafx@}{der*}[\der]{\let#1=\mafx@derit}
\define@key{mafx@}{diff}[\diff]{\let#1=\mafx@diffup}
\define@key{mafx@}{diff*}[\diff]{\let#1=\mafx@diffit}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Assorted Symbols.}
%
% Define macros for assorted symbols:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@order}{\mathnormal{o}}
\DeclareRobustCommand{\mafx@Order}{\mathnormal{O}}
\DeclareRobustCommand{\mafx@OrderCal}{\mathcal{O}}
\DeclareRobustCommand{\mafx@defeq}{\mathrel{\mathop:}=}
\DeclareRobustCommand{\mafx@eqdef}{=\mathrel{\mathop:}}
\DeclareRobustCommand{\mafx@lapl}{\mathnormal{\Delta}}
\DeclareRobustCommand{\mafx@dualop}{\star}
%    \end{macrocode}

% Implement assorted symbols individually
% with the option to adjust their macro names:
%    \begin{macrocode}
\define@key{mafx@}{order}[\order]{\let#1=\mafx@order}
\define@key{mafx@}{Order}[\Order]{\let#1=\mafx@Order}
\define@key{mafx@}{Order*}[\Order]{\let#1=\mafx@OrderCal}
\define@key{mafx@}{defeq}[\defeq]{\let#1=\mafx@defeq}
\define@key{mafx@}{eqdef}[\eqdef]{\let#1=\mafx@eqdef}
\define@key{mafx@}{lapl}[\lapl]{\let#1=\mafx@lapl}
\define@key{mafx@}{dualop}[\dualop]{\let#1=\mafx@dualop}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Number Sets.}
%
% \macro{\numset}
% Define macros for number sets.
% Use default font |\mathbb| if available, otherwise |\mathbf|:
%    \begin{macrocode}
\ifdefined\mathbb
\let\mafx@numset@font=\mathbb
\else
\let\mafx@numset@font=\mathbf
\fi
\DeclareRobustCommand{\mafx@numset}{\mafx@numset@font}
\DeclareRobustCommand{\mafx@numsetZ}{\mafx@numset{Z}}
\DeclareRobustCommand{\mafx@numsetQ}{\mafx@numset{Q}}
\DeclareRobustCommand{\mafx@numsetR}{\mafx@numset{R}}
\DeclareRobustCommand{\mafx@numsetC}{\mafx@numset{C}}
\DeclareRobustCommand{\mafx@numsetH}{\mafx@numset{H}}
\DeclareRobustCommand{\mafx@numsetN}{\mafx@numset{N}}
\DeclareRobustCommand{\mafx@numsetO}{\mafx@numset{O}}
%    \end{macrocode}

% \macro{numset}
% \macro{numsetfont}
% \macro{numsets}
% Implement number set font and a collection of standard number sets by name:
%    \begin{macrocode}
\define@key{mafx@}{numset}[\numset]{\let#1=\mafx@numset}
\define@key{mafx@}{numsetfont}{\let\mafx@numset@font=#1}
\define@key{mafx@}{numsets}[]{%
  \let\Integer=\mafx@numsetZ
  \let\Rational=\mafx@numsetQ
  \let\Real=\mafx@numsetR
  \let\Complex=\mafx@numsetC
  \let\Quaternion=\mafx@numsetH
  \let\Natural=\mafx@numsetN
  \let\Octonion=\mafx@numsetO
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Groups.}
%
% \macro{\grp}
% Define macros for Lie groups.
% Use oeprator font |\operator@font|:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@grp}[1]{\mafx@mathopfont{#1}}
%    \end{macrocode}

% Define macros for basic finite groups.
% Use oeprator font |\operator@font|:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@grp@perm}{\mafx@grp{S}}
\DeclareRobustCommand{\mafx@grp@alt}{\mafx@grp{A}}
\DeclareRobustCommand{\mafx@grp@dih}{\mafx@grp{D}}
\DeclareRobustCommand{\mafx@grp@cycZ}{\mafx@grp{Z}}
\DeclareRobustCommand{\mafx@grp@cycC}{\mafx@grp{C}}
%    \end{macrocode}

% Define macros for groups of Lie type:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@grp@GL}{\mafx@grp{GL}}
\DeclareRobustCommand{\mafx@grp@SL}{\mafx@grp{SL}}
\DeclareRobustCommand{\mafx@grp@PGL}{\mafx@grp{PGL}}
\DeclareRobustCommand{\mafx@grp@PSL}{\mafx@grp{PSL}}
\DeclareRobustCommand{\mafx@grp@U}{\mafx@grp{U}}
\DeclareRobustCommand{\mafx@grp@SU}{\mafx@grp{SU}}
\DeclareRobustCommand{\mafx@grp@PU}{\mafx@grp{PU}}
\DeclareRobustCommand{\mafx@grp@PSU}{\mafx@grp{PSU}}
\DeclareRobustCommand{\mafx@grp@O}{\mafx@grp{O}}
\DeclareRobustCommand{\mafx@grp@SO}{\mafx@grp{SO}}
\DeclareRobustCommand{\mafx@grp@PSO}{\mafx@grp{PSO}}
\DeclareRobustCommand{\mafx@grp@Spin}{\mafx@grp{Spin}}
\DeclareRobustCommand{\mafx@grp@Pin}{\mafx@grp{Pin}}
\DeclareRobustCommand{\mafx@grp@Sp}{\mafx@grp{Sp}}
\DeclareRobustCommand{\mafx@grp@Mp}{\mafx@grp{Mp}}
%    \end{macrocode}

% Define macros for groups related to Dynkin diagrams:
%    \begin{macrocode}
\DeclareRobustCommand{\mafx@grp@A}{\mafx@grp{A}}
\DeclareRobustCommand{\mafx@grp@B}{\mafx@grp{B}}
\DeclareRobustCommand{\mafx@grp@C}{\mafx@grp{C}}
\DeclareRobustCommand{\mafx@grp@D}{\mafx@grp{D}}
\DeclareRobustCommand{\mafx@grp@E}{\mafx@grp{E}}
\DeclareRobustCommand{\mafx@grp@F}{\mafx@grp{F}}
\DeclareRobustCommand{\mafx@grp@G}{\mafx@grp{G}}
%    \end{macrocode}

% \macro{grp}
% \macro{grpfin}
% \macro{grpcycC}
% \macro{grplie}
% \macro{grpdynkin}
% Implement Lie group and a collection of standard Lie groups by name:
%    \begin{macrocode}
\define@key{mafx@}{grp}[\grp]{\let#1=\mafx@grp}
\define@key{mafx@}{grpfin}[]{%
  \let\grpperm=\mafx@grp@perm
  \let\grpalt=\mafx@grp@alt
  \let\grpdih=\mafx@grp@dih
  \let\grpcyc=\mafx@grp@cycZ
}
\define@key{mafx@}{grpfin*}[]{%
  \let\grpperm=\mafx@grp@perm
  \let\grpalt=\mafx@grp@alt
  \let\grpdih=\mafx@grp@dih
  \let\grpcyc=\mafx@grp@cycC
}
\define@key{mafx@}{grpcycC}[\grpcyc]{\let#1=\mafx@grp@cycC}
\define@key{mafx@}{grplie}[]{%
  \let\grpGL=\mafx@grp@GL
  \let\grpSL=\mafx@grp@SL
  \let\grpPGL=\mafx@grp@PGL
  \let\grpPSL=\mafx@grp@PSL
  \let\grpU=\mafx@grp@U
  \let\grpSU=\mafx@grp@SU
  \let\grpPU=\mafx@grp@PU
  \let\grpPSU=\mafx@grp@PSU
  \let\grpO=\mafx@grp@U
  \let\grpSO=\mafx@grp@SO
  \let\grpPSO=\mafx@grp@PSO
  \let\grpSpin=\mafx@grp@Spin
  \let\grpPin=\mafx@grp@Pin
  \let\grpSp=\mafx@grp@Sp
  \let\grpMp=\mafx@grp@Mp
}
\define@key{mafx@}{grpdynkin}[]{%
  \let\grpA=\mafx@grp@A
  \let\grpB=\mafx@grp@B
  \let\grpC=\mafx@grp@C
  \let\grpD=\mafx@grp@D
  \let\grpE=\mafx@grp@E
  \let\grpF=\mafx@grp@F
  \let\grpG=\mafx@grp@G
}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Conjugation Operations.}
%
% \macro{\trans}
% \macro{\hconj}
% \macro{\conj}
% Define macros for conjugation operations:
%    \begin{macrocode}
\def\mafx@miniscript#1{\mathchoice%
  {\textstyle#1}{\textstyle#1}{\scriptscriptstyle#1}{\scriptscriptstyle#1}}
\let\mafx@trans@font=\mathsf
\DeclareRobustCommand{\mafx@transt}{{\mafx@trans@font{t}}}
\DeclareRobustCommand{\mafx@transT}{{\mafx@trans@font{T}}}
\DeclareRobustCommand{\mafx@transTs}{{\mafx@trans@font{\mafx@miniscript T}}}
\DeclareRobustCommand{\mafx@hconjh}{{\mafx@trans@font{h}}}
\DeclareRobustCommand{\mafx@hconjH}{{\mafx@trans@font{H}}}
\DeclareRobustCommand{\mafx@hconjHs}{{\mafx@trans@font{\mafx@miniscript H}}}
\DeclareRobustCommand{\mafx@trans}{\top}
\DeclareRobustCommand{\mafx@transi}{\intercal}
\DeclareRobustCommand{\mafx@hconj}{\dagger}
\DeclareRobustCommand{\mafx@conj}{\ast}
\DeclareRobustCommand{\mafx@dual}{\ast}
%    \end{macrocode}

% \macro{trans}
% \macro{hconj}
% \macro{conj}
% Implement conjugation operations individually
% with the option to adjust their macro names:
%    \begin{macrocode}
\define@key{mafx@}{transfont}{\let\mafx@trans@font=#1}
\define@key{mafx@}{trans}[\trans]{\let#1=\mafx@trans}
\define@key{mafx@}{trans*}[\trans]{\let#1=\mafx@transi}
\define@key{mafx@}{transT}[\trans]{\let#1=\mafx@transT}
\define@key{mafx@}{transT*}[\trans]{\let#1=\mafx@transTs}
\define@key{mafx@}{transt}[\trans]{\let#1=\mafx@transt}
\define@key{mafx@}{hconj}[\hconj]{\let#1=\mafx@hconj}
\define@key{mafx@}{hconjH}[\hconj]{\let#1=\mafx@hconjH}
\define@key{mafx@}{hconjH*}[\hconj]{\let#1=\mafx@hconjHs}
\define@key{mafx@}{hconjh}[\hconj]{\let#1=\mafx@hconjh}
\define@key{mafx@}{conj}[\conj]{\let#1=\mafx@conj}
\define@key{mafx@}{dual}[\dual]{\let#1=\mafx@dual}
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \paragraph{Package Options.}
%
% \macro{\ProvideMathFix}
% Implement a particular fix or option:
%    \begin{macrocode}
\newcommand{\ProvideMathFix}[1]{\setkeys{mafx@}{#1}}
%    \end{macrocode}

% Pass undeclared options on to \ctanpkg{keyval} processing:
%    \begin{macrocode}
\DeclareOption*{\expandafter\ProvideMathFix\expandafter{\CurrentOption}}
%    \end{macrocode}
%
% Process package options:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \iffalse
%</package>
% \fi
%
\endinput
