summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/phfqit/phfqit.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/phfqit/phfqit.dtx')
-rw-r--r--macros/latex/contrib/phfqit/phfqit.dtx594
1 files changed, 478 insertions, 116 deletions
diff --git a/macros/latex/contrib/phfqit/phfqit.dtx b/macros/latex/contrib/phfqit/phfqit.dtx
index 60833cd48e..5ccc6cdade 100644
--- a/macros/latex/contrib/phfqit/phfqit.dtx
+++ b/macros/latex/contrib/phfqit/phfqit.dtx
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{phfqit}
%<*package>
- [2017/08/16 v2.0 phfqit package]
+ [2021/10/08 v4.1 phfqit package]
%</package>
%
%<*driver>
@@ -75,9 +75,9 @@
% \maketitle
%
% \begin{abstract}
-% \pkgname{phfqit}---Utilities to typeset stuff in Quantum Information Theory
-% (quite biased towards theory), in particular general mathematical symbols,
-% operators, and shorthands for entropy measures.
+% \pkgname{phfqit}---Utilities to typeset stuff in Quantum Information Theory,
+% in particular general mathematical symbols, operators, and shorthands for
+% entropy measures.
% \end{abstract}
%
% \inlinetoc
@@ -98,6 +98,7 @@
% (\autoref{sec:Lie-groups-algebras})
% \item Bra-ket notation, and delimited expressions such as average, norm,
% \ldots (\autoref{sec:delimited})
+% \item Double bra-ket notation for operators (\autoref{sec:delimited})
% \item Typesetting entropy measures, including the Shannon/von Neumann entropy,
% the smooth entropies, relative entropies, as well as my coherent relative
% entropy
@@ -123,6 +124,19 @@
% \item[newReIm=\metatruefalsearg] Do not override \LaTeX{}'s default
% {\makeatletter $\phfqit@Re$ and $\phfqit@Im$} symbols by $\Re$ and $\Im$.
% See \autoref{sec:description-newReIm}.
+% \item[llanglefrommnsymbolfonts=\metatruefalsearg] In order to define the
+% operator-kets and operator-bra symbols, we need to have double-angle bracket
+% symbol delimiters loaded as |\llangle| and |\rrangle|. Unlike |\langle| and
+% |\rangle|, they are not provided by default by \pkgname{latex},
+% \pkgname{amsmath} or \pkgname{amssymb}. What we do is that we load the
+% |\llangle| and |\rrangle| symbols from the MnSymbol fonts in order to define
+% |\oket| and friends. If you would like to provide your own definitions for
+% |\llangle| and |\rrangle|, or if you have problems loading the MnSymbol
+% fonts and don't need the operator-ket symbols, then you can specify
+% |llanglefrommnsymbolfonts=false| and we won't bother loading the MnSymbol
+% fonts. (Note that if you provide your own definitions for |\llangle| and
+% |\rrangle|, they have to be valid delimiters, such that for example the
+% syntax |\left\llangle| is valid.)
% \end{pkgoptions}
%
% \changed[v2.0-pkg-opt-qitobjdef]{v2.0}{2017/08/16}{Added the
@@ -178,7 +192,7 @@
%
%
%
-% \section{General Symbols (and Math Operators)}
+% \section{General Symbols and Math Operators}
% \label{sec:symbols}
%
% \DescribeMacro{\Hs}
@@ -210,6 +224,14 @@
% symbol, or even to change the notation to |\exp{<ARGUMENT>}| if needed for
% inline math.
%
+% \DescribeMacro{\phfqitExpPowerExpression}
+% To change the appearance of whatever you typed as |\ee^{XYZ}|, you can
+% redefine |\phfqitExpPowerExpression|; for instance, to use an upright
+% ``$\mathrm{e}$'' symbol, you could type:
+% \begin{verbatim}
+% \renewcommand\phfqitExpPowerExpression[1]{\mathrm{e}^{#1}}
+% \end{verbatim}
+%
%
% \subsection{Math/Linear Algebra Operators}
% \label{sec:math-operators}
@@ -267,26 +289,60 @@
% \needspace{7\baselineskip}
% \DescribeMacro{\uu(N)} \DescribeMacro{\UU(N)} \DescribeMacro{\su(N)}
% \DescribeMacro{\SU(N)} \DescribeMacro{\so(N)} \DescribeMacro{\SO(N)}
-% \DescribeMacro{\SN(N)} Format some common Lie groups and algebras.
+% \DescribeMacro{\slalg(N)} \DescribeMacro{\SL(N)}
+% \DescribeMacro{\GL(N)} \DescribeMacro{\SN(N)}
+% Format some common Lie groups and algebras. Note the use of |\slalg| instead
+% of |\sl| because of name conflict with \TeX's font command {\sl producing
+% slanted text}.
%
% |\SN(N)| is the symmetric group of $N$ items, and formats by default as
-% $\SN(N)$. \vspace{4\baselineskip}
-%
+% $\SN(N)$.
+%
+% \DescribeMacro{\phfqitLieGroup} \DescribeMacro{\phfqitLieAlgebra}
+% \DescribeMacro{\phfqitDiscreteGroup}
+% The macros |\phfqitLieGroup|, |\phfqitLieAlgebra|, and |\phfqitDiscreteGroup|
+% format the name for a standard Lie group, Lie algebra or discrete group along
+% with its argument. Redefine these macros with |\renewcommand| to change the
+% formatting font for Lie groups and algebras for instance. For instance, to
+% format standard Lie groups/algebras and the permutation group with simple
+% italic letters, you can use:
+% \begin{verbatim}
+% \renewcommand\phfqitLieAlgebra[2]{\mathit{#1}({#2})}
+% \renewcommand\phfqitLieGroup[2]{\mathit{#1}({#2})}
+% \renewcommand\phfqitDiscreteGroup[2]{\mathit{#1}_{#2}}
+% \end{verbatim}
+%
+% \verbdef\GLNverbatim=\GL(N)=
+% \changed[v2.0]{v2.0}{2018/02/28}{Added the macro \GLNverbatim}
+% \verbdef\SLNverbatim=\slalg(n),\SL(N)=
+% \changed[v3.0]{v3.0}{2020/07/31}{Added the macros \SLNverbatim, as well
+% as \phfverb{\phfqitLieAlgebra}, \phfverb{\phfqitLieGroup}, and
+% \phfverb{\phfqitDiscreteGroup}}
+%
+% \iffalse \vspace{3\baselineskip} <-- space for all the \SU(xx) listings in margin \fi
+%
% \section{Bra-Ket Notation and Delimited Expressions}
-% \label{sec:bra-ket} \label{sec:delimited}
%
-% All commands here work in math mode only. They all accept an optional
-% argument, which is a size modifier. Use the starred form to enclose the
-% delimiters with |\left...\right| and have the size determined automatically.
-% Usage for example is:
+% \subsection{Bras and kets}
+% \label{sec:bra-ket}
+%
+% All commands here work in math mode only. They all accept a size modifier as
+% described in \autoref{topic:size-specification-backtick}. (The size may also
+% be provided as an optional argument; the starred form of the command may also
+% be used to enclose the delimiters with |\left...\right| and have the size
+% determined automatically.) Example usage is:
% \begin{center}
% \begin{tabular}{lc}
-% |\ket{\psi}| & $\ket{\psi}$ \\[1em]
-% |\ket[\big]{\psi}| & $\ket[\big]{\psi}$ \\[1em]
-% |\ket[\Big]{\psi}| & $\ket[\Big]{\psi}$ \\[1em]
-% |\ket[\bigg]{\psi}| & $\ket[\bigg]{\psi}$ \\[1em]
-% |\ket[\Bigg]{\psi}| & $\ket[\Bigg]{\psi}$ \\[1em]
-% |\ket*{\displaystyle\sum_k \psi_k}| & $\ket*{\displaystyle\sum_k \psi_k}$ \\
+% |\ket{\psi}| & $\ket{\psi}$ \\[1em]
+% |\ket`\big{\psi}|~,~~|\ket[\big]{\psi}| & $\ket`\big{\psi}$ \\[1em]
+% |\ket`\Big{\psi}|~,~~|\ket[\Big]{\psi}| & $\ket`\Big{\psi}$ \\[1em]
+% |\ket`\bigg{\psi}|~,~~|\ket[\bigg]{\psi}| & $\ket`\bigg{\psi}$ \\[1em]
+% |\ket`\Bigg{\psi}|~,~~|\ket[\Bigg]{\psi}| & $\ket`\Bigg{\psi}$ \\[1em]
+% \begin{minipage}{7cm}\relax
+% \noindent|\ket`*{\displaystyle\sum_k \psi_k}|,\\
+% \hspace*{2em}|\ket*{\displaystyle\sum_k \psi_k}|
+% \end{minipage}
+% & $\ket*{\displaystyle\sum_k \psi_k}$
% \end{tabular}
% \end{center}
%
@@ -315,17 +371,53 @@
% |\innerprod{\phi}{\psi}| gives $\innerprod{\phi}{\psi}$.
%
%
-% There are also some further delimited expressions defined, for convenience.
+% \DescribeMacro{\oket} \DescribeMacro{\obra} \DescribeMacro{\obraket}
+% \DescribeMacro{\oketbra} \DescribeMacro{\oproj} \DescribeMacro{\omatrixel}
+% \DescribeMacro{\odmatrixel} This package also provides associated
+% double-bra-ket commands as is occasionally used to write ``vectors'' in
+% Hilbert-Schmidt operator space, such as $\oket{A}$, $\obraket{A}{\Ident}$,
+% $\oketbra{\Ident}{E_k}$, etc. The commands are named |\oket|, |\obra|,
+% |\obraket|, |\oketbra|, |\oproj|, |\omatrixel|, and |\odmatrixel|.
+%
+% The commands |\oket|, |\obra|, |\obraket|, etc.\@ offer the same syntax as
+% their corresponding |\ket|, |\bra|, etc.\@ counterparts. For instance, you can
+% type |\obra`\Big{\sum A_i}| to obtain $\obra`\Big{\sum A_i}$.
+%
+% \DescribeMacro{\llangle} \DescribeMacro{\rrangle} The \pkgname{phfqit} package
+% defines the |\llangle| and |\rrangle| delimiters, by taking the relevant
+% symbols from the \pkgname{MnSymbol} fonts. These double-angle bracket symbols
+% are used for the double-bra-ket type constructs (|\oket| and friends).
+%
+% If you'd like to provide your own definition of |\llangle| and |\rrangle|, or
+% if for any reason you would not want us to attempt to load the
+% \pkgname{MnSymbol} fonts at all, then you can set the package option
+% |llanglefrommnsymbolfonts=false|.
+%
+% If you provide your own definition of |\llangle| and |\rrangle|, then make
+% sure that they are proper \TeX\ delimiters, i.e., constructs of the form
+% |\left\llangle ... \right\rrangle| or |\bigl\llangle ... \bigr\rrangle| must
+% work.
+%
+% If your document never uses the double-bra-ket macros (i.e., none of the
+% |\oket|, |\obra|, and friends), then you may safely specifiy
+% |llanglefrommnsymbolfonts=false| to avoid loading the relevant symbols.
+%
+%
+% \subsection{Delimited expressions: norms, absolute value, etc.}
+% \label{sec:delimited}
+%
+% There are also some commonly used delimited expressions defined for
+% convenience.
%
% \DescribeMacro{\abs} The absolute value of an expression. |\abs{A}| gives
% $\abs{A}$.
%
-% \DescribeMacro{\avg} The average of an expression. |\avg[\big]{\sum_k A_k}|
-% gives $\avg[\big]{\sum_k A_k}$.
+% \DescribeMacro{\avg} The average of an expression. |\avg`\big{\sum_k A_k}|
+% gives $\avg`\big{\sum_k A_k}$.
%
% \DescribeMacro{\norm} The norm of an expression. |\norm{A_k}| gives
-% $\norm{A_k}$. (You can add subscripts, e.g.\@ |\norm{A_k}_\infty| is
-% $\norm{A_k}_\infty$.)
+% $\norm{A_k}$. (If you'd like to define customized norms, e.g., to add
+% subscripts, then check out the |\phfqitDefineNorm| command discussed below.)
%
% \DescribeMacro{\intervalc} A closed interval. |\intervalc{x}{y}| gives
% $\intervalc{x}{y}$.
@@ -340,6 +432,26 @@
% and closed on the upper bound. |\intervaloc{x}{y}| gives $\intervaloc{x}{y}$.
%
%
+% \DescribeMacro{\phfqitDefineNorm} The handy command |\phfqitDefineNorm| can be
+% used to define custom norms (e.g. 1-norm, infinity-norm, p/q-norms, etc.).
+% The syntax is |\phfqitDefineNorm|\meta{command name}\meta{before}\meta{after},
+% for example:
+% \begin{verbatim}
+% \phfqitDefineNorm\onenorm{}{_1}
+% \phfqitDefineNorm\opnorm{}{_\infty}
+% \end{verbatim}
+%
+% \DescribeMacro{\phfqitDeclarePairedDelimiterXWithAltSizing}
+% \DescribeMacro{\phfqitDeclarePairedDelimiterXPPWithAltSizing} For defining
+% more advanced custom delimited expressions, you can use the
+% |\phfqitDeclarePairedDelimiterXWithAltSizing| and
+% |\phfqitDeclarePairedDelimiterXPPWithAltSizing| helpers. These macros wrap
+% the \pkgname{mathtools} package's |\DeclarePairedDelimiterX| and
+% |\DeclarePairedDelimiterX| macros, by furthermore enabling the newly defined
+% command to accept the size argument using the backtick syntax described in
+% \autoref{topic:size-specification-backtick}. These helpers are used
+% internally to define the commands for kets, bras, norms, etc.
+%
%
% \section{Entropy Measures and Other ``Qit Objects''}
%
@@ -456,9 +568,9 @@
% \label{sec:entropy-function}
%
% \DescribeMacro{\Hfn} The entropy, written as a mathematical function. It is
-% useful to write, e.g., $\Hfunc(p_1\rho_1 + p_2\rho_2)$ as \relax
-% |\Hfunc(p_1\rho_1 + p_2\rho_2)|. Sizing specifications also work, e.g.\@
-% |\Hfunc`\big(x)| or |\Hfunc`*(x)|.
+% useful to write, e.g., $\Hfn(p_1\rho_1 + p_2\rho_2)$ as \relax
+% |\Hfn(p_1\rho_1 + p_2\rho_2)|. Sizing specifications also work, e.g.\@
+% |\Hfn`\big(x)| or |\Hfn`*(x)|.
%
% Usage is: |\Hfn|\hspace{0pt}\meta{size-spec}\hspace{0pt}|(|\meta{argument}|)|
%
@@ -547,16 +659,21 @@
% \DescribeMacro{\Dr} The Rob-relative entropy. The syntax is the same as for
% |\Dmax|.
%
-% \DescribeMacro{\DHyp} The hypothesis testing relative entropy. The syntax is
-% the same as for |\Dmax|, except that by default the optional argument is
-% |\eta|. That is, |\DHyp{\rho}{\sigma}| gives $\DHyp{\rho}{\sigma}$. (This is
-% because this quantity is directly defined with a $\eta$ (or $\epsilon$) built
-% in, and it is not a zero-error quantity which is smoothed with the purified
-% distance.)
+% \DescribeMacro{\DHyp} \DescribeMacro{\Dhyp} The hypothesis testing relative
+% entropy (two possible variants). The syntax is the same as for |\Dmax|,
+% except that by default the optional argument is |\eta|. The symbols
+% `$\mathrm{H}$' and `$\mathrm{h}$' are used as subscripts, respectively, for
+% |\DHyp| and |\Dhyp|. Examples: The code |\DHyp{\rho}{\sigma}| gives
+% $\DHyp{\rho}{\sigma}$ and |\Dhyp[\eta']{\rho}{\sigma}| gives
+% $\Dhyp[\eta']{\rho}{\sigma}$. (This is because this quantity is directly
+% defined with a $\eta$ (or $\epsilon$) built in, and it is not a zero-error
+% quantity which is smoothed with the purified distance.)
+%
+% The commands |\DD|, |\Dmax|, |\Dminz|, |\Dminf|, |\Dr|, |\DHyp| and |\Dhyp|
+% are defined only if the package option \pkgoptionfmt{qitobjdef=stdset} is set
+% (which is the default).
%
-% The commands |\DD|, |\Dmax|, |\Dminz|, |\Dminf|, |\Dr| and |\DHyp| are defined
-% only if the package option \pkgoptionfmt{qitobjdef=stdset} is set (which is
-% the default).
+% \changedreftext{v3.1-added-Dhyp-qitobjdef-stdset}
%
% \DescribeMacro{\DSym} The symbol to use to denote a relative entropy. You
% may redefine this command to change the symbol. (This works like |\HSym|
@@ -847,6 +964,7 @@
\RequirePackage{calc}
\RequirePackage{etoolbox}
\RequirePackage{amsmath}
+\RequirePackage{amssymb}
\RequirePackage{dsfont}
\RequirePackage{mathrsfs}
\RequirePackage{mathtools}
@@ -929,8 +1047,24 @@
% \begingroup\catcode`\^=12\relax
% \begin{macro}{\ee^...}
% Macro for the exponential.
+%
+% Because the character |^| might have different catcodes (e.g. with the
+% \pkgname{breqn} package), we use a hack with |\detokenize|. Basically this
+% boils down to |\def\ee^#1{\phfqitExpPowerExpression{#1}}| and
+% |\def\phfqitExpPowerExpression#1{e^{#1}}|, up to making sure that all the
+% |^| symbols are compared without catcodes.
+%
+% \changed[v4.0-fixed-ee-for-catcodes]{v4.0}{2021/10/07}{Fixed the definition
+% of \phfverb{\ee} in order to support the case where the catcode of
+% \phfverb{^} changes}
% \begin{macrocode}
-\def\ee^#1{e^{#1}} % we could imagine that in inlines, we replace this by exp()...
+\edef\phfqit@def@hat{\detokenize{^}}
+\expandafter\def\expandafter\phfqit@ee@gobblehat\phfqit@def@hat{%
+ \phfqitExpPowerExpression}
+\def\phfqitExpPowerExpression#1{e^{#1}}
+\def\ee#1{\expandafter\phfqit@ee@gobblehat\detokenize{#1}}
+\robustify\phfqitExpPowerExpression
+\robustify\ee
% \end{macrocode}
% \end{macro}
% \endgroup
@@ -1084,16 +1218,22 @@
% \begin{macro}{\SU(N)}
% \begin{macro}{\so(N)}
% \begin{macro}{\SO(N)}
+% \begin{macro}{\slalg(N)}
+% \begin{macro}{\SL(N)}
+% \begin{macro}{\GL(N)}
% \begin{macro}{\SN(N)}
% Some Lie Groups \& Algebras. See \autoref{sec:Lie-groups-algebras}
% \begin{macrocode}
-\def\uu(#1){\phfqit@fmtLieAlgebra{u}(#1)}
-\def\UU(#1){\phfqit@fmtGroup{U}(#1)}
-\def\su(#1){\phfqit@fmtLieAlgebra{su}(#1)}
-\def\SU(#1){\phfqit@fmtGroup{SU}(#1)}
-\def\so(#1){\phfqit@fmtLieAlgebra{so}(#1)}
-\def\SO(#1){\phfqit@fmtGroup{SO}(#1)}
-\def\SN(#1){\mathrm{S}_{#1}}
+\def\uu(#1){\phfqitLieAlgebra{u}{#1}}
+\def\UU(#1){\phfqitLieGroup{U}{#1}}
+\def\su(#1){\phfqitLieAlgebra{su}{#1}}
+\def\SU(#1){\phfqitLieGroup{SU}{#1}}
+\def\so(#1){\phfqitLieAlgebra{so}{#1}}
+\def\SO(#1){\phfqitLieGroup{SO}{#1}}
+\def\slalg(#1){\phfqitLieAlgebra{sl}{#1}} % \sl is "slanted font" in TeX
+\def\SL(#1){\phfqitLieGroup{SL}{#1}}
+\def\GL(#1){\phfqitLieGroup{GL}{#1}}
+\def\SN(#1){\phfqitDiscreteGroup{S}{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1102,26 +1242,131 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\phfqit@fmtLieAlgebra}
-% \begin{macro}{\phfqit@fmtLieGroup}
-% Override these to change the appearance of the group names or algebra names. The
-% argument is the name of the group or algebra (e.g. |su| or |SU|).
+% \begin{macro}{\phfqitLieAlgebra}
+% \begin{macro}{\phfqitLieGroup}
+% \begin{macro}{\phfqitDiscreteGroup}
+% Override these to change the appearance of the group names or algebra names.
+% The first argument is the name of the group or algebra (e.g. |su| or |SU|),
+% and the second argument is the parenthesized argument e.g. ``N''.
% \begin{macrocode}
-\def\phfqit@fmtLieAlgebra#1{\mathrm{#1}}
-\def\phfqit@fmtGroup#1{\mathrm{#1}}
+\newcommand\phfqitLieAlgebra[2]{\mathfrak{#1}({#2})}
+\newcommand\phfqitLieGroup[2]{\mathrm{#1}({#2})}
+\newcommand\phfqitDiscreteGroup[2]{\mathrm{#1}_{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
+%
+%
%
%
%
+% \subsection{Helper for parsing a size argument}
+%
+% \begin{macro}{\phfqit@parsesizearg}
+% Utility to parse size argument with the backtick specification
+% (\autoref{topic:size-specification-backtick}).
+%
+% Parses a size argument, if any, and stores it into |\phfqit@val@sizearg|.
+% The value stored can directly be expanded as an optional argument to a
+% |\DeclarePairedDelimiter|-compatible command (see \pkgname{mathtools} package).
+%
+% |#1| should be a command token. It is the next action to take, after
+% argument has been parsed.
+% \begin{macrocode}
+\def\phfqit@parsesizearg#1{%
+ \begingroup%
+ \mathcode`\`="0060\relax%
+ \gdef\phfqit@val@sizearg{}%
+ \def\phfqit@tmp@contwithsize{\phfqit@parsesizearg@withsize{#1}}%
+ \@ifnextchar`{\phfqit@tmp@contwithsize}{\endgroup#1}%
+}
+\def\phfqit@parsesizearg@withsize#1`#2{%
+ \def\phfqit@tmp@x{#2}%
+ \def\phfqit@tmp@star{*}%
+ \ifx\phfqit@tmp@x\phfqit@tmp@star%
+ \gdef\phfqit@val@sizearg{*}%
+ \def\phfqit@tmp@cont{\endgroup#1}%
+ \expandafter\phfqit@tmp@cont%
+ \else%
+ \gdef\phfqit@val@sizearg{[#2]}%
+ \def\phfqit@tmp@cont{\endgroup#1}%
+ \expandafter\phfqit@tmp@cont%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\phfqitDeclarePairedDelimiterXWithAltSizing}
+% \begin{macro}{\phfqitDeclarePairedDelimiterXPPWithAltSizing}
+% Macros that behave exactly like \pkgname{mathtools}'
+% |\DeclarePairedDelimiterX| and |\DeclarePairedDelimiterXPP|, except that
+% their size argument can also be specified by a backtick as for entropy
+% measures or other objects in this package (e.g., to define |\abs| such that
+% |$\abs`\Big{x - y}$| gives $\abs`\Big{x - y}$).
+% \changed[v4.0-new-phfqitDeclarePairedDelimiterxxx]{v4.0}{2021/10/07}{Added
+% \phfverb{\phfqitDeclarePairedDelimiterXWithAltSizing} and
+% \phfverb{\phfqitDeclarePairedDelimiterXPPWithAltSizing}}
+% \begin{macrocode}
+\def\phfqitDeclarePairedDelimiterXWithAltSizing{%
+ \phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing\DeclarePairedDelimiterX
+}
+\def\phfqitDeclarePairedDelimiterXPPWithAltSizing{%
+ \phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing\DeclarePairedDelimiterXPP
+}
+\def\phfqitDeclareMathtoolsPairedDelimiterCmdWithAltSizing#1#2{%
+ \begingroup
+ \escapechar=-1\relax
+ \xdef\phfqit@tmp@thecmd{%
+ \expandafter\noexpand\csname phfqit@paireddelim@def@\string#2\endcsname}%
+ \endgroup
+ \edef\x{%
+ \noexpand\phfqit@paireddelim@parsesizearg{\expandonce\phfqit@tmp@thecmd}%
+ }%
+ \expandafter\DeclareRobustCommand\expandafter#2\expandafter{\x}%
+ \expandafter#1\phfqit@tmp@thecmd
+}
+\def\phfqit@paireddelim@parsesizearg#1{%
+ \phfqit@parsesizearg{\expandafter#1\phfqit@val@sizearg}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
%
%
% \subsection{Bra-Ket Notation}
%
-%
-% \needspace{8\baselineskip}
+%
+% \begin{macro}{\phfqitKetsBarSpace}
+% \begin{macro}{\phfqitKetsRLAngleSpace}
+% These macros can be redefined to fine-tune the space that is inserted in
+% some of the ket/bra constructs.
+%
+% |\phfqitKetsBarSpace| is the space around the vertical bars, e.g., in a
+% bra-ket, or in matrix elements. (Previously, this space was hard-coded to
+% |\hspace*{0.2ex}|. Now, the spacing can be specified in this macro. We
+% furthermore use ``math units'' (|mu|), which are more suitable for
+% specifying space in math mode; recall that $1\,\mathrm{mu}$ is
+% $1/18\,\mathrm{em}$ in the math font.)
+% \begin{macrocode}
+\def\phfqitKetsBarSpace{\mkern 1.5mu\relax}
+% \end{macrocode}
+% The macro |\phfqitKetsRLAngleSpace| specifies the space between the right
+% angle bracket and the left angle bracket in ket-bra type constructs
+% ($\ketbra\phi\psi$). By default, it expands to negative space to bring the
+% angle brackets closer together. (Previously, this space was hard-coded to
+% |\hspace*{-0.25ex}|.)
+% \begin{macrocode}
+\def\phfqitKetsRLAngleSpace{\mkern -1.8mu\relax}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \needspace{7\baselineskip}
% \begin{macro}{\ket}
% \begin{macro}{\bra}
% \begin{macro}{\braket}
@@ -1129,36 +1374,105 @@
% \begin{macro}{\proj}
% \begin{macro}{\matrixel}
% \begin{macro}{\dmatrixel}
-% \begin{macro}{\innerprod}
% Bras, kets, norms, some delimiter stuff. User documentation in
% \autoref{sec:bra-ket}.
% \begin{macrocode}
-\DeclarePairedDelimiterX\ket[1]{\lvert}{\rangle}{{#1}}
-\DeclarePairedDelimiterX\bra[1]{\langle}{\rvert}{{#1}}
-\DeclarePairedDelimiterX\braket[2]{\langle}{\rangle}{%
- {#1}\hspace*{0.2ex}\delimsize\vert\hspace*{0.2ex}{#2}%
+\phfqitDeclarePairedDelimiterXWithAltSizing\ket[1]{\lvert}{\rangle}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\bra[1]{\langle}{\rvert}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\braket[2]{\langle}{\rangle}{%
+ {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
}
-\DeclarePairedDelimiterX\ketbra[2]{\lvert}{\rvert}{%
- {#1}\delimsize\rangle\hspace*{-0.25ex}\delimsize\langle{#2}%
+\phfqitDeclarePairedDelimiterXWithAltSizing\ketbra[2]{\lvert}{\rvert}{%
+ {#1}\delimsize\rangle\phfqitKetsRLAngleSpace\delimsize\langle{#2}%
}
-\DeclarePairedDelimiterX\proj[1]{\lvert}{\rvert}{%
- {#1}\delimsize\rangle\hspace*{-0.25ex}\delimsize\langle{#1}%
+\phfqitDeclarePairedDelimiterXWithAltSizing\proj[1]{\lvert}{\rvert}{%
+ {#1}\delimsize\rangle\phfqitKetsRLAngleSpace\delimsize\langle{#1}%
}
-\DeclarePairedDelimiterX\matrixel[3]{\langle}{\rangle}{%
- {#1}\hspace*{0.2ex}\delimsize\vert\hspace*{0.2ex}{#2}%
- \hspace*{0.2ex}\delimsize\vert\hspace*{0.2ex}{#3}%
+\phfqitDeclarePairedDelimiterXWithAltSizing\matrixel[3]{\langle}{\rangle}{%
+ {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
+ \phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#3}%
}
-\DeclarePairedDelimiterX\dmatrixel[2]{\langle}{\rangle}{%
- {#1}\hspace*{0.2ex}\delimsize\vert\hspace*{0.2ex}{#2}%
- \hspace*{0.2ex}\delimsize\vert\hspace*{0.2ex}{#1}%
+\phfqitDeclarePairedDelimiterXWithAltSizing\dmatrixel[2]{\langle}{\rangle}{%
+ {#1}\phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#2}%
+ \phfqitKetsBarSpace\delimsize\vert\phfqitKetsBarSpace{#1}%
}
-\DeclarePairedDelimiterX\innerprod[2]{\langle}{\rangle}{%
- {#1},\hspace*{0.2ex}{#2}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\phfqitKetsBeforeCommaSpace}
+% \begin{macro}{\phfqitKetsAfterCommaSpace}
+% \begin{macro}{\innerprod}
+% We also provide the |\innerprod| macro at this point. Customize the inner
+% spacing before and after the comma with |\phfqitKetsBeforeCommaSpace| and
+% |\phfqitKetsAfterCommaSpace|.
+% \begin{macrocode}
+\def\phfqitKetsBeforeCommaSpace{}
+\def\phfqitKetsAfterCommaSpace{\mkern 1.5mu\relax}
+\phfqitDeclarePairedDelimiterXWithAltSizing\innerprod[2]{\langle}{\rangle}{%
+ {#1}\phfqitKetsBeforeCommaSpace,\phfqitKetsAfterCommaSpace{#2}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+%
+% \begin{macro}{\phfqitOKetsBarSpace}
+% \begin{macro}{\phfqitOKetsRLAngleSpace}
+% These macros are the same as |\phfqitKetsBarSpace| and
+% |\phfqitKetsRLAngleSpace|, except that they specify the corresponding
+% spacing for the |\oket| family of bra/ket-type constructs.
+% \begin{macrocode}
+\def\phfqitOKetsBarSpace{\phfqitKetsBarSpace}
+\def\phfqitOKetsRLAngleSpace{\phfqitKetsRLAngleSpace}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \needspace{8\baselineskip}
+% \begin{macro}{\oket}
+% \begin{macro}{\obra}
+% \begin{macro}{\obraket}
+% \begin{macro}{\oketbra}
+% \begin{macro}{\oproj}
+% \begin{macro}{\omatrixel}
+% \begin{macro}{\odmatrixel}
+% Again Bras, kets, but for operator space this time. User documentation in
+% \autoref{sec:bra-ket}. These definitions depend on |\llangle| and
+% |\rrangle| being available and expanding to valid delimiter symbols. See
+% also the |llanglefrommnsymbolfonts| option.
+%
+% \changed[v4.1-okets-obras]{v4.1}{2021/10/08}{Added support for
+% \phfverb{\oket} and friends}
+% \begin{macrocode}
+\phfqitDeclarePairedDelimiterXWithAltSizing\oket[1]{\lvert}{\rrangle}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\obra[1]{\llangle}{\rvert}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\obraket[2]{\llangle}{\rrangle}{%
+ {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
+}
+\phfqitDeclarePairedDelimiterXWithAltSizing\oketbra[2]{\lvert}{\rvert}{%
+ {#1}\delimsize\rrangle\phfqitOKetsRLAngleSpace\delimsize\llangle{#2}%
+}
+\phfqitDeclarePairedDelimiterXWithAltSizing\oproj[1]{\lvert}{\rvert}{%
+ {#1}\delimsize\rrangle\phfqitOKetsRLAngleSpace\delimsize\llangle{#1}%
+}
+\phfqitDeclarePairedDelimiterXWithAltSizing\omatrixel[3]{\llangle}{\rrangle}{%
+ {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
+ \phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#3}%
+}
+\phfqitDeclarePairedDelimiterXWithAltSizing\odmatrixel[2]{\llangle}{\rrangle}{%
+ {#1}\phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#2}%
+ \phfqitOKetsBarSpace\delimsize\vert\phfqitOKetsBarSpace{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
@@ -1174,14 +1488,30 @@
% \begin{macro}{\norm}
% Other delimited expressions.
% \begin{macrocode}
-\DeclarePairedDelimiterX\abs[1]{\lvert}{\rvert}{{#1}}
-\DeclarePairedDelimiterX\avg[1]{\langle}{\rangle}{{#1}}
-\DeclarePairedDelimiterX\norm[1]{\lVert}{\rVert}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\abs[1]{\lvert}{\rvert}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\avg[1]{\langle}{\rangle}{{#1}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\norm[1]{\lVert}{\rVert}{{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\phfqitDefineNorm}
+% Use |\phfqitDefineNorm\opnorm{}{_\infty}| to define specific norms, with the
+% syntax |\phfqitDefineNorm|\meta{new command name}\meta{tokens
+% before}\meta{tokens after}. If you need arguments in the before/after
+% tokens, then your norm starts to be more complicated than what
+% |\phfqitDefineNorm| can handle, perhaps it's best you use
+% |\phfqitDeclarePairedDelimiterXPPWithAltSizing| directly.
+%
+% \changed[v4.0-new-phfqitDefineNorm]{v4.0}{2021/10/07}{Added
+% \phfverb{\phfqitDefineNorm}}
+% \begin{macrocode}
+\def\phfqitDefineNorm#1#2#3{%
+ \phfqitDeclarePairedDelimiterXPPWithAltSizing#1[1]{#2}{\lVert}{\rVert}{#3}{{##1}}%
+}
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\phfqit@insideinterval}
% Format the contents of an interval. Utility for defining |\intervalc| and
@@ -1198,10 +1528,14 @@
% \begin{macro}{\intervaloc}
% Open/Closed/Semi-Open Intervals
% \begin{macrocode}
-\DeclarePairedDelimiterX\intervalc[2]{[}{]}{\phfqit@insideinterval{#1}{#2}}
-\DeclarePairedDelimiterX\intervalo[2]{]}{[}{\phfqit@insideinterval{#1}{#2}}
-\DeclarePairedDelimiterX\intervalco[2]{[}{[}{\phfqit@insideinterval{#1}{#2}}
-\DeclarePairedDelimiterX\intervaloc[2]{]}{]}{\phfqit@insideinterval{#1}{#2}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\intervalc[2]{[}{]}{%
+ \phfqit@insideinterval{#1}{#2}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\intervalo[2]{]}{[}{%
+ \phfqit@insideinterval{#1}{#2}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\intervalco[2]{[}{[}{%
+ \phfqit@insideinterval{#1}{#2}}
+\phfqitDeclarePairedDelimiterXWithAltSizing\intervaloc[2]{]}{]}{%
+ \phfqit@insideinterval{#1}{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1218,43 +1552,9 @@
%
% \subsubsection{Some Internal Utilities}
%
-% \begin{macro}{\phfqit@parsesizearg}
-% Internal utility to parse size argument with the backtick specification
-% (\autoref{topic:size-specification-backtick}).
-%
-% Parses a size argument, if any, and stores it into |\phfqit@val@sizearg|.
-% The value stored can directly be expanded as an optional argument to a
-% |\DeclarePairedDelimiter|-compatible command (see \pkgname{mathtools} package).
-%
-% |#1| should be a command token. It is the next action to take, after
-% argument has been parsed.
-% \begin{macrocode}
-\def\phfqit@parsesizearg#1{%
- \begingroup%
- \mathcode`\`="0060\relax%
- \gdef\phfqit@val@sizearg{}%
- \def\phfqit@tmp@contwithsize{\phfqit@parsesizearg@withsize{#1}}%
- \@ifnextchar`{\phfqit@tmp@contwithsize}{\endgroup#1}%
-}
-\def\phfqit@parsesizearg@withsize#1`#2{%
- \def\phfqit@tmp@x{#2}%
- \def\phfqit@tmp@star{*}%
- \ifx\phfqit@tmp@x\phfqit@tmp@star%
- \gdef\phfqit@val@sizearg{*}%
- \def\phfqit@tmp@cont{\endgroup#1}%
- \expandafter\phfqit@tmp@cont%
- \else%
- \gdef\phfqit@val@sizearg{[#2]}%
- \def\phfqit@tmp@cont{\endgroup#1}%
- \expandafter\phfqit@tmp@cont%
- \fi%
-}
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\phfqitParens}
% Simple parenthesis-delimited expression, with
-% |\DeclarePairedDelimiter|-compatible syntax. For example,
+% |\DeclarePairedDelimiterX|-compatible syntax. For example,
% \par |\phfqitParens|\marg{content} \quad$\to$\quad
% \fbox{\phfverb( \meta{content} \phfverb)}
% \par |\phfqitParens*|\marg{content} \quad$\to$\quad
@@ -1269,7 +1569,7 @@
%
% \begin{macro}{\phfqitSquareBrackets}
% Simple bracket-delimited expression, with
-% |\DeclarePairedDelimiter|-compatible syntax. For example,
+% |\DeclarePairedDelimiterX|-compatible syntax. For example,
% \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
% \fbox{\phfverb[ \meta{content} \phfverb]}
% \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
@@ -1284,7 +1584,7 @@
%
% \begin{macro}{\phfqitCurlyBrackets}
% Simple bracket-delimited expression, with
-% |\DeclarePairedDelimiter|-compatible syntax. For example,
+% |\DeclarePairedDelimiterX|-compatible syntax. For example,
% \par |\phfqitSquareBrackets|\marg{content} \quad$\to$\quad
% \fbox{\phfverb\{ \meta{content} \phfverb\}}
% \par |\phfqitSquareBrackets*|\marg{content} \quad$\to$\quad
@@ -1940,10 +2240,19 @@
% \end{macrocode}
% \ldots{} add conditional system, if specified:
% \begin{macrocode}
- \notblank{#3#4}{%
+ \notblank{#3}{%
\DCohbase@addtoks\mathclose{}\,\delimsize\Vert\,\mathopen{}%
- #3\mathclose{},\mathopen{}#4\@DCohbase@END@ADD@TOKS%
- }{}%
+ #3\@DCohbase@END@ADD@TOKS%
+ \notblank{#4}{%
+ \DCohbase@addtoks\mathclose{},\mathopen{}%
+ #4\@DCohbase@END@ADD@TOKS%
+ }{}%
+ }{%
+ \notblank{#4}{%
+ \PackageWarning{phfqit}{Value `#4' ignored because previous parameter
+ was blank}%
+ }{}%
+ }
% \end{macrocode}
% The tokens are ready now. Prepare the argument to the command
% |\DCohbaseRenderContentsInnerParens| (by default just |\phfqitParens|), and go:
@@ -2041,6 +2350,12 @@
\DeclareStringOption[stdset]{qitobjdef}
% \end{macrocode}
%
+% Whether we should load the |\llangle| and |\rrangle| delimiters from the
+% MnSymbol fonts.
+% \begin{macrocode}
+\DeclareBoolOption[true]{llanglefrommnsymbolfonts}
+% \end{macrocode}
+%
% Whether to override \LaTeX{}'s default {\makeatletter $\phfqit@Re$ and
% $\phfqit@Im$} symbols by our more readable $\Re$ and $\Im$.
% \begin{macrocode}
@@ -2069,6 +2384,44 @@
% \end{macro}
% \end{macro}
%
+% \subsubsection{Load \phfverb{\llangle} and \phfverb{\rrangle} from the
+% \emph{MnSymbol} fonts}
+%
+% We need to import |\llangle| and |\rrangle| from the |MnSymbol|
+% fonts.\footnote{see e.g. \url{https://tex.stackexchange.com/a/79701/32188}}
+%
+% \begin{macrocode}
+\ifphfqit@opt@llanglefrommnsymbolfonts
+ \DeclareFontFamily{OMX}{MnSymbolE}{}
+ \DeclareSymbolFont{phfqit@MnLargeSymbols}{OMX}{MnSymbolE}{m}{n}
+ \SetSymbolFont{phfqit@MnLargeSymbols}{bold}{OMX}{MnSymbolE}{b}{n}
+ \DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
+ <-6> MnSymbolE5
+ <6-7> MnSymbolE6
+ <7-8> MnSymbolE7
+ <8-9> MnSymbolE8
+ <9-10> MnSymbolE9
+ <10-12> MnSymbolE10
+ <12-> MnSymbolE12
+ }{}
+ \DeclareFontShape{OMX}{MnSymbolE}{b}{n}{
+ <-6> MnSymbolE-Bold5
+ <6-7> MnSymbolE-Bold6
+ <7-8> MnSymbolE-Bold7
+ <8-9> MnSymbolE-Bold8
+ <9-10> MnSymbolE-Bold9
+ <10-12> MnSymbolE-Bold10
+ <12-> MnSymbolE-Bold12
+ }{}
+ \let\llangle\@undefined
+ \let\rrangle\@undefined
+ \DeclareMathDelimiter{\llangle}{\mathopen}%
+ {phfqit@MnLargeSymbols}{'164}{phfqit@MnLargeSymbols}{'164}
+ \DeclareMathDelimiter{\rrangle}{\mathclose}%
+ {phfqit@MnLargeSymbols}{'171}{phfqit@MnLargeSymbols}{'171}
+\fi
+% \end{macrocode}
+%
% \subsubsection{Standard entropy measures}
%
% Load the requested set of qit objects.
@@ -2150,6 +2503,15 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\Dhyp}
+% Hypothesis testing relative entropy (alternative definition).
+% \changed[v3.1-added-Dhyp-qitobjdef-stdset]{v3.1}{2021/07/27}{Added the
+% \phfverb{\Dhyp} variant of the hypothesis testing relative entropy}
+% \begin{macrocode}
+\newcommand\Dhyp[1][\eta]{\Dbase{\DSym}_{\mathrm{h}}^{#1}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\DCoh}
% Coherent relative entropy (old style).
% \begin{macrocode}