From e7c703c953f148411c70d5ca86dc1c1023d73806 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 27 Oct 2023 03:03:08 +0000 Subject: CTAN sync 202310270303 --- macros/latex/contrib/physics2/README.md | 3 +- macros/latex/contrib/physics2/doc/phy2docdef.tex | 70 - .../latex/contrib/physics2/doc/physics2-legacy.pdf | Bin 82817 -> 0 bytes .../latex/contrib/physics2/doc/physics2-legacy.tex | 540 -------- macros/latex/contrib/physics2/doc/physics2.pdf | Bin 87994 -> 0 bytes macros/latex/contrib/physics2/doc/physics2.tex | 569 --------- macros/latex/contrib/physics2/phy2docdef.tex | 70 + macros/latex/contrib/physics2/physics2-code.dtx | 1345 ++++++++++++++++++++ macros/latex/contrib/physics2/physics2-code.pdf | Bin 0 -> 137994 bytes macros/latex/contrib/physics2/physics2-legacy.pdf | Bin 0 -> 82674 bytes macros/latex/contrib/physics2/physics2-legacy.tex | 544 ++++++++ macros/latex/contrib/physics2/physics2.ins | 104 ++ macros/latex/contrib/physics2/physics2.pdf | Bin 0 -> 88146 bytes macros/latex/contrib/physics2/physics2.tex | 575 +++++++++ .../latex/contrib/physics2/tex/phy-ab.braket.sty | 84 -- .../latex/contrib/physics2/tex/phy-ab.legacy.sty | 43 - macros/latex/contrib/physics2/tex/phy-ab.sty | 111 -- .../contrib/physics2/tex/phy-bm-um.legacy.sty | 62 - macros/latex/contrib/physics2/tex/phy-braket.sty | 110 -- macros/latex/contrib/physics2/tex/phy-common.sty | 68 - macros/latex/contrib/physics2/tex/phy-diagmat.sty | 92 -- .../latex/contrib/physics2/tex/phy-doubleprod.sty | 40 - .../latex/contrib/physics2/tex/phy-explsetup.sty | 29 - .../contrib/physics2/tex/phy-nabla.legacy.sty | 32 - .../latex/contrib/physics2/tex/phy-op.legacy.sty | 51 - .../contrib/physics2/tex/phy-qtext.legacy.sty | 52 - macros/latex/contrib/physics2/tex/phy-xmat.sty | 148 --- macros/latex/contrib/physics2/tex/physics2.sty | 70 - 28 files changed, 2640 insertions(+), 2172 deletions(-) delete mode 100644 macros/latex/contrib/physics2/doc/phy2docdef.tex delete mode 100644 macros/latex/contrib/physics2/doc/physics2-legacy.pdf delete mode 100644 macros/latex/contrib/physics2/doc/physics2-legacy.tex delete mode 100644 macros/latex/contrib/physics2/doc/physics2.pdf delete mode 100644 macros/latex/contrib/physics2/doc/physics2.tex create mode 100644 macros/latex/contrib/physics2/phy2docdef.tex create mode 100644 macros/latex/contrib/physics2/physics2-code.dtx create mode 100644 macros/latex/contrib/physics2/physics2-code.pdf create mode 100644 macros/latex/contrib/physics2/physics2-legacy.pdf create mode 100644 macros/latex/contrib/physics2/physics2-legacy.tex create mode 100644 macros/latex/contrib/physics2/physics2.ins create mode 100644 macros/latex/contrib/physics2/physics2.pdf create mode 100644 macros/latex/contrib/physics2/physics2.tex delete mode 100644 macros/latex/contrib/physics2/tex/phy-ab.braket.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-ab.legacy.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-ab.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-bm-um.legacy.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-braket.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-common.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-diagmat.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-doubleprod.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-explsetup.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-nabla.legacy.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-op.legacy.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-qtext.legacy.sty delete mode 100644 macros/latex/contrib/physics2/tex/phy-xmat.sty delete mode 100644 macros/latex/contrib/physics2/tex/physics2.sty (limited to 'macros/latex/contrib/physics2') diff --git a/macros/latex/contrib/physics2/README.md b/macros/latex/contrib/physics2/README.md index f8efc73124..6cdfe86e8a 100644 --- a/macros/latex/contrib/physics2/README.md +++ b/macros/latex/contrib/physics2/README.md @@ -24,4 +24,5 @@ either version 1.3c of this license or (at your option) any later version. This work has the LPPL maintenance status `maintained`. The Current Maintainer of this work is -[Zhang Tingxuan](https://www.ctan.org/author/zhang-tx). \ No newline at end of file +[Zhang Tingxuan](https://www.ctan.org/author/zhang-tx). + diff --git a/macros/latex/contrib/physics2/doc/phy2docdef.tex b/macros/latex/contrib/physics2/doc/phy2docdef.tex deleted file mode 100644 index 53fb2f9dea..0000000000 --- a/macros/latex/contrib/physics2/doc/phy2docdef.tex +++ /dev/null @@ -1,70 +0,0 @@ -%% This is part of physics2 documentation. -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * http://www.latex-project.org/lppl.txt * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -\makeatletter -\usepackage[nohyperref]{doc} -\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.1em}} -\def\contentsonly{\@starttoc{toc}} -\usepackage{manfnt} -\protected\def\pardanger{\ifnum\lastnodetype=1% - \leavevmode\hbox to \z@{\hss\dbend\hskip10pt\hskip\parindent}\else - \ifnum\lastnodetype=11% - \leavevmode\hbox to \z@{\hss\dbend\hskip10pt}% - \fi\fi\ignorespaces} -\usepackage{hyperref,color,xr} -\definecolor{pkgcolor}{RGB}{0,120,80} -\definecolor{moducolor}{RGB}{0,0,150} -\hypersetup{colorlinks,urlcolor=magenta,linkcolor=black,filecolor=blue, - pdfstartview=FitH,pdfview=FitH,pdfcreator=XeTeX output} -\def\s@pkg#1{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}} -\def\@pkg#1{\texorpdfstring{\hyperref{https://www.ctan.org/pkg/#1}% - {}{}{\textcolor{pkgcolor}{\textsf{#1}}}}{“#1”}} -\DeclareRobustCommand\pkg{\@ifstar\@pkg\s@pkg} -\def\modu#1{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}} -\def\opt#1{\texorpdfstring{\texttt{#1}}{“#1”}} -\protected\def\marg#1{\texttt\{\meta{#1}\texttt\}} -\protected\def\oarg#1{\texttt[\meta{#1}\texttt]} -\parindent2.4em -\linespread{1.06} -\usepackage{multicol,fancyvrb,verbatim,array,hologo} -\fvset{xleftmargin=\parindent} -\newenvironment{displayed}{\trivlist\item[]\leftskip\parindent\relax}{\endtrivlist} -\usepackage[normalem]{ulem} -\newcounter{example}[subsection] -\renewcommand\theexample{\thesubsection.\arabic{example}} -\newwrite\example@out -\def\example@name{\jobname.example.aux} -\long\def\example@start{\begingroup\@bsphack - \immediate\openout\example@out=\example@name - \let\do\@makeother\dospecials\catcode`\^^M\active - \def\verbatim@processline{\immediate\write\example@out{\the\verbatim@line}}% - \verbatim@start} -\long\def\example@end{\immediate\closeout\example@out\@esphack\endgroup% - \trivlist\item[]\relax - \leavevmode\hbox to \z@{% - \hbox to \z@{\hss{\footnotesize[\theexample]}\hskip10pt}% - \hskip\parindent - \begin{minipage}[c]{0.55\textwidth}% - \small\verbatiminput{\example@name}% - \end{minipage}% - \fbox{% - \begin{minipage}[c]{0.5\textwidth}% - \normalsize\input{\example@name}% - \end{minipage}% - }% - \hss}% - \endtrivlist} -\newenvironment{example*}[1]% - {\refstepcounter{example}\label{#1}\example@start}{\example@end} -\newenvironment{example} - {\stepcounter{example}\example@start}{\example@end} -\author{Zhang Tingxuan} -\date{2023/04/02\quad Version 0.2.1\thanks{% - \url{https://www.github.com/AlphaZTX/physics2}}} -\makeatother -\endinput \ No newline at end of file diff --git a/macros/latex/contrib/physics2/doc/physics2-legacy.pdf b/macros/latex/contrib/physics2/doc/physics2-legacy.pdf deleted file mode 100644 index cee629a676..0000000000 Binary files a/macros/latex/contrib/physics2/doc/physics2-legacy.pdf and /dev/null differ diff --git a/macros/latex/contrib/physics2/doc/physics2-legacy.tex b/macros/latex/contrib/physics2/doc/physics2-legacy.tex deleted file mode 100644 index d1b64a4374..0000000000 --- a/macros/latex/contrib/physics2/doc/physics2-legacy.tex +++ /dev/null @@ -1,540 +0,0 @@ -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * http://www.latex-project.org/lppl.txt * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -\documentclass[11pt,letterpaper]{article} -\usepackage{amsmath} -\usepackage{unicode-math} -\setmainfont{Libertinus Serif} -\setsansfont{Libertinus Sans} -\setmonofont{Noto Sans Mono}[Scale=MatchLowercase] -\setmathfont{Libertinus Math} -\usepackage{physics2} -\usephysicsmodule{ab} -\usephysicsmodule{ab.legacy,nabla.legacy} -\usephysicsmodule{op.legacy,qtext.legacy} -\usephysicsmodule{ab.braket} -\usephysicsmodule{diagmat} -\usephysicsmodule[showleft=3,showtop=3]{xmat} -\usepackage{derivative} -\input{phy2docdef.tex} -\title{\pkg{physics2} manual for the legacy \pkg{physics} users} -\begin{document} -\maketitle - -\begin{abstract} -This short document describes \pkg*{physics2} package for those who are -used to the \pkg*{physics} package. This document is only a simple reference -manual for: -\begin{itemize} -\item Frequent users of the legacy \pkg{physics} package; -\item Those who have to maintain a document written with \pkg{physics}; -\item Users who failed to use \pkg*{unicode-math} with \pkg{physics}. -\end{itemize} -It seems no reason for any other user to read \emph{this} document instead of -the \hyperref{./physics2.pdf}{}{}{package documentation} of \pkg{physics2}, -because this document cannot describe the package in detail. - -In this document, the modules of \pkg{physics2} will be introduced in -the same order as the \pkg{physics} documentation. -\end{abstract} - -\section*{Contents} -\begin{multicols}{2} -\contentsonly -\end{multicols} -\ifnum\value{page}=1 \vfil\clearpage\fi - -\section{Before you start} -\subsection{Legacy problems with \pkg{physics} package} -\label{subsec:physics-legacy-problems} -The \pkg{physics} package provides \cs{qty} command for automatic-sizing -braces. The \cs{qty} command would cause conflict with the \pkg{siunitx} -package, which provides a unified method to typeset numbers and units -correctly. - -Besides, after you loaded \pkg{physics}, when you type \cs{homework} you -will get Maxwell equations and Schrödinger equation. The \cs{homework} -command is ``declared'' in \texttt{physics.sty} but it was not described -in the documentation. That is, if you have defined \cs{homework} before -loading \pkg{physics} package, \pkg{physics} would overwrite the definition -``silently''. - -The vector-notation part of \pkg{physics} uses \pkg*{amsmath}'s (more exactly, -\texttt{amsbsy.sty}'s) \cs{boldsymbol} command to generate bold vectors. -Commands for cross/dot product are defined with \cs{boldsymbol}. -\cs{boldsymbol} uses \cs{mathversion}, a \LaTeXe\ kernel command that works -well with traditional TFM-based fonts but fails when using \pkg{unicode-math}. - -In the definition of \cs{imat}, \cs{xmat}, \cs{dmat} and \cs{admat} commands -from \pkg{physics}, there is a \cs{newtoks} command which allocates a token -list register and two \cs{newcount} commands allocating two count registers. -Every time you write a command like \cs{imat} in your document, then one token -list register and two count registers will be wasted. What's even worse is -that, if you wrote really too many matrix commands from \pkg{physics} (for -example, 32767 \cs{imat}s in \hologo{LuaLaTeX}), there'd be no room for a new -\cs{count}. - -\pkg{physics} integrated all the functions in one file (\texttt{physics.sty}), -that is, you cannot load one of the total seven parts of functions; you have -to load the seven parts altogether, even included the extra \cs{homework} -command we mentioned in the first paragraph. - -Moreover, the code of \texttt{physics.sty} ``abuses'' the \texttt{g}-type -arguments of \pkg*{xparse} package. Therefore the syntax of \pkg{physics} package -looks kind of weird. See \hyperref{https://tex.stackexchange.com/questions/% -470819/macros-dv-and-pdv-eat-the-subsequent-parenthesis-argument/470842#470842}% -{}{}{here} for more. - -\subsection{Loading \pkg{physics2}} -The \pkg{physics2} package includes different modules, among which every module -focuses on one single function. - -Write the following line in the preamble to load \pkg{physics2}: -\begin{Verbatim} -\usepackage{physics2} -\end{Verbatim} -But this is not enough. \pkg{physics2} contains different modules, among which, -only the \modu{common} module would be loaded automatically by the package. -If you want to load other modules of \pkg{physics2}, write this after loading -\pkg{physics2} package: -\begin{displayed} -\cs{usephysicsmodule}\marg{module list} -\end{displayed} -For example, ``\verb|\usephysicsmodule{ab,doubleprod}|'' loads the \modu{ab} -module and the \modu{doubleprod} module. - -You can also load a module with options: -\begin{displayed} -\cs{usephysicsmodule}\oarg{option list}\marg{module} -\end{displayed} -For example, ``\verb|\usephysicsmodule[legacy]{ab}|'' loads \modu{ab} with the -option ``\opt{legacy}''. - -\pardanger Attention, if you used any font package in your document, remember -that \pkg{physics2} requires to be loaded \emph{after} font packages. - - -\section{List of commands} -\subsection{Automatic bracing}\label{subsec:ab-and-legacy} -As mentioned in \S\ref{subsec:physics-legacy-problems}, the \cs{qty} command -from \pkg{physics} would cause conflicts with \pkg{siunitx}. The command for -automatic braces in \pkg{physics2} is \cs{ab}, a shorthand for -{\bfseries a}utomatic {\bfseries b}races. - -The \cs{ab} command requires the \modu{ab} module, so don't forget to write -\verb|\usephysicsmodule{ab}| in the preamble after you loaded \pkg{physics2}. -Always remember, \emph{do not put an \cs{ab} separately in the end of a math -formula}. Take some examples: -\begin{example} -\[ \ab ( \frac12 ) \quad - \ab [ \frac12 ] \quad - \ab\{ \frac12 \} \] -\end{example} -\cs{ab} can modify a delimiter-braced subformula. But the delimiters should -not be out of the range described by the following chart: -\begin{center} -\begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} -\opt{(},\quad\opt{)} && \\ -\opt{[},\quad\opt{]} && \\ -\cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ -\opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ -\opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ - \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} -\end{tabular} -\end{center} -For example, \verb|$\ab{foo}$| and \verb|$\ab(foo]$| are illegal, but -\verb|$\ab\{foo\}$| and \verb|$\ab(foo)$| are okay; \verb|$\ab([)$| -is okay but \verb|$\ab(()$| is illegal. - -\pardanger Attention, if you want to delimit a subformula with ``\{'' and -``\}'', you can only write \verb|\{|, \verb|\}| or \cs{lbrace}, \cs{rbrace} -around it. \verb|{| and \verb|}| are not supported in \modu{ab} module. - -Between \cs{ab} and the first delimiter can be a ``biggg'' command, that is, -from \cs{big} to \cs{Bigg}. Actually, you can also write \cs{biggg} and -\cs{Biggg} because \pkg{physics2} defines these after you load it. For example, -\begin{example} -\[ \ab\Big \| \frac12 \| \quad - \ab\Bigg < \frac12 > \quad - \ab\Biggg| \frac12 | \] -\end{example} -Between \cs{ab} and the first delimiter can also be a star (\opt{*}), which -means ``use the default size of delimiters''. But in this situation, you -needn't use the \cs{ab} command at all. - -The \pkg{physics} package provides commands like \cs{pqty}, \cs{bqty}. In -the \modu{ab} module of \pkg{physics2}, these commands have changed to -\cs{pab}, \cs{bab}, etc. The following example shows all the -\texttt{\textbackslash}$X$\texttt{ab} commands in \modu{ab} module: -\begin{example} -\def\0{\frac12} -\[ \pab{\0} \quad \bab{\0} - \quad \Bab{\0} \] -\[ \aab{\0} \quad \vab{\0} - \quad \Vab{\0} \] -\end{example} -\texttt{\textbackslash$X$ab} can take an optional star and an optional \oarg{biggg} -argument. For example, -\begin{example} -\def\0{\frac12} -\[ \pab[Big]{\0} \quad \bab*{\0} \] -\end{example} - -\pkg{physics} also provides the following commands: -\begin{Verbatim}[fontsize=\small] -\abs \norm \eval \order \comm \acomm \pb -\end{Verbatim} -\pardanger These commands are not originally supported by \pkg{physics2}, but -the first four commands can be used through the \modu{ab.legacy} module of -\pkg{physics2}: -\begin{Verbatim} -\usephysicsmodule{ab.legacy} -\end{Verbatim} -For example, -\begin{example} -\def\0{\frac12} -\[ \abs{\0} \quad \abs[big]{\0} - \quad \abs*{\0} \] -\end{example} -Users of the legacy \pkg{physics} package should notice that the syntax of -\cs{eval} has been changed. The \modu{ab.legacy} module abandoned the -\verb"\eval(foo|"-like syntax. The new \cs{eval}'s syntax is just like other -commands in this module. There are also two variants of \cs{eval} --- \cs{peval} -and \cs{beval}. For example, -\begin{example} -\def\0{1+\frac12x} -\[ \eval{\0}_a^b \quad - \peval*{\0}_a^b \quad - \beval[big]{\0}_a^b \] -\end{example} -The \cs{comm}, \cs{acomm} and \cs{pb} (Poisson bracket) are not supported. -But you can write like \verb|\ab[foo,baz]| or \verb|\bab{foo,baz}| instead. - -By the way, you can set the ``order'' symbol in \modu{ab.legacy} through -the \opt{order} option like this: -\begin{Verbatim} -\usephysicsmodule[order=O]{ab.legacy} -\end{Verbatim} -Then \verb|$\order(N)$| yields $O(N)$. - -\subsection{Vector notation} -Unfortunately, there is not a plan for \pkg{physics2} to support this part -of \pkg{physics} completely, but the rest of this section will show some -methods to maintain the document written with \pkg{physics}. - -The \cs{vb}(\opt{*}), \cs{va}(\opt{*}) and \cs{vu}(\opt{*}) are not supported -in any module of \pkg{physics2}. But these commands can be defined by copying -the following lines below and pasting them in the preamble: -\begin{Verbatim}[fontsize=\small] -\makeatletter -\newcommand\vb{\@ifstar\boldsymbol\mathbf} -\newcommand\va[1]{\@ifstar{\vec{#1}}{\vec{\mathrm{#1}}}} -\newcommand\vu[1]{% - \@ifstar{\hat{\boldsymbol{#1}}}{\hat{\mathbf{#1}}}} -\makeatother -\end{Verbatim} -The \cs{boldsymbol} command requires the \pkg*{amsmath} or \pkg*{bm} package. -If you prefer to use \pkg{bm}, you can also use the \cs{bm} command. -What's more, if you tried the commands above, you might find that, -the result of \cs{va} above is different from that of \pkg{physics}. -This is beacuse, if you choose to present a vector in bold, it's alomost -no need to put a \cs{vec} ($\vec{\mskip9mu}$) sign above it. - -However, the method above may not work well with \pkg*{unicode-math} -because there are so many OpenType math fonts without a bold version. -When using \pkg{unicode-math}, it's recommended to use \cs{symbf} and -\cs{symbfit} for a separate vector. For example, \verb|$\symbf{0}$| yields -$\symbf{0}$, and \verb|$\symbfit{A}$| yields $\symbfit{A}$. - -The \cs{vdot} and \cs{cross} commands are not supported in any module -of \pkg{physics2}. Actually, there is no need to use a bold ``$\cdot$'' -or ``$\times$'' for the products of two vectors. Using \cs{cdot} and -\cs{times} is enough. - -The commands related to ``$\nabla$'' are supported through \modu{nabla.legacy} -module. These commands are \cs{grad}, \cs{div} and \cs{curl}. These commands -should not be put in the end of a math formula either (just like \cs{ab}). -Notice that the former \cs{div} command for a ``$\divsymbol$'' (if there -exists one) is redefined as \cs{divsymbol}. For example, -\begin{example} -% \usephysicsmodule{nabla.legacy} -\[ \grad F \quad - \grad(\frac G2) \] -\[ \div\Bigg[X] \quad - \curl*\{\frac Y2\} \] -\[ 2 \divsymbol 1 \] -\end{example} -Actually, the nabla-related commands end with \cs{ab}. Thus, the subformula -after these commands can be delimited with \verb|()|, \verb|[]| and \verb|\{\}|. - -The \modu{nabla.legacy} requires the \pkg*{fixdif} package at least -version 2.0 (file date: 2023/01/31 or after 2023/01/31). - -By the way, if you are used to write \cs{bm} for a vector but interested in -\pkg{unicode-math}, the \modu{bm-um.legacy} module would be a passable -alternative to \pkg{bm} package. Notice that the \cs{bm} command from the -\modu{bm-um.legacy} module can only take \emph{one} letter (or \emph{one} digit) -as its argument. - -\subsection{Operators} -There's no plan for \pkg{physics2} to support this part of \pkg{physics} -completely. The syntax in this part of \pkg{physics} (such as \verb|\tan[2](x)|) -abuses \pkg*{xparse}. - -It's suggested to write like this if you used the \modu{ab} module: -\begin{Verbatim}[fontsize=\small] -$ \sin^2 \ab( \frac{\alpha}{2} ) $ -\end{Verbatim} -Rather than take the superscript as an optional argument of the command of -log-like functions. - -The \pkg{physics} package provides a bundle of commands for log-like functions -that have not been defined in the \LaTeXe\ kernel. Those log-like functions -can be used with the \modu{op.legacy} module; this module do not support -the syntax of \pkg{physics} either. For example: -\begin{example} -% \usephysicsmodule{op.legacy} -\[ \asin^2 x \quad \rank \{ A \} \] -\end{example} -The \cs{Re} and \cs{Im} commands are redefined as operators ``$\Re$'' and -``$\Im$'', while $\Resymbol$ and $\Imsymbol$ are reserved as \cs{Resymbol} and -\cs{Imsymbol}. $\Resymbol$ and $\Imsymbol$ are ordinary symbols but $\Re$ and -$\Im$ are opetators. - -\subsection{Quick quad text}\label{subsec:qtext} -The \modu{qtext.legacy} module provides the \cs{q}\meta{foo} commands -for \cs{quad}-wrapped texts. These commands have the same syntax as -\pkg{physics}. For example, -\begin{example} -% \usephysicsmodule{qtext.legacy} -\[ A \qq {foo bar} B \] -\[ A \qq*{foo bar} B \] -\[ C \qcc D \qcc* E \] -\[ F \qif G \qthen H \] -\end{example} -All the commands described in \S2.4 of -\hyperref{http://mirrors.ctan.org/macros/latex/contrib/physics/physics.pdf}{}{}% -{\textsf{physics} documentation} are supported when using \modu{qtext.legacy} -module, but I don't recommend to use this module unless you are maintaining a -document written with \pkg{physics}'s \cs{q}\meta{foo} commands. - -\subsection{Derivatives} -There is no plan for \pkg{physics2} to support this part of \pkg{physics}. If -you want to typeset the differential operators on a better sense, you can try -the \pkg*{fixdif} package; if you want an easy way to type derivatives, you -can try the \pkg*{derivative} package. These two packages can be used -together. For example, -\begin{example} -% \usepackage{fixdif,derivative} -\[ \pdv{f}{x,y,z} \d x \] -Math ($\d x$) v.s.\ Text (\d x) -\end{example} -Here are the documentations of -\hyperref{http://mirrors.ctan.org/macros/latex/contrib/fixdif/fixdif.pdf}% -{}{}{\textsf{fixdif}} and -\hyperref{http://mirrors.ctan.org/macros/latex/contrib/derivative/derivative% -.pdf}{}{}{\textsf{derivative}}. - -\pkg{fixdif}'s commands behave better in superscripts and subscripts. - -\subsection{Dirac bra-ket notation} -There are two solutions to Dirac bra-ket in \pkg{physics2} --- \modu{ab.braket} -and \modu{braket}. These two modules are \emph{not} compatible and neither of -them supports \pkg{physics}'s syntax completely. -Click \hyperlink{para:ab.braket}{\textcolor{cyan}{here}} to see the -\modu{ab.braket} module and \hyperlink{para:braket}{\textcolor{cyan}{here}} -to see the \modu{braket} module. - -\paragraph{The \modu{ab.braket} module} -\hypertarget{para:ab.braket}{This} module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and -\cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' -command. These commands share similar syntaxes like \cs{ab}'s syntax. But, -\emph{the bra-ket commands from \modu{ab.braket} module are completely different -from \cs{ab}}. Their internal structures are different. - -The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, -\begin{center} -\cs{bra} \opt{<} \meta{subformula} \opt{|} -\end{center} -For example, -\begin{example} -\[ \bra < \frac \phi 2 | \] -\[ \bra*< \frac \phi 2 | \] -\[ \bra\Big< \phi | \] -\end{example} -The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, -\begin{center} -\cs{ket} \opt{|} \meta{subformula} \opt{>} -\end{center} -For example, -\begin{example} -\[ \ket | \frac \psi 2 > \] -\[ \ket*| \frac \psi 2 > \] -\[ \ket\Big| \psi > \] -\end{example} -\pardanger -If you want to write ``$>$'' and ``$<$'' for relations in the argument of -\cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| -(although there is almost no such need). - -The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, -that is, -\begin{center} -\cs{braket} \opt{<} \meta{subformula} \opt{>} -\end{center} -In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an -extensible vertical bar. For example, -\begin{example} -\[ \braket< \phi > \] -\[ \braket< \phi | \psi > \] -\[ \braket< \phi | A | \psi > \] -\end{example} -\begin{example} -\def\0{\frac\phi2} -\[ \braket < \0 | \psi > \] -\[ \braket* < \0 | \psi > \] -\[ \braket\Bigg< \0 | \psi > \] -\end{example} -The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. -In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ -and $\langle$. that is, -\begin{center} -\cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} - \opt{<} \meta{subformula$_2$} \opt{|} -\end{center} -For example, -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra | \0 >< \psi | \] -\[ \ketbra* | \0 >< \psi | \] -\[ \ketbra\Bigg| \0 >< \psi | \] -\end{example} -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra| \0 >_x^y < \psi | \] -\end{example} -\pardanger -If you want to write ``$>$'' and ``$<$'' for relations in the argument of -\cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there -is almost no such need). It is quite different from \verb|\mathrel{>}| or -\verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} -will be redefined. - -\paragraph{The \modu{braket} module} -\begingroup -\makeatletter\def\phy@requiremodule#1{}% -\def\PackageWarning#1#2{}% -\input phy-braket.sty\makeatother -\hypertarget{para:braket}{This} module contains four commands --- \cs{bra}, -\cs{ket}, \cs{braket} and \cs{ketbra}. After these commands can be a star -(\opt{*}) or a square-bracket-delimited size option, the size option can -take the following values: -\begin{center} -\opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad -\opt{biggg}\quad or\quad\opt{Biggg}. -\end{center} -Star stands for ``do not size the bra-ket automatically''. - -The argument(s) of these four commands are braced with \verb|{| and \verb|}|. -\cs{bra} and \cs{ket} take one mandatory argument. For example, -\begin{example} -\def\0{\frac\phi2} -\[ \bra {\0} \quad \bra* {\0} - \quad \bra[Big] {\0} \] -\[ \ket {\0} \quad \ket* {\0} - \quad \ket[Big] {\0} \] -\end{example} -The \cs{braket} command, in default, can take two arguments. -\begin{example} -\def\0{\frac\phi2} -\[ \braket {\0} {\psi} \quad - \braket*{\0} {\psi} \quad - \braket[big] {\0} {\psi} \] -\end{example} -If you want \cs{braket} to take one or three arguments, you can write the -number of arguments in the sqare bracket. If you need to specify the size -of bra-ket simultaneously, you need to separate the number and the size with -a comma: -\begin{example} -\def\0{\frac\phi2} -\[ \braket [1] {\0} \quad - \braket*[1] {\0} \] -\[ \braket [3] {\0}{A}{\psi} \] -\[ \braket[3,big] {\0}{A}{\psi} - \quad - \braket[Big,3] {\0}{A}{\psi} \] -\end{example} -The \cs{ketbra} command takes two mandatory arguments. It can also take an -optional argument between the two mandatory arguments. The optional argument -will be placed between $\rangle$ and $\langle$: -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra {\0} {\psi} \quad - \ketbra* {\0} {\psi} \] -\[ \ketbra [Bigg] {\0} {\psi} \] -\[ \ketbra {\0} [_x^y] {\psi} \] -\end{example} -\endgroup - -\subsection{Matrix macros} -Unfortunately, \pkg{physics2} do not support the \cs{mqty} command from -\pkg{physics}. If you are used to this command, you can write like this: -\begin{Verbatim}[fontsize=\small] -\newcommand\mqty[1]{\begin{matrix}#1\end{matrix}} -\newcommand\pmqty[1]{\begin{pmatrix}#1\end{pmatrix}} -$\ab(\mqty{foo})$ or $\pmqty{foo}$ -\end{Verbatim} -These are equal to physics's \verb|\mqty(foo)| (require \pkg{amsmath}). - -\pkg{physics2}'s \modu{diagmat} module provides \cs{diagmat} command -for diagonal matrices. For example, -\begin{example} -\[ - \diagmat { 1, 2, 3 } -\] -\end{example} -\begin{example} -\[ - \pdiagmat [ empty = {} ] - { a, b, c, d } -\] -\end{example} -\cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} -are also available. - -\pkg{physics2}'s \modu{xmat} module provides \cs{xmat} command -for matrices with formatted entries. For example, -\begin{example} -\[ - \xmat{a}{2}{3} -\] -\end{example} -\begin{example} -% \usephysicsmodule -% [showleft=3,showtop=3]{xmat} -\[ - \pxmat{X}{m}{n} -\] -\end{example} -\begin{example} -\[ - \xmat [showleft=2,showtop=2, - format=\texttt{#1[#2][#3]}] - {x}{m}{n} -\] -\end{example} -\cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also available. - - - - - - - - - -\end{document} \ No newline at end of file diff --git a/macros/latex/contrib/physics2/doc/physics2.pdf b/macros/latex/contrib/physics2/doc/physics2.pdf deleted file mode 100644 index 5a56e39b67..0000000000 Binary files a/macros/latex/contrib/physics2/doc/physics2.pdf and /dev/null differ diff --git a/macros/latex/contrib/physics2/doc/physics2.tex b/macros/latex/contrib/physics2/doc/physics2.tex deleted file mode 100644 index f567d5219c..0000000000 --- a/macros/latex/contrib/physics2/doc/physics2.tex +++ /dev/null @@ -1,569 +0,0 @@ -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * http://www.latex-project.org/lppl.txt * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -\documentclass[11pt,letterpaper]{article} -\usepackage{amsmath} -\usepackage{unicode-math} -\setmainfont{Libertinus Serif} -\setsansfont{Libertinus Sans} -\setmonofont{Noto Sans Mono}[Scale=MatchLowercase] -\setmathfont{Libertinus Math} -\usepackage{physics2} -\usephysicsmodule{ab,ab.braket} -\usephysicsmodule{diagmat} -\usephysicsmodule{doubleprod} -\usephysicsmodule[showleft=3,showtop=3]{xmat} -\usephysicsmodule{ab.legacy,nabla.legacy,op.legacy,qtext.legacy,bm-um.legacy} -\input{phy2docdef.tex} -\externaldocument[lega-]{physics2-legacy} -\title{The \pkg{physics2} package} -\begin{document} -\maketitle - -\begin{abstract} -This is the document for \pkg{physics2} package, which defines commands for -typesetting math formulae faster and more simply. \pkg{physics2} is a -modularized package, each module provides its own function. - -This document describes the \pkg{physics2} package in more detail. -But if you are a user of the legacy \pkg{physics} package, you can click -\hyperref{./physics2-legacy.pdf}{}{}{here} to see the documention for -\pkg{physics} users before you start. If you never used \pkg{physics} package -before, just read \emph{this} documentation. -\end{abstract} - -\tableofcontents - -\section{Introduction} -\subsection{The purpose of this package} -This package aims to provide a bundle of commands for typesetting math faster -in different modules. The commands provided by \pkg{physics2} and its different -modules are designed to be short and easy to memorize. - -\subsection{Packages required} -The \pkg{physics2} package itself only requires the \pkg*{keyval} package, which -is part of the \pkg*{latex-graphics} bundle. Almost every \LaTeX\ distribution -will include this bundle. - -Different modules of \pkg{physics2} might require different packages. It will -be explained in the following sections that which module requires which package. - -The \pkg{physics2} package requires \LaTeXe\ kernel released after 2020/10. -Please make sure that your \LaTeX\ distribution is not too old. - -\subsection{Loading the \pkg{physics2} package} -Just like loading any package, write -\begin{Verbatim} -\usepackage{physics2} -\end{Verbatim} -in the preamble to load the \pkg{physics2} package. In this version, -\pkg{physics2} doesn't provide a package option. - -However, \pkg{physics2} itself only provides very few functions. Actually, it -just provides a method to load modules. You need to load different modules of -\pkg{physics2} to have different kinds of functions applied to your document. - -\subsection{Loading a module of \pkg{physics2}} -You can load a module of \pkg{physics2} only \emph{after} you write -\verb|\usepackage{physics2}| in the preamble. Load a \pkg{physics2} module -like this: -\begin{center} -\cs{usephysicsmodule}\marg{module} -\end{center} -The usage of \cs{usephysicsmodule} is similar to \cs{usepackage}, so you can -load more than one modules in one line. For example, -\begin{Verbatim} -\usephysicsmodule{ab,ab.braket} -\end{Verbatim} -This line loads the \modu{ab} and \modu{ab.braket} modules. - -You can also load \emph{one} module with options. The options of a -\pkg{physics2} module can be a comma-separated key-value list. For example, -\begin{Verbatim} -\usephysicsmodule[tightbraces=true]{ab} -\usephysicsmodule{ab.braket,doubleprod} -\end{Verbatim} -These two lines load the \modu{ab} module with option -\opt{tightbraces\:=\:true} and load \modu{ab.braket} and \modu{doubleprod} -modules. - -\pardanger -The \modu{common} module will be loaded automatically when you load the -\pkg{physics2} package and \emph{only} the \modu{common} module will be -loaded automatically. Any other module should be loaded manually by writing -\cs{usephysicsmodule}\marg{module} after you loaded \pkg{physics2} in the -preamble. - -The following sections introduce all the user-level modules of \pkg{physics2}. -View back to the table of contents to see the names of user-level modules. - -\section{Modules of \pkg{physics2}} -\subsection{The automatically loaded \modu{common} module} -The \modu{common} module provides the following commands: - -\cs{delopen} and \cs{delclose}, followed by a math delimiter. They can be -regarded as abbreviations of ``open delimiter'' and ``close delimiter''. If -you had heard of the \pkg*{mleftright} package. You can regard \cs{delopen} -and \cs{delclose} as a simpler version of \cs{mleft} and \cs{mright}. -For example, -\begin{example} -\[ 0 \left(\frac12\right) 3 \] -\[ 0 \delopen(\frac12\delclose) 3 \] -\end{example} - -\cs{biggg} and \cs{Biggg}, followed by a math delimiter. They are even bigger -than \cs{Bigg}. \cs{biggg} and \cs{Biggg} may be useful when you need to write -something really tall in math mode, but most OpenType math font do not support -\cs{langle} (or U+27E8) and \cs{rangle} (or U+27E9) in this large size. Take -an example, -\begin{example} -\[\Biggg(\biggg(\Bigg(\bigg(\Big(\big(( -)\big)\Big)\bigg)\Bigg)\biggg)\Biggg)\] -\end{example} -\cs{bigggl}, \cs{bigggm}, \cs{bigggr}, \cs{Bigggl}, \cs{Bigggm} and \cs{Bigggr} -are also supported. - -\subsection{The \modu{ab} module --- automatic braces} -This module provides the command \cs{ab}. The \cs{ab} command, as a shorthand -of ``automatic braces'', would specify the size of the following pair of -delimiters. The delimiters after \cs{ab} should not be out of the range -described by the following chart: -\begin{center} -\begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} -\opt{(},\quad\opt{)} && \\ -\opt{[},\quad\opt{]} && \\ -\cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ -\opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ -\opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ - \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} -\end{tabular} -\end{center} -For example, it's illegal to write an ``\verb|\ab(|'' without a ``\verb|)|''; -it's also illegal to write \verb|\ab=foo=|. Take some correct examples: -\begin{example} -\[ \ab ( \frac12 ) \quad - \ab [ \frac12 ] \quad - \ab\{ \frac12 \} \] -\end{example} -You can also write a command from \cs{big} to \cs{Biggg} between \cs{ab} -and the first delimiter, which means to specify the size of delimiters manually. -Also, you can write a star (\opt{*}) between \cs{ab} and the first delimiter, -to prevent \cs{ab} from setting the size of delimiters. For example, -\begin{example} -\[ \ab <\frac12> \quad - \ab\biggg|\frac12| \quad - \ab* \|\frac12\| \] -\end{example} -\pardanger -Always remember, do not put an \cs{ab} separately at the end of math mode like -\verb|$\ab$|, because \cs{ab} will try to absorb the following math shift -character (\verb|$|) as its argument. - -The \modu{ab} module also provides \texttt{\textbackslash}$X$\texttt{ab} -commands, where $X$ can be \opt{p}, \opt{b}, \opt{B}, \opt{a}, \opt{v} and -\opt{V}. These commands take a normal argument but not an argument delimited -with paired delimiters. For example, -\begin{example} -\def\0{\frac12} -\[ \pab{\0} \bab{\0} \Bab{\0} \] -\[ \aab{\0} \vab{\0} \Vab{\0} \] -\end{example} -These \texttt{\textbackslash$X$ab} commands can take an optional star and -an optional \oarg{biggg} argument. Star stands for using the default sizes. -For example, -\begin{example} -\def\0{n+\frac12} -\[ \pab[Big]{\0} \quad \bab*{\0} \] -\end{example} - -\paragraph{The options of \modu{ab} module} -\opt{tightbraces}, a bool type key, whose default value is \opt{true}, -influences whether thin skips are reserved around the paired delimiters. -It only works with the automatically sized delimiters. - -\subsection{The \modu{ab.braket} module --- Dirac bra-ket notation} -This module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and -\cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' -command. These commands share similar syntaxes like \cs{ab}'s syntax. But, -\emph{the bra-ket commands from \modu{ab.braket} module are completely different -from \cs{ab}}. Their internal structures are different. - -The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, -\begin{center} -\cs{bra} \opt{<} \meta{subformula} \opt{|} -\end{center} -For example, -\begin{example} -\[ \bra < \frac \phi 2 | \] -\[ \bra*< \frac \phi 2 | \] -\[ \bra\Big< \phi | \] -\end{example} -The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, -\begin{center} -\cs{ket} \opt{|} \meta{subformula} \opt{>} -\end{center} -For example, -\begin{example} -\[ \ket | \frac \psi 2 > \] -\[ \ket*| \frac \psi 2 > \] -\[ \ket\Big| \psi > \] -\end{example} -\pardanger -If you want to write ``$>$'' and ``$<$'' for relations in the argument of -\cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| -(although there is almost no such need). - -The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, -that is, -\begin{center} -\cs{braket} \opt{<} \meta{subformula} \opt{>} -\end{center} -In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an -extensible vertical bar. For example, -\begin{example} -\[ \braket< \phi > \] -\[ \braket< \phi | \psi > \] -\[ \braket< \phi | A | \psi > \] -\end{example} -\begin{example} -\def\0{\frac\phi2} -\[ \braket < \0 | \psi > \] -\[ \braket* < \0 | \psi > \] -\[ \braket\Bigg< \0 | \psi > \] -\end{example} -The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. -In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ -and $\langle$. that is, -\begin{center} -\cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} - \opt{<} \meta{subformula$_2$} \opt{|} -\end{center} -For example, -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra | \0 >< \psi | \] -\[ \ketbra* | \0 >< \psi | \] -\[ \ketbra\Bigg| \0 >< \psi | \] -\end{example} -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra| \0 >_x^y < \psi | \] -\end{example} -\pardanger -If you want to write ``$>$'' and ``$<$'' for relations in the argument of -\cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there -is almost no such need). It is quite different from \verb|\mathrel{>}| or -\verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} -will be redefined. - -Next, the \modu{braket} module will be introduced. Please notice that -\modu{braket} is conflict with \modu{ab.braket}, they cannot be used together. - -\subsection{The \modu{braket} module --- Dirac bra-ket notation} -\begingroup -\makeatletter\def\phy@requiremodule#1{}% -\def\PackageWarning#1#2{}% -\input phy-braket.sty\makeatother -Please notice that this module is conflict with the \modu{ab.braket} module. -Don't use them together. - -This module contains four commands --- \cs{bra}, \cs{ket}, \cs{braket} and -\cs{ketbra}. After these commands can be a star (\opt{*}) or a -square-bracket-delimited size option, the size option can -take the following values: -\begin{center} -\opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad -\opt{biggg}\quad or\quad\opt{Biggg}. -\end{center} -Star stands for ``do not size the bra-ket automatically''. - -The argument(s) of these four commands are braced with \verb|{| and \verb|}|. -\cs{bra} and \cs{ket} take one mandatory argument. For example, -\begin{example} -\def\0{\frac\phi2} -\[ \bra {\0} \quad \bra* {\0} - \quad \bra[Big] {\0} \] -\[ \ket {\0} \quad \ket* {\0} - \quad \ket[Big] {\0} \] -\end{example} -The \cs{braket} command, in default, can take two arguments. -\begin{example} -\def\0{\frac\phi2} -\[ \braket {\0} {\psi} \quad - \braket*{\0} {\psi} \quad - \braket[big] {\0} {\psi} \] -\end{example} -If you want \cs{braket} to take one or three arguments, you can write the -number of arguments in the sqare bracket. If you need to specify the size -of bra-ket simultaneously, you need to separate the number and the size with -a comma: -\begin{example} -\def\0{\frac\phi2} -\[ \braket [1] {\0} \quad - \braket*[1] {\0} \] -\[ \braket [3] {\0}{A}{\psi} \] -\[ \braket[3,big] {\0}{A}{\psi} - \quad - \braket[Big,3] {\0}{A}{\psi} \] -\end{example} -The \cs{ketbra} command takes two mandatory arguments. It can also take an -optional argument between the two mandatory arguments. The optional argument -will be placed between $\rangle$ and $\langle$: -\begin{example} -\def\0{\frac\phi2} -\[ \ketbra {\0} {\psi} \quad - \ketbra* {\0} {\psi} \] -\[ \ketbra [Bigg] {\0} {\psi} \] -\[ \ketbra {\0} [_x^y] {\psi} \] -\end{example} -\endgroup - -\subsection{The \modu{diagmat} module --- simple diagonal matrices} -This module provides \cs{diagmat} command: -\begin{center} -\cs{diagmat}\opt{[empty\:=\:}\meta{empty entry}\opt{]}\marg{diag} -\end{center} -where \meta{diag} is the diagonal of the diagonal matrix. The entries should -be separated by commas. The \opt{empty} option is optional, with default value -\opt{0}. For example, -\begin{example} -\[ - \diagmat { 1, 2, 3 } -\] -\end{example} -\cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} -are also available. Prefixes like \opt{p}, \opt{b}, \opt{B} have the same -meaning as the \opt{p}, \opt{b}, \opt{B} in \pkg{amsmath}'s \opt{pmatrix}, -\opt{bmatrix} and \opt{Bmatrix}. For example, -\begin{example} -\[ - \pdiagmat [ empty = {} ] - { a, b, c, d } -\] -\end{example} -This module requires \pkg{amsmath}. - -\paragraph{The options of \modu{diagmat} module} -You can set the default value of \cs{diagmat}'s empty entries in the module -option like this: -\begin{Verbatim} -\usephysicsmodule[empty={\cdot}]{diagmat} -\end{Verbatim} - -\subsection{The \modu{doubleprod} module --- tensors' double product operator} -Take an example of this module: -\begin{example} -$ A \doublecross B \doubledot C $ -\end{example} -\cs{doublecross} and \cs{doubledot} are regarded as binary operators by \TeX. - -\paragraph{The options of \modu{doubleprod} module} -You can control the scale of ``$\times$'' and ``$\cdot$'' in \cs{doublecross} -and \cs{doubledot} in module option. For example, -\begin{Verbatim} -\usephysicsmodule[crossscale=0.75,dotscale=1.2]{doubleprod} -\end{Verbatim} -The default values of \opt{crossscale} and \opt{dotscale} are \opt{0.8} and -\opt{1}. You can also control the distances between the two ``$\times$''s and -``$\cdot$''s through the \opt{crossopenup} and \opt{dotopenup} options. -For example, -\begin{Verbatim} -\usephysicsmodule[crossopenup=.05,dotopenup=.25]{doubleprod} -\end{Verbatim} -The default values of \opt{crossopenup} and \opt{dotopenup} are \opt{0.02} -and \opt{0.2}. The value stands for the multiple of current font size. -Moreover, you can change the symbols produced by \cs{doublecross} and -\cs{doubledot} by setting \opt{crosssymbol} and \opt{dotsymbol} in module -option. - -\subsection{The \modu{xmat} module --- matrices with formatted entries} -The \modu{xmat} module provides \cs{xmat} command for matrices with formatted -entries: -\begin{center} -\cs{xmat}\oarg{options}\marg{entry}\marg{rows shown}\marg{cols shown} -\end{center} -If \meta{rows shown} and \meta{cols shown} are digits, the value of them -must be less at least 2 than the value of \pkg{amsmath}'s \opt{MaxMatrixCols} -counter. For example, -\begin{example} -\[ - \xmat{a}{2}{3} -\] -\end{example} -\cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also -available. The meaning of \opt{p} and so on is the same as the \opt{p} -in \opt{pmatrix} of \pkg{amsmath}. For example, -\begin{example} -\[ - \pxmat{M}{3}{3} -\] -\end{example} -If \meta{rows shown} and \meta{cols shown} contain non-digit characters, -extra dots will be added. For example, -\begin{example} -\[ - \bxmat[showleft=3,showtop=2] - {X}{m}{n} -\] -\end{example} -In this example we used the \opt{showleft} and \opt{showtop} options. The -default value of them is the value of \opt{MaxMatrixCols} minus 2. You can -also set them in the module option like this: -\begin{Verbatim} -\usephysicsmodule[showtop=3,showleft=3]{xmat} -\end{Verbatim} -Then every \cs{xmat} with non-digital \meta{rows shown} and \meta{cols shown} -will have 2 top-most rows and 3 left-most columns shown. This will also -influence ``\cs{xmat}''s with digital \meta{rows shown} and \meta{cols shown} -when \meta{rows shown} and \meta{cols shown} are larger than the values -corresponding to \opt{showtop} and \opt{showleft}. For example, -\begin{example} -% \usephysicsmodule -% [showtop=3,showleft=3]{xmat} -\[ \pxmat{A}{8}{8} \] -\end{example} -However, when \meta{rows shown} and \meta{cols shown} are 1 greater than -\meta{showtop} and \meta{showleft}, for example, \meta{rows shown}$\:=4$ and -\meta{cols shown}$\:=4$ in last example's settings, \cs{xmat} will still add -the extra dots: -\begin{example} -% \usephysicsmodule -% [showtop=3,showleft=3]{xmat} -\[ \pxmat{A}{4}{4} \] -\end{example} -In such situations, we need to specify \opt{showtop} and \opt{showleft} -manually. For example, -\begin{example} -% \usephysicsmodule -% [showtop=3,showleft=3]{xmat} -\[ \pxmat[showtop=4,showleft=4] - {A}{4}{4} \] -\end{example} - -The \cs{xmat} command provides the \opt{format} option, which allows users -to use a new entry format. For example, -\begin{example} -\[ - \xmat [showleft=2,showtop=2, - format=\texttt{#1[#2][#3]}] - {x}{m}{n} -\] -\end{example} -In the value of \opt{format} key, \verb|#1| stands for the common entry, -or the first mandotary \meta{entry} argument of \cs{xmat}; \verb|#2| -stands for the row index and \verb|#3| stands for the column index. - -This module requires \pkg{amsmath}. - -\paragraph{The options of \modu{xmat} module} -Only \opt{showtop} and \opt{showleft} can be used as module options. -\opt{format} should be only used in the optional argument of the -\cs{xmat} command. - -\section{The ``legacy'' modules} -The legacy modules have similar names like \meta{module}\opt{.legacy}. Most of -them are designed to provide solutions to maintain documents written with the -legacy \pkg{physics} package. It's not suggest to use them in a new document. - -\subsection{The \modu{ab.legacy} module} -This module provides the following commands: -\begin{Verbatim}[fontsize=\small] -\abs \norm \eval (\peval \beval) \order -\end{Verbatim} -They shares the same syntax as \meta{cmd}\opt{*}\oarg{biggg}\marg{subformula}. -Star and \meta{biggg} are optional. Star stands for ``use the default size''. -For example, -\begin{example} -\def\0{1+\frac12} -\[ \abs{\0} \quad - \norm[Big]{\0} \quad - \order*{\0} \] -\end{example} -\begin{example} -\def\0{1+\frac12x} -\[ \eval{\0}_a^b \quad - \peval*{\0}_a^b \quad - \beval[big]{\0}_a^b \] -\end{example} -You can set the ``order'' symbol in this module through -the \opt{order} option like this: -\begin{Verbatim} -\usephysicsmodule[order=O]{ab.legacy} -\end{Verbatim} -For further information of this module, see \S\ref*{lega-subsec:ab-and-legacy} -of \hyperref{./physics2-legacy.pdf}{}{}{physics2-legacy}. - -\subsection{The \modu{bm-um.legacy} module} -If you are maintaining a document with plenty of ``\cs{bm}''s or -``\cs{boldsymbol}''s in it but want to use \pkg{unicode-math} package -simultaneously, you could take a look at this module. - -The \cs{bm} command from \pkg{bm} package uses \cs{mathversion} to support -its function, but there are few OpenType math fonts who released with a bold -version. The \modu{bm-um.legacy} module provides a \cs{bm} command too, but -this \cs{bm} can only take \emph{one} math character or a series of math -characters sharing the same category code as its argument. -If the argument was Latin letters or Greek letters, \cs{bm} would switch to -the bold italic glyphs corresponding to them (if there exists bold italic -glyphs); else \cs{bm} would switch to the bold upright glyphs. For example, -\begin{example} -$\bm{0}\bm{A}\bm{z} - \bm{\alpha}\bm{\Omega}$ -\end{example} - -\subsection{The \modu{nabla.legacy} module} -This module provides some commands related to nabla ($\nabla$). Notice that -this module requires the \pkg{fixdif} package with file date 2023/01/31 at -minimum. - -This module defines \cs{grad} and \cs{curl} and redefines \cs{div}. For example, -\begin{example} -\[ \grad V \] -\[ \div (x,y,z) \] -\[ \curl(x,y,z) \] -\end{example} -The ``$\divsymbol$'' symbol was redefined as \cs{divsymbol}. - -\subsection{The \modu{op.legacy} module} -This module provides a series of commands for log-like operators. They are -\begin{Verbatim} -\asin \acos \atan -\acsc \asec \acot -\Tr \tr \rank -\erf \Res \res -\PV \pv -\Re \Im -\end{Verbatim} -where \cs{Re} and \cs{Im} are redefined. The first four lines of commands -yield what they look like in math mode. For example, -\begin{example} -$\asin x$ \quad $\rank A$ -\end{example} -\cs{PV} yields ``$\PV$'' as an ordinary symbol and \cs{pv} yields ``$\pv$''. -For example, -\begin{example} -$\PV f(z)$ \quad $\pv f(z)$ -\end{example} -\cs{Re} and \cs{Im} are redefined as ``$\Re$'' and ``$\Im$''. $\Resymbol$ -and $\Imsymbol$ are redefined as \cs{Resymbol} and \cs{Imsymbol}, in default. - -This module \emph{does not} require \pkg{amsmath}. - -\paragraph{The options of \modu{op.legacy} module} -\opt{ReIm}, a bool key with default value \opt{true}, determines whether to -redefine \cs{Re} and \cs{Im}. If you want to reserve the definition of -\cs{Re} and \cs{Im}, you can write like this: -\begin{Verbatim} -\usephysicsmodule[ReIm=false]{op.legacy} -\end{Verbatim} - -\subsection{The \modu{qtext.legacy} module} -This module was written just to offer a method to maintain documents written -with the legacy \pkg{physics} package. See \S\ref*{lega-subsec:qtext} of -\hyperref{./physics2-legacy.pdf}{}{}{physics2-legacy} for more information. - -\end{document} \ No newline at end of file diff --git a/macros/latex/contrib/physics2/phy2docdef.tex b/macros/latex/contrib/physics2/phy2docdef.tex new file mode 100644 index 0000000000..2590823097 --- /dev/null +++ b/macros/latex/contrib/physics2/phy2docdef.tex @@ -0,0 +1,70 @@ +%% This is part of physics2 documentation. +%% ****************************************************** +%% * This work may be distributed and/or modified under * +%% * the conditions of the LaTeX Project Public License * +%% * http://www.latex-project.org/lppl.txt * +%% * either version 1.3c of this license or any later * +%% * version. * +%% ****************************************************** +\makeatletter +\usepackage[nohyperref]{doc} +\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.1em}} +\def\contentsonly{\@starttoc{toc}} +\usepackage{manfnt} +\protected\def\pardanger{\ifnum\lastnodetype=1% + \leavevmode\hbox to \z@{\hss\dbend\hskip10pt\hskip\parindent}\else + \ifnum\lastnodetype=11% + \leavevmode\hbox to \z@{\hss\dbend\hskip10pt}% + \fi\fi\ignorespaces} +\usepackage{hyperref,color,xr} +\definecolor{pkgcolor}{RGB}{0,120,80} +\definecolor{moducolor}{RGB}{0,0,150} +\hypersetup{colorlinks,urlcolor=magenta,linkcolor=black,filecolor=blue, + pdfstartview=FitH,pdfview=FitH,pdfcreator=XeTeX output} +\def\s@pkg#1{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}} +\def\@pkg#1{\texorpdfstring{\href{https://www.ctan.org/pkg/#1}% + {\textcolor{pkgcolor}{\textsf{#1}}}}{“#1”}} +\DeclareRobustCommand\pkg{\@ifstar\@pkg\s@pkg} +\def\modu#1{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}} +\def\opt#1{\texorpdfstring{\texttt{#1}}{“#1”}} +\protected\def\marg#1{\texttt\{\meta{#1}\texttt\}} +\protected\def\oarg#1{\texttt[\meta{#1}\texttt]} +\parindent2.4em +\linespread{1.06} +\usepackage{multicol,fancyvrb,verbatim,array,hologo} +\fvset{xleftmargin=\parindent} +\newenvironment{displayed}{\trivlist\item[]\leftskip\parindent\relax}{\endtrivlist} +\usepackage[normalem]{ulem} +\newcounter{example}[subsection] +\renewcommand\theexample{\thesubsection.\arabic{example}} +\newwrite\example@out +\def\example@name{\jobname.example.aux} +\long\def\example@start{\begingroup\@bsphack + \immediate\openout\example@out=\example@name + \let\do\@makeother\dospecials\catcode`\^^M\active + \def\verbatim@processline{\immediate\write\example@out{\the\verbatim@line}}% + \verbatim@start} +\long\def\example@end{\immediate\closeout\example@out\@esphack\endgroup% + \trivlist\item[]\relax + \leavevmode\hbox to \z@{% + \hbox to \z@{\hss{\footnotesize[\theexample]}\hskip10pt}% + \hskip\parindent + \begin{minipage}[c]{0.55\textwidth}% + \small\verbatiminput{\example@name}% + \end{minipage}% + \fbox{% + \begin{minipage}[c]{0.5\textwidth}% + \normalsize\input{\example@name}% + \end{minipage}% + }% + \hss}% + \endtrivlist} +\newenvironment{example*}[1]% + {\refstepcounter{example}\label{#1}\example@start}{\example@end} +\newenvironment{example} + {\stepcounter{example}\example@start}{\example@end} +\author{Zhang Tingxuan} +\date{2023/10/24\quad Version 1.0.0\thanks{% + \url{https://www.github.com/AlphaZTX/physics2}}} +\makeatother +\endinput diff --git a/macros/latex/contrib/physics2/physics2-code.dtx b/macros/latex/contrib/physics2/physics2-code.dtx new file mode 100644 index 0000000000..f83913530f --- /dev/null +++ b/macros/latex/contrib/physics2/physics2-code.dtx @@ -0,0 +1,1345 @@ +% \iffalse meta-comment +% +% Copyright (C) 2023 by Zhang Tingxuan +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3c of this license or (at your option) any later +% version. The latest version of this license is in: +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.3 or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Zhang Tingxuan. +% +% This work consists of the files physics2-code.dtx, +% and the derived files physics2.ins, +% physics2.sty, +% phy-.sty, +% physics2-code.pdf, +% and README.md. +% +%<*internal> +\iffalse +% +% +%<*readme> +# The `physics2` package + +This package defines commands for typesetting math formulae faster and +more simply. `physics2` is a modularized package, each module provides its +own function while `physics2.sty` itself only provides very few functions. +Therefore you can load modules separately after loading `physics2`. + +Modules of `physics2` provide the following supports: + +- Automatic braces; +- Dirac bra-ket notation; +- Easy way to typeset diagonal matrices and matrices with similar entries; +- Double cross and double dot (binary) operators for tensors; + +**Welcome to pull requests +[here](https://github.com/AlphaZTX/physics2/pulls).** + +## License + +This work may be distributed and/or modified under the conditions of the +[LaTeX Project Public License](http://www.latex-project.org/lppl.txt), +either version 1.3c of this license or (at your option) any later version. + +This work has the LPPL maintenance status `maintained`. + +The Current Maintainer of this work is +[Zhang Tingxuan](https://www.ctan.org/author/zhang-tx). + +% +% +%<*internal> +\fi +\begingroup + \def\NameOfLaTeXe{LaTeX2e} +\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else +\csname fi\endcsname +% +% +%<*install> +\input docstrip.tex +\keepsilent + +\preamble + + Copyright (C) 2023 by Zhang Tingxuan + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. The latest version of this license is in: + + http://www.latex-project.org/lppl.txt + + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is Zhang Tingxuan. + + This work consists of the files physics2-code.dtx, + and the derived files physics2.ins, + physics2.sty, + phy-.sty, + physics2-code.pdf, + and README.md. + +\endpreamble + +\generate{ + \usedir{tex/latex/physics2} + \file{physics2.sty} {\from{physics2-code.dtx}{package}} + \file{phy-ab.sty} {\from{physics2-code.dtx}{ab}} + \file{phy-ab.braket.sty} {\from{physics2-code.dtx}{ab.braket}} + \file{phy-braket.sty} {\from{physics2-code.dtx}{braket}} + \file{phy-diagmat.sty} {\from{physics2-code.dtx}{diagmat}} + \file{phy-doubleprod.sty} {\from{physics2-code.dtx}{doubleprod}} + \file{phy-xmat.sty} {\from{physics2-code.dtx}{xmat}} + \file{phy-ab.legacy.sty} {\from{physics2-code.dtx}{ab.legacy}} + \file{phy-bm-um.legacy.sty} {\from{physics2-code.dtx}{bm-um.legacy}} + \file{phy-nabla.legacy.sty} {\from{physics2-code.dtx}{nabla.legacy}} + \file{phy-op.legacy.sty} {\from{physics2-code.dtx}{op.legacy}} + \file{phy-qtext.legacy.sty} {\from{physics2-code.dtx}{qtext.legacy}} +% +%<*internal> + \usedir{source/latex/physics2} + \file{physics2.ins} {\from{physics2-code.dtx}{install}} +% +%<*install> + \usedir{doc/latex/physics2} + \nopreamble\nopostamble + \file{README.md} {\from{physics2-code.dtx}{readme}} +} + +\obeyspaces +\Msg{**********************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the *} +\Msg{* following files into a directory searched by TeX: *} +\Msg{* *} +\Msg{* physics2.sty, *} +\Msg{* (for all modules) phy-.sty. *} +\Msg{* *} +\Msg{* The recommended directory is *} +\Msg{* TEXMFDIST/tex/latex/physics2 *} +\Msg{* *} +\Msg{* To produce the documentation, run the file *} +\Msg{* physics2-code.dtx through XeLaTeX or LuaLaTeX. *} +\Msg{* XeLaTeX is recommended. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{**********************************************************} + +\endbatchfile +% +% +%<*internal> +\fi +% +% +%<*driver> +\ProvidesFile{fixdif.dtx}[2023/03/20 (c) Copyright 2022-2023 by Zhang Tingxuan] +\documentclass{l3doc} +\usepackage{doc} +\hypersetup{hidelinks} +\usepackage{color} +\definecolor{pkgcolor}{RGB}{0,120,80} +\definecolor{moducolor}{RGB}{0,0,150} +\definecolor{gray}{rgb}{.5,.5,.5} +\DeclareRobustCommand\pkg[1]{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}} +\DeclareRobustCommand\modu[1]{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}} +\DeclareRobustCommand\note{\textbf{Note:} } +\usepackage{amsmath} +\usepackage{fontspec} +\setmonofont{Latin Modern Mono Light} +\usepackage{fancyvrb} +\fvset{gobble=2,xleftmargin=2em} +\usepackage{physics2} +\usephysicsmodule{ab} +\makeatletter +\@addtoreset{CodelineNo}{section} +\newbox\@tempboxb +\DeclareDocumentCommand\macrodef{O{4em}O{.6}mo+m}{\leavevmode +\ensuremath{% + \setbox\@tempboxa\hbox to #1 {\hss\cs{#3}}% + \setbox\@tempboxb\vbox{\hsize=#2\textwidth + \textwidth=\hsize + \leftskip=\z@ + \parindent=\z@ + \textbf{begindef}\IfValueT{#4}{ \textcolor{gray}{(#4)}}\par + \begingroup\leftskip2em\parindent-1em#5\par\endgroup + \textbf{enddef}% + }% + \dp\@tempboxb=\dimexpr\ht\@tempboxb-\ht\@tempboxa\relax + \ht\@tempboxb=\ht\@tempboxa + \box\@tempboxa\leftarrow\box\@tempboxb +}} +\protected\long\def\macroifelse#1#2#3{\par + \textbf{if} #1 \textbf{then}\par + \begingroup\advance\leftskip1em#2\par\endgroup + \textbf{else}\par + \begingroup\advance\leftskip1em#3\par\endgroup + \textbf{endif}\par +} +\protected\long\def\macroif#1#2{\par + \textbf{if} #1 \textbf{then}\par + \begingroup\advance\leftskip1em#2\par\endgroup + \textbf{endif}\par +} +\protected\def\macrocr{\par} +\newdimen\ttwd +\protected\def\updatettwd{% + \setbox\@tempboxa\hbox{\normalsize\ttfamily a} + \ttwd=\wd\@tempboxa +} +\updatettwd +\makeatother +\title{Code documentation to the \pkg{physics2} package} +\author{Zhang Tingxuan} +\date{2023/10/24 v1.0.0} +\begin{document} + \DocInput{physics2-code.dtx} +\end{document} +% +% \fi +% +% \maketitle +% +% \tableofcontents\newpage +% +%^^A******************************************************************************** [physics2.sty] +% \part{The bare \pkg{physics2}} +% \section{The \pkg{physics2} package} +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e}[2020/10/01] +\ProvidesPackage{physics2} + [2023/10/24 v1.0.0 Tools for typesetting math for physics.] +% \end{macrocode} +% \subsection{Common variables} +% \begin{variable}{\phy@temp..} +% \begin{syntax} +% \cs{phy@temp}\meta{register type}\meta{a|b|c} +% \end{syntax} +% Some \LaTeXe\ variables starting with ``|\phy@temp|''. +% These variables can be shared by any module of \pkg{physics2}. +% \end{variable} +% \begin{macrocode} +\newcount \phy@tempcnta +\newdimen \phy@tempdima +\newdimen \phy@tempdimb +\newskip \phy@tempskipa +\newmuskip \phy@tempmuskipa +\newbox \phy@tempboxa +\newif \ifphy@tempswa +\newtoks \phy@toksa +% \end{macrocode} +% \subsection{Package requirements and module-loading methods} +% \pkg{physics2} requires \pkg{keyval} (part of the graphics bundle) to +% process options of modules. +% \begin{macrocode} +\RequirePackage{keyval} +\def\phy@true{true} +\def\phy@false{false} +% \end{macrocode} +% \begin{function}{\phy@define@key, \phy@setkeys, \phy@processkeyopt} +% \begin{syntax} +% \cs{phy@define@key} \marg{module} \marg{key} \oarg{default value} \marg{code} +% \cs{phy@setkeys} \marg{module} \marg{key-val list} +% \cs{phy@processkeyopt} \marg{module} +% \end{syntax} +% The position of \cs{phy@processkeyopt} in a \pkg{physics2} module is just the same +% as the position of \cs{ProcessOptions} in a regular \LaTeX\ package. +% \end{function} +% \begin{macrocode} +\long\def\phy@define@key#1{\define@key{phy-#1}} +\long\def\phy@setkeys#1{\setkeys{phy-#1}} +\def\phy@processkeyopt#1{\let\reserved@a\@empty% + \edef\reserved@a{\@ptionlist{\@currname.\@currext}}% + \edef\reserved@a{\noexpand\phy@setkeys{#1}{\reserved@a}}% + \reserved@a% the next line thanks to `geometry' + \AtEndOfPackage{\let\@unprocessedoptions\relax}} +% \end{macrocode} +% We use almost the same way to load \pkg{physics2} modules as \LaTeXe\ kernel +% does. We use a lot of kernel commands in \LaTeXe. +% +% \begin{function}{\usephysicsmodule, \phy@requiremodule} +% \begin{syntax} +% \cs{usephysicsmodule} \oarg{key-val options} \marg{module} \oarg{key-val options} +% \cs{phy@requiremodule} \oarg{key-val options} \marg{module} \oarg{key-val options} +% \end{syntax} +% \cs{usephysicsmodule} is a user command, and \cs{phy@requiremodule} is a developer +% command. +% \end{function} +% \begin{macrocode} +\def\usephysicsmodule{\phy@FWoptions\@pkgextension} +\let\phy@requiremodule\usephysicsmodule +\@onlypreamble\usephysicsmodule +\def\phy@FWoptions#1{\@ifnextchar[%] + {\phy@FW@ptions#1}{\phy@FW@ptions#1[]}} +\@onlypreamble\phy@FWoptions +\def\phy@FW@ptions#1[#2]#3{\@ifnextchar[%] + {\phy@FW@pti@ns#1[{#2}]#3}{\phy@FW@pti@ns#1[{#2}]#3[]}} +\@onlypreamble\phy@FW@ptions +\def\phy@FW@pti@ns#1[#2]#3[#4]{% + \def\reserved@b##1,{% + \ifx\@nnil##1\relax\else + \ifx\@nnil##1\@nnil\else + \noexpand\@onefilewithoptions{phy-##1}[{\unexpanded{#2}}][{#4}]% + \noexpand\@pkgextension + \fi + \expandafter\reserved@b + \fi}% + \edef\reserved@a{\zap@space#3 \@empty}% + \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nnil,}% + \reserved@a} +\@onlypreamble\phy@FW@pti@ns +% \end{macrocode} +% \subsection{The (used to be) \modu{common} module} +% The code below used to be the automatically-loaded \modu{common} module, +% but now we load it together with \pkg{physics2}'s code. This change may +% bring better performance in Windows system. +% +% Check if \pkg{unicode-math} loaded and (re)define the vert symbols. +% The \cs{relax}'s at the ends of \cs{vert} and \cs{Vert}'s definitions must not be +% removed. They are for \cs{ifx} to compare. \pkg{unicode-math} sets these symbols +% \cs{fam}1, \cs{symoperators} is equal to 1 in \LaTeXe\ kernel. Moreover, we make +% \cs{mid} as a delimiter but it may not work. +% \begin{macrocode} +\AtBeginDocument{\ifcsname symrm\endcsname + \protected\def\|{\Udelimiter 0 \symoperators "2016 }% + \protected\def\vert{\Udelimiter 0 \symoperators "007C\relax}% + \protected\def\Vert{\Udelimiter 0 \symoperators "2016\relax}% + \protected\def\mid{\Udelimiter 3 \symoperators "007C }% +\fi} +\protected\def\Vert{\delimiter"026B30D\relax} +\protected\def\mid{\delimiter"326A30C } +% \end{macrocode} +% \begin{function}{\delopen, \delclose} +% \begin{syntax} +% \cs{delopen} \meta{left delimiter} +% \cs{delclose} \meta{right delimiter} +% \end{syntax} +% Actually in \TeX, \cs{left} and \cs{right} will enclose the subformula as ``inner'', +% but \cs{delopen} and \cs{delclose} will make the subformula an empty open node and +% a non-empty close node. +% \end{function} +% \begin{macrocode} +\DeclareRobustCommand\delopen{\mathopen{}\mathclose\bgroup\left} +\DeclareRobustCommand\delclose{\aftergroup\egroup\right} +% Extension to 2e kernel's or amsmath's biggggg commands. +% \end{macrocode} +% \cs{bBigg@} is a command from \pkg{amsmath}. The code below should +% update with \pkg{amsmath} together. +% \begin{macrocode} +\ifdefined\bBigg@ + \DeclareRobustCommand\biggg{\bBigg@{3}} + \DeclareRobustCommand\Biggg{\bBigg@{3.5}} +\else + \DeclareRobustCommand\biggg[1]{\leavevmode@ifvmode + {\hbox{$\left#1\vbox to20.5\p@{}\right.\n@space$}}} + \DeclareRobustCommand\Biggg[1]{\leavevmode@ifvmode + {\hbox{$\left#1\vbox to23.5\p@{}\right.\n@space$}}} + \AtBeginDocument{\ifdefined\bBigg@ + \DeclareRobustCommand\biggg{\bBigg@{3}}% + \DeclareRobustCommand\Biggg{\bBigg@{3.5}}% + \fi} +\fi +\DeclareRobustCommand\bigggl{\mathopen\biggg} +\DeclareRobustCommand\bigggm{\mathrel\biggg} +\DeclareRobustCommand\bigggr{\mathclose\biggg} +\DeclareRobustCommand\Bigggl{\mathopen\Biggg} +\DeclareRobustCommand\Bigggm{\mathrel\Biggg} +\DeclareRobustCommand\Bigggr{\mathclose\Biggg} +% \end{macrocode} +% \begin{function}{\phy@mathvphantom} +% \begin{syntax} +% \cs{phy@mathvphantom} \marg{math mode material} +% \end{syntax} +% This command is just like \cs{vphantom} in \LaTeXe\ kernel but only works +% in math mode. +% \end{function} +% \begin{macrocode} +\def\phy@mathvphantom#1{\setbox\phy@tempboxa=\hbox{}% + \mathchoice + {\setbox\@tempboxa\hbox{$\displaystyle#1$}% + \ht\phy@tempboxa=\ht\@tempboxa + \dp\phy@tempboxa=\dp\@tempboxa + \box\phy@tempboxa} + {\setbox\@tempboxa\hbox{$\textstyle#1$}% + \ht\phy@tempboxa=\ht\@tempboxa + \dp\phy@tempboxa=\dp\@tempboxa + \box\phy@tempboxa} + {\setbox\@tempboxa\hbox{$\scriptstyle#1$}% + \ht\phy@tempboxa=\ht\@tempboxa + \dp\phy@tempboxa=\dp\@tempboxa + \box\phy@tempboxa} + {\setbox\@tempboxa\hbox{$\scriptscriptstyle#1$}% + \ht\phy@tempboxa=\ht\@tempboxa + \dp\phy@tempboxa=\dp\@tempboxa + \box\phy@tempboxa}% +} +% \end{macrocode} +% \subsection{The (used to be) \modu{explsetup} module} +% Some common variables and functions for experimental \LaTeX3 syntax. +% \begin{macrocode} +%<@@=phy> +\ExplSyntaxOn +\int_new:N \l_@@_tmpa_int +\int_new:N \l_@@_tmpb_int +\tl_new:N \l_@@_tmpa_tl +\tl_new:N \l_@@_tmpb_tl +% \end{macrocode} +% The function that can gobble one token. +% \begin{macrocode} +\cs_new:Npn \_@@_gobble_i:n #1 { } +\ExplSyntaxOff +%<@@=> +% +% \end{macrocode} +% +%^^A******************************************************************************** [l2e modules] +% \part{Modules written in \LaTeXe\ syntax} +% \section{The \modu{ab} module} +% \begingroup\color{gray}% +% \noindent$\langle*\hbox{\sffamily gibberish}\rangle$\par +% This module is important but the code is hard to read. One of the motivations +% I manage \pkg{physics2} with \pkg{DocStrip} is that, when I tried to write a +% new module based on \modu{ab} after 5 months when I maintained \pkg{physics2} +% the last time, I found that I could not understand the code I wrote at all! +% Therefore, it's significant to comment out the alien code in \modu{ab}.\par +% \noindent$\langle/\hbox{\sffamily gibberish}\rangle$\par +% \endgroup +% \begin{macrocode} +%<*ab> +\ProvidesFile{phy-ab.sty} + [2023/10/24 `ab' (autobraces) module of physics2] +% \end{macrocode} +% If you don't know when to use \cs{phy@define@key}, \cs{phy@setkeys} and +% \cs{phy@processkeyopt} in a module, see ahead. In \modu{ab}, the |tightbraces| +% option can control if the automatically-sized braces are tight or not. Do you +% remember \cs{delopen} and \cs{delclose}? +% \begin{macrocode} +\phy@define@key{ab}{tightbraces}[true]{\def\@phy@abtight{#1}} +\phy@setkeys{ab}{tightbraces=true} +\phy@processkeyopt{ab} +% \end{macrocode} +% \begin{function}{\phy@abopen, \phy@abclose} +% \begin{syntax} +% \cs{phy@abopen} \meta{left delimiter} +% \cs{phy@abclose} \meta{right delimiter} +% \end{syntax} +% They are defined either \{\cs{delopen}, \cs{delclose}\} or +% \{\cs{left}, \cs{right}\}. If a module requires \modu{ab}, +% these two commands are likely to be used. +% \end{function} +% \begin{macrocode} +\ifx\@phy@abtight\phy@true + \let\phy@abopen\delopen + \let\phy@abclose\delclose +\else + \let\phy@abopen\left + \let\phy@abclose\right +\fi +% \end{macrocode} +% \subsection{The implementation of \cs{ab}} +% This is the alienest part of \modu{ab}. It's better to draw something rather +% than write boring comments. First let's take a look at \cs{ab}'s syntax. +% After \cs{ab} should be a pair of delimiters; take \texttt{()} as an example. +% Between \cs{ab} and ``\texttt{(}'' can be a biggg command or star, or even nothing. +% \cs{ab} is defined as follows: +% \[ \macrodef{ab}{\cs{phy@d@lx} \texttt{\{mb\}} \texttt{\{ab\}}} \] +% where \texttt{ab} is the branch name of |\ab()|, and \texttt{mb} is the branch +% name of |\ab\big()| and |\ab*()|. Then let's see the syntax of \cs{phy@d@lx}. +% \[ \hbox{\ttfamily\cs{phy@d@lx} \marg{biggg or star branch name} \marg{automatic branch name} \{\#3\}} \] +% Here exists an \texttt{\#3}. \texttt{\#3} is one token immediately following \cs{ab}, +% which can be \{\,a biggg command or a star\,\} or a ``\texttt{(}'', under our assumption. + +% \cs{phy@d@lx} is defined as follows: +% \[ +% \macrodef {phy@d@lx} [\#1: biggg or star branch name, \meta{mb}; \#2: automatic branch name, \meta{ab}; \#3, the token after \cs{ab}] +% {% +% \macroifelse {\#3 == biggg or \#3 == star ($\Leftrightarrow$ csname \{phy@del\cs{string}\#3\} is defined)} +% {let \meta{next cs} = csname \{phy@d@lx\meta{mb}\}} +% {let \meta{next cs} = csname \{phy@d@lx\meta{ab}\}} +% \meta{next cs} \#3 +% } +% \] +% The condition should be true when \#3 is |\big| or |*|, and it should be false when +% \#3 is ``|(|''. Accordingly, in math mode, +% \begin{align*} +% \hbox{\ttfamily\cs{ab} \cs{big} (}&\quad\to\quad\hbox{\ttfamily\cs{phy@d@lxmb} \cs{big} (}\\ +% \hbox{\ttfamily\cs{ab} \phantom{\cs{big}} (}&\quad\to\quad\hbox{\ttfamily\cs{phy@d@lxab} \phantom{\cs{big}} (} +% \end{align*} +% Then we meet two new commands --- \cs{phy@d@lxmb} and \cs{phy@d@lxab}. Syntax is as follows. +% \begin{align*} +% &\hbox{\ttfamily\cs{phy@d@lxmb} \meta{biggg or *} +% \meta{left delimiter} \meta{subformula} \meta{right delimiter}}\\ +% &\hbox{\ttfamily\cs{phy@d@lxab} \phantom{\meta{biggg or *}} +% \meta{left delimiter} \meta{subformula} \meta{right delimiter}} +% \end{align*} +% Notice that \texttt{ab} and \texttt{mb} in the above commands are names of \cs{ab}'s +% two branches --- they are like namespaces. \cs{phy@d@lxmb} and \cs{phy@d@lxab} are +% defined by the following two lines: +% \begin{Verbatim} +% \phy@d@l@genxm{mb} +% \phy@d@l@genxa{ab} +% \end{Verbatim} +% \cs{phy@d@l@genxm} and \cs{phy@d@l@genxa} are defined as follows: +% \begin{align*} +% & \macrodef {phy@d@l@genxm} [\#1: biggg or star branch name, \meta{mb}] +% {% +% \macrodef [12\ttwd] {phy@d@lx\meta{mb}} [\#\#1: biggg or star; \#\#2: left delimiter] +% {% +% \cs{begingroup} +% \macroifelse {\#\#1 == star} +% {\meta{temp} $\gets$ \cs{relax}} +% {\meta{temp} $\gets$ \#\#1} +% csname \{phy@\meta{mb}@\cs{string}\#\#2\} \meta{temp} \#\#2 \macrocr +% \% requires an \cs{endgroup} after the right delimiter +% } +% } \\[1ex] +% & \macrodef {phy@d@l@genxa} [\#1: automatic branch name, \meta{ab}] +% {% +% \macrodef [12\ttwd] {phy@d@lx\meta{ab}} [\#\#1: left delimiter] +% {% +% csname \{phy@\meta{ab}@\cs{string}\#\#1\} \#\#1 +% } +% } +% \end{align*} +% So we can get +% \begin{align*} +% \hbox{\ttfamily\cs{ab} \cs{big} (}&\quad\to\quad\hbox{\cs{begingroup} csname \{phy@mb@(\} \cs{big}\hskip2\ttwd\ \texttt(}\\ +% \hbox{\ttfamily\cs{ab} *\phantom{big} (}&\quad\to\quad\hbox{\cs{begingroup} csname \{phy@mb@(\} \cs{relax} \texttt(}\\ +% \hbox{\ttfamily\cs{ab} \phantom{\cs{big}} (}&\quad\to\quad\hbox{\hskip11\ttwd\ csname \{phy@ab@(\} \texttt(} +% \end{align*} +% The csnames above (\cs{phy@mb@(} and \cs{phy@ab@(}) are generated with \cs{phy@AB@gen}. +% \[ \hbox{\cs{phy@AB@gen} \marg{branch name} \meta{left delimiter} \marg{arg spec} \marg{definition}} \] +% If \meta{branch name} is \texttt{mb}, \marg{arg spec} should be |mr()|, where |m| is for biggg or star; +% If \meta{branch name} is \texttt{ab}, \marg{arg spec} should be |r()|. +% +% \note The ``|(|'' in the example above must not be replaced by a subformula braced by a pair of |{}|. +% +% \begin{function}{\phy@AB@gen} +% \begin{syntax} +% \cs{phy@AB@gen} \marg{branch name} \meta{left delimiter} \marg{arg spec} \marg{definition} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\def\phy@AB@gen#1#2{\expandafter\DeclareDocumentCommand\csname phy@#1@\string#2\endcsname} +\phy@AB@gen{ab}({r()}{\phy@abopen(#1\phy@abclose)} +\phy@AB@gen{ab}[{r[]}{\phy@abopen[#1\phy@abclose]} +\phy@AB@gen{ab}\{{r\{\}}{\phy@abopen\{#1\phy@abclose\}} +\phy@AB@gen{ab}|{r||}{\phy@abopen|#1\phy@abclose|} +\phy@AB@gen{ab}\|{r\|\|}{\phy@abopen\|#1\phy@abclose\|} +\phy@AB@gen{ab}<{r<>}{\phy@abopen<#1\phy@abclose>} +\phy@AB@gen{ab}\lbrace{r\lbrace\rbrace}{\phy@abopen\lbrace#1\phy@abclose\rbrace} +\phy@AB@gen{ab}\vert{r\vert\vert}{\phy@abopen\vert#1\phy@abclose\vert} +\phy@AB@gen{ab}\Vert{r\Vert\Vert}{\phy@abopen\Vert#1\phy@abclose\Vert} +\phy@AB@gen{ab}\langle{r\langle\rangle}{\phy@abopen\langle#1\phy@abclose\rangle} +% \end{macrocode} +% \cs{endgroup}'s in the end of the following definitions are corresponding to +% \cs{begingroup}'s in the definition of \cs{phy@d@l@genxm}. +% \begin{macrocode} +\phy@AB@gen{mb}({mr()}{\mathopen#1(#2\mathclose#1)\endgroup} +\phy@AB@gen{mb}[{mr[]}{\mathopen#1[#2\mathclose#1]\endgroup} +\phy@AB@gen{mb}\{{mr\{\}}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} +\phy@AB@gen{mb}|{mr||}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} +\phy@AB@gen{mb}\|{mr\|\|}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} +\phy@AB@gen{mb}<{mr<>}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} +\phy@AB@gen{mb}\lbrace{mr\lbrace\rbrace}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} +\phy@AB@gen{mb}\vert{mr\vert\vert}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} +\phy@AB@gen{mb}\Vert{mr\Vert\Vert}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} +\phy@AB@gen{mb}\langle{mr\langle\rangle}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} +% \end{macrocode} +% \begin{function}{\phy@del\string.} +% The syntax seems not important. These following lines seems only for \cs{ifcsname} +% to judge if the commands are defined. +% \end{function} +% \begin{macrocode} +\def\phy@del#1#2#3{\phy@abopen#1#3\phy@abclose#2} +\expandafter\def\csname phy@del\string*\endcsname#1#2#3{\mathopen#1#3\mathclose#2} +\expandafter\def\csname phy@del\string\big\endcsname#1#2#3{\bigl#1#3\bigr#2} +\expandafter\def\csname phy@del\string\Big\endcsname#1#2#3{\Bigl#1#3\Bigr#2} +\expandafter\def\csname phy@del\string\bigg\endcsname#1#2#3{\biggl#1#3\biggr#2} +\expandafter\def\csname phy@del\string\Bigg\endcsname#1#2#3{\Biggl#1#3\Biggr#2} +\expandafter\def\csname phy@del\string\biggg\endcsname#1#2#3{\bigggl#1#3\bigggr#2} +\expandafter\def\csname phy@del\string\Biggg\endcsname#1#2#3{\Bigggl#1#3\Bigggr#2} +% \end{macrocode} +% \begin{function}{\phy@d@lx} +% \begin{syntax} +% \cs{phy@d@lx} \marg{biggg or star branch name} \marg{automatic branch name} \{\#3\} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\def\phy@d@lx#1#2#3{% + \ifcsname phy@del\string#3\endcsname + \def\reserved@a{#1}% #3 is star or \biggg + \else + \def\reserved@a{#2}% #3 is delimiter + \fi + \csname phy@d@lx\reserved@a\endcsname#3} +% \end{macrocode} +% \begin{function}{\phy@d@l@genxm, \phy@d@l@genxa} +% \begin{syntax} +% \cs{phy@d@l@genxm} \marg{biggg or star branch name} +% \cs{phy@d@l@genxa} \marg{automatic branch name} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\def\phy@d@l@genxm#1{% + \expandafter\def\csname phy@d@lx#1\endcsname##1##2{% + \begingroup % \endgroup is at the end of #4 of \phy@AB@gen + \ifx##1*\let\phy@tempa=\relax\else\let\phy@tempa=##1\fi + \csname phy@#1@\string##2\endcsname\phy@tempa##2}} +\def\phy@d@l@genxa#1{% + \expandafter\def\csname phy@d@lx#1\endcsname##1{% + \csname phy@#1@\string##1\endcsname##1}} +% \end{macrocode} +% \begin{function}{\phy@d@lxmb, \phy@d@lxab} +% \begin{syntax} +% \cs{phy@d@lxmb} \meta{biggg or *} \meta{left delimiter} \meta{subformula} \meta{right delimiter} +% \cs{phy@d@lxab} \phantom{\meta{biggg or *}} \meta{left delimiter} \meta{subformula} \meta{right delimiter} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\phy@d@l@genxm{mb} +\phy@d@l@genxa{ab} +% \end{macrocode} +% \begin{function}{\ab} +% The users' command \cs{ab}. +% \end{function} +% \begin{macrocode} +\DeclareRobustCommand\ab{\phy@d@lx{mb}{ab}} +% \end{macrocode} +% \subsection{\cs{pab}-like commands} +% This is so simple. No need to comment a lot. +% +% \begin{function}{\phy@d@l@geny} +% \begin{syntax} +% \cs{phy@d@l@geny} \meta{command} \meta{left delimiter} \meta{right delimiter} +% \end{syntax} +% This command used to define commands like \cs{pab}. +% \end{function} +% \begin{macrocode} +\def\phy@d@l@geny#1#2#3{% + \DeclareDocumentCommand#1{som}{% ##1: star; ##2: bigg (csname); ##3: subformula. + \IfBooleanTF{##1}% + {#2##3#3}% + {\IfValueTF{##2}% + {\csname##2l\endcsname#2##3\csname##2r\endcsname#3}% + {\phy@abopen#2##3\phy@abclose#3}% + }% + }% +} +\phy@d@l@geny\pab() +\phy@d@l@geny\bab[] +\phy@d@l@geny\Bab\lbrace\rbrace +\phy@d@l@geny\vab\vert\vert +\phy@d@l@geny\aab\langle\rangle +\phy@d@l@geny\Vab\Vert\Vert +% +% \end{macrocode} +% \section{The \modu{ab.braket} module} +% \begin{macrocode} +%<*ab.braket> +\ProvidesFile{phy-ab.braket.sty} + [2023/10/24 `ab.braket' module of physics2] +% \end{macrocode} +% This module requires \cs{phy@abopen} and \cs{phy@abclose} from \modu{ab}. +% This module may have conflict with \modu{braket}. +% \begin{macrocode} +\phy@requiremodule{ab} +\ifdefined\phy@bra@@ + \PackageWarning{physics2}{You cannot load `ab.braket' and `braket' + modules together.\MessageBreak Only `ab.braket' module works now.} +\fi +% \end{macrocode} +% \begin{function}{\bra} +% \begin{syntax} +% \cs{bra} \char`\<\ \meta{subformula} \char`\| +% \end{syntax} +% \end{function} +% \begin{macrocode} +\phy@AB@gen{br.m}<{mr<|}{\mathopen#1\langle#2\mathclose#1\vert\endgroup} +\phy@AB@gen{br.a}<{r<|}{\phy@abopen\langle#1\phy@abclose\vert} +\phy@d@l@genxm{br.m} +\phy@d@l@genxa{br.a} +\DeclareRobustCommand\bra{\phy@d@lx{br.m}{br.a}} +% \end{macrocode} +% \begin{function}{\ket} +% \begin{syntax} +% \cs{ket} \char`\|\ \meta{subformula} \char`\> +% \end{syntax} +% \end{function} +% \begin{macrocode} +\phy@AB@gen{kt.m}|{mr|>}{\mathopen#1\vert#2\mathclose#1\rangle\endgroup} +\phy@AB@gen{kt.a}|{r|>}{\phy@abopen\vert#1\phy@abclose\rangle} +\phy@d@l@genxm{kt.m} +\phy@d@l@genxa{kt.a} +\DeclareRobustCommand\ket{\phy@d@lx{kt.m}{kt.a}} +% \end{macrocode} +% \begin{function}{\braket} +% \begin{syntax} +% \cs{braket} \char`\<\ \meta{subformula 1} \char`\|\ \meta{subformula 2} {\color{gray}\textrm{[}\char`\|\ \meta{subformula 3} \textrm{\dots]}} \char`\> +% \end{syntax} +% \end{function} +% \begin{macrocode} +\begingroup +\catcode`\|=\active +\gdef\phy@@mb@bk#1#2{\begingroup + \mathcode`\|="8000\def|{\egroup#1\vert\bgroup}% + \def\<{\mathrel{<}}\def\>{\mathrel{>}}% + \mathopen#1\langle\bgroup#2\egroup\mathclose#1\rangle\endgroup} +\gdef\phy@@ab@bk#1{\begingroup + \mathcode`\|="8000\def|{\egroup\phy@abb@bkv\bgroup}% + \def\<{\mathrel{<}}\def\>{\mathrel{>}}% + \phy@abopen\langle\bgroup#1\egroup\phy@abclose\rangle\endgroup} +\endgroup +\def\phy@abb@bkv{\middle\vert} +\phy@AB@gen{bk.m}<{mr<>}{\phy@@mb@bk#1{#2}\endgroup} +\phy@AB@gen{bk.a}<{r<>}{\phy@@ab@bk{#1}} +\phy@d@l@genxm{bk.m} +\phy@d@l@genxa{bk.a} +\DeclareRobustCommand\braket{\phy@d@lx{bk.m}{bk.a}} +% \end{macrocode} +% \begin{function}{\ketbra} +% \begin{syntax} +% \cs{braket} \char`\|\ \meta{subformula 1} \char`\>\ \meta{subformula 2} \char`\<\ \meta{subformula 3} \char`\| +% \end{syntax} +% \end{function} +% \begin{macrocode} +\begingroup +\catcode`\<=\active +\catcode`\>=\active +\gdef\phy@@mb@kb#1#2{\begingroup + \mathcode`\<="8000 \mathcode`\>="8000% + \def<{#1\langle}\def>{#1\rangle}% + \def\<{\phy@abb@l}\def\>{\phy@abb@r}% + \mathopen#1\vert#2\mathclose#1\vert\endgroup} +\endgroup +\gdef\phy@@ab@kb#1>#2<#3\phy@@end{\begingroup + \def\<{\phy@abb@l}\def\>{\phy@abb@r}% + \phy@abopen\vert\mathopen{\phy@mathvphantom{#3}}#1\phy@abclose\rangle#2% + \phy@abopen\langle#3\mathclose{\phy@mathvphantom{#1}}\phy@abclose\vert +\endgroup} +\AtBeginDocument{\ifcsname symbf\endcsname + \def\phy@abb@l{\Umathchar 3 \symoperators "003C }% + \def\phy@abb@r{\Umathchar 3 \symoperators "003E }% +\fi} +\def\phy@abb@l{\mathchar"313C } +\def\phy@abb@r{\mathchar"313E } +\phy@AB@gen{kb.m}|{mr||}{\phy@@mb@kb#1{#2}\endgroup} +\phy@AB@gen{kb.a}|{r||}{\phy@@ab@kb#1\phy@@end} +\phy@d@l@genxm{kb.m} +\phy@d@l@genxa{kb.a} +\DeclareRobustCommand\ketbra{\phy@d@lx{kb.m}{kb.a}} +% +% \end{macrocode} +% \section{The \modu{braket} module} +% \begin{macrocode} +%<*braket> +\ProvidesFile{phy-braket.sty} + [2023/10/24 `braket' module of physics2] +% \end{macrocode} +% This module requires \cs{phy@abopen} and \cs{phy@abclose} from \modu{ab}. +% This module may have conflict with \modu{ab.braket}. +% \begin{macrocode} +\phy@requiremodule{ab} +\ifdefined\phy@abb@bkv + \PackageWarning{physics2}{You cannot load `ab.braket' and `braket' + modules together.\MessageBreak Only `braket' module works now.} +\fi +% \end{macrocode} +% \begin{function}{\bra} +% \begin{syntax} +% \cs{bra} * \oarg{biggg} \marg{subformula} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\DeclareDocumentCommand\bra{ s o m }{% + \IfBooleanTF{#1} + {\mathopen\langle#3\mathclose\vert} + {\IfValueTF{#2} + {\csname#2l\endcsname\langle#3\csname#2r\endcsname\vert} + {\phy@abopen\langle#3\phy@abclose\vert}% + }% +} +% \end{macrocode} +% \begin{function}{\ket} +% \begin{syntax} +% \cs{ket} * \oarg{biggg} \marg{subformula} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\DeclareDocumentCommand\ket{ s o m }{% + \IfBooleanTF{#1} + {\mathopen\vert#3\mathclose\rangle} + {\IfValueTF{#2} + {\csname#2l\endcsname\vert#3\csname#2r\endcsname\rangle} + {\phy@abopen\vert#3\phy@abclose\rangle}% + }% +} +% \end{macrocode} +% \begin{function}{\braket} +% \begin{syntax} +% \cs{ket} * [\meta{biggg}, $n \in \{1,2,3\}$] \marg{subformula 1} \dots \marg{subformula $n$} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\DeclareDocumentCommand\braket{ s O{} }{% + \IfBooleanTF{#1}% + {% + \gdef\@phy@bk@argnum{ii}% + \phy@bk@doopt{#2}% + \gdef\@phy@bk@l{mathopen}% + \gdef\@phy@bk@m{mathord}% + \gdef\@phy@bk@r{mathclose}% + }% + {% + \gdef\@phy@bk@argnum{ii}% + \gdef\@phy@bk@l{phy@abopen}% + \gdef\@phy@bk@m{middle}% + \gdef\@phy@bk@r{phy@abclose}% + \phy@bk@doopt{#2}% + }% + \csname phy@bk@in@\@phy@bk@argnum\endcsname% +} +% \end{macrocode} +% \begin{function}{\phy@bk@in@i, \phy@bk@in@ii, \phy@bk@in@iii} +% \begin{syntax} +% \cs{phy@bk@in@\meta{n.roman}} \marg{subformula 1} \dots \marg{subformula $n$} +% \end{syntax} +% \meta{n.roman} is $n$ in roman lowercase, where $n \in \{1,2,3\}$. +% \end{function} +% \begin{macrocode} +\def\phy@bk@in@i#1{% + \csname\@phy@bk@l\endcsname\langle{#1}% + \csname\@phy@bk@r\endcsname\rangle} +\def\phy@bk@in@ii#1#2{% + \csname\@phy@bk@l\endcsname\langle{#1}% + \csname\@phy@bk@m\endcsname\vert{#2}% + \csname\@phy@bk@r\endcsname\rangle} +\def\phy@bk@in@iii#1#2#3{% + \csname\@phy@bk@l\endcsname\langle{#1}% + \csname\@phy@bk@m\endcsname\vert{#2}% + \csname\@phy@bk@m\endcsname\vert{#3}% + \csname\@phy@bk@r\endcsname\rangle} +% \end{macrocode} +% \begin{function}{\phy@bk@doopt, \phy@bk@do@pt} +% \begin{syntax} +% \cs{phy@bk@doopt} \marg{clist} +% \end{syntax} +% Parse the optional argument of \cs{braket}. This will add 3 entries to hash. +% \end{function} +% \begin{macrocode} +\def\@phy@bk@do@pt#1,{\ifx#1\relax\@empty\else + \edef\reserved@a{\zap@space#1 \@empty}% + \ifx\reserved@a\@empty\else + \ifcsname phy@del\expandafter\string\csname\reserved@a\endcsname\endcsname + \xdef\@phy@bk@l{\reserved@a l}% + \xdef\@phy@bk@m{\reserved@a}% but not m (m stands for \mathrel) + \xdef\@phy@bk@r{\reserved@a r}% + \else + \ifnum\reserved@a>3% + \PackageError{physics2}{\string\braket\space can only take 3 + mandatory arguments at most}{Check if you had written a number + more than 3 in the [optional] argument.}% + \fi + \xdef\@phy@bk@argnum{\romannumeral\reserved@a}% + \fi + \fi + \expandafter\@phy@bk@do@pt\fi} +\def\phy@bk@doopt#1{\@phy@bk@do@pt#1,\relax,} +% \end{macrocode} +% \begin{function}{\ketbra} +% \begin{syntax} +% \cs{ketbra} * [\meta{biggg}] \marg{subformula 1} \oarg{between 1 and 2} \marg{subformula 2} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\DeclareDocumentCommand\ketbra{ s o m O{} m }{% + \IfBooleanTF{#1}% + {\mathopen\vert#3\mathclose\rangle#4\mathopen\langle#5\mathclose\vert}% + {\IfValueTF{#2}% + {\csname#2l\endcsname\vert#3\csname#2r\endcsname\rangle#4% + \csname#2l\endcsname\langle#5\csname#2r\endcsname\vert}% + {\begingroup + \phy@abopen\vert\mathopen{\phy@mathvphantom{#5}}#3\phy@abclose\rangle#4% + \phy@abopen\langle#5\mathclose{\phy@mathvphantom{#3}}\phy@abclose\vert + \endgroup}% + }% +} +% +% \end{macrocode} +% \section{The \modu{doubleprod} module} +% \begin{macrocode} +%<*doubleprod> +\ProvidesFile{phy-doubleprod.sty} + [2023/10/24 `doubleprod' (vertically stacked binary operators) module of physics2] +% \end{macrocode} +% Boolean options. +% \begin{macrocode} +\phy@define@key{doubleprod}{crosssymbol}{\def\@phy@dbl@c{#1}} +\phy@define@key{doubleprod}{dotsymbol}{\def\@phy@dbl@d{#1}} +\phy@define@key{doubleprod}{crossscale}{\def\@phy@dbl@sc{#1}} +\phy@define@key{doubleprod}{dotscale}{\def\@phy@dbl@sd{#1}} +\phy@define@key{doubleprod}{crossopenup}{\def\@phy@dbl@oc{#1}} +\phy@define@key{doubleprod}{dotopenup}{\def\@phy@dbl@od{#1}} +\phy@setkeys{doubleprod}{crosssymbol=\times,dotsymbol=\ldotp, + crossscale=0.8,dotscale=1,crossopenup=.02,dotopenup=.2} +\phy@processkeyopt{doubleprod} +\def\phy@dbl@gen#1#2#3#4{% + \DeclareRobustCommand#1{\mathbin{\vcenter{\baselineskip\z@skip% + \lineskip#4\phy@dblcurrf@size% + \setbox\@tempboxa=\hbox{\fontsize{#2\phy@dblcurrf@size}\z@$#3$}% + \copy\@tempboxa\box\@tempboxa}}}} +\def\phy@dblcurrf@size{\dimexpr\f@size pt\relax} +\phy@dbl@gen\doublecross\@phy@dbl@sc\@phy@dbl@c\@phy@dbl@oc +\phy@dbl@gen\doubledot\@phy@dbl@sd\@phy@dbl@d\@phy@dbl@od +% +% \end{macrocode} +%^^A******************************************************************************** [l3 modules] +% \part{Modules written in \LaTeX3 syntax} +% We use |phy| as the namespace for \pkg{physics2} modules. +% \begin{macrocode} +%<@@=phy> +% \end{macrocode} +% \section{The \modu{diagmat} module} +% \begin{macrocode} +%<*diagmat> +\ProvidesExplFile{phy-diagmat.sty}{2023/10/24}{} + {`diagmat' module of physics2} +\RequirePackage { amsmath } +\phy@define@key { diagmat } { empty } [ 0 ] { \tl_gset:Nn \l_@@_mat_empty_tl { #1 } } +% \end{macrocode} +% This module requires some new variables. +% \begin{macrocode} +\clist_new:N \l_@@_mat_diag_clist +\clist_new:N \l_@@_mat_tmpa_clist +\clist_new:N \l_@@_mat_tmpb_clist +\clist_new:N \l_@@_mat_diagpos_clist +\int_new:N \l_@@_mat_dim_int +\tl_new:N \l_@@_mat_line_tl +\tl_new:N \l_@@_diagmat_tl +\tl_new:N \l_@@_mat_empty_tl +\tl_gset:Nn \l_@@_mat_empty_tl { 0 } +\phy@processkeyopt { diagmat } +\keys_define:nn { phy/diagmat } + { + empty .tl_set:N = \l_@@_mat_empty_tl , + } +% \end{macrocode} +% \begin{function}{\diagmat} +% \begin{syntax} +% \cs{\meta{delimiter type}diagmat} \oarg{key-val list} \marg{diagonal} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\DeclareDocumentCommand \diagmat { O{} m } + { \_@@_diagmat_type:nnn { } { #1 } { #2 } } +\DeclareDocumentCommand \pdiagmat { O{} m } + { \_@@_diagmat_type:nnn { p } { #1 } { #2 } } +\DeclareDocumentCommand \bdiagmat { O{} m } + { \_@@_diagmat_type:nnn { b } { #1 } { #2 } } +\DeclareDocumentCommand \Bdiagmat { O{} m } + { \_@@_diagmat_type:nnn { B } { #1 } { #2 } } +\DeclareDocumentCommand \vdiagmat { O{} m } + { \_@@_diagmat_type:nnn { v } { #1 } { #2 } } +\DeclareDocumentCommand \Vdiagmat { O{} m } + { \_@@_diagmat_type:nnn { V } { #1 } { #2 } } +% \end{macrocode} +% \begin{function}{\_@@_diagmat_type:nnn} +% \begin{syntax} +% \cs{_@@_diagmat_type:nnn} \marg{delimiter type} \marg{key-val list} \marg{diagonal} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\cs_new:Npn \_@@_diagmat_type:nnn #1#2#3 + { + \group_begin: + \clist_set:Nn \l_@@_mat_diag_clist { #3 } + \int_set:Nn \l_@@_mat_dim_int { \clist_count:N \l_@@_mat_diag_clist } + \int_compare:nNnT { \l_@@_mat_dim_int } > { \value { MaxMatrixCols } } + { \setcounter { MaxMatrixCols } { \l_@@_mat_dim_int } } + \keys_set:nn { phy/diagmat } { #2 } + \tl_gclear:N \l_@@_diagmat_tl + \int_step_inline:nnn { 0 } { \l_@@_mat_dim_int - 1 } + { + \int_step_inline:nnn { 0 } { \l_@@_mat_dim_int - 1 } + { + \int_compare:nNnTF { ##1 } = { ####1 } + { + \clist_gpop:NN \l_@@_mat_diag_clist \l_@@_tmpa_tl + \tl_if_empty:NTF \l_@@_tmpa_tl + { \tl_gput_right:Nn \l_@@_mat_line_tl { \l_@@_mat_empty_tl } } + { \tl_gput_right:Nx \l_@@_mat_line_tl { \l_@@_tmpa_tl } } + } + { \tl_gput_right:Nn \l_@@_mat_line_tl { \l_@@_mat_empty_tl } } +% \end{macrocode} +% Add |&| (or |\\|) between matrix entries. +% \begin{macrocode} + \int_compare:nNnTF { ####1 } = { \l_@@_mat_dim_int - 1 } + { + \tl_gput_right:Nn \l_@@_mat_line_tl { \\ } + } + { + \tl_gput_right:Nn \l_@@_mat_line_tl { & } + } + } + \tl_gput_right:Nx \l_@@_diagmat_tl { \l_@@_mat_line_tl } + \tl_gclear:N \l_@@_mat_line_tl + } + \begin { #1 matrix } + \tl_use:N \l_@@_diagmat_tl + \end { #1 matrix } + \group_end: + } +% +% \end{macrocode} +% \section{The \modu{xmat} module} +% \begin{macrocode} +%<*xmat> +\ProvidesExplFile{phy-xmat.sty}{2023/10/24}{} + {`xmat' module of physics2} +\RequirePackage { amsmath } +\phy@define@key { xmat } { showtop } + { \int_gset:Nn \l_@@_xmat_showtop_int { #1 } } +\phy@define@key { xmat } { showleft } + { \int_gset:Nn \l_@@_xmat_showleft_int { #1 } } +% \end{macrocode} +% This module requires some new variables. +% \begin{macrocode} +\bool_new:N \l_@@_xmat_extra_vdots_bool +\bool_new:N \l_@@_xmat_extra_cdots_bool +\int_new:N \l_@@_xmat_showtop_int +\int_new:N \l_@@_xmat_showleft_int +\tl_new:N \l_@@_xmat_tl +\int_gset:Nn \l_@@_xmat_showtop_int { \value { MaxMatrixCols } - 2 } +\int_gset:Nn \l_@@_xmat_showleft_int { \value { MaxMatrixCols } - 2 } +\cs_new:Npn \_@@_xmat_entry_format:nnn #1#2#3 + { + #1 \c_math_subscript_token { #2 #3 } + } +\phy@processkeyopt { xmat } +\DeclareDocumentCommand \xmat { O{} m m m } + { \_@@_xmat_type:nnnnn { } { #1 } { #2 } { #3 } { #4 } } +\DeclareDocumentCommand \pxmat { O{} m m m } + { \_@@_xmat_type:nnnnn { p } { #1 } { #2 } { #3 } { #4 } } +\DeclareDocumentCommand \bxmat { O{} m m m } + { \_@@_xmat_type:nnnnn { b } { #1 } { #2 } { #3 } { #4 } } +\DeclareDocumentCommand \Bxmat { O{} m m m } + { \_@@_xmat_type:nnnnn { B } { #1 } { #2 } { #3 } { #4 } } +\DeclareDocumentCommand \vxmat { O{} m m m } + { \_@@_xmat_type:nnnnn { v } { #1 } { #2 } { #3 } { #4 } } +\DeclareDocumentCommand \Vxmat { O{} m m m } + { \_@@_xmat_type:nnnnn { V } { #1 } { #2 } { #3 } { #4 } } +\keys_define:nn { phy/xmat } + { + format .cs_set:Np = \_@@_xmat_entry_format:nnn #1#2#3 , + showtop .int_set:N = \l_@@_xmat_showtop_int , + showleft.int_set:N = \l_@@_xmat_showleft_int , + } +% \end{macrocode} +% \begin{function}[pTF]{\_@@_if_digits_only:n} +% \begin{syntax} +% \cs{_@@_if_digits_only:nTF} \marg{token list} \marg{true code} \marg{flase code} +% \end{syntax} +% Use \LaTeX3 regular expression to tell if \meta{token list} +% (the numbers of rows or columns) contain digits only. +% \end{function} +% \begin{macrocode} +\prg_new_conditional:Npnn \_@@_if_digits_only:n #1 { TF } + { + \regex_match:nnTF { \A [[:digit:]]* \Z } { #1 } + { \prg_return_true: } { \prg_return_false: } + } +% \end{macrocode} +% \begin{function}{\_@@_xmat_type:nnnnn} +% \begin{syntax} +% \cs{_@@_xmat_type:nnnnn} \marg{delimiter type} \marg{key-val list} \marg{common entry} \marg{row number} \marg{column number} +% \end{syntax} +% \end{function} +% \begin{macrocode} +\cs_new:Npn \_@@_xmat_type:nnnnn #1#2#3#4#5 + { + \group_begin: + \tl_gclear:N \l_@@_xmat_tl + \keys_set:nn { phy/xmat } { #2 } % + \_@@_if_digits_only:nTF { #4 } + { + \int_compare:nNnTF { #4 } < { \l_@@_xmat_showtop_int + 1 } + { + \int_set:Nn \l_@@_xmat_showtop_int { #4 } + \bool_set_false:N \l_@@_xmat_extra_vdots_bool + } + { + \bool_set_true:N \l_@@_xmat_extra_vdots_bool + } + } + { + \bool_set_true:N \l_@@_xmat_extra_vdots_bool + } + \_@@_if_digits_only:nTF { #5 } + { + \int_compare:nNnTF { #5 } < { \l_@@_xmat_showleft_int + 1 } + { + \int_set:Nn \l_@@_xmat_showleft_int { #5 } + \bool_set_false:N \l_@@_xmat_extra_cdots_bool + } + { + \bool_set_true:N \l_@@_xmat_extra_cdots_bool + } + } + { + \bool_set_true:N \l_@@_xmat_extra_cdots_bool + } + \int_step_inline:nn { \l_@@_xmat_showtop_int } + { + \tl_put_right:Nn \l_@@_xmat_tl + { \_@@_xmat_entry_format:nnn { #3 } { ##1 } { 1 } } + \int_step_inline:nnn { 2 } { \l_@@_xmat_showleft_int } + { + \tl_put_right:Nn \l_@@_xmat_tl + { & \_@@_xmat_entry_format:nnn { #3 } { ##1 } { ####1 } } + } + \bool_if:NT \l_@@_xmat_extra_cdots_bool + { + \tl_put_right:Nn \l_@@_xmat_tl + { & \cdots & \_@@_xmat_entry_format:nnn { #3 } { ##1 } { #5 } } + } + \tl_put_right:Nn \l_@@_xmat_tl { \\ } + } + \bool_if:NT \l_@@_xmat_extra_vdots_bool + { + \tl_put_right:Nn \l_@@_xmat_tl { \vdots } + \prg_replicate:nn { \l_@@_xmat_showleft_int - 1 } + { + \tl_put_right:Nn \l_@@_xmat_tl { & \vdots } + } + % Add \ddots if vdots_bool and cdots_bool be true simultaneously. + \bool_if:NT \l_@@_xmat_extra_cdots_bool + { + \tl_put_right:Nn \l_@@_xmat_tl { & \ddots & \vdots } + } % else relax + \tl_put_right:Nn \l_@@_xmat_tl { \\ } + % The last row. + \tl_put_right:Nn \l_@@_xmat_tl + { \_@@_xmat_entry_format:nnn { #3 } { #4 } { 1 } } + \int_step_inline:nnn { 2 } { \l_@@_xmat_showleft_int } + { + \tl_put_right:Nn \l_@@_xmat_tl + { & \_@@_xmat_entry_format:nnn { #3 } { #4 } { ##1 } } + } + \bool_if:NT \l_@@_xmat_extra_cdots_bool + { + \tl_put_right:Nn \l_@@_xmat_tl + { & \cdots & \_@@_xmat_entry_format:nnn { #3 } { #4 } { #5 } } + } + } % else relax + \begin { #1 matrix } + \tl_use:N \l_@@_xmat_tl + \end { #1 matrix } + \group_end: + } +% +% \end{macrocode} +% This part ends here. +% \begin{macrocode} +%<@@=> +% \end{macrocode} +%^^A******************************************************************************** [l2e legacy] +% \part{Legacy modules written in \LaTeXe\ syntax} +% \section{The \modu{ab.legacy} module} +% \begin{macrocode} +%<*ab.legacy> +\ProvidesFile{phy-ab.legacy.sty} + [2023/10/24 `ab.legacy' module of physics2] +% \end{macrocode} +% Requires \modu{ab}'s |tight| option. +% \begin{macrocode} +\phy@requiremodule{ab} +\phy@define@key{ab.legacy}{order}[\mathcal{O}]{\def\phy@ab@ordersym{#1}} +\phy@setkeys{ab.legacy}{order} +\phy@processkeyopt{ab.legacy} +\phy@d@l@geny\abs\vert\vert +\phy@d@l@geny\norm\Vert\Vert +\DeclareDocumentCommand\order{som}{% + \phy@ab@ordersym + \IfBooleanTF{#1} + {(#3)} + {\IfValueTF{#2} + {\csname#2l\endcsname(#3\csname#2r\endcsname)} + {\phy@abopen(#3\phy@abclose)}% + }% +} +\phy@d@l@geny\eval.\vert +\phy@d@l@geny\peval(\vert +\phy@d@l@geny\beval[\vert +% +% \end{macrocode} +% \section{The \modu{nabla.legacy} module} +% \begin{macrocode} +%<*nabla.legacy> +\ProvidesFile{phy-nabla.legacy.sty} + [2023/10/24 `nabla.legacy' module of physics2] +\phy@requiremodule{ab} +% \end{macrocode} +% Requires \pkg{fixdif} version 2.$x$. +% \begin{macrocode} +\RequirePackage{fixdif}[2023/01/31] +\letdif\phy@nl@nabla{nabla} +\AtBeginDocument{\ifcsname div\endcsname\let\divsymbol\div\fi + \DeclareRobustCommand\grad{\phy@nl@nabla\ab}% + \DeclareRobustCommand\div{\phy@nl@nabla\cdot\ab}% + \DeclareRobustCommand\curl{\phy@nl@nabla\times\ab}% + \DeclareRobustCommand\laplacian{\phy@nl@nabla^2\ab}% +} +% +% \end{macrocode} +% \section{The \modu{op.legacy} module} +% \begin{macrocode} +%<*op.legacy> +\ProvidesFile{phy-op.legacy.sty} + [2023/10/24 `op.legacy' module of physics2] +\phy@define@key{op.lega}{ReIm}[true]{\def\phy@reserveda{#1}} +\phy@define@key{op.lega}{PV}{\def\@phy@oplega@PV{#1}} +\phy@define@key{op.lega}{pv}{\def\@phy@oplega@pv{#1}} +\phy@setkeys{op.lega}{PV=\mathcal{P},pv={p.v.},ReIm=true} +\phy@processkeyopt{ab} +\DeclareRobustCommand\asin{\mathop{\operator@font asin}\nolimits} +\DeclareRobustCommand\acos{\mathop{\operator@font acos}\nolimits} +\DeclareRobustCommand\atan{\mathop{\operator@font atan}\nolimits} +\DeclareRobustCommand\acsc{\mathop{\operator@font acsc}\nolimits} +\DeclareRobustCommand\asec{\mathop{\operator@font asec}\nolimits} +\DeclareRobustCommand\acot{\mathop{\operator@font acot}\nolimits} +\DeclareRobustCommand\Tr{\mathop{\operator@font Tr}\nolimits} +\DeclareRobustCommand\tr{\mathop{\operator@font tr}\nolimits} +\DeclareRobustCommand\rank{\mathop{\operator@font rank}\nolimits} +\DeclareRobustCommand\erf{\mathop{\operator@font erf}\nolimits} +\DeclareRobustCommand\Res{\mathop{\operator@font Res}\nolimits} +\DeclareRobustCommand\res{\mathop{\operator@font res}\nolimits} +\DeclareRobustCommand\PV{\mathord{\@phy@oplega@PV}} +\DeclareRobustCommand\pv{\mathop{\operator@font\@phy@oplega@pv{}}\nolimits} +% \end{macrocode} +% Restore \cs{Re} and \cs{Im} in \cs{Resymbol} and \cs{Imsymbol}. The \cs{AtBeginDocument} +% hook is used for the compatibility of \pkg{unicode-math}. +% \begin{macrocode} +\ifx\phy@reserveda\phy@true +\AtBeginDocument{% + \let\Resymbol\Re% + \let\Imsymbol\Im% + \DeclareRobustCommand\Re{\mathop{\operator@font Re}\nolimits}% + \DeclareRobustCommand\Im{\mathop{\operator@font Im}\nolimits}% +} +\fi +% +% \end{macrocode} +% \section{The \modu{qtext.legacy} module} +% This module is written for the compatibility with the bad commands provided by +% \pkg{physics} only. The commands in this module should NEVER be used! +% \begin{macrocode} +%<*qtext.legacy> +\ProvidesFile{phy-qtext.legacy.sty} + [2023/10/24 `qtext.legacy' module of physics2.sty] +\RequirePackage{amstext} +\def\phy@qtext@#1#2{#1\text{#2}\quad} +\DeclareRobustCommand\qqtext{\@ifstar{\phy@qtext@{}}{\phy@qtext@\quad}} +\DeclareRobustCommand\qq{\qqtext} +\DeclareRobustCommand\qcomma{,\quad} +\DeclareRobustCommand\qc{\qcomma} +\DeclareRobustCommand\qcc{\@ifstar{\phy@qtext@{}{c.c}}{\phy@qtext@\quad{c.c}}} +\def\phy@qtext@lega@gen@#1{% + \expandafter\DeclareRobustCommand\csname q#1\endcsname% + {\@ifstar{\phy@qtext@{}{#1}}{\phy@qtext@\quad{#1}}}} +\phy@qtext@lega@gen@{if} +\phy@qtext@lega@gen@{then} +\phy@qtext@lega@gen@{else} +\phy@qtext@lega@gen@{otherwise} +\phy@qtext@lega@gen@{unless} +\phy@qtext@lega@gen@{give} +\phy@qtext@lega@gen@{using} +\phy@qtext@lega@gen@{unless} +\phy@qtext@lega@gen@{assume} +\phy@qtext@lega@gen@{since} +\phy@qtext@lega@gen@{let} +\phy@qtext@lega@gen@{for} +\phy@qtext@lega@gen@{all} +\phy@qtext@lega@gen@{even} +\phy@qtext@lega@gen@{odd} +\phy@qtext@lega@gen@{integer} +\phy@qtext@lega@gen@{and} +\phy@qtext@lega@gen@{or} +\phy@qtext@lega@gen@{as} +\phy@qtext@lega@gen@{in} +% +% \end{macrocode} +%^^A******************************************************************************** [l3 legacy] +% \part{Legacy modules written in \LaTeX3 syntax} +% \begin{macrocode} +%<@@=phy> +% \end{macrocode} +% \section{The \modu{bm-um.legacy} module} +% \begin{macrocode} +%<*bm-um.legacy> +\ProvidesExplFile{phy-bm-um.legacy.sty}{2023/10/24}{} + {`bm-um.legacy' module of physics2} +\AtBeginDocument + { + \cs_if_exist:cF { symbf } + { + \PackageError { physics2 } + { + The ~ `bm-um.legacy' ~ module ~ requires ~ + `unicode-math' ~ package + } + { + Have ~ you ~ used ~ `unicode-math' ~ + in ~ the ~ preamble? + } + } + } +\DeclareDocumentCommand \bm { m } + { + \mode_if_math:TF + { + \tl_if_head_eq_catcode:nNTF { #1 } A + { + \symbfit { #1 } + } + { + \symbf { #1 } + } + } + { + \PackageError { physics2 } + { + The ~ \string\bm\space command ~ should ~ be ~ + used ~ in ~ math ~ mode ~ only. \MessageBreak + This ~ is ~ an ~ error ~ from ~ `bm-um.legacy' ~ module + } + { + Check ~ if ~ any ~ `\string\bm' ~ is ~ out ~ + of ~ math ~ mode. + } + } + } +% +% \end{macrocode} +% This part ends here. +% \begin{macrocode} +%<@@=> +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/physics2/physics2-code.pdf b/macros/latex/contrib/physics2/physics2-code.pdf new file mode 100644 index 0000000000..ea4d90cd31 Binary files /dev/null and b/macros/latex/contrib/physics2/physics2-code.pdf differ diff --git a/macros/latex/contrib/physics2/physics2-legacy.pdf b/macros/latex/contrib/physics2/physics2-legacy.pdf new file mode 100644 index 0000000000..5406b3d748 Binary files /dev/null and b/macros/latex/contrib/physics2/physics2-legacy.pdf differ diff --git a/macros/latex/contrib/physics2/physics2-legacy.tex b/macros/latex/contrib/physics2/physics2-legacy.tex new file mode 100644 index 0000000000..fe3dcb1ce2 --- /dev/null +++ b/macros/latex/contrib/physics2/physics2-legacy.tex @@ -0,0 +1,544 @@ +%% ****************************************************** +%% * This work may be distributed and/or modified under * +%% * the conditions of the LaTeX Project Public License * +%% * http://www.latex-project.org/lppl.txt * +%% * either version 1.3c of this license or any later * +%% * version. * +%% ****************************************************** +\documentclass[11pt,letterpaper]{article} +\usepackage{amsmath} +\usepackage{unicode-math} +\setmainfont{Libertinus Serif} +\setsansfont{Libertinus Sans} +\setmonofont{NotoSansMono}[ + Scale=MatchLowercase, + Extension=.ttf, + UprightFont=*-Light, + BoldFont=*-Medium +] +\setmathfont{Libertinus Math} +\usepackage{physics2} +\usephysicsmodule{ab} +\usephysicsmodule{ab.legacy,nabla.legacy} +\usephysicsmodule{op.legacy,qtext.legacy} +\usephysicsmodule{ab.braket} +\usephysicsmodule{diagmat} +\usephysicsmodule[showleft=3,showtop=3]{xmat} +\usepackage{derivative} +\input{phy2docdef.tex} +\title{\pkg{physics2} manual for the legacy \pkg{physics} users} +\begin{document} +\maketitle + +\begin{abstract} +This short document describes \pkg*{physics2} package for those who are +used to the \pkg*{physics} package. This document is only a simple reference +manual for: +\begin{itemize} +\item Frequent users of the legacy \pkg{physics} package; +\item Those who have to maintain a document written with \pkg{physics}; +\item Users who failed to use \pkg*{unicode-math} with \pkg{physics}. +\end{itemize} +It seems no reason for any other user to read \emph{this} document instead of +the \href{./physics2.pdf}{package documentation} of \pkg{physics2}, +because this document cannot describe the package in detail. + +In this document, the modules of \pkg{physics2} will be introduced in +the same order as the \pkg{physics} documentation. +\end{abstract} + +\section*{Contents} +\begin{multicols}{2} +\contentsonly +\end{multicols} +\ifnum\value{page}=1 \vfil\clearpage\fi + +\section{Before you start} +\subsection{Legacy problems with \pkg{physics} package} +\label{subsec:physics-legacy-problems} +The \pkg{physics} package provides \cs{qty} command for automatic-sizing +braces. The \cs{qty} command would cause conflict with the \pkg{siunitx} +package, which provides a unified method to typeset numbers and units +correctly. + +Besides, after you loaded \pkg{physics}, when you type \cs{homework} you +will get Maxwell equations and Schrödinger equation. The \cs{homework} +command is ``declared'' in \texttt{physics.sty} but it was not described +in the documentation. That is, if you have defined \cs{homework} before +loading \pkg{physics} package, \pkg{physics} would overwrite the definition +``silently''. + +The vector-notation part of \pkg{physics} uses \pkg*{amsmath}'s (more exactly, +\texttt{amsbsy.sty}'s) \cs{boldsymbol} command to generate bold vectors. +Commands for cross/dot product are defined with \cs{boldsymbol}. +\cs{boldsymbol} uses \cs{mathversion}, a \LaTeXe\ kernel command that works +well with traditional TFM-based fonts but fails when using \pkg{unicode-math}. + +In the definition of \cs{imat}, \cs{xmat}, \cs{dmat} and \cs{admat} commands +from \pkg{physics}, there is a \cs{newtoks} command which allocates a token +list register and two \cs{newcount} commands allocating two count registers. +Every time you write a command like \cs{imat} in your document, then one token +list register and two count registers will be wasted. What's even worse is +that, if you wrote really too many matrix commands from \pkg{physics} (for +example, 32767 \cs{imat}s in \hologo{LuaLaTeX}), there'd be no room for a new +\cs{count}. + +\pkg{physics} integrated all the functions in one file (\texttt{physics.sty}), +that is, you cannot load one of the total seven parts of functions; you have +to load the seven parts altogether, even included the extra \cs{homework} +command we mentioned in the first paragraph. + +Moreover, the code of \texttt{physics.sty} ``abuses'' the \texttt{g}-type +arguments of \pkg*{xparse} package. Therefore the syntax of \pkg{physics} package +looks kind of weird. See \href{https://tex.stackexchange.com/questions/% +470819/macros-dv-and-pdv-eat-the-subsequent-parenthesis-argument/470842#470842}% +{here} for more. + +\subsection{Loading \pkg{physics2}} +The \pkg{physics2} package includes different modules, among which every module +focuses on one single function. + +Write the following line in the preamble to load \pkg{physics2}: +\begin{Verbatim} +\usepackage{physics2} +\end{Verbatim} +But this is not enough. \pkg{physics2} contains different modules. +If you want to load any module of \pkg{physics2}, write this line after loading +\pkg{physics2} package: +\begin{displayed} +\cs{usephysicsmodule}\marg{module list} +\end{displayed} +For example, ``\verb|\usephysicsmodule{ab,doubleprod}|'' loads the \modu{ab} +module and the \modu{doubleprod} module. + +You can also load a module with options: +\begin{displayed} +\cs{usephysicsmodule}\oarg{option list}\marg{module} +\end{displayed} +For example, ``\verb|\usephysicsmodule[legacy]{ab}|'' loads \modu{ab} with the +option ``\opt{legacy}''. + +\pardanger Attention, if you used any font package in your document, remember +that \pkg{physics2} requires to be loaded \emph{after} font packages. + + +\section{List of commands} +\subsection{Automatic bracing}\label{subsec:ab-and-legacy} +As mentioned in \S\ref{subsec:physics-legacy-problems}, the \cs{qty} command +from \pkg{physics} would cause conflicts with \pkg{siunitx}. The command for +automatic braces in \pkg{physics2} is \cs{ab}, a shorthand for +{\bfseries a}utomatic {\bfseries b}races. + +The \cs{ab} command requires the \modu{ab} module, so don't forget to write +\verb|\usephysicsmodule{ab}| in the preamble after you loaded \pkg{physics2}. +Always remember, \emph{do not put an \cs{ab} separately in the end of a math +formula}. Take some examples: +\begin{example} +\[ \ab ( \frac12 ) \quad + \ab [ \frac12 ] \quad + \ab\{ \frac12 \} \] +\end{example} +\cs{ab} can modify a delimiter-braced subformula. But the delimiters should +not be out of the range described by the following chart: +\begin{center} +\begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} +\opt{(},\quad\opt{)} && \\ +\opt{[},\quad\opt{]} && \\ +\cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ +\opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ +\opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ + \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} +\end{tabular} +\end{center} +For example, \verb|$\ab{foo}$| and \verb|$\ab(foo]$| are illegal, but +\verb|$\ab\{foo\}$| and \verb|$\ab(foo)$| are okay; \verb|$\ab([)$| +is okay but \verb|$\ab(()$| is illegal. + +\pardanger Attention, if you want to delimit a subformula with ``\{'' and +``\}'', you can only write \verb|\{|, \verb|\}| or \cs{lbrace}, \cs{rbrace} +around it. \verb|{| and \verb|}| are not supported in \modu{ab} module. + +Between \cs{ab} and the first delimiter can be a ``biggg'' command, that is, +from \cs{big} to \cs{Bigg}. Actually, you can also write \cs{biggg} and +\cs{Biggg} because \pkg{physics2} defines these after you load it. For example, +\begin{example} +\[ \ab\Big \| \frac12 \| \quad + \ab\Bigg < \frac12 > \quad + \ab\Biggg| \frac12 | \] +\end{example} +Between \cs{ab} and the first delimiter can also be a star (\opt{*}), which +means ``use the default size of delimiters''. But in this situation, you +needn't use the \cs{ab} command at all. + +The \pkg{physics} package provides commands like \cs{pqty}, \cs{bqty}. In +the \modu{ab} module of \pkg{physics2}, these commands have changed to +\cs{pab}, \cs{bab}, etc. The following example shows all the +\texttt{\textbackslash}$X$\texttt{ab} commands in \modu{ab} module: +\begin{example} +\def\0{\frac12} +\[ \pab{\0} \quad \bab{\0} + \quad \Bab{\0} \] +\[ \aab{\0} \quad \vab{\0} + \quad \Vab{\0} \] +\end{example} +\texttt{\textbackslash$X$ab} can take an optional star and an optional \oarg{biggg} +argument. For example, +\begin{example} +\def\0{\frac12} +\[ \pab[Big]{\0} \quad \bab*{\0} \] +\end{example} + +\pkg{physics} also provides the following commands: +\begin{Verbatim}[fontsize=\small] +\abs \norm \eval \order \comm \acomm \pb +\end{Verbatim} +\pardanger These commands are not originally supported by \pkg{physics2}, but +the first four commands can be used through the \modu{ab.legacy} module of +\pkg{physics2}: +\begin{Verbatim} +\usephysicsmodule{ab.legacy} +\end{Verbatim} +For example, +\begin{example} +\def\0{\frac12} +\[ \abs{\0} \quad \abs[big]{\0} + \quad \abs*{\0} \] +\end{example} +Users of the legacy \pkg{physics} package should notice that the syntax of +\cs{eval} has been changed. The \modu{ab.legacy} module abandoned the +\verb"\eval(foo|"-like syntax. The new \cs{eval}'s syntax is just like other +commands in this module. There are also two variants of \cs{eval} --- \cs{peval} +and \cs{beval}. For example, +\begin{example} +\def\0{1+\frac12x} +\[ \eval{\0}_a^b \quad + \peval*{\0}_a^b \quad + \beval[big]{\0}_a^b \] +\end{example} +The \cs{comm}, \cs{acomm} and \cs{pb} (Poisson bracket) are not supported. +But you can write like \verb|\ab[foo,baz]| or \verb|\bab{foo,baz}| instead. + +By the way, you can set the ``order'' symbol in \modu{ab.legacy} through +the \opt{order} option like this: +\begin{Verbatim} +\usephysicsmodule[order=O]{ab.legacy} +\end{Verbatim} +Then \verb|$\order(N)$| yields $O(N)$. + +\subsection{Vector notation} +Unfortunately, there is not a plan for \pkg{physics2} to support this part +of \pkg{physics} completely, but the rest of this section will show some +methods to maintain the document written with \pkg{physics}. + +The \cs{vb}(\opt{*}), \cs{va}(\opt{*}) and \cs{vu}(\opt{*}) are not supported +in any module of \pkg{physics2}. But these commands can be defined by copying +the following lines below and pasting them in the preamble: +\begin{Verbatim}[fontsize=\small] +\makeatletter +\newcommand\vb{\@ifstar\boldsymbol\mathbf} +\newcommand\va[1]{\@ifstar{\vec{#1}}{\vec{\mathrm{#1}}}} +\newcommand\vu[1]{% + \@ifstar{\hat{\boldsymbol{#1}}}{\hat{\mathbf{#1}}}} +\makeatother +\end{Verbatim} +The \cs{boldsymbol} command requires the \pkg*{amsmath} or \pkg*{bm} package. +If you prefer to use \pkg{bm}, you can also use the \cs{bm} command. +What's more, if you tried the commands above, you might find that, +the result of \cs{va} above is different from that of \pkg{physics}. +This is because, if you choose to present a vector in bold, there's almost +no need to put a \cs{vec} ($\vec{\mskip9mu}$) sign above it. + +However, the method above may not work well with \pkg*{unicode-math} +because there are so many OpenType math fonts without a bold version. +When using \pkg{unicode-math}, it's recommended to use \cs{symbf} and +\cs{symbfit} for a separate vector. For example, \verb|$\symbf{0}$| yields +$\symbf{0}$, and \verb|$\symbfit{A}$| yields $\symbfit{A}$. + +The \cs{vdot} and \cs{cross} commands are not supported in any module +of \pkg{physics2}. Actually, there is no need to use a bold ``$\cdot$'' +or ``$\times$'' for the products of two vectors. Using \cs{cdot} and +\cs{times} is enough. + +The commands related to ``$\nabla$'' are supported through \modu{nabla.legacy} +module. These commands are \cs{grad}, \cs{div} and \cs{curl}. These commands +should not be put in the end of a math formula either (just like \cs{ab}). +Notice that the former \cs{div} command for a ``$\divsymbol$'' (if there +exists one) is redefined as \cs{divsymbol}. For example, +\begin{example} +% \usephysicsmodule{nabla.legacy} +\[ \grad F \quad + \grad(\frac G2) \] +\[ \div\Bigg[X] \quad + \curl*\{\frac Y2\} \] +\[ 2 \divsymbol 1 \] +\end{example} +Actually, the nabla-related commands end with \cs{ab}. Thus, the subformula +after these commands can be delimited with \verb|()|, \verb|[]| and \verb|\{\}|. + +The \modu{nabla.legacy} requires the \pkg*{fixdif} package at least +version 2.0 (file date: 2023/01/31 or after 2023/01/31). + +By the way, if you are used to writing \cs{bm} for a vector but interested in +\pkg{unicode-math}, the \modu{bm-um.legacy} module would be a passable +alternative to \pkg{bm} package. Notice that the \cs{bm} command from the +\modu{bm-um.legacy} module can only take \emph{one} letter (or \emph{one} digit) +as its argument. + +\subsection{Operators} +There's no plan for \pkg{physics2} to support this part of \pkg{physics} +completely. The syntax in this part of \pkg{physics} (such as \verb|\tan[2](x)|) +abuses \pkg*{xparse}. + +It's suggested to write like this if you used the \modu{ab} module: +\begin{Verbatim}[fontsize=\small] +$ \sin^2 \ab( \frac{\alpha}{2} ) $ +\end{Verbatim} +Rather than take the superscript as an optional argument of the command of +log-like functions. + +The \pkg{physics} package provides a bundle of commands for log-like functions +that have not been defined in the \LaTeXe\ kernel. Those log-like functions +can be used with the \modu{op.legacy} module; this module does not support +the syntax of \pkg{physics} either. For example: +\begin{example} +% \usephysicsmodule{op.legacy} +\[ \asin^2 x \quad \rank \{ A \} \] +\end{example} +The \cs{Re} and \cs{Im} commands are redefined as operators ``$\Re$'' and +``$\Im$'', while $\Resymbol$ and $\Imsymbol$ are reserved as \cs{Resymbol} and +\cs{Imsymbol}. $\Resymbol$ and $\Imsymbol$ are ordinary symbols but $\Re$ and +$\Im$ are operators. + +\subsection{Quick quad text}\label{subsec:qtext} +The \modu{qtext.legacy} module provides the \cs{q}\meta{foo} commands +for \cs{quad}-wrapped texts. These commands have the same syntax as +\pkg{physics}. For example, +\begin{example} +% \usephysicsmodule{qtext.legacy} +\[ A \qq {foo bar} B \] +\[ A \qq*{foo bar} B \] +\[ C \qcc D \qcc* E \] +\[ F \qif G \qthen H \] +\end{example} +All the commands described in \S2.4 of +\href{http://mirrors.ctan.org/macros/latex/contrib/physics/physics.pdf}% +{\textsf{physics} documentation} are supported when using \modu{qtext.legacy} +module, but I don't recommend using this module unless you are maintaining a +document written with \pkg{physics}'s \cs{q}\meta{foo} commands. + +\subsection{Derivatives} +There is no plan for \pkg{physics2} to support this part of \pkg{physics}. If +you want to typeset the differential operators on a better sense, you can try +the \pkg*{fixdif} package; if you want an easy way to type derivatives, you +can try the \pkg*{derivative} package. These two packages can be used +together. For example, +\begin{example} +% \usepackage{fixdif,derivative} +\[ \pdv{f}{x,y,z} \d x \] +Math ($\d x$) v.s.\ Text (\d x) +\end{example} +Here are the documentations of +\href{http://mirrors.ctan.org/macros/latex/contrib/fixdif/fixdif.pdf}% +{\textsf{fixdif}} and +\href{http://mirrors.ctan.org/macros/latex/contrib/derivative/derivative% +.pdf}{\textsf{derivative}}. + +\pkg{fixdif}'s commands behave better in superscripts and subscripts. + +\subsection{Dirac bra-ket notation} +There are two solutions to Dirac bra-ket in \pkg{physics2} --- \modu{ab.braket} +and \modu{braket}. These two modules are \emph{not} compatible and neither of +them supports \pkg{physics}'s syntax completely. +Click \hyperlink{para:ab.braket}{\textcolor{cyan}{here}} to see the +\modu{ab.braket} module and \hyperlink{para:braket}{\textcolor{cyan}{here}} +to see the \modu{braket} module. + +\paragraph{The \modu{ab.braket} module} +\hypertarget{para:ab.braket}{This} module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and +\cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' +command. These commands share similar syntaxes like \cs{ab}'s syntax. But, +\emph{the bra-ket commands from \modu{ab.braket} module are completely different +from \cs{ab}}. Their internal structures are different. + +The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, +\begin{center} +\cs{bra} \opt{<} \meta{subformula} \opt{|} +\end{center} +For example, +\begin{example} +\[ \bra < \frac \phi 2 | \] +\[ \bra*< \frac \phi 2 | \] +\[ \bra\Big< \phi | \] +\end{example} +The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, +\begin{center} +\cs{ket} \opt{|} \meta{subformula} \opt{>} +\end{center} +For example, +\begin{example} +\[ \ket | \frac \psi 2 > \] +\[ \ket*| \frac \psi 2 > \] +\[ \ket\Big| \psi > \] +\end{example} +\pardanger +If you want to write ``$>$'' and ``$<$'' for relations in the argument of +\cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| +(although there is almost no such need). + +The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, +that is, +\begin{center} +\cs{braket} \opt{<} \meta{subformula} \opt{>} +\end{center} +In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an +extensible vertical bar. For example, +\begin{example} +\[ \braket< \phi > \] +\[ \braket< \phi | \psi > \] +\[ \braket< \phi | A | \psi > \] +\end{example} +\begin{example} +\def\0{\frac\phi2} +\[ \braket < \0 | \psi > \] +\[ \braket* < \0 | \psi > \] +\[ \braket\Bigg< \0 | \psi > \] +\end{example} +The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. +In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ +and $\langle$. That is, +\begin{center} +\cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} + \opt{<} \meta{subformula$_2$} \opt{|} +\end{center} +For example, +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra | \0 >< \psi | \] +\[ \ketbra* | \0 >< \psi | \] +\[ \ketbra\Bigg| \0 >< \psi | \] +\end{example} +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra| \0 >_x^y < \psi | \] +\end{example} +\pardanger +If you want to write ``$>$'' and ``$<$'' for relations in the argument of +\cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there +is almost no such need). It is quite different from \verb|\mathrel{>}| or +\verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} +will be redefined. + +\paragraph{The \modu{braket} module} +\begingroup +\makeatletter\def\phy@requiremodule#1{}% +\def\PackageWarning#1#2{}% +\input phy-braket.sty\makeatother +\hypertarget{para:braket}{This} module contains four commands --- \cs{bra}, +\cs{ket}, \cs{braket} and \cs{ketbra}. After these commands can be a star +(\opt{*}) or a square-bracket-delimited size option, the size option can +take the following values: +\begin{center} +\opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad +\opt{biggg}\quad or\quad\opt{Biggg}. +\end{center} +Star stands for ``do not size the bra-ket automatically''. + +The argument(s) of these four commands are braced with \verb|{| and \verb|}|. +\cs{bra} and \cs{ket} take one mandatory argument. For example, +\begin{example} +\def\0{\frac\phi2} +\[ \bra {\0} \quad \bra* {\0} + \quad \bra[Big] {\0} \] +\[ \ket {\0} \quad \ket* {\0} + \quad \ket[Big] {\0} \] +\end{example} +The \cs{braket} command, in default, can take two arguments. +\begin{example} +\def\0{\frac\phi2} +\[ \braket {\0} {\psi} \quad + \braket*{\0} {\psi} \quad + \braket[big] {\0} {\psi} \] +\end{example} +If you want \cs{braket} to take one or three arguments, you can write the +number of arguments in the square bracket. If you need to specify the size +of bra-ket simultaneously, you need to separate the number and the size with +a comma: +\begin{example} +\def\0{\frac\phi2} +\[ \braket [1] {\0} \quad + \braket*[1] {\0} \] +\[ \braket [3] {\0}{A}{\psi} \] +\[ \braket[3,big] {\0}{A}{\psi} + \quad + \braket[Big,3] {\0}{A}{\psi} \] +\end{example} +The \cs{ketbra} command takes two mandatory arguments. It can also take an +optional argument between the two mandatory arguments. The optional argument +will be placed between $\rangle$ and $\langle$: +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra {\0} {\psi} \quad + \ketbra* {\0} {\psi} \] +\[ \ketbra [Bigg] {\0} {\psi} \] +\[ \ketbra {\0} [_x^y] {\psi} \] +\end{example} +\endgroup + +\subsection{Matrix macros} +Unfortunately, \pkg{physics2} do not support the \cs{mqty} command from +\pkg{physics}. If you are used to this command, you can write like this: +\begin{Verbatim}[fontsize=\small] +\newcommand\mqty[1]{\begin{matrix}#1\end{matrix}} +\newcommand\pmqty[1]{\begin{pmatrix}#1\end{pmatrix}} +$\ab(\mqty{foo})$ or $\pmqty{foo}$ +\end{Verbatim} +These are equal to physics's \verb|\mqty(foo)| (require \pkg{amsmath}). + +\pkg{physics2}'s \modu{diagmat} module provides \cs{diagmat} command +for diagonal matrices. For example, +\begin{example} +\[ + \diagmat { 1, 2, 3 } +\] +\end{example} +\begin{example} +\[ + \pdiagmat [ empty = {} ] + { a, b, c, d } +\] +\end{example} +\cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} +are also available. + +\pkg{physics2}'s \modu{xmat} module provides \cs{xmat} command +for matrices with formatted entries. For example, +\begin{example} +\[ + \xmat{a}{2}{3} +\] +\end{example} +\begin{example} +% \usephysicsmodule +% [showleft=3,showtop=3]{xmat} +\[ + \pxmat{X}{m}{n} +\] +\end{example} +\begin{example} +\[ + \xmat [showleft=2,showtop=2, + format=\texttt{#1[#2][#3]}] + {x}{m}{n} +\] +\end{example} +\cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also available. + + + + + + + + + +\end{document} \ No newline at end of file diff --git a/macros/latex/contrib/physics2/physics2.ins b/macros/latex/contrib/physics2/physics2.ins new file mode 100644 index 0000000000..38faddfe10 --- /dev/null +++ b/macros/latex/contrib/physics2/physics2.ins @@ -0,0 +1,104 @@ +%% +%% This is file `physics2.ins', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% physics2-code.dtx (with options: `install') +%% +%% Copyright (C) 2023 by Zhang Tingxuan +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Zhang Tingxuan. +%% +%% This work consists of the files physics2-code.dtx, +%% and the derived files physics2.ins, +%% physics2.sty, +%% phy-.sty, +%% physics2-code.pdf, +%% and README.md. +%% +\input docstrip.tex +\keepsilent + +\preamble + + Copyright (C) 2023 by Zhang Tingxuan + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. The latest version of this license is in: + + http://www.latex-project.org/lppl.txt + + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is Zhang Tingxuan. + + This work consists of the files physics2-code.dtx, + and the derived files physics2.ins, + physics2.sty, + phy-.sty, + physics2-code.pdf, + and README.md. + +\endpreamble + +\generate{ + \usedir{tex/latex/physics2} + \file{physics2.sty} {\from{physics2-code.dtx}{package}} + \file{phy-ab.sty} {\from{physics2-code.dtx}{ab}} + \file{phy-ab.braket.sty} {\from{physics2-code.dtx}{ab.braket}} + \file{phy-braket.sty} {\from{physics2-code.dtx}{braket}} + \file{phy-diagmat.sty} {\from{physics2-code.dtx}{diagmat}} + \file{phy-doubleprod.sty} {\from{physics2-code.dtx}{doubleprod}} + \file{phy-xmat.sty} {\from{physics2-code.dtx}{xmat}} + \file{phy-ab.legacy.sty} {\from{physics2-code.dtx}{ab.legacy}} + \file{phy-bm-um.legacy.sty} {\from{physics2-code.dtx}{bm-um.legacy}} + \file{phy-nabla.legacy.sty} {\from{physics2-code.dtx}{nabla.legacy}} + \file{phy-op.legacy.sty} {\from{physics2-code.dtx}{op.legacy}} + \file{phy-qtext.legacy.sty} {\from{physics2-code.dtx}{qtext.legacy}} + \usedir{doc/latex/physics2} + \nopreamble\nopostamble + \file{README.md} {\from{physics2-code.dtx}{readme}} +} + +\obeyspaces +\Msg{**********************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the *} +\Msg{* following files into a directory searched by TeX: *} +\Msg{* *} +\Msg{* physics2.sty, *} +\Msg{* (for all modules) phy-.sty. *} +\Msg{* *} +\Msg{* The recommended directory is *} +\Msg{* TEXMFDIST/tex/latex/physics2 *} +\Msg{* *} +\Msg{* To produce the documentation, run the file *} +\Msg{* physics2-code.dtx through XeLaTeX or LuaLaTeX. *} +\Msg{* XeLaTeX is recommended. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{**********************************************************} + +\endbatchfile +\endinput +%% +%% End of file `physics2.ins'. diff --git a/macros/latex/contrib/physics2/physics2.pdf b/macros/latex/contrib/physics2/physics2.pdf new file mode 100644 index 0000000000..d8a1f3a376 Binary files /dev/null and b/macros/latex/contrib/physics2/physics2.pdf differ diff --git a/macros/latex/contrib/physics2/physics2.tex b/macros/latex/contrib/physics2/physics2.tex new file mode 100644 index 0000000000..c643ab72f9 --- /dev/null +++ b/macros/latex/contrib/physics2/physics2.tex @@ -0,0 +1,575 @@ +%% ****************************************************** +%% * This work may be distributed and/or modified under * +%% * the conditions of the LaTeX Project Public License * +%% * http://www.latex-project.org/lppl.txt * +%% * either version 1.3c of this license or any later * +%% * version. * +%% ****************************************************** +\documentclass[11pt,letterpaper]{article} +\usepackage{amsmath} +\usepackage{unicode-math} +\setmainfont{Libertinus Serif} +\setsansfont{Libertinus Sans} +\setmonofont{NotoSansMono}[ + Scale=MatchLowercase, + Extension=.ttf, + UprightFont=*-Light, + BoldFont=*-Medium +] +\setmathfont{Libertinus Math} +\usepackage{physics2} +\usephysicsmodule{ab,ab.braket} +\usephysicsmodule{diagmat} +\usephysicsmodule{doubleprod} +\usephysicsmodule[showleft=3,showtop=3]{xmat} +\usephysicsmodule{ab.legacy,nabla.legacy,op.legacy,qtext.legacy,bm-um.legacy} +\input{phy2docdef.tex} +\externaldocument[lega-]{physics2-legacy} +\title{The \pkg{physics2} package} +\begin{document} +\maketitle + +\begin{abstract} +This is the document for \pkg{physics2} package, which defines commands for +typesetting math formulae faster and more simply. \pkg{physics2} is a +modularized package, each module provides its own function. + +This document describes the \pkg{physics2} package in more detail. +But if you are a user of the legacy \pkg{physics} package, you can click +\href{./physics2-legacy.pdf}{here} to see the documentation for +\pkg{physics} users before you start. If you never used \pkg{physics} package +before, just read \emph{this} documentation. +\end{abstract} + +\tableofcontents + +\section{Introduction} +\subsection{The purpose of this package} +This package aims to provide a bundle of commands for typesetting math faster +in different modules. The commands provided by \pkg{physics2} and its different +modules are designed to be short and easy to memorize. + +\subsection{Packages required} +The \pkg{physics2} package itself only requires the \pkg*{keyval} package, which +is part of the \pkg*{latex-graphics} bundle. Almost every \LaTeX\ distribution +will include this bundle. + +Different modules of \pkg{physics2} might require different packages. It will +be explained in the following sections that which module requires which package. + +The \pkg{physics2} package requires \LaTeXe\ kernel released after 2020/10. +Please make sure that your \LaTeX\ distribution is not too old. + +\subsection{Loading \pkg{physics2} and its modules} +Just like loading any package, write +\begin{Verbatim} +\usepackage{physics2} +\end{Verbatim} +in the preamble to load the \pkg{physics2} package. In the current version, +\pkg{physics2} doesn't provide a package option. + +\pkg{physics2} itself doesn't provide many features. +You need to load different modules of \pkg{physics2} to have different +features applied to your document. + +\subsection{Loading a module of \pkg{physics2}} +You can load a module of \pkg{physics2} only \emph{after} you write +\verb|\usepackage{physics2}| in the preamble. Load a \pkg{physics2} module +like this: +\begin{center} +\cs{usephysicsmodule}\marg{module} +\end{center} +The usage of \cs{usephysicsmodule} is similar to \cs{usepackage}, so you can +load several modules in one line. For example, +\begin{Verbatim} +\usephysicsmodule{ab,ab.braket} +\end{Verbatim} +This line loads the \modu{ab} and \modu{ab.braket} modules. + +You can also load \emph{one} module with options. The options of a +\pkg{physics2} module can be a comma-separated key-value list. For example, +\begin{Verbatim} +\usephysicsmodule[tightbraces=true]{ab} +\usephysicsmodule{ab.braket,doubleprod} +\end{Verbatim} +These two lines load the \modu{ab} module with option +\opt{tightbraces\:=\:true} and load \modu{ab.braket} and \modu{doubleprod} +modules. + +The following sections introduce all the user-level modules of \pkg{physics2}. +View back to the table of contents to see the names of user-level modules. + +\section{Modules of \pkg{physics2}} +\subsection{Features of the bare \pkg{physics2} package} +The following commands are available once you load \pkg{physics2} in preamble. + +\cs{delopen} and \cs{delclose}, followed by a math delimiter. They can be +regarded as abbreviations of ``open delimiter'' and ``close delimiter''. If +you had heard of the \pkg*{mleftright} package. You can regard \cs{delopen} +and \cs{delclose} as a simpler version of \cs{mleft} and \cs{mright}. +For example, +\begin{example} +\[ 0 \left(\frac12\right) 3 \] +\[ 0 \delopen(\frac12\delclose) 3 \] +\end{example} + +\cs{biggg} and \cs{Biggg}, followed by a math delimiter. They are even bigger +than \cs{Bigg}. \cs{biggg} and \cs{Biggg} may be useful when you need to write +something really tall in math mode, but most OpenType math font do not support +\cs{langle} (or U+27E8) and \cs{rangle} (or U+27E9) in this large size. Take +an example, +\begin{example} +\[\Biggg(\biggg(\Bigg(\bigg(\Big(\big(( +)\big)\Big)\bigg)\Bigg)\biggg)\Biggg)\] +\end{example} +\cs{bigggl}, \cs{bigggm}, \cs{bigggr}, \cs{Bigggl}, \cs{Bigggm} and \cs{Bigggr} +are also supported. + +\textbf{Note:} +If you had heard version $0.x.y$ of \pkg{physics2}, you might know the +\modu{common} module. Now the \modu{common} module is included in +\pkg{physics2}.sty --- the source file of \modu{common} module is deleted +but all the features of \modu{common} are reserved. Those commands above +used to be provided by \modu{common} module, but now they are provided by +\pkg{physics2}. + +\subsection{The \modu{ab} module --- automatic braces} +This module provides the command \cs{ab}. The \cs{ab} command, as a shorthand +of ``automatic braces'', would specify the size of the following pair of +delimiters. The delimiters after \cs{ab} should not be out of the range +described by the following chart: +\begin{center} +\begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} +\opt{(},\quad\opt{)} && \\ +\opt{[},\quad\opt{]} && \\ +\cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ +\opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ +\opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ + \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} +\end{tabular} +\end{center} +For example, it's illegal to write an ``\verb|\ab(|'' without a ``\verb|)|''; +it's also illegal to write \verb|\ab=foo=|. Take some correct examples: +\begin{example} +\[ \ab ( \frac12 ) \quad + \ab [ \frac12 ] \quad + \ab\{ \frac12 \} \] +\end{example} +You can also write a command from \cs{big} to \cs{Biggg} between \cs{ab} +and the first delimiter, which means to specify the size of delimiters manually. +Also, you can write a star (\opt{*}) between \cs{ab} and the first delimiter, +to prevent \cs{ab} from setting the size of delimiters. For example, +\begin{example} +\[ \ab <\frac12> \quad + \ab\biggg|\frac12| \quad + \ab* \|\frac12\| \] +\end{example} +\pardanger +Always remember, do not put an \cs{ab} separately at the end of math mode like +\verb|$\ab$|, because \cs{ab} will try to absorb the following math shift +character (\verb|$|) as its argument. + +The \modu{ab} module also provides \texttt{\textbackslash}$X$\texttt{ab} +commands, where $X$ can be \opt{p}, \opt{b}, \opt{B}, \opt{a}, \opt{v} and +\opt{V}. These commands take a normal argument but not an argument delimited +with paired delimiters. For example, +\begin{example} +\def\0{\frac12} +\[ \pab{\0} \bab{\0} \Bab{\0} \] +\[ \aab{\0} \vab{\0} \Vab{\0} \] +\end{example} +These \texttt{\textbackslash$X$ab} commands can take an optional star and +an optional \oarg{biggg} argument. Star stands for using the default sizes. +For example, +\begin{example} +\def\0{n+\frac12} +\[ \pab[Big]{\0} \quad \bab*{\0} \] +\end{example} + +\paragraph{The options of \modu{ab} module} +\opt{tightbraces}, a bool type key, whose default value is \opt{true}, +influences whether thin skips are reserved around the paired delimiters. +It only works with the automatically sized delimiters. + +\subsection{The \modu{ab.braket} module --- Dirac bra-ket notation} +This module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and +\cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' +command. These commands share similar syntaxes like \cs{ab}'s syntax. But, +\emph{the bra-ket commands from \modu{ab.braket} module are completely different +from \cs{ab}}. Their internal structures are different. + +The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, +\begin{center} +\cs{bra} \opt{<} \meta{subformula} \opt{|} +\end{center} +For example, +\begin{example} +\[ \bra < \frac \phi 2 | \] +\[ \bra*< \frac \phi 2 | \] +\[ \bra\Big< \phi | \] +\end{example} +The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, +\begin{center} +\cs{ket} \opt{|} \meta{subformula} \opt{>} +\end{center} +For example, +\begin{example} +\[ \ket | \frac \psi 2 > \] +\[ \ket*| \frac \psi 2 > \] +\[ \ket\Big| \psi > \] +\end{example} +\pardanger +If you want to write ``$>$'' and ``$<$'' for relations in the argument of +\cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| +(although there is almost no such need). + +The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, +that is, +\begin{center} +\cs{braket} \opt{<} \meta{subformula} \opt{>} +\end{center} +In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an +extensible vertical bar. For example, +\begin{example} +\[ \braket< \phi > \] +\[ \braket< \phi | \psi > \] +\[ \braket< \phi | A | \psi > \] +\end{example} +\begin{example} +\def\0{\frac\phi2} +\[ \braket < \0 | \psi > \] +\[ \braket* < \0 | \psi > \] +\[ \braket\Bigg< \0 | \psi > \] +\end{example} +The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. +In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ +and $\langle$. That is, +\begin{center} +\cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} + \opt{<} \meta{subformula$_2$} \opt{|} +\end{center} +For example, +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra | \0 >< \psi | \] +\[ \ketbra* | \0 >< \psi | \] +\[ \ketbra\Bigg| \0 >< \psi | \] +\end{example} +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra| \0 >_x^y < \psi | \] +\end{example} +\pardanger +If you want to write ``$>$'' and ``$<$'' for relations in the argument of +\cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there +is almost no such need). It is quite different from \verb|\mathrel{>}| or +\verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} +will be redefined. + +Next, the \modu{braket} module will be introduced. Please notice that +\modu{braket} is conflict with \modu{ab.braket}, they cannot be used together. + +\subsection{The \modu{braket} module --- Dirac bra-ket notation} +\begingroup +\makeatletter\def\phy@requiremodule#1{}% +\def\PackageWarning#1#2{}% +\input phy-braket.sty\makeatother +Please notice that this module is conflict with the \modu{ab.braket} module. +Don't use them together. + +This module contains four commands --- \cs{bra}, \cs{ket}, \cs{braket} and +\cs{ketbra}. After these commands can be a star (\opt{*}) or a +square-bracket-delimited size option, the size option can +take the following values: +\begin{center} +\opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad +\opt{biggg}\quad or\quad\opt{Biggg}. +\end{center} +Star stands for ``do not size the bra-ket automatically''. + +The argument(s) of these four commands are braced with \verb|{| and \verb|}|. +\cs{bra} and \cs{ket} take one mandatory argument. For example, +\begin{example} +\def\0{\frac\phi2} +\[ \bra {\0} \quad \bra* {\0} + \quad \bra[Big] {\0} \] +\[ \ket {\0} \quad \ket* {\0} + \quad \ket[Big] {\0} \] +\end{example} +The \cs{braket} command, in default, can take two arguments. +\begin{example} +\def\0{\frac\phi2} +\[ \braket {\0} {\psi} \quad + \braket*{\0} {\psi} \quad + \braket[big] {\0} {\psi} \] +\end{example} +If you want \cs{braket} to take one or three arguments, you can write the +number of arguments in the square bracket. If you need to specify the size +of bra-ket simultaneously, you need to separate the number and the size with +a comma: +\begin{example} +\def\0{\frac\phi2} +\[ \braket [1] {\0} \quad + \braket*[1] {\0} \] +\[ \braket [3] {\0}{A}{\psi} \] +\[ \braket[3,big] {\0}{A}{\psi} + \quad + \braket[Big,3] {\0}{A}{\psi} \] +\end{example} +The \cs{ketbra} command takes two mandatory arguments. It can also take an +optional argument between the two mandatory arguments. The optional argument +will be placed between $\rangle$ and $\langle$: +\begin{example} +\def\0{\frac\phi2} +\[ \ketbra {\0} {\psi} \quad + \ketbra* {\0} {\psi} \] +\[ \ketbra [Bigg] {\0} {\psi} \] +\[ \ketbra {\0} [_x^y] {\psi} \] +\end{example} +\endgroup + +\subsection{The \modu{diagmat} module --- simple diagonal matrices} +This module provides \cs{diagmat} command: +\begin{center} +\cs{diagmat}\opt{[empty\:=\:}\meta{empty entry}\opt{]}\marg{diag} +\end{center} +where \meta{diag} is the diagonal of the diagonal matrix. The entries should +be separated by commas. The \opt{empty} option is optional, with default value +\opt{0}. For example, +\begin{example} +\[ + \diagmat { 1, 2, 3 } +\] +\end{example} +\cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} +are also available. Prefixes like \opt{p}, \opt{b}, \opt{B} have the same +meaning as the \opt{p}, \opt{b}, \opt{B} in \pkg{amsmath}'s \opt{pmatrix}, +\opt{bmatrix} and \opt{Bmatrix}. For example, +\begin{example} +\[ + \pdiagmat [ empty = {} ] + { a, b, c, d } +\] +\end{example} +This module requires \pkg{amsmath}. + +\paragraph{The options of \modu{diagmat} module} +You can set the default value of \cs{diagmat}'s empty entries in the module +option like this: +\begin{Verbatim} +\usephysicsmodule[empty={\cdot}]{diagmat} +\end{Verbatim} + +\subsection{The \modu{doubleprod} module --- tensors' double product operator} +Take an example of this module: +\begin{example} +$ A \doublecross B \doubledot C $ +\end{example} +\cs{doublecross} and \cs{doubledot} are regarded as binary operators by \TeX. + +\paragraph{The options of \modu{doubleprod} module} +You can control the scale of ``$\times$'' and ``$\cdot$'' in \cs{doublecross} +and \cs{doubledot} in module option. For example, +\begin{Verbatim} +\usephysicsmodule[crossscale=0.75,dotscale=1.2]{doubleprod} +\end{Verbatim} +The default values of \opt{crossscale} and \opt{dotscale} are \opt{0.8} and +\opt{1}. You can also control the distances between the two ``$\times$''s and +``$\cdot$''s through the \opt{crossopenup} and \opt{dotopenup} options. +For example, +\begin{Verbatim} +\usephysicsmodule[crossopenup=.05,dotopenup=.25]{doubleprod} +\end{Verbatim} +The default values of \opt{crossopenup} and \opt{dotopenup} are \opt{0.02} +and \opt{0.2}. The value stands for the multiple of current font size. +Moreover, you can change the symbols produced by \cs{doublecross} and +\cs{doubledot} by setting \opt{crosssymbol} and \opt{dotsymbol} in module +option. + +\subsection{The \modu{xmat} module --- matrices with formatted entries} +The \modu{xmat} module provides \cs{xmat} command for matrices with formatted +entries: +\begin{center} +\cs{xmat}\oarg{options}\marg{entry}\marg{rows shown}\marg{cols shown} +\end{center} +If \meta{rows shown} and \meta{cols shown} are digits, the value of them +must be less at least 2 than the value of \pkg{amsmath}'s \opt{MaxMatrixCols} +counter. For example, +\begin{example} +\[ + \xmat{a}{2}{3} +\] +\end{example} +\cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also +available. The meaning of \opt{p} and so on is the same as the \opt{p} +in \opt{pmatrix} of \pkg{amsmath}. For example, +\begin{example} +\[ + \pxmat{M}{3}{3} +\] +\end{example} +If \meta{rows shown} and \meta{cols shown} contain non-digit characters, +extra dots will be added. For example, +\begin{example} +\[ + \bxmat[showleft=3,showtop=2] + {X}{m}{n} +\] +\end{example} +In this example we used the \opt{showleft} and \opt{showtop} options. The +default value of them is the value of \opt{MaxMatrixCols} minus 2. You can +also set them in the module option like this: +\begin{Verbatim} +\usephysicsmodule[showtop=3,showleft=3]{xmat} +\end{Verbatim} +Then every \cs{xmat} with non-digital \meta{rows shown} and \meta{cols shown} +will have 2 top-most rows and 3 left-most columns shown. This will also +influence ``\cs{xmat}''s with digital \meta{rows shown} and \meta{cols shown} +when \meta{rows shown} and \meta{cols shown} are larger than the values +corresponding to \opt{showtop} and \opt{showleft}. For example, +\begin{example} +% \usephysicsmodule +% [showtop=3,showleft=3]{xmat} +\[ \pxmat{A}{8}{8} \] +\end{example} +However, when \meta{rows shown} and \meta{cols shown} are 1 greater than +\meta{showtop} and \meta{showleft}, for example, \meta{rows shown}$\:=4$ and +\meta{cols shown}$\:=4$ in last example's settings, \cs{xmat} will still add +the extra dots: +\begin{example} +% \usephysicsmodule +% [showtop=3,showleft=3]{xmat} +\[ \pxmat{A}{4}{4} \] +\end{example} +In such situations, we need to specify \opt{showtop} and \opt{showleft} +manually. For example, +\begin{example} +% \usephysicsmodule +% [showtop=3,showleft=3]{xmat} +\[ \pxmat[showtop=4,showleft=4] + {A}{4}{4} \] +\end{example} + +The \cs{xmat} command provides the \opt{format} option, which allows users +to use a new entry format. For example, +\begin{example} +\[ + \xmat [showleft=2,showtop=2, + format=\texttt{#1[#2][#3]}] + {x}{m}{n} +\] +\end{example} +In the value of \opt{format} key, \verb|#1| stands for the common entry, +or the first mandatory \meta{entry} argument of \cs{xmat}; \verb|#2| +stands for the row index and \verb|#3| stands for the column index. + +This module requires \pkg{amsmath}. + +\paragraph{The options of \modu{xmat} module} +Only \opt{showtop} and \opt{showleft} can be used as module options. +\opt{format} should be only used in the optional argument of the +\cs{xmat} command. + +\section{The ``legacy'' modules} +The legacy modules have similar names like \meta{module}\opt{.legacy}. Most of +them are designed to provide solutions to maintain documents written with the +legacy \pkg{physics} package. It's not suggested to use them in a new document. + +\subsection{The \modu{ab.legacy} module} +This module provides the following commands: +\begin{Verbatim}[fontsize=\small] +\abs \norm \eval (\peval \beval) \order +\end{Verbatim} +They share the same syntax as \meta{cmd}\opt{*}\oarg{biggg}\marg{subformula}. +Star and \meta{biggg} are optional. Star stands for ``use the default size''. +For example, +\begin{example} +\def\0{1+\frac12} +\[ \abs{\0} \quad + \norm[Big]{\0} \quad + \order*{\0} \] +\end{example} +\begin{example} +\def\0{1+\frac12x} +\[ \eval{\0}_a^b \quad + \peval*{\0}_a^b \quad + \beval[big]{\0}_a^b \] +\end{example} +You can set the ``order'' symbol in this module through +the \opt{order} option like this: +\begin{Verbatim} +\usephysicsmodule[order=O]{ab.legacy} +\end{Verbatim} +For further information of this module, see \S\ref*{lega-subsec:ab-and-legacy} +of \hyperref{./physics2-legacy.pdf}{}{}{physics2-legacy}. + +\subsection{The \modu{bm-um.legacy} module} +If you are maintaining a document with plenty of ``\cs{bm}''s or +``\cs{boldsymbol}''s in it but want to use \pkg{unicode-math} package +simultaneously, you could take a look at this module. + +The \cs{bm} command from \pkg{bm} package uses \cs{mathversion} to support +its function, but there are few OpenType math fonts who released with a bold +version. The \modu{bm-um.legacy} module provides a \cs{bm} command too, but +this \cs{bm} can only take \emph{one} math character or a series of math +characters sharing the same category code as its argument. +If the argument was Latin letters or Greek letters, \cs{bm} would switch to +the bold italic glyphs corresponding to them (if there exists bold italic +glyphs); else \cs{bm} would switch to the bold upright glyphs. For example, +\begin{example} +$\bm{0}\bm{A}\bm{z} + \bm{\alpha}\bm{\Omega}$ +\end{example} + +\subsection{The \modu{nabla.legacy} module} +This module provides some commands related to nabla ($\nabla$). Notice that +this module requires the \pkg{fixdif} package with file date 2023/01/31 at +minimum. + +This module defines \cs{grad} and \cs{curl} and redefines \cs{div}. For example, +\begin{example} +\[ \grad V \] +\[ \div (x,y,z) \] +\[ \curl(x,y,z) \] +\end{example} +The ``$\divsymbol$'' symbol was redefined as \cs{divsymbol}. + +\subsection{The \modu{op.legacy} module} +This module provides a series of commands for log-like operators. They are +\begin{Verbatim} +\asin \acos \atan +\acsc \asec \acot +\Tr \tr \rank +\erf \Res \res +\PV \pv +\Re \Im +\end{Verbatim} +where \cs{Re} and \cs{Im} are redefined. The first four lines of commands +yield what they look like in math mode. For example, +\begin{example} +$\asin x$ \quad $\rank A$ +\end{example} +\cs{PV} yields ``$\PV$'' as an ordinary symbol and \cs{pv} yields ``$\pv$''. +For example, +\begin{example} +$\PV f(z)$ \quad $\pv f(z)$ +\end{example} +\cs{Re} and \cs{Im} are redefined as ``$\Re$'' and ``$\Im$''. $\Resymbol$ +and $\Imsymbol$ are redefined as \cs{Resymbol} and \cs{Imsymbol}, in default. + +This module \emph{does not} require \pkg{amsmath}. + +\paragraph{The options of \modu{op.legacy} module} +\opt{ReIm}, a bool key with default value \opt{true}, determines whether to +redefine \cs{Re} and \cs{Im}. If you want to reserve the definition of +\cs{Re} and \cs{Im}, you can write like this: +\begin{Verbatim} +\usephysicsmodule[ReIm=false]{op.legacy} +\end{Verbatim} + +\subsection{The \modu{qtext.legacy} module} +This module was written just to offer a method to maintain documents written +with the legacy \pkg{physics} package. See \S\ref*{lega-subsec:qtext} of +\href{./physics2-legacy.pdf}{physics2-legacy} for more information. + +\end{document} \ No newline at end of file diff --git a/macros/latex/contrib/physics2/tex/phy-ab.braket.sty b/macros/latex/contrib/physics2/tex/phy-ab.braket.sty deleted file mode 100644 index e8e7bb30b7..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-ab.braket.sty +++ /dev/null @@ -1,84 +0,0 @@ -%% -%% This is file `phy-ab.braket.sty', -%% the `ab.braket' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-ab.braket.sty} - [2023/04/02 `ab.braket' module of `physics2.sty'] -% This module requires \phy@abopen and \phy@abclose from `ab'. -\phy@requiremodule{ab} -\ifdefined\phy@bra@@ - \PackageWarning{physics2}{You cannot load `ab.braket' and `braket' - modules together.\MessageBreak Only `ab.braket' module works now.} -\fi -% \bra -\phy@AB@gen{kt.m}|{mr|>}{\mathopen#1\vert#2\mathclose#1\rangle\endgroup} -\phy@AB@gen{kt.a}|{r|>}{\phy@abopen\vert#1\phy@abclose\rangle} -\phy@d@l@genxm{kt.m} -\phy@d@l@genxa{kt.a} -\DeclareRobustCommand\ket{\phy@d@lx{kt.m}{kt.a}} -% \braket -\begingroup -\catcode`\|=\active -\gdef\phy@@mb@bk#1#2{\begingroup - \mathcode`\|="8000\def|{\egroup#1\vert\bgroup}% - \def\<{\mathrel{<}}\def\>{\mathrel{>}}% - \mathopen#1\langle\bgroup#2\egroup\mathclose#1\rangle\endgroup} -\gdef\phy@@ab@bk#1{\begingroup - \mathcode`\|="8000\def|{\egroup\phy@abb@bkv\bgroup}% - \def\<{\mathrel{<}}\def\>{\mathrel{>}}% - \phy@abopen\langle\bgroup#1\egroup\phy@abclose\rangle\endgroup} -\endgroup -\def\phy@abb@bkv{\middle\vert} -\phy@AB@gen{bk.m}<{mr<>}{\phy@@mb@bk#1{#2}\endgroup} -\phy@AB@gen{bk.a}<{r<>}{\phy@@ab@bk{#1}} -\phy@d@l@genxm{bk.m} -\phy@d@l@genxa{bk.a} -\DeclareRobustCommand\braket{\phy@d@lx{bk.m}{bk.a}} -% \ketbra|foo>bar=\active -\gdef\phy@@mb@kb#1#2{\begingroup - \mathcode`\<="8000 \mathcode`\>="8000% - \def<{#1\langle}\def>{#1\rangle}% - \def\<{\phy@abb@l}\def\>{\phy@abb@r}% - \mathopen#1\vert#2\mathclose#1\vert\endgroup} -\endgroup -\gdef\phy@@ab@kb#1>#2<#3\phy@@end{\begingroup - \def\<{\phy@abb@l}\def\>{\phy@abb@r}% - \phy@abopen\vert\mathopen{\phy@mathvphantom{#3}}#1\phy@abclose\rangle#2% - \phy@abopen\langle#3\mathclose{\phy@mathvphantom{#1}}\phy@abclose\vert -\endgroup} -\AtBeginDocument{\ifcsname symbf\endcsname - \def\phy@abb@l{\Umathchar 3 \symoperators "003C }% - \def\phy@abb@r{\Umathchar 3 \symoperators "003E }% -\fi} -\def\phy@abb@l{\mathchar"313C } -\def\phy@abb@r{\mathchar"313E } -\phy@AB@gen{kb.m}|{mr||}{\phy@@mb@kb#1{#2}\endgroup} -\phy@AB@gen{kb.a}|{r||}{\phy@@ab@kb#1\phy@@end} -\phy@d@l@genxm{kb.m} -\phy@d@l@genxa{kb.a} -\DeclareRobustCommand\ketbra{\phy@d@lx{kb.m}{kb.a}} -\endinput -%% End of file `phy-ab.braket.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-ab.legacy.sty b/macros/latex/contrib/physics2/tex/phy-ab.legacy.sty deleted file mode 100644 index bbfa1f2b4a..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-ab.legacy.sty +++ /dev/null @@ -1,43 +0,0 @@ -%% -%% This is file `phy-ab.legacy.sty', -%% the `ab.legacy' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-ab.legacy.sty} - [2023/03/29 `ab.legacy' module of `physics2.sty'] -\phy@requiremodule{ab} -% The `tight' bool option, true or false. -\phy@define@key{ab.legacy}{order}[\mathcal{O}]{\def\phy@ab@ordersym{#1}} -% The default values to keys in this module. -\phy@setkeys{ab.legacy}{order} -\phy@processkeyopt{ab.legacy} -% The braced operators. -\phy@d@l@geny\abs\vert\vert -\phy@d@l@geny\norm\Vert\Vert -\DeclareDocumentCommand\order{som}{% - \phy@ab@ordersym - \IfBooleanTF{#1}% - {(#3)}% - {\IfValueTF{#2}% - {\csname#2l\endcsname(#3\csname#2r\endcsname)}% - {\phy@abopen(#3\phy@abclose)}% - }% -} -\phy@d@l@geny\eval.\vert -\phy@d@l@geny\peval(\vert -\phy@d@l@geny\beval[\vert -\endinput -%% End of file `phy-ab.legacy.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-ab.sty b/macros/latex/contrib/physics2/tex/phy-ab.sty deleted file mode 100644 index 9845903a82..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-ab.sty +++ /dev/null @@ -1,111 +0,0 @@ -%% -%% This is file `phy-ab.sty', -%% the `ab' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-ab.sty} - [2023/04/02 `ab' (autobraces) module of `physics2.sty'] -% \phy@requiremodule{common} -% The `tightbraces' bool option, true or false. -\phy@define@key{ab}{tightbraces}[true]{\def\@phy@abtight{#1}} -% Execute the default values to keys in this module. -\phy@setkeys{ab}{tightbraces=true} -\phy@processkeyopt{ab} -% \phy@abopen and \phy@abclose, -% internal definition for all commands in this module. -\ifx\@phy@abtight\phy@true - \let\phy@abopen\delopen - \let\phy@abclose\delclose -\else - \let\phy@abopen\left - \let\phy@abclose\right -\fi -% The internal version of \ab. #1: `ab' or `mb'; #2: open symbol; (#3: arg-spec; #4: definition) -\def\phy@AB@gen#1#2{\expandafter\DeclareDocumentCommand\csname phy@#1@\string#2\endcsname} -% #1 (r): inner content. -\phy@AB@gen{ab}({r()}{\phy@abopen(#1\phy@abclose)} -\phy@AB@gen{ab}[{r[]}{\phy@abopen[#1\phy@abclose]} -\phy@AB@gen{ab}\{{r\{\}}{\phy@abopen\{#1\phy@abclose\}} -\phy@AB@gen{ab}|{r||}{\phy@abopen|#1\phy@abclose|} -\phy@AB@gen{ab}\|{r\|\|}{\phy@abopen\|#1\phy@abclose\|} -\phy@AB@gen{ab}<{r<>}{\phy@abopen<#1\phy@abclose>} -\phy@AB@gen{ab}\lbrace{r\lbrace\rbrace}{\phy@abopen\lbrace#1\phy@abclose\rbrace} -\phy@AB@gen{ab}\vert{r\vert\vert}{\phy@abopen\vert#1\phy@abclose\vert} -\phy@AB@gen{ab}\Vert{r\Vert\Vert}{\phy@abopen\Vert#1\phy@abclose\Vert} -\phy@AB@gen{ab}\langle{r\langle\rangle}{\phy@abopen\langle#1\phy@abclose\rangle} -% #1 (m): \biggg; #2 (r): inner content. -% \endgroup's in the end of definition are corresponding to \begingroup in \phy@d@l@genxm. -\phy@AB@gen{mb}({mr()}{\mathopen#1(#2\mathclose#1)\endgroup} -\phy@AB@gen{mb}[{mr[]}{\mathopen#1[#2\mathclose#1]\endgroup} -\phy@AB@gen{mb}\{{mr\{\}}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} -\phy@AB@gen{mb}|{mr||}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} -\phy@AB@gen{mb}\|{mr\|\|}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} -\phy@AB@gen{mb}<{mr<>}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} -\phy@AB@gen{mb}\lbrace{mr\lbrace\rbrace}{\mathopen#1\lbrace#2\mathclose#1\rbrace\endgroup} -\phy@AB@gen{mb}\vert{mr\vert\vert}{\mathopen#1\vert#2\mathclose#1\vert\endgroup} -\phy@AB@gen{mb}\Vert{mr\Vert\Vert}{\mathopen#1\Vert#2\mathclose#1\Vert\endgroup} -\phy@AB@gen{mb}\langle{mr\langle\rangle}{\mathopen#1\langle#2\mathclose#1\rangle\endgroup} -% \phy@del, the automatic braces. #1: opensymbol; #2: close symbol; #3 -\def\phy@del#1#2#3{\phy@abopen#1#3\phy@abclose#2} -\expandafter\def\csname phy@del\string*\endcsname#1#2#3{\mathopen#1#3\mathclose#2} -\expandafter\def\csname phy@del\string\big\endcsname#1#2#3{\bigl#1#3\bigr#2} -\expandafter\def\csname phy@del\string\Big\endcsname#1#2#3{\Bigl#1#3\Bigr#2} -\expandafter\def\csname phy@del\string\bigg\endcsname#1#2#3{\biggl#1#3\biggr#2} -\expandafter\def\csname phy@del\string\Bigg\endcsname#1#2#3{\Biggl#1#3\Biggr#2} -\expandafter\def\csname phy@del\string\biggg\endcsname#1#2#3{\bigggl#1#3\bigggr#2} -\expandafter\def\csname phy@del\string\Biggg\endcsname#1#2#3{\Bigggl#1#3\Bigggr#2} -% \phy@d@lx (phy_del_x): the internal defination of \ab. -% #1: `mb', according to \phy@AB@gen; #2: `ab'; #3: star or big or left delimiter. -\def\phy@d@lx#1#2#3{% - \ifcsname phy@del\string#3\endcsname% - \def\reserved@a{#1}% #3 is star or \biggg, then get the next argument. - \else% - \def\reserved@a{#2}% #3 is delimiter, the braces are automatic. - \fi% - \csname phy@d@lx\reserved@a\endcsname#3} -% The first two arguments of \phy@d@lx need to be generated by the following two commands. -\def\phy@d@l@genxm#1{% generate arguments like `mb' - \expandafter\def\csname phy@d@lx#1\endcsname##1##2{% - \begingroup% \endgroup in \phy@AB@gen{mb} - \ifx##1*\let\phy@tempa=\relax\else\let\phy@tempa=##1\fi - \csname phy@#1@\string##2\endcsname\phy@tempa##2}} -\def\phy@d@l@genxa#1{% generate arguments like `ab' - \expandafter\def\csname phy@d@lx#1\endcsname##1{% - \csname phy@#1@\string##1\endcsname##1}} -% Generate the `mb' and `ab' arguments. -\phy@d@l@genxm{mb} -\phy@d@l@genxa{ab} -% \ab(), after \ab can be a star or \biggg. -\DeclareRobustCommand\ab{\phy@d@lx{mb}{ab}} -% \phy@d@l@geny: define commands like \pab. #1: cs; #2: open symbol; #3: close symbol. -\def\phy@d@l@geny#1#2#3{% - \DeclareDocumentCommand#1{som}{% ##1: star; ##2: bigg (csname); ##3: subformula. - \IfBooleanTF{##1}% - {#2##3#3}% - {\IfValueTF{##2}% - {\csname##2l\endcsname#2##3\csname##2r\endcsname#3}% - {\phy@abopen#2##3\phy@abclose#3}% - }% - }% -} -\phy@d@l@geny\pab() -\phy@d@l@geny\bab[] -\phy@d@l@geny\Bab\lbrace\rbrace -\phy@d@l@geny\vab\vert\vert -\phy@d@l@geny\aab\langle\rangle -\phy@d@l@geny\Vab\Vert\Vert -\endinput -%% End of file `phy-ab.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-bm-um.legacy.sty b/macros/latex/contrib/physics2/tex/phy-bm-um.legacy.sty deleted file mode 100644 index 36ffe206a6..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-bm-um.legacy.sty +++ /dev/null @@ -1,62 +0,0 @@ -%% -%% This is file `phy-bm-um.legacy.sty', -%% the `bm-um.legacy' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesExplFile{phy-bm-um.legacy.sty}{2023/01/25}{} - {`bm-um.legacy' module of `physics2.sty'} -\AtBeginDocument - { - \cs_if_exist:cF { symbf } - { - \PackageError { physics2 } - { - The ~ `bm-um.legacy' ~ module ~ requires ~ - `unicode-math' ~ package - } - { - Have ~ you ~ used ~ `unicode-math' ~ - in ~ the ~ preamble? - } - } - } -\DeclareDocumentCommand \bm { m } - { - \mode_if_math:TF - { - \tl_if_head_eq_catcode:nNTF { #1 } A - { - \symbfit { #1 } - } - { - \symbf { #1 } - } - } - { - \PackageError { physics2 } - { - The ~ \string\bm\space command ~ should ~ be ~ - used ~ in ~ math ~ mode ~ only. \MessageBreak - This ~ is ~ an ~ error ~ from ~ `bm-um.legacy' ~ module - } - { - Check ~ if ~ any ~ `\string\bm' ~ is ~ out ~ - of ~ math ~ mode. - } - } - } -\endinput -%% End of file `phy-bm-um.legacy.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-braket.sty b/macros/latex/contrib/physics2/tex/phy-braket.sty deleted file mode 100644 index bd3a9f3249..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-braket.sty +++ /dev/null @@ -1,110 +0,0 @@ -%% -%% This is file `phy-braket.sty', -%% the `braket' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-braket.sty} - [2023/03/29 `braket' module of `physics2.sty'] -% Here we need to get the definition of \phy@abopen and \phy@abclose. -\phy@requiremodule{ab} -\ifdefined\phy@abb@bkv - \PackageWarning{physics2}{You cannot load `ab.braket' and `braket' - modules together.\MessageBreak Only `braket' module works now.} -\fi -% \bra -\DeclareDocumentCommand\bra{ s o m }{% - \IfBooleanTF{#1}% - {\mathopen\langle#3\mathclose\vert}% - {\IfValueTF{#2}% - {\csname#2l\endcsname\langle#3\csname#2r\endcsname\vert}% - {\phy@abopen\langle#3\phy@abclose\vert}% - }% -} -% \ket -\DeclareDocumentCommand\ket{ s o m }{% - \IfBooleanTF{#1}% - {\mathopen\vert#3\mathclose\rangle}% - {\IfValueTF{#2}% - {\csname#2l\endcsname\vert#3\csname#2r\endcsname\rangle}% - {\phy@abopen\vert#3\phy@abclose\rangle}% - }% -} -% \braket -\DeclareDocumentCommand\braket{ s O{} }{% - \IfBooleanTF{#1}% - {% - \gdef\@phy@bk@argnum{ii}% - \phy@bk@doopt{#2}% - \gdef\@phy@bk@l{mathopen}% - \gdef\@phy@bk@m{mathord}% - \gdef\@phy@bk@r{mathclose}% - }% - {% - \gdef\@phy@bk@argnum{ii}% - \gdef\@phy@bk@l{phy@abopen}% - \gdef\@phy@bk@m{middle}% - \gdef\@phy@bk@r{phy@abclose}% - \phy@bk@doopt{#2}% - }% - \csname phy@bk@in@\@phy@bk@argnum\endcsname% -} -% The internal version of \braket -\def\phy@bk@in@i#1{% - \csname\@phy@bk@l\endcsname\langle{#1}% - \csname\@phy@bk@r\endcsname\rangle} -\def\phy@bk@in@ii#1#2{% - \csname\@phy@bk@l\endcsname\langle{#1}% - \csname\@phy@bk@m\endcsname\vert{#2}% - \csname\@phy@bk@r\endcsname\rangle} -\def\phy@bk@in@iii#1#2#3{% - \csname\@phy@bk@l\endcsname\langle{#1}% - \csname\@phy@bk@m\endcsname\vert{#2}% - \csname\@phy@bk@m\endcsname\vert{#3}% - \csname\@phy@bk@r\endcsname\rangle} -% Parse the optional argument of \braket. This will add 3 entries to hash table. -\def\@phy@bk@do@pt#1,{\ifx#1\relax\@empty\else - \edef\reserved@a{\zap@space#1 \@empty}% - \ifx\reserved@a\@empty\else - \ifcsname phy@del\expandafter\string\csname\reserved@a\endcsname\endcsname - \xdef\@phy@bk@l{\reserved@a l}% - \xdef\@phy@bk@m{\reserved@a}% but not m (m stands for \mathrel) - \xdef\@phy@bk@r{\reserved@a r}% - \else - \ifnum\reserved@a>3% - \PackageError{physics2}{\string\braket\space can only take 3 - mandatory arguments at most}{Check if you had written a number - more than 3 in the [optional] argument.}% - \fi - \xdef\@phy@bk@argnum{\romannumeral\reserved@a}% - \fi - \fi -\expandafter\@phy@bk@do@pt\fi} -\def\phy@bk@doopt#1{\@phy@bk@do@pt#1,\relax,} -% \ketbra -\DeclareDocumentCommand\ketbra{ s o m O{} m }{% - \IfBooleanTF{#1}% - {\mathopen\vert#3\mathclose\rangle#4\mathopen\langle#5\mathclose\vert}% - {\IfValueTF{#2}% - {\csname#2l\endcsname\vert#3\csname#2r\endcsname\rangle#4% - \csname#2l\endcsname\langle#5\csname#2r\endcsname\vert}% - {\begingroup - \phy@abopen\vert\mathopen{\phy@mathvphantom{#5}}#3\phy@abclose\rangle#4% - \phy@abopen\langle#5\mathclose{\phy@mathvphantom{#3}}\phy@abclose\vert - \endgroup}% - }% -} -\endinput -%% End of file `phy-braket.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-common.sty b/macros/latex/contrib/physics2/tex/phy-common.sty deleted file mode 100644 index e587c02bec..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-common.sty +++ /dev/null @@ -1,68 +0,0 @@ -%% -%% This is file `phy-common.sty', -%% the `common' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-common.sty} - [2023/03/29 `common' module of `physics2.sty'] -% Check if unicode-math loaded and (re)define the vert symbols. -% The \relax's here are for \ifx to compare. -% unicode-math sets these symbols in \fam1, \symoperators is set 1 in 2e kernel. -\AtBeginDocument{\ifcsname symrm\endcsname - \protected\def\|{\Udelimiter 0 \symoperators "2016 }% - \protected\def\vert{\Udelimiter 0 \symoperators "007C\relax}% - \protected\def\Vert{\Udelimiter 0 \symoperators "2016\relax}% - \protected\def\mid{\Udelimiter 3 \symoperators "007C }% -\fi} -\protected\def\Vert{\delimiter"026B30D\relax} -\protected\def\mid{\delimiter"326A30C } -% \delopen and \delclose, make inner subformulae delimited by -% \left and \right behave as an open plus a close atom. -\DeclareRobustCommand\delopen{\mathopen{}\mathclose\bgroup\left} -\DeclareRobustCommand\delclose{\aftergroup\egroup\right} -% Extension to the 2e kernel biggggg commands. -\DeclareRobustCommand\biggg[1]{\leavevmode@ifvmode - {\hbox{$\left#1\vbox to20.5\p@{}\right.\n@space$}}} -\DeclareRobustCommand\Biggg[1]{\leavevmode@ifvmode - {\hbox{$\left#1\vbox to23.5\p@{}\right.\n@space$}}} -\DeclareRobustCommand\bigggl{\mathopen\biggg} -\DeclareRobustCommand\bigggm{\mathrel\biggg} -\DeclareRobustCommand\bigggr{\mathclose\biggg} -\DeclareRobustCommand\Bigggl{\mathopen\Biggg} -\DeclareRobustCommand\Bigggm{\mathrel\Biggg} -\DeclareRobustCommand\Bigggr{\mathclose\Biggg} -% \phy@mathvphantom, does the same job as \vphantom in math mode actually. -\def\phy@mathvphantom#1{\setbox\phy@tempboxa=\hbox{}% - \mathchoice% - {\setbox\@tempboxa\hbox{$\displaystyle#1$}% - \ht\phy@tempboxa=\ht\@tempboxa% - \dp\phy@tempboxa=\dp\@tempboxa% - \box\phy@tempboxa}% - {\setbox\@tempboxa\hbox{$\textstyle#1$}% - \ht\phy@tempboxa=\ht\@tempboxa% - \dp\phy@tempboxa=\dp\@tempboxa% - \box\phy@tempboxa}% - {\setbox\@tempboxa\hbox{$\scriptstyle#1$}% - \ht\phy@tempboxa=\ht\@tempboxa% - \dp\phy@tempboxa=\dp\@tempboxa% - \box\phy@tempboxa}% - {\setbox\@tempboxa\hbox{$\scriptscriptstyle#1$}% - \ht\phy@tempboxa=\ht\@tempboxa% - \dp\phy@tempboxa=\dp\@tempboxa% - \box\phy@tempboxa}% -} -\endinput -%% End of file `phy-common.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-diagmat.sty b/macros/latex/contrib/physics2/tex/phy-diagmat.sty deleted file mode 100644 index e90c99d928..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-diagmat.sty +++ /dev/null @@ -1,92 +0,0 @@ -%% -%% This is file `phy-diagmat.sty', -%% the `diagmat' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesExplFile{phy-diagmat.sty}{2023/01/25}{} - {`diagmat' module of `physics2.sty'} -\phy@requiremodule { explsetup } -\RequirePackage { amsmath } -\phy@define@key { diagmat } { empty } [ 0 ] { \tl_gset:Nn \l__phy_mat_empty_tl { #1 } } -% New variables -\clist_new:N \l__phy_mat_diag_clist -\clist_new:N \l__phy_mat_tmpa_clist -\clist_new:N \l__phy_mat_tmpb_clist -\clist_new:N \l__phy_mat_diagpos_clist -\int_new:N \l__phy_mat_dim_int -\tl_new:N \l__phy_mat_line_tl -\tl_new:N \l__phy_diagmat_tl -\tl_new:N \l__phy_mat_empty_tl -\tl_gset:Nn \l__phy_mat_empty_tl { 0 } -\phy@processkeyopt { diagmat } -\keys_define:nn { phy/diagmat } - { - empty .tl_set:N = \l__phy_mat_empty_tl , - } -% Document Commands -\DeclareDocumentCommand \diagmat { O{} m } - { \__phy_diagmat_type:nnn { } { #1 } { #2 } } -\DeclareDocumentCommand \pdiagmat { O{} m } - { \__phy_diagmat_type:nnn { p } { #1 } { #2 } } -\DeclareDocumentCommand \bdiagmat { O{} m } - { \__phy_diagmat_type:nnn { b } { #1 } { #2 } } -\DeclareDocumentCommand \Bdiagmat { O{} m } - { \__phy_diagmat_type:nnn { B } { #1 } { #2 } } -\DeclareDocumentCommand \vdiagmat { O{} m } - { \__phy_diagmat_type:nnn { v } { #1 } { #2 } } -\DeclareDocumentCommand \Vdiagmat { O{} m } - { \__phy_diagmat_type:nnn { V } { #1 } { #2 } } -% Internal function -\cs_new:Npn \__phy_diagmat_type:nnn #1#2#3 - { - \group_begin: - \clist_set:Nn \l__phy_mat_diag_clist { #3 } - \int_set:Nn \l__phy_mat_dim_int { \clist_count:N \l__phy_mat_diag_clist } - \int_compare:nNnT { \l__phy_mat_dim_int } > { \value { MaxMatrixCols } } - { \setcounter { MaxMatrixCols } { \l__phy_mat_dim_int } } - \keys_set:nn { phy/diagmat } { #2 } - \tl_gclear:N \l__phy_diagmat_tl - \int_step_inline:nnn { 0 } { \l__phy_mat_dim_int - 1 } - { - \int_step_inline:nnn { 0 } { \l__phy_mat_dim_int - 1 } - { - \int_compare:nNnTF { ##1 } = { ####1 } - { - \clist_gpop:NN \l__phy_mat_diag_clist \l__phy_tmpa_tl - \tl_if_empty:NTF \l__phy_tmpa_tl - { \tl_gput_right:Nn \l__phy_mat_line_tl { \l__phy_mat_empty_tl } } - { \tl_gput_right:Nx \l__phy_mat_line_tl { \l__phy_tmpa_tl } } - } - { \tl_gput_right:Nn \l__phy_mat_line_tl { \l__phy_mat_empty_tl } } - % The `&' and `\\' between entries. - \int_compare:nNnTF { ####1 } = { \l__phy_mat_dim_int - 1 } - { - \tl_gput_right:Nn \l__phy_mat_line_tl { \\ } - } - { - \tl_gput_right:Nn \l__phy_mat_line_tl { & } - } - } - \tl_gput_right:Nx \l__phy_diagmat_tl { \l__phy_mat_line_tl } - \tl_gclear:N \l__phy_mat_line_tl - } - \begin { #1 matrix } - \tl_use:N \l__phy_diagmat_tl - \end { #1 matrix } - \group_end: - } -\endinput -%% End of file `phy-diagmat.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-doubleprod.sty b/macros/latex/contrib/physics2/tex/phy-doubleprod.sty deleted file mode 100644 index 1888b6e70a..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-doubleprod.sty +++ /dev/null @@ -1,40 +0,0 @@ -%% -%% This is file `phy-doubleprod.sty', -%% the `doubleprod' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-doubleprod.sty} - [2023/01/25 `doubleprod' (double binary) module of `physics2.sty'] -% The options, true or false. -\phy@define@key{doubleprod}{crosssymbol}{\def\@phy@dbl@c{#1}} -\phy@define@key{doubleprod}{dotsymbol}{\def\@phy@dbl@d{#1}} -\phy@define@key{doubleprod}{crossscale}{\def\@phy@dbl@sc{#1}} -\phy@define@key{doubleprod}{dotscale}{\def\@phy@dbl@sd{#1}} -\phy@define@key{doubleprod}{crossopenup}{\def\@phy@dbl@oc{#1}} -\phy@define@key{doubleprod}{dotopenup}{\def\@phy@dbl@od{#1}} -\phy@setkeys{doubleprod}{crosssymbol=\times,dotsymbol=\ldotp, - crossscale=0.8,dotscale=1,crossopenup=.02,dotopenup=.2} -\phy@processkeyopt{doubleprod} -\def\phy@dbl@gen#1#2#3#4{% - \DeclareRobustCommand#1{\mathbin{\vcenter{\baselineskip\z@skip% - \lineskip#4\phy@dblcurrf@size% - \setbox\@tempboxa=\hbox{\fontsize{#2\phy@dblcurrf@size}\z@$#3$}% - \copy\@tempboxa\box\@tempboxa}}}} -\def\phy@dblcurrf@size{\dimexpr\f@size pt\relax} -\phy@dbl@gen\doublecross\@phy@dbl@sc\@phy@dbl@c\@phy@dbl@oc -\phy@dbl@gen\doubledot\@phy@dbl@sd\@phy@dbl@d\@phy@dbl@od -\endinput -%% End of file `phy-doubleprod.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-explsetup.sty b/macros/latex/contrib/physics2/tex/phy-explsetup.sty deleted file mode 100644 index a861201f9a..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-explsetup.sty +++ /dev/null @@ -1,29 +0,0 @@ -%% -%% This is file `phy-explsetup.sty', -%% the `explsetup' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesExplFile{phy-explsetup.sty}{2023/01/25}{} - {`explsetup' module of `physics2.sty'} -% temporary variables -\int_new:N \l__phy_tmpa_int -\int_new:N \l__phy_tmpb_int -\tl_new:N \l__phy_tmpa_tl -\tl_new:N \l__phy_tmpb_tl -% gobble one token -\cs_new:Npn \__phy_gobble_i:n #1 { } -\endinput -%% End of file `phy-explsetup.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-nabla.legacy.sty b/macros/latex/contrib/physics2/tex/phy-nabla.legacy.sty deleted file mode 100644 index 04d75d88fd..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-nabla.legacy.sty +++ /dev/null @@ -1,32 +0,0 @@ -%% -%% This is file `phy-nabla.legacy.sty', -%% the `nabla.legacy' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-nabla.legacy.sty} - [2023/01/25 `nabla.legacy' (autobraces) module of `physics2.sty'] -\phy@requiremodule{ab} -% This package required `fixdif' package version 2.x. -\RequirePackage{fixdif}[2023/01/31] -\letdif\phy@nl@nabla{nabla} -\AtBeginDocument{\ifcsname div\endcsname\let\divsymbol\div\fi - \DeclareRobustCommand\grad{\phy@nl@nabla\ab}% - \DeclareRobustCommand\div{\phy@nl@nabla\cdot\ab}% - \DeclareRobustCommand\curl{\phy@nl@nabla\times\ab}% - \DeclareRobustCommand\laplacian{\phy@nl@nabla^2\ab}% -} -\endinput -%% End of file `phy-nabla.legacy.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-op.legacy.sty b/macros/latex/contrib/physics2/tex/phy-op.legacy.sty deleted file mode 100644 index ec7bd359d4..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-op.legacy.sty +++ /dev/null @@ -1,51 +0,0 @@ -%% -%% This is file `phy-op.legacy.sty', -%% the `op.legacy' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-op.legacy.sty} - [2023/01/25 `op.legacy' module of `physics2.sty'] -\phy@define@key{op.lega}{ReIm}[true]{\def\phy@reserveda{#1}} -% The keys for \PV and \pv -\phy@define@key{op.lega}{PV}{\def\@phy@oplega@PV{#1}} -\phy@define@key{op.lega}{pv}{\def\@phy@oplega@pv{#1}} -\phy@setkeys{op.lega}{PV=\mathcal{P},pv={p.v.},ReIm=true} -\phy@processkeyopt{ab} -\DeclareRobustCommand\asin{\mathop{\operator@font asin}\nolimits} -\DeclareRobustCommand\acos{\mathop{\operator@font acos}\nolimits} -\DeclareRobustCommand\atan{\mathop{\operator@font atan}\nolimits} -\DeclareRobustCommand\acsc{\mathop{\operator@font acsc}\nolimits} -\DeclareRobustCommand\asec{\mathop{\operator@font asec}\nolimits} -\DeclareRobustCommand\acot{\mathop{\operator@font acot}\nolimits} -\DeclareRobustCommand\Tr{\mathop{\operator@font Tr}\nolimits} -\DeclareRobustCommand\tr{\mathop{\operator@font tr}\nolimits} -\DeclareRobustCommand\rank{\mathop{\operator@font rank}\nolimits} -\DeclareRobustCommand\erf{\mathop{\operator@font erf}\nolimits} -\DeclareRobustCommand\Res{\mathop{\operator@font Res}\nolimits} -\DeclareRobustCommand\res{\mathop{\operator@font res}\nolimits} -\DeclareRobustCommand\PV{\mathord{\@phy@oplega@PV}} -\DeclareRobustCommand\pv{\mathop{\operator@font\@phy@oplega@pv{}}\nolimits} -% \Re and \Im, restore the former comands as \Resymbol and \Imsymbol -\ifx\phy@reserveda\phy@true -\AtBeginDocument{% - \let\Resymbol\Re% - \let\Imsymbol\Im% - \DeclareRobustCommand\Re{\mathop{\operator@font Re}\nolimits}% - \DeclareRobustCommand\Im{\mathop{\operator@font Im}\nolimits}% -} -\fi -\endinput -%% End of file `phy-op.legacy.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-qtext.legacy.sty b/macros/latex/contrib/physics2/tex/phy-qtext.legacy.sty deleted file mode 100644 index 6ac0d250b0..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-qtext.legacy.sty +++ /dev/null @@ -1,52 +0,0 @@ -%% -%% This is file `phy-qtext.legacy.sty', -%% the `qtext.legacy' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesFile{phy-qtext.legacy.sty} - [2023/01/25 `qtext.legacy' module of `physics2.sty'] -\RequirePackage{amstext} -\def\phy@qtext@#1#2{#1\text{#2}\quad} -\DeclareRobustCommand\qqtext{\@ifstar{\phy@qtext@{}}{\phy@qtext@\quad}} -\DeclareRobustCommand\qq{\qqtext} -\DeclareRobustCommand\qcomma{,\quad} -\DeclareRobustCommand\qc{\qcomma} -\DeclareRobustCommand\qcc{\@ifstar{\phy@qtext@{}{c.c}}{\phy@qtext@\quad{c.c}}} -\def\phy@qtext@lega@gen@#1{% - \expandafter\DeclareRobustCommand\csname q#1\endcsname% - {\@ifstar{\phy@qtext@{}{#1}}{\phy@qtext@\quad{#1}}}} -\phy@qtext@lega@gen@{if} -\phy@qtext@lega@gen@{then} -\phy@qtext@lega@gen@{else} -\phy@qtext@lega@gen@{otherwise} -\phy@qtext@lega@gen@{unless} -\phy@qtext@lega@gen@{give} -\phy@qtext@lega@gen@{using} -\phy@qtext@lega@gen@{unless} -\phy@qtext@lega@gen@{assume} -\phy@qtext@lega@gen@{since} -\phy@qtext@lega@gen@{let} -\phy@qtext@lega@gen@{for} -\phy@qtext@lega@gen@{all} -\phy@qtext@lega@gen@{even} -\phy@qtext@lega@gen@{odd} -\phy@qtext@lega@gen@{integer} -\phy@qtext@lega@gen@{and} -\phy@qtext@lega@gen@{or} -\phy@qtext@lega@gen@{as} -\phy@qtext@lega@gen@{in} -\endinput -%% End of file `phy-qtext.legacy.sty'. diff --git a/macros/latex/contrib/physics2/tex/phy-xmat.sty b/macros/latex/contrib/physics2/tex/phy-xmat.sty deleted file mode 100644 index 9e7058b062..0000000000 --- a/macros/latex/contrib/physics2/tex/phy-xmat.sty +++ /dev/null @@ -1,148 +0,0 @@ -%% -%% This is file `phy-xmat.sty', -%% the `xmat' module of `physics2' package. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\ProvidesExplFile{phy-xmat.sty}{2023/01/25}{} - {`xmat' module of `physics2.sty'} -\phy@requiremodule { explsetup } -\RequirePackage { amsmath } -\phy@define@key { xmat } { showtop } - { \int_gset:Nn \l__phy_xmat_showtop_int { #1 } } -\phy@define@key { xmat } { showleft } - { \int_gset:Nn \l__phy_xmat_showleft_int { #1 } } -% New variables -\bool_new:N \l__phy_xmat_extra_vdots_bool -\bool_new:N \l__phy_xmat_extra_cdots_bool -\int_new:N \l__phy_xmat_showtop_int -\int_new:N \l__phy_xmat_showleft_int -\tl_new:N \l__phy_xmat_tl -\int_gset:Nn \l__phy_xmat_showtop_int { \value { MaxMatrixCols } - 2 } -\int_gset:Nn \l__phy_xmat_showleft_int { \value { MaxMatrixCols } - 2 } -\cs_new:Npn \__phy_xmat_entry_format:nnn #1#2#3 - { - #1 \c_math_subscript_token { #2 #3 } - } -\phy@processkeyopt { xmat } -\DeclareDocumentCommand \xmat { O{} m m m } - { \__phy_xmat_type:nnnnn { } { #1 } { #2 } { #3 } { #4 } } -\DeclareDocumentCommand \pxmat { O{} m m m } - { \__phy_xmat_type:nnnnn { p } { #1 } { #2 } { #3 } { #4 } } -\DeclareDocumentCommand \bxmat { O{} m m m } - { \__phy_xmat_type:nnnnn { b } { #1 } { #2 } { #3 } { #4 } } -\DeclareDocumentCommand \Bxmat { O{} m m m } - { \__phy_xmat_type:nnnnn { B } { #1 } { #2 } { #3 } { #4 } } -\DeclareDocumentCommand \vxmat { O{} m m m } - { \__phy_xmat_type:nnnnn { v } { #1 } { #2 } { #3 } { #4 } } -\DeclareDocumentCommand \Vxmat { O{} m m m } - { \__phy_xmat_type:nnnnn { V } { #1 } { #2 } { #3 } { #4 } } - -\keys_define:nn { phy/xmat } - { - format .cs_set:Np = \__phy_xmat_entry_format:nnn #1#2#3 , - showtop .int_set:N = \l__phy_xmat_showtop_int , - showleft.int_set:N = \l__phy_xmat_showleft_int , - } -% Use regex to judge if the total row/column number contains digits **only**. -\prg_new_conditional:Npnn \__phy_if_digits_only:n #1 { TF } - { - \regex_match:nnTF { \A [[:digit:]]* \Z } { #1 } - { \prg_return_true: } { \prg_return_false: } - } -% #1: p,b,B; #2: options; #2: common entry; #3: total rows; #4: total cols. -\cs_new:Npn \__phy_xmat_type:nnnnn #1#2#3#4#5 - { - \group_begin: - \tl_gclear:N \l__phy_xmat_tl - \keys_set:nn { phy/xmat } { #2 } % - \__phy_if_digits_only:nTF { #4 } - { - \int_compare:nNnTF { #4 } < { \l__phy_xmat_showtop_int + 1 } - { - \int_set:Nn \l__phy_xmat_showtop_int { #4 } - \bool_set_false:N \l__phy_xmat_extra_vdots_bool - } - { - \bool_set_true:N \l__phy_xmat_extra_vdots_bool - } - } - { - \bool_set_true:N \l__phy_xmat_extra_vdots_bool - } - \__phy_if_digits_only:nTF { #5 } - { - \int_compare:nNnTF { #5 } < { \l__phy_xmat_showleft_int + 1 } - { - \int_set:Nn \l__phy_xmat_showleft_int { #5 } - \bool_set_false:N \l__phy_xmat_extra_cdots_bool - } - { - \bool_set_true:N \l__phy_xmat_extra_cdots_bool - } - } - { - \bool_set_true:N \l__phy_xmat_extra_cdots_bool - } - \int_step_inline:nn { \l__phy_xmat_showtop_int } - { - \tl_put_right:Nn \l__phy_xmat_tl - { \__phy_xmat_entry_format:nnn { #3 } { ##1 } { 1 } } - \int_step_inline:nnn { 2 } { \l__phy_xmat_showleft_int } - { - \tl_put_right:Nn \l__phy_xmat_tl - { & \__phy_xmat_entry_format:nnn { #3 } { ##1 } { ####1 } } - } - \bool_if:NT \l__phy_xmat_extra_cdots_bool - { - \tl_put_right:Nn \l__phy_xmat_tl - { & \cdots & \__phy_xmat_entry_format:nnn { #3 } { ##1 } { #5 } } - } - \tl_put_right:Nn \l__phy_xmat_tl { \\ } - } - \bool_if:NT \l__phy_xmat_extra_vdots_bool - { - \tl_put_right:Nn \l__phy_xmat_tl { \vdots } - \prg_replicate:nn { \l__phy_xmat_showleft_int - 1 } - { - \tl_put_right:Nn \l__phy_xmat_tl { & \vdots } - } - % Add \ddots if vdots_bool and cdots_bool be true simultaneously. - \bool_if:NT \l__phy_xmat_extra_cdots_bool - { - \tl_put_right:Nn \l__phy_xmat_tl { & \ddots & \vdots } - } % else relax - \tl_put_right:Nn \l__phy_xmat_tl { \\ } - % The last row. - \tl_put_right:Nn \l__phy_xmat_tl - { \__phy_xmat_entry_format:nnn { #3 } { #4 } { 1 } } - \int_step_inline:nnn { 2 } { \l__phy_xmat_showleft_int } - { - \tl_put_right:Nn \l__phy_xmat_tl - { & \__phy_xmat_entry_format:nnn { #3 } { #4 } { ##1 } } - } - \bool_if:NT \l__phy_xmat_extra_cdots_bool - { - \tl_put_right:Nn \l__phy_xmat_tl - { & \cdots & \__phy_xmat_entry_format:nnn { #3 } { #4 } { #5 } } - } - } % else relax - \begin { #1 matrix } - \tl_use:N \l__phy_xmat_tl - \end { #1 matrix } - \group_end: - } -\endinput -%% End of file `phy-xmat.sty'. diff --git a/macros/latex/contrib/physics2/tex/physics2.sty b/macros/latex/contrib/physics2/tex/physics2.sty deleted file mode 100644 index 3d732b8d29..0000000000 --- a/macros/latex/contrib/physics2/tex/physics2.sty +++ /dev/null @@ -1,70 +0,0 @@ -%% -%% This is file `physics2.sty'. -%% -%% ****************************************************** -%% * This work may be distributed and/or modified under * -%% * the conditions of the LaTeX Project Public License * -%% * * -%% * http://www.latex-project.org/lppl.txt * -%% * * -%% * either version 1.3c of this license or any later * -%% * version. * -%% ****************************************************** -%% -%% This work has the LPPL maintenance status `maintained'. -%% -%% The Current Maintainer of this work is Zhang Tingxuan. -%% -\NeedsTeXFormat{LaTeX2e}[2020/10/01] -\ProvidesPackage{physics2} - [2023/04/02 v0.2.1 Tools for typesetting math for physics.] -% Some common variables. -\newcount\phy@tempcnta -\newdimen\phy@tempdima -\newdimen\phy@tempdimb -\newskip\phy@tempskipa -\newmuskip\phy@tempmuskipa -\newbox\phy@tempboxa -\newif\ifphy@tempswa -\newtoks\phy@toksa -% The package uses `keyval' to support key-value settings. -\RequirePackage{keyval} -\def\phy@true{true} -\def\phy@false{false} -% \phy@define@key{}{}[]{} -\long\def\phy@define@key#1{\define@key{phy-#1}} -% \phy@setkeys{}{} -\long\def\phy@setkeys#1{\setkeys{phy-#1}} -% \phy@processkeyopt{} -\def\phy@processkeyopt#1{\let\reserved@a\@empty% - \edef\reserved@a{\@ptionlist{\@currname.\@currext}}% - \edef\reserved@a{\noexpand\phy@setkeys{#1}{\reserved@a}}% - \reserved@a% the next line thanks to `geometry' - \AtEndOfPackage{\let\@unprocessedoptions\relax}} -% Load the physics modules as 2e kernel does. -\def\usephysicsmodule{\phy@FWoptions\@pkgextension} -\let\phy@requiremodule\usephysicsmodule -\@onlypreamble\usephysicsmodule -\def\phy@FWoptions#1{\@ifnextchar[%] - {\phy@FW@ptions#1}{\phy@FW@ptions#1[]}} -\@onlypreamble\phy@FWoptions -\def\phy@FW@ptions#1[#2]#3{\@ifnextchar[%] - {\phy@FW@pti@ns#1[{#2}]#3}{\phy@FW@pti@ns#1[{#2}]#3[]}} -\@onlypreamble\phy@FW@ptions -\def\phy@FW@pti@ns#1[#2]#3[#4]{% - \def\reserved@b##1,{% - \ifx\@nnil##1\relax\else - \ifx\@nnil##1\@nnil\else - \noexpand\@onefilewithoptions{phy-##1}[{\unexpanded{#2}}][{#4}]% - \noexpand\@pkgextension - \fi - \expandafter\reserved@b - \fi}% - \edef\reserved@a{\zap@space#3 \@empty}% - \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nnil,}% - \reserved@a} -\@onlypreamble\phy@FW@pti@ns -% The `common' module of physics2, every module needs this. -\phy@requiremodule{common} -\endinput -%% End of file `physics2.sty'. -- cgit v1.2.3