\documentclass[a4paper,12pt]{article} \usepackage[margin=1.27cm,foot=0.77cm]{geometry} \usepackage{amsmath,amssymb,array,etoolbox,fontspec,longtable,listings,multirow,needspace,parskip,setspace,verbatim,titling,xcolor,xparse,xstring} \usepackage[override,pretend,nosiintegrate,originaldiv,trig,uprightdiff,bolddel,plaindot,shorttextgreek,shortvargreek,shortupgreek,shortupvargreek,shortboldgreek,shortmathrm,shorttext]{physics-patch} \usepackage[colorlinks,urlcolor=blue]{hyperref} \setmainfont{TeX Gyre Termes}[Ligatures=TeX] \setsansfont{TeX Gyre Heros}[Ligatures=TeX] \setmonofont{TeX Gyre Cursor}[Ligatures=TeX] \usepackage{unicode-math} \setmathfont{XITS Math}\setmathfont[range={cal,bfcal},StylisticSet=1]{XITS Math} \everymath{\displaystyle} \everydisplay{\displaystyle} \newcolumntype{M}{>{$\displaystyle}c<{$}} \newcolumntype{L}{>{$\displaystyle}l<{$}} \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} \setlength{\LTleft}{\fill} \setlength{\LTright}{\fill} \renewcommand{\maketitle}{ \begin{titlepage} \begin{center} \vspace*{\fill} {\huge \bfseries \thetitle\par} \vskip 1.5em {\Large \theauthor\par} \vskip 1em {\large \thedate\par} \vspace*{\fill} \end{center} \end{titlepage} } \lstset{ basicstyle=\ttfamily\scriptsize, keywordstyle=\color{blue}, stringstyle=\color{red}, commentstyle=\color{green!50!black}, numbers=none, backgroundcolor=\color{white}, showspaces=false, showstringspaces=false, showtabs=false, frame=none, tabsize=4, captionpos=b, breaklines=true, breakatwhitespace=false } \title{The \texttt{physics-patch} package\\\mbox{}\\\textnormal{\large Improved version of the physics package}} \author{\mbox{}\\Willie Shen (Willie169)} \date{Version 2.9\\\textnormal{Last update: May 21, 2025}} \begin{document} \onehalfspacing\thispagestyle{empty}\Needspace{1\textheight}\maketitle\setcounter{page}{1}\Needspace{1\textheight}\tableofcontents\Needspace{1\textheight}\setcounter{page}{1} \section{Preface} Since version 2.0, the \texttt{physics-patch} package has evolved from merely patching the \texttt{physics} package to fully replacing it. While preserving the original goal—simplifying mathematical and physics typesetting for greater readability and efficiency—this package refines the design by addressing unintuitive behaviors, extending commands, and introducing additional macros. For instance, in the original package, parentheses and their contents after \verb|\dv{f}{x}| are ignored. This package also extends commands for broader applicability such as enabling \verb|\xmat| to support ellipses and introducing entirely new macros such as \verb|\omat|. \section{Usage} \subsection{Required packages} The \texttt{physics-patch} package requires \texttt{amsmath}, \texttt{etoolbox}, \texttt{xcolor}, \texttt{xparse}, and \texttt{xstring} package to work. If you are unsure whether you've had them installed, you can either install it again using your local package manager (comes with most distributions) or by visiting the \href{http://www.ctan.org}{CTAN} online package database, or even just try to use \texttt{physics-patch} package without worrying about it. Many modern \LaTeX compilers will locate and offer to download missing required packages for you. \subsection{Using \texttt{physics-patch} in your \LaTeX~document} To use \texttt{physics-patch} in your \LaTeX~document, simply insert \verb|\usepackage{physics-patch}| in the preamble of your document, before \verb|\begin{document}| and after \verb|\documentclass{class}|: \begin{lstlisting} \documentclass{class} ... \usepackage{physics-patch} ... \begin{document} content... \end{document} \end{lstlisting} This package will silently override the commands that have been defined before this package is loaded. To use the original definition provided by \texttt{physics}, load \texttt{physics} before this package and use the \texttt{nooverride} option for this package (not recommended). \texttt{nooverride} falls back to the original behavior if \texttt{physics} has not been loaded. This package pretends that \texttt{physics} is loaded so that this package won't be overriden if loading \texttt{physics} is called afterward and packages that depend on \texttt{physics} (e.g. \texttt{siunitx}) work correctly. To disable this, use the \texttt{nopretend} option (not recommended). If \texttt{siuitx} is loaded before this package, this package will define \verb|\ITquantity| and \verb|\ITqty| with the integration of the revised definition of \texttt{physics}'s \verb|\qty| (in \verb|\PHquantity| and \verb|\PHqty|) and \texttt{siuitx}'s \verb|\SI|. You can optionally set \texttt{siintegrate} option to override \verb|\PTquantity| and \verb|\PTqty| with \verb|\ITqty| (not recommended). \texttt{siintegrate} falls back to the original behavior if \texttt{siunitx} is not loaded. \subsection{Options} Options available in this package include \begin{itemize} \item \verb|nooverride|: Not override macros in physics to patched ones (not recommended). Fall back to override if physics is not loaded. \item \verb|override|: Override macros in physics to patched ones (default). This option can be set no matter whether physics is loaded. \item \verb|nopretend|: Not pretend that physics package is loaded (not recommend). \item \verb|pretend|: Pretend that \texttt{physics} is loaded so that this package won't be overriden if loading \texttt{physics} is called afterward and packages that depend on \texttt{physics} (e.g. \texttt{siunitx}) work correctly. \item \verb|nosiintegrate|: Not override \verb|\PTquantity| and \verb|\PTqty| with \verb|\ITqty|. \item \verb|siintegrate|: Override \verb|\PTquantity| and \verb|\PTqty| with \verb|\ITqty| (not recommended). Fall back to nosiintegrate if siunitx is not loaded. \item \verb|nooriginaldiv|: Let \verb|\div| be \verb|\divergence| (not recommended). \item \verb|originaldiv|: Let \verb|\div| be division symbol (default). \item \verb|notrig|: Not redefine trig function and operator. \item \verb|trig|: Redefine trig function and operator (default). \item \verb|italicdiff|: Italic differentials. \item \verb|uprightdiff|: Upright differentials (default). \item \verb|arrowdel|: Vector arrow \verb|\nabla| symbol. \item \verb|bolddel|: Vector bold \verb|\nabla| symbol (default). \item \verb|bolddot|: Vector bold dot product symbol. \item \verb|plaindot|: Vector plain dot product symbol (default). \item \verb|noshorttextgreek|: Not define shorthands for text Greek alphabet (default). \item \verb|shorttextgreek|: Define shorthands for text Greek alphabet. \item \verb|noshortvargreek|: Not define shorthands for variant Greek alphabet (default). \item \verb|shortvargreek|: Define shorthands for variant Greek alphabet. \item \verb|noshortupgreek|: Not define shorthands for upright Greek alphabet (default). \item \verb|shortupgreek|: Define shorthands for upright Greek alphabet. \item \verb|noshortupvargreek|: Not define shorthands for upright variant Greek alphabet (default). \item \verb|shortupvargreek|: Define shorthands for upright variant Greek alphabet. \item \verb|noshortboldgreek|: Not define shorthands for bold Greek alphabet (default). \item \verb|shortboldgreek|: Define shorthands for bold Greek alphabet. \item \verb|noshortgreek|: For backward compatibility. Do nothing. \item \verb|shortgreek|: Define all shorthands for Greek alphabet. \item \verb|noshortmathrm|: Not define shorthands for mathrm alphabet and chemical element symbols (default). \item \verb|shortmathrm|: Define shorthands for mathrm alphabet and chemical element symbols. \item \verb|noshorttext|: Not define shorthands for textnormal alphabet (default). \item \verb|shorttext|: Define shorthands for textnormal alphabet. \end{itemize} To use all features of this package, load it with \verb|\usepackage[override,pretend,nosiintegrate,originaldiv,trig,uprightdiff,bolddel,plaindot,shorttextgreek,shortvargreek,shortupgreek,shortupvargreek,shortboldgreek,shortmathrm,shorttext]{physics-patch}|. If two opposite options which one of them with the name of the other prefixed with a no are loaded at the same time, the one without the no in the name will be used. If two opposite options which have the same suffix and different prefix are loaded at the same time, the default one will be used. If \verb|shortgreek| option is used, \verb|noshorttextgreek|, \verb|noshortvargreek|, \verb|noshortupgreek|, \verb|noshortupvargreek|, and \verb|noshortboldgreek| are ignored. \section{Communication Channels} \begin{itemize} \item \textbf{Bug tracker:} \href{https://github.com/Willie169/physics-patch/issues}{https://github.com/Willie169/physics-patch/issues}. \item \textbf{Announcements:} \href{https://github.com/Willie169/physics-patch/releases}{https://github.com/Willie169/physics-patch/releases}. \item \textbf{Repository:} \href{https://github.com/Willie169/physics-patch}{https://github.com/Willie169/physics-patch}. \end{itemize} \section{License and Credit} \begin{itemize} \item This package is released under the \textbf{LaTeX Project Public License (LPPL) 1.3c.} See \href{https://www.latex-project.org/lppl/lppl-1-3c}{https://www.latex-project.org/lppl/lppl-1-3c} for the details of that license. \item Many parts of this package are modified or copied from the \texttt{physics} package, created by \textbf{Sergio C. de la Barrera} and licenced under \textbf{LPPL 1.3}. See \href{https://ctan.org/pkg/physics}{https://ctan.org/pkg/physics} for the details of that package. \item Many parts of this package rely on the \texttt{amsmath} package, created by \textbf{The \LaTeX{} Project Team} and licenced under \textbf{LPPL 1.3c}. See \href{https://ctan.org/pkg/amsmath}{https://ctan.org/pkg/amsmath} for the details of that package. \end{itemize} \section{List of Commands} In the commands listed below, the left column is long-form names with non-default alternate names (if any), the middle column is default shorthand commands with detailed syntaxes and explanations. If \texttt{nooverride} is not used or the \texttt{physics} package is not loaded before this package, the commands prefixed with \texttt{PT} will silently override those without \texttt{PT}. \subsection{Automatic bracing} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\PTquantity|, \verb|\PHquantity| or \verb|\PHqty| & \verb|\PTqty(\typical)| $\displaystyle\rightarrow \PTqty(\typical)$ & automatic $\PTqty(\;)$ braces \\ & \verb|\PTqty(\tall)| $\displaystyle\rightarrow \PTqty(\tall)$ & \\ & \verb|\PTqty(\grande)| $\displaystyle\rightarrow \PTqty(\grande)$ & \\ & \verb|\PTqty[\typical]| $\rightarrow \PTqty[\typical]$ & automatic $\PTqty[\;]$ braces \\ & \verb+\PTqty|\typical|+ $\rightarrow \PTqty|\typical|$ & automatic $\PTqty|\;|$ braces \\ & \verb|\PTqty{\typical}| $\rightarrow \PTqty{\typical}$ & automatic $\PTqty{\;}$ braces \\ & \verb|\PTqty\big{}| $\rightarrow \PTqty\big{}$ & \multirow{2}{*}{\parbox{6cm}{manual sizing (works with any of the above bracket types)}} \\ & \verb|\PTqty\Big{}| $\rightarrow \PTqty\Big{}$ & \\ & \verb|\PTqty\bigg{}| $\rightarrow \PTqty\bigg{}$ & \\ & \verb|\PTqty\Bigg{}| $\rightarrow \PTqty\Bigg{}$ & \\ & \verb|\pqty{}| $\leftrightarrow$ \verb|\PTqty()| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\ & \verb|\bqty{}| $\leftrightarrow$ \verb|\PTqty[]| & \\ & \verb+\vqty{}+ $\leftrightarrow$ \verb+\PTqty||+ & \\ & \verb|\Bqty{}| $\leftrightarrow$ \verb|\PTqty{}| & \\\hline \verb|\absolutevalue| & \verb|\abs{a}| $\rightarrow \abs{a}$ & automatic sizing; equivalent to \verb|\PTqty| \!\!\texttt{|a|} \\ & \verb|\abs\Big{a}| $\rightarrow \abs\Big{a}$ & inherits manual sizing syntax from \verb|\PTqty| \\ & \verb|\abs*{\grande}| $\displaystyle\rightarrow \abs*{\grande}$ & star for no resize \\\hline \verb|\norm| & \verb|\norm{a}| $\rightarrow \norm{a}$ & automatic sizing \\ & \verb|\norm\Big{a}| $\rightarrow \norm\Big{a}$ & manual sizing \\ & \verb|\norm*{\grande}| $\displaystyle\rightarrow \norm*{\grande}$ & star for no resize \\\hline \verb|\evaluated| & \verb|\eval{x}_0^\infty| $\displaystyle\rightarrow \eval{x}_0^\infty$ & vertical bar for evaluation limits \\ & \verb|\eval(x| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval(x|_0^\infty$ & alternate form \\ & \verb|\eval[x| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval[x|_0^\infty$ & alternate form \\ & \verb|\eval[\venti| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval[\venti|_0^\infty$ & automatic sizing\\ & \verb|\eval*[\venti| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval*[\venti|_0^\infty$ & star for no resize \\\hline \verb|\order| & \verb|\order{x^2}| $\rightarrow \order{x^2}$ & order symbol; automatic sizing and space handling \\ & \verb|\order\Big{x^2}| $\rightarrow \order\Big{x^2}$ & manual sizing \\ & \verb|\order*{\grande}| $\displaystyle\rightarrow \order*{\grande}$ & star for no resize \\\hline \verb|\commutator| & \verb|\comm{A}{B}| $\rightarrow \comm{A}{B}$ & automatic sizing \\ & \verb|\comm\Big{A}{B}| $\rightarrow \comm\Big{A}{B}$ & manual sizing \\ & \verb|\comm*{A}{\grande}| $\displaystyle\rightarrow \comm*{A}{\grande}$ & star for no resize \\\hline \verb|\anticommutator| or \verb|\acommutator| & \verb|\acomm{A}{B}| $\rightarrow \acomm{A}{B}$ & same as \verb|\poissonbracket| \\\hline \verb|\poissonbracket| & \verb|\pb{A}{B}| $\rightarrow \pb{A}{B}$ & same as \verb|\anticommutator|\\\hline \end{longtable} \subsection{Vector notation} The default del symbol $\vnabla$ used in \texttt{physics-patch} vector notation can be switched to appear with an arrow $\vec{\vnabla}$ by including the option \texttt{arrowdel} in the document preamble: \begin{lstlisting}[language=TeX] \usepackage[arrowdel]{physics-patch} \end{lstlisting} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\vectorbold| & \verb|\vb{a}| $\rightarrow \vb{a}$ & upright/no Greek \\ & \verb|\vb*{a}|, \verb|\vb*{\theta}| $\rightarrow \vb*{a}$, $\vb*{\theta}$ & italic/Greek \\\hline \verb|\vectorarrow| & \verb|\va{a}| $\rightarrow \va{a}$ & upright/no Greek \\ & \verb|\va*{a}|, \verb|\va*{\theta}| $\rightarrow \va*{a}$, $\va*{\theta}$ & italic/Greek \\\hline \verb|\vectorunit| & \verb|\vu{a}| $\rightarrow \vu{a}$ & upright/no Greek \\ & \verb|\vu*{a}|, \verb|\vu*{\theta}| $\rightarrow \vu*{a}$, $\vu*{\theta}$ & italic/Greek \\\hline \verb|\dotproduct| & \verb|\vdot| $\rightarrow \vdot$ as in $\vb{a} \vdot \vb{b}$ & note: \verb|\dp| is a protected \TeX\ primitive \\\hline \verb|\crossproduct| & \verb|\cross| $\rightarrow \cross$ as in $\vb{a} \cross \vb{b}$ & alternate name \\ & \verb|\cp| $\rightarrow \cp$ as in $\vb{a} \cp \vb{b}$ & shorthand name \\\hline \verb|\gradient| & \verb|\grad| $\rightarrow \grad$ & \\ & \verb|\grad{\Psi}| $\rightarrow \grad{\Psi}$ & default mode \\ & \verb|\grad(\Psi+\tall)| $\displaystyle\rightarrow \grad(\Psi+\tall)$ & long-form (like \verb|\PTqty| but also handles spacing) \\ & \verb|\grad[\Psi+\tall]| $\displaystyle\rightarrow \grad[\Psi+\tall]$ & \\\hline \verb|\divisionsymbol| & \verb|\divisionsymbol| $\rightarrow \divisionsymbol$ & \\\hline \verb|\divergence| & \verb|\divg| $\rightarrow \divg$ & note: if \texttt{nooriginaldiv} option is used, \verb|\div| will be overriden as $\divg$ too (not recommended) \\ & \verb|\divg{\vb{a}}| $\rightarrow \divg{\vb{a}}$ & default mode \\ & \verb|\divg(\vb{a}+\tall)| $\displaystyle\rightarrow \divg(\vb{a}+\tall)$ & long-form \\ & \verb|\divg[\vb{a}+\tall]| $\displaystyle\rightarrow \divg[\vb{a}+\tall]$ & \\\hline \verb|\curl| & \verb|\curl| $\rightarrow \curl$ & \\ & \verb|\curl{\vb{a}}| $\rightarrow \curl{\vb{a}}$ & default mode \\ & \verb|\curl(\vb{a}+\tall)| $\displaystyle\rightarrow \curl(\vb{a}+\tall)$ & long-form \\ & \verb|\curl[\vb{a}+\tall]| $\displaystyle\rightarrow \curl[\vb{a}+\tall]$ & \\\hline \verb|\laplacian| & \verb|\laplacian| $\rightarrow \laplacian$ & \\ & \verb|\laplacian{\Psi}| $\rightarrow \laplacian{\Psi}$ & default mode \\ & \verb|\laplacian(\Psi+\tall)| $\displaystyle\rightarrow \laplacian(\Psi+\tall)$ & long-form \\ & \verb|\laplacian[\Psi+\tall]| $\displaystyle\rightarrow \laplacian[\Psi+\tall]$ &\\\hline \end{longtable} \subsection{Operators} The standard set of trig functions is redefined in \texttt{physics-patch} to provide automatic braces that behave like \verb|\PTqty()|. In addition, an optional power argument is provided. This behavior can be switched off by including the option \texttt{notrig} in the preamble: \begin{lstlisting}[language=TeX] \usepackage[notrig]{physics-patch} \end{lstlisting} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \multicolumn{3}{|l|}{Example trig redefinitions:} \\\hline \verb|\sin| & \verb|\sin(\grande)| $\displaystyle\rightarrow \sin(\grande)$ & automatic braces; old \verb|\sin| renamed \verb|\sine| \\ & \verb|\sin[2](x)| $\rightarrow \sin[2](x)$ & optional power \\ & \verb|\sin x| $\rightarrow \sin x$ & can still use without an argument \\\hline \end{longtable} The full set of available trig functions in \texttt{physics-patch} includes:\\ \begin{longtable}[c]{llll} \verb|\sin(x)| & \verb|\sinh(x)| & \verb|\arcsin(x)| & \verb|\asin(x)| \\ \verb|\cos(x)| & \verb|\cosh(x)| & \verb|\arccos(x)| & \verb|\acos(x)| \\ \verb|\tan(x)| & \verb|\tanh(x)| & \verb|\arctan(x)| & \verb|\atan(x)| \\ \verb|\csc(x)| & \verb|\csch(x)| & \verb|\arccsc(x)| & \verb|\acsc(x)| \\ \verb|\sec(x)| & \verb|\sech(x)| & \verb|\arcsec(x)| & \verb|\asec(x)| \\ \verb|\cot(x)| & \verb|\coth(x)| & \verb|\arccot(x)| & \verb|\acot(x)| \end{longtable}$\Rightarrow$ \begin{longtable}[c]{MMMM} \sin(x) & \sinh(x) & \arcsin(x) & \asin(x) \\ \cos(x) & \cosh(x) & \arccos(x) & \acos(x) \\ \tan(x) & \tanh(x) & \arctan(x) & \atan(x) \\ \csc(x) & \csch(x) & \arccsc(x) & \acsc(x) \\ \sec(x) & \sech(x) & \arcsec(x) & \asec(x) \\ \cot(x) & \coth(x) & \arccot(x) & \acot(x)\\ \end{longtable} The standard trig functions (plus a few that are missing in \texttt{amsmath}) are available without any automatic bracing under a new set of longer names:\\ \begin{longtable}[c]{llll} \verb|\sine| & \verb|\hypsine| & \verb|\arcsine| & \verb|\asine| \\ \verb|\cosine| & \verb|\hypcosine| & \verb|\arccosine| & \verb|\acosine| \\ \verb|\tangent| & \verb|\hyptangent| & \verb|\arctangent| & \verb|\atangent| \\ \verb|\cosecant| & \verb|\hypcosecant| & \verb|\arccosecant| & \verb|\acosecant| \\ \verb|\secant| & \verb|\hypsecant| & \verb|\arcsecant| & \verb|\asecant| \\ \verb|\cotangent| & \verb|\hypcotangent| & \verb|\arccotangent| & \verb|\acotangent|\\ \end{longtable} Similar behavior has also been extended to the following functions:\\ \begin{longtable}[c]{|l|>{$}l<{$}|l|l|} \hline \verb|\exp(\tall)| & \exp(\tall) & \multirow{5}{*}{old definitions $\Rightarrow$} & \verb|\exponential| \\\cline{1-2}\cline{4-4} \verb|\log(\tall)| & \log(\tall) & & \verb|\logarithm| \\\cline{1-2}\cline{4-4} \verb|\ln(\tall)| & \ln(\tall) & & \verb|\naturallogarithm| \\\cline{1-2}\cline{4-4} \verb|\det(\tall)| & \det(\tall) & & \verb|\determinant| \\\cline{1-2}\cline{4-4} \verb|\Pr(\tall)| & \Pr(\tall) & & \verb|\Probability|\\\hline \verb|\Arg(\tall)| & \Arg(\tall) & & \verb|\Argument|\\\hline \verb|\arg(\tall)| & \arg(\tall) & & \verb|\argument|\\\hline \verb|\Re(\tall)| & \Re(\tall) & & \verb|\real|\\\hline \verb|\Im(\tall)| & \Im(\tall) & & \verb|\imaginary|\\\hline \end{longtable} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \multicolumn{3}{|l|}{New operators:} \\\hline \verb|\tr| & \verb|\tr\rho| $\rightarrow \tr\rho$ also \verb|\tr(\tall)| $\rightarrow \tr(\tall)$ & trace; same bracing as trig functions \\\hline \verb|\Tr| & \verb|\Tr\rho| $\rightarrow \Tr\rho$ & alternate \\\hline \verb|\rank| & \verb|\rank M| $\rightarrow \rank M$ & matrix rank \\\hline \verb|\erf| & \verb|\erf(x)|$\rightarrow \erf(x)$ & error function \\\hline \verb|\Res| & \verb|\Res[f(z)]|$\rightarrow \Res[f(z)]$ & \parbox{6cm}{residue; same bracing as trig functions} \\\hline \verb|\acosh| & \verb|\acosh(\pi)| $\rightarrow\acosh(\pi)$ & acosh \\\hline \verb|\acsch| & \verb|\acsch(\pi)| $\rightarrow\acsch(\pi)$ & acsch \\\hline \verb|\arccosh| & \verb|\arccosh(\pi)| $\rightarrow\arccosh(\pi)$ & arccosh \\\hline \verb|\arccsch| & \verb|\arccsch(\pi)| $\rightarrow\arccsch(\pi)$ & arccsch \\\hline \verb|\arcsech| & \verb|\arcsech(\pi)| $\rightarrow\arcsech(\pi)$ & arcsech \\\hline \verb|\arcsinh| & \verb|\arcsinh(\pi)| $\rightarrow\arcsinh(\pi)$ & arcsinh \\\hline \verb|\arctanh| & \verb|\arctanh(\pi)| $\rightarrow\arctanh(\pi)$ & arctanh \\\hline \verb|\arctantwo| & \verb|\arctantwo(\pi)| $\rightarrow\arctantwo(\pi)$ & arctan2 \\\hline \verb|\asech| & \verb|\asech(\pi)| $\rightarrow\asech(\pi)$ & asech \\\hline \verb|\asinh| & \verb|\asinh(\pi)| $\rightarrow\asinh(\pi)$ & asinh \\\hline \verb|\atanh| & \verb|\atanh(\pi)| $\rightarrow\atanh(\pi)$ & atanh \\\hline \verb|\atantwo| & \verb|\atantwo(\pi)| $\rightarrow\atantwo(\pi)$ & atan2 \\\hline \verb|\closure| & \verb|\closure(A)| $\rightarrow\closure(A)$ & closure \\\hline \verb|\col| & \verb|\col(\mathbf{A})| $\rightarrow\col(\mathbf{A})$ & column space \\\hline \verb|\Col| & \verb|\Col(\mathbf{A})| $\rightarrow\Col(\mathbf{A})$ & column space \\\hline \verb|\dim| & \verb|\dim(V)| $\rightarrow\dim(V)$ & dimension \\\hline \verb|\distance| & \verb|\distance(A,B)| $\rightarrow\distance(A,B)$ & lowercase distance \\\hline \verb|\Distance| & \verb|\Distance(A,B)| $\rightarrow\Distance(A,B)$ & uppercase distance \\\hline \verb|\row| & \verb|\row(\mathbf{A})| $\rightarrow\row(\mathbf{A})$ & row space \\\hline \verb|\Row| & \verb|\Row(\mathbf{A})| $\rightarrow\Row(\mathbf{A})$ & row space \\\hline \verb|\ker| & \verb|\ker(\mathbf{A})| $\rightarrow\ker(\mathbf{A})$ & kernel \\\hline \verb|\SD| & \verb|\SD(X)| $\rightarrow\SD(X)$ & standard deviation \\\hline \verb|\Var| & \verb|\Var(X)| $\rightarrow\Var(X)$ & variation \\\hline \verb|\Mode| & \verb|\Mode(X)| $\rightarrow\Mode(X)$ & mode \\\hline \verb|\Median| & \verb|\Median(X)| $\rightarrow\Median(X)$ & median \\\hline \verb|\gcd| & \verb|\gcd(X)| $\rightarrow\gcd(X)$ & lowercase greatest common divisor \\\hline \verb|\lcm| & \verb|\lcm(X)| $\rightarrow\lcm(X)$ & lowercase lowest common multiple \\\hline \verb|\GCD| & \verb|\GCD(X)| $\rightarrow\GCD(X)$ & uppercase greatest common divisor \\\hline \verb|\LCM| & \verb|\LCM(X)| $\rightarrow\LCM(X)$ & uppercase lowest common multiple \\\hline \verb|\UnitVector| & \verb|\UnitVector(\mathbf{r})| $\rightarrow\UnitVector(\mathbf{r})$ & unit vector \\\hline \verb|\principalvalue| & \verb|\pv{\int f(z) \dd{z}}|$\rightarrow \pv{\int f(z) \dd{z}}$ & Cauchy principal value \\ & \verb|\PV{\int f(z) \dd{z}}|$\rightarrow \PV{\int f(z) \dd{z}}$ & alternate \\\hline \end{longtable} \subsection{Utilities} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\mathcolorbox| & \verb|\mcbox{color}{content}| & \multirow{2}{*}{\parbox{6cm}{\texttt{\textbackslash colorbox} for math environment, applying to all four levels of math styles}} \\ & \verb|\mcbox{cyan}{\typical}| $\rightarrow \mcbox{cyan}{\typical}$ & \\\hline \verb|\autocolorbox| or \verb|\acbox| & \verb|\cbox{color}{content}| & calls \verb|\colorbox| when in text mode, calls \verb|\mathcolorbox| when in math mode \\\hline \verb|\tentothepowerof| & \verb|\tenpow{n}| $\rightarrow \tenpow{n}$ & work in both math mode and text mode \\\hline \verb|\scientificnotation| & \verb|\scinote{3.00}{8}| $\rightarrow \scinote{3.00}{8}$ & work in both math mode and text mode\\\hline \verb|\numbercircled| & \verb|\numcir{1}| $\rightarrow$ \numcir{1} & patched \verb|\textcircled| for numbers \\\hline \verb|\boldsymbol| & \verb|\bsb{\tau}| $\rightarrow\bsb{\tau}$ & shorthand for \verb|\boldsymbol| \\\hline \verb|\RNum| & \verb|\RNum{1}| $\rightarrow$ \RNum{1} & uppercase roman numeral\\\hline \verb|\flatfrac| & \verb|\flatfrac{a}{b}| $\rightarrow\flatfrac{a}{b}$ & flat fraction\\\hline \end{longtable} \subsection{Quick quad text} This set of commands produces text in math-mode padded by \verb|\quad| spacing on either side. This is meant to provide a quick way to insert simple words or phrases in a sequence of equations. Each of the following commands includes a starred version which pads the text only on the right side with \verb|\quad| for use in aligned environments such as \texttt{cases}.\\ \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \multicolumn{3}{|l|}{General text:} \\\hline \verb|\qqtext| & \verb|\qq{}| & general quick quad text with argument \\ & \verb|\qq{word or phrase}| $\rightarrow$\Vtextvisiblespace[1em]$\text{word or phrase}$\Vtextvisiblespace[1em] & normal mode; left and right \verb|\quad| \\ & \verb|\qq*{word or phrase}| $\rightarrow \text{word or phrase}$\Vtextvisiblespace[1em] & starred mode; right \verb|\quad| only\\\hline \end{longtable} \begin{longtable}[c]{| l | l | } \hline Special macros: & \\\hline \verb|\qcomma| or \verb|\qc| $\rightarrow ,$\Vtextvisiblespace[1em] & right \verb|\quad| only \\\hline \verb|\qcc| $\rightarrow$\Vtextvisiblespace[1em]$\text{c.c.}$\Vtextvisiblespace[1em] & complex conjugate; left and right \verb|\quad| unless starred \verb|\qcc*| $\rightarrow \text{c.c.}$\Vtextvisiblespace[1em] \\\hline \verb|\qif| $\rightarrow$\Vtextvisiblespace[1em]$\text{if}$\Vtextvisiblespace[1em] & left and right \verb|\quad| unless starred \verb|\qif*| $\rightarrow \text{if}$\Vtextvisiblespace[1em]\\\hline \end{longtable} \begin{longtable}[c]{ | l | } \hline Similar to \verb|\qif|: \\\hline \verb|\qthen|, \verb|\qelse|, \verb|\qotherwise|, \verb|\qunless|, \verb|\qgiven|, \verb|\qusing|, \verb|\qassume|, \verb|\qsince|, \verb|\qlet| \\ \verb|\qfor|, \verb|\qall|, \verb|\qeven|, \verb|\qodd|, \verb|\qinteger|, \verb|\qand|, \verb|\qor|, \verb|\qas|, \verb|\qin| \\\hline \end{longtable} \subsection{Derivatives} The default differential symbol $\dd$ which is used in \verb|\differential| and \verb|\derivative| can be switched to an italic form $d$ by including the option \texttt{italicdiff} in the preamble: \begin{lstlisting}[language=TeX] \usepackage[italicdiff]{physics-patch} \end{lstlisting} \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\differential| & \verb|\dd| $\rightarrow \dd$ & \\ & \verb|\dd x| $\rightarrow \dd x$ & no spacing (not recommended) \\ & \verb|\dd{x}| $\rightarrow$ \textvisiblespace\,$\dd{x}$\textvisiblespace & automatic spacing based on neighbors \\ & \verb|\dd[3]{x}| $\rightarrow \dd[3]{x}$ & optional power \\ & \verb|\dd(\cos\theta)| $\rightarrow \dd(\cos\theta)$ & long-form; automatic braces \\\hline \verb|\PTderivative| & \verb|\PTdv{x}| $\displaystyle\rightarrow \PTdv{x}$ & one argument \\ & \verb|\PTdv{f}{x}| $\displaystyle\rightarrow \PTdv{f}{x}$ & two arguments \\ & \verb|\PTdv[n]{f}{x}| $\displaystyle\rightarrow \PTdv[n]{f}{x}$ & optional power \\ & \verb|\PTdv{x}(\grande)| $\displaystyle\rightarrow \PTdv{x}(\grande)$ & long-form; automatic braces, spacing \\ & \verb|\PTdv*{f}{x}| $\displaystyle\rightarrow \PTdv*{f}{x}$ & inline form using \verb|\flatfrac| \\\hline \verb|\PTpartialderivative| or \verb|\PTpderivative| & \verb|\PTdv{f}{x}(\grande)| $\displaystyle\rightarrow \PTdv{f}{x}(\grande)$ & note: in original \texttt{physics} package, \verb|\dv{f}{x}(\grande)| $\displaystyle\rightarrow \dv{f}{x}$\\ & \verb|\PTpdv{x}| $\displaystyle\rightarrow \PTpdv{x}$ & shorthand name \\ & \verb|\PTpdv{f}{x}| $\displaystyle\rightarrow \PTpdv{f}{x}$ & two arguments \\ & \verb|\PTpdv[n]{f}{x}| $\displaystyle\rightarrow \PTpdv[n]{f}{x}$ & optional power \\ & \verb|\PTpdv{x}(\grande)| $\displaystyle\rightarrow \PTpdv{x}(\grande)$ & long-form \\ & \verb|\PTpdv{f}{x}{y}| $\displaystyle\rightarrow \PTpdv{f}{x}{y}$ & mixed partial \\ & \verb|\PTpdv*{f}{x}| $\displaystyle\rightarrow \PTpdv*{f}{x}$ & inline form using \verb|\flatfrac| \\ & \verb|\PTpdv{f}{x}(\grande)| $\displaystyle\rightarrow \PTpdv{f}{x}(\grande)$ & note: in original \texttt{physics} package, \verb|\pdv{f}{x}(\grande)| $\displaystyle\rightarrow \pdv{f}{x}$ \\\hline \verb|\variation| & \verb|\var{F[g(x)]}| $\rightarrow \var{F[g(x)]}$ & functional variation (works like \verb|\dd|) \\ & \verb|\var(E-TS)| $\rightarrow \var(E-TS)$ & long-form \\\hline \verb|\functionalderivative| & \verb|\fdv{g}| $\displaystyle\rightarrow \fdv{g}$ & functional derivative (works like \verb|\PTdv|) \\ & \verb|\fdv{F}{g}| $\displaystyle\rightarrow \fdv{F}{g}$ & \\ & \verb|\fdv{V}(E-TS)| $\displaystyle\rightarrow \fdv{V}(E-TS)$ & long-form \\ & \verb|\fdv*{F}{x}| $\displaystyle\rightarrow \fdv*{F}{x}$ & inline form using \verb|\flatfrac| \\\hline \end{longtable} \subsection{Dirac bra-ket notation} The following collection of macros for Dirac notation contains two fundamental commands, \verb|\bra| and \verb|\ket|, along with a set of more specialized macros which are essentially combinations of the fundamental pair. The fundamental commands are designed to contract with one another algebraically when appropriate and are thus suggested for general use. For instance, the following code renders correctly\footnote{Note the lack of a space between the bra and ket commands. This is necessary in order for the bra to find the corresponding ket and form a contraction.} \begin{displaymath} \verb|\bra{\phi}\ket{\psi}| \rightarrow \bra{\phi}\ket{\psi} \qq{as opposed to} \bra{\phi} \ket{\psi} \end{displaymath} whereas a similar construction with higher-level macros will not contract in a robust manner \begin{displaymath} \verb|\bra{\phi}\dyad{\psi}{\xi}| \rightarrow \bra{\phi}\dyad{\psi}{\xi}. \end{displaymath} On the other hand, the correct output can be generated by sticking to the fundamental commands, \begin{displaymath} \verb|\bra{\phi}\ket{\psi}\bra{\xi}| \rightarrow \bra{\phi}\ket{\psi}\bra{\xi} \end{displaymath} allowing the user to type out complicated quantum mechanical expressions without worrying about bra-ket contractions. That being said, the high-level macros do have a place in convenience and readability, as long as the user is aware of rendering issues that may arise due to an absence of automatic contractions.\\ \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\ket| & \verb|\ket{\tall}| $\rightarrow \ket{\tall}$ & automatic sizing \\ & \verb|\ket*{\tall}| $\rightarrow \ket*{\tall}$ & no resize \\\hline \verb|\bra| & \verb|\bra{\tall}| $\rightarrow \bra{\tall}$ & automatic sizing \\ & \verb|\bra*{\tall}| $\rightarrow \bra*{\tall}$ & no resize \\ & \verb|\bra{\phi}\ket{\psi}| $\rightarrow \bra{\phi}\ket{\psi}$ & automatic contraction \\ & \verb|\bra{\phi}\ket{\tall}| $\rightarrow \bra{\phi}\ket{\tall}$ & contraction inherits automatic sizing \\ & \verb|\bra{\phi}\ket*{\tall}| $\rightarrow \bra{\phi}\ket*{\tall}$ & \multirow{2}{*}{\parbox{6cm}{a star on either term in the contraction prohibits resizing}} \\ & \verb|\bra*{\phi}\ket{\tall}| $\rightarrow \bra*{\phi}\ket{\tall}$ & \\ & \verb|\bra*{\phi}\ket*{\tall}| $\rightarrow \bra*{\phi}\ket*{\tall}$ & \\\hline \verb|\innerproduct| & $\verb|\braket{a}{b}| \rightarrow \braket{a}{b}$ & two-argument braket \\ & \verb|\braket{a}| $\rightarrow \braket{a}$ & one-argument (norm) \\ & \verb|\braket{a}{\tall}| $\rightarrow \braket{a}{\tall}$ & automatic sizing \\ & \verb|\braket*{a}{\tall}| $\rightarrow \braket*{a}{\tall}$ & no resize \\ & \verb|\ip{a}{b}| $\rightarrow \ip{a}{b}$ & shorthand name \\\hline \verb|\outerproduct| & \verb|\dyad{a}{b}| $\rightarrow \dyad{a}{b}$ & two-argument dyad \\ & \verb|\dyad{a}| $\rightarrow \dyad{a}$ & one-argument (projector) \\ & \verb|\dyad{a}{\tall}| $\rightarrow \dyad{a}{\tall}$ & automatic sizing \\ & \verb|\dyad*{a}{\tall}| $\rightarrow \dyad*{a}{\tall}$ & no resize \\ & \verb|\ketbra{a}{b}| $\rightarrow \ketbra{a}{b}$ & alternative name \\ & \verb|\op{a}{b}| $\rightarrow \op{a}{b}$ & shorthand name \\\hline \verb|\expectationvalue| & \verb|\expval{A}| $\rightarrow \expval{A}$ & implicit form \\ & \verb|\expval{A}{\Psi}| $\rightarrow \expval{A}{\Psi}$ & explicit form \\ & \verb|\ev{A}{\Psi}| $\rightarrow \ev{A}{\Psi}$ & shorthand name \\ & \verb|\ev{\grande}{\Psi}| $\rightarrow \ev{\grande}{\Psi}$ & default sizing ignores middle argument \\ & \verb|\ev*{\grande}{\tall}| $\rightarrow \ev*{\grande}{\tall}$ & single star does no resizing whatsoever \\ & \verb|\ev**{\grande}{\Psi}| $\rightarrow \ev**{\grande}{\Psi}$ & double star resizes based on all parts \\\hline \verb|\matrixelement| & \verb|\matrixel{n}{A}{m}| $\rightarrow \matrixel{n}{A}{m}$ & requires all three arguments \\ & \verb|\mel{n}{A}{m}| $\rightarrow \mel{n}{A}{m}$ & shorthand name \\ & \verb|\mel{n}{\grande}{m}| $\rightarrow \mel{n}{\grande}{m}$ & default sizing ignores middle argument \\ & \verb|\mel*{n}{\grande}{\tall}| $\rightarrow \mel*{n}{\grande}{\tall}$ & single star does no resizing whatsoever \\ & \verb|\mel**{n}{\grande}{m}| $\rightarrow \mel**{n}{\grande}{m}$ & double star resizes based on all parts \\\hline \end{longtable} \subsection{Matrix macros} Note: \verb|\mqty| and \verb|\smqty| in \texttt{physics} uses \verb|\mathord|, while \verb|\PTmqty| and \verb|\PTsmqty| in \texttt{physics-patch} don't. The following matrix macros produce unformatted rows and columns of matrix elements for use as separate matrices as well as blocks within larger matrices. For example, the command \verb|\identitymatrix{2}| which has also has the shortcut \verb|\imat{2}| produces the elements of a $2 \times 2$ identity matrix $\PTsmqty{\imat{2}}$ without braces or grouping. This allows the command to also be used within another matrix, as in:\\ \begin{minipage}{3cm} \begin{lstlisting}[language=TeX] \begin{pmatrix} \imat{2} \\ a & b \end{pmatrix} \end{lstlisting} \end{minipage} \begin{minipage}{6cm} \begin{displaymath} \Rightarrow\qquad \begin{pmatrix} \imat{2} \\ a & b \end{pmatrix} \end{displaymath} \end{minipage} To specify elements on the right of left sides of our \verb|\imat{2}| sub-matrix we use the grouping command \verb|\PTmatrixquantity| or \verb|\PTmqty| to effectively convert \verb|\imat{2}| into a single matrix element of a larger matrix:\\ \begin{minipage}{9cm} \begin{lstlisting}[language=TeX] \begin{pmatrix} \PTmqty{\imat{2}} & \PTmqty{a\\b} \\ \PTmqty{c & d} & e \end{pmatrix} \end{lstlisting} \end{minipage} \begin{minipage}{6cm} \begin{displaymath} \Rightarrow\qquad \begin{pmatrix} \PTmqty{\imat{2}} & \PTmqty{a\\b} \\ \PTmqty{c & d} & e \end{pmatrix} \end{displaymath} \end{minipage} The extra \verb|\PTmqty| groups were required in this case in order to get the $a$ and $b$ elements to behave as a single element, since \verb|\PTmqty{\imat{2}}| also acts like a single matrix element (the same can be said of the grouped $c$ and $d$ elements). Finally, the outermost \texttt{pmatrix} environment could have also been replaced with the \texttt{physics-patch} macro \verb|\PTmqty()|, allowing the above example to be written on one line:\\ \begin{minipage}{9cm} \begin{lstlisting}[language=TeX] \PTmqty(\PTmqty{\imat{2}} & \PTmqty{a\\b} \\ \PTmqty{c & d} & e) \end{lstlisting} \end{minipage} \begin{minipage}{6cm} \begin{displaymath} \Rightarrow\qquad \PTmqty(\PTmqty{\imat{2}} & \PTmqty{a\\b} \\ \PTmqty{c & d} & e) \end{displaymath} \end{minipage} {\fontsize{8pt}{12pt}\selectfont\\ \begin{longtable}[c]{ | C{6cm} | C{6cm} | C{6cm} | } \hline \verb|\PTmatrixquantity| & \verb|\PTmqty{a & b \\ c & d}| $\rightarrow \PTmqty{a & b \\ c & d}$ & groups a set of matrix elements into a single object \\ & \verb|\PTmqty(a & b \\ c & d)| $\rightarrow {\PTmqty(a & b \\ c & d)}$ & parentheses \\ & \verb|\PTmqty*(a & b \\ c & d)| $\rightarrow {\PTmqty*(a & b \\ c & d)}$ & alternate parentheses \\ & \verb|\PTmqty[a & b \\ c & d]| $\rightarrow {\PTmqty[a & b \\ c & d]}$ & square brackets \\ & \verb|\PTmqty| \texttt{|} \verb|a & b \\ c & d| \texttt{|} $\rightarrow {\PTmqty|a & b \\ c & d|}$ & vertical bars \\ & \verb|\omqty{}| $\leftrightarrow$ \verb|\PTmqty{}| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\ & \verb|\pmqty{}| $\leftrightarrow$ \verb|\PTmqty()| & \\ & \verb|\PTpmqty{}| $\leftrightarrow$ \verb|\PTmqty()| & \\ & \verb|\PTpmqty*{}| $\leftrightarrow$ \verb|\PTmqty*{}| & \\ & \verb|\Pmqty{}| $\leftrightarrow$ \verb|\PTmqty*()| & \\ & \verb|\bmqty{}| $\leftrightarrow$ \verb|\PTmqty[]| & \\ & \verb|\vmqty{}| $\leftrightarrow$ \verb+\PTmqty||+ & \\\hline \verb|\PTsmallmatrixquantity| & \verb|\PTsmqty{a & b \\ c & d}| $\rightarrow \PTsmqty{a & b \\ c & d}$ & the \texttt{smallmatrix} form of \verb|\PTmqty| \\ & \verb|\PTsmqty()| \qor \verb|\spmqty{}| \qor \verb|\PTspmqty{}| & small version of \verb|\PTmqty()| \\ & \verb|\PTsmqty*()| \qor \verb|\sPmqty{}| \qor \verb|\PTspmqty*{}| & small version of \verb|\PTmqty*()|\\ & \verb|\PTsmqty[]| \qor \verb|\sbmqty{}| & small version of \verb|\PTmqty[]| \\ & \verb+\PTsmqty||+ \qor \verb|\svmqty{}| & small version of \verb+\PTmqty||+ \\\hline \verb|\matrixdeterminant| & \verb|\mdet{a & b \\ c & d}| $\rightarrow {\mdet{a & b \\ c & d}}$ & matrix determinant \\ & \verb|\smdet{a & b \\ c & d}| $\rightarrow {\smdet{a & b \\ c & d}}$ & small matrix determinant \\\hline \verb|\identitymatrix| & \verb|\imat{n}| & elements of $n \times n$ identity matrix \\ & \verb|\PTmqty(\imat{3})| $\rightarrow \PTmqty(\imat{3})$ & formatted with \verb|\PTmqty| or \verb|\PTsmqty| \\\hline \verb|\PTxmatrix| & \verb|\PTxmat{x}{n}{m}| & \multirow{4}{*}{\parbox{6cm}{elements of $n \times m$ matrix filled with $x$, if not provided, $1$ is used}} \\ & \verb|\PTmqty(\PTxmat{x}{3}{3})| $\rightarrow \PTmqty(\PTxmat{x}{3}{3})$ & \\ & \verb|\PTmqty(\PTxmat{x}{}{3})| $\rightarrow \PTmqty(\PTxmat{x}{}{3})$ & \\ & \verb|\PTmqty(\PTxmat{x}{3}{})| $\rightarrow \PTmqty(\PTxmat{x}{3}{})$ & \\ & \verb|\PTxmat*{x}{n}{m}| & \multirow{4}{*}{\parbox{6cm}{star for element indices, skip row/column indices $n=1$/$m=1$}} \\ & \verb|\PTmqty(\PTxmat*{x}{3}{3})| $\rightarrow \PTmqty(\PTxmat*{x}{3}{3})$ & \\ & \verb|\PTmqty(\PTxmat*{x}{1}{3})| $\rightarrow \PTmqty(\PTxmat*{x}{1}{3})$ & \\ & \verb|\PTmqty(\PTxmat*{x}{3}{1})| $\rightarrow \PTmqty(\PTxmat*{x}{3}{1})$ & \\ & \verb|\PTxmat{x}{n}{m}[p]| & \multirow{4}{*}{\parbox{6cm}{only show $p$ rows (including \texttt{\textbackslash vdots} row) with skipped rows indicated by \texttt{\textbackslash vdots}. If $n$ isn't provided, $p$ is used}} \\ & \verb|\PTmqty(\PTxmat{x}{5}{3}[3])| $\rightarrow \PTmqty(\PTxmat{x}{5}{3}[3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{3}{3}[3])| $\rightarrow \PTmqty(\PTxmat{x}{3}{3}[3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{}{3}[3])| $\rightarrow \PTmqty(\PTxmat{x}{}{3}[3])$ & \\ & \verb|\PTxmat{x}{n}{m}[p][q]| & \multirow{6}{*}{\parbox{6cm}{only show $p$ rows (including \texttt{\textbackslash vdots} row) and $q$ columns (including \texttt{\textbackslash ldots} column) with skipped rows indicated by \texttt{\textbackslash vdots}, skipped columns indicated by \texttt{\textbackslash ldots}, intersection of \texttt{\textbackslash vdots} row and \texttt{\textbackslash ldots} column being \texttt{\textbackslash ddots}. If $n$/$m$ isn't provided, $p$/$q$ is used. No indices will be added for ellipses even if star is given}} \\ & \verb|\PTmqty(\PTxmat{x}{5}{5}[3][3])| $\rightarrow \PTmqty(\PTxmat{x}{5}{5}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{5}{3}[3][3])| $\rightarrow \PTmqty(\PTxmat{x}{5}{3}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{3}{3}[3][3])| $\rightarrow \PTmqty(\PTxmat{x}{3}{3}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{5}{}[3][3])| $\rightarrow \PTmqty(\PTxmat{x}{5}{}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat{x}{}{}[3][3])| $\rightarrow \PTmqty(\PTxmat{x}{}{}[3][3])$ & \\ & \verb|\PTxmat*{x}{n}{m}{g}| & \multirow{3}{*}{\parbox{6cm}{customize last row's element indices to $g$}} \\ & \verb|\PTmqty(\PTxmat*{x}{3}{3}{A})| $\rightarrow \PTmqty(\PTxmat*{x}{3}{3}{A})$ & \\ & \verb|\PTmqty(\PTxmat*{x}{5}{5}[3][3]{A})| $\rightarrow \PTmqty(\PTxmat*{x}{5}{5}[3][3]{A})$ & \\ & \verb|\PTxmat*{x}{n}{m}{g}{h}| & \multirow{3}{*}{\parbox{6cm}{customize last row's element indices to $g$ and last column's element indices to $h$}} \\ & \verb|\PTmqty(\PTxmat*{x}{3}{3}{A}{B})| $\rightarrow \PTmqty(\PTxmat*{x}{3}{3}{A}{B})$ & \\ & \verb|\PTmqty(\PTxmat*{x}{5}{5}[3][3]{A}{B})| $\rightarrow \PTmqty(\PTxmat*{x}{5}{5}[3][3]{A}{B})$ & \\ & \verb|\PTxmat[0 or 1 or 2]{x}{n}{m}[p][q]| & \multirow{4}{*}{\parbox{6cm}{Change the \texttt{\textbackslash vdots} row/\texttt{\textbackslash ldots} column from the second last one to last one, 0 for both, 1 for row only, 2 for column only. Only work when corresponding $p$/$q$ is provided and do not change the behavior of element indices}} \\ & \verb|\PTmqty(\PTxmat[0]{x}{5}{5}[3][3])| $\rightarrow \PTmqty(\PTxmat[0]{x}{5}{5}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat[1]{x}{5}{5}[3][3])| $\rightarrow \PTmqty(\PTxmat[1]{x}{5}{5}[3][3])$ & \\ & \verb|\PTmqty(\PTxmat[2]{x}{5}{5}[3][3])| $\rightarrow \PTmqty(\PTxmat[2]{x}{5}{5}[3][3])$ & \\\hline \verb|\zeromatrix| & \verb|\zmat{n}{m}| & \multirow{3}{*}{\parbox{6cm}{$n \times m$ matrix filled with zeros, equivalent to \texttt{\textbackslash xmat\{0\}\{n\}\{m\}}. If $m$ isn't provided, $n$ is used}} \\ & \verb|\PTmqty(\zmat{2}{2})| $\rightarrow \PTmqty(\zmat{2}{2})$ & \\ & \verb|\PTmqty(\zmat{2})| $\rightarrow \PTmqty(\zmat{2})$ & \\\hline \verb|\paulimatrix| & \verb|\pmat{n}| & $n^\text{th}$ Pauli matrix \\ & \verb|\PTmqty(\pmat{0})| $\rightarrow \PTmqty(\pmat{0})$ & $n\in \lbrace 0,1,2,3$ or $x,y,z \rbrace$ \\ & \verb|\PTmqty(\pmat{1})| $\rightarrow \PTmqty(\pmat{1})$ & \\ & \verb|\PTmqty(\pmat{2})| $\rightarrow \PTmqty(\pmat{2})$ & \\ & \verb|\PTmqty(\pmat{3})| $\rightarrow \PTmqty(\pmat{3})$ & \\\hline \verb|\diagonalmatrix| & \verb|\dmat{a,b,c,...}| & \multirow{2}{*}{\parbox{6cm}{specify up to eight diagonal or block diagonal elements}} \\ & \verb|\PTmqty(\dmat{1,2,3})| $\rightarrow \PTmqty(\dmat{1,2,3})$ & \\ & \verb|\PTmqty(\dmat[0]{1,2})| $\rightarrow \PTmqty(\dmat[0]{1,2})$ & optional argument to fill spaces \\ & \verb|\PTmqty(\dmat{1,2&3\\4&5})| $\rightarrow \PTmqty(\dmat{1,2&3\\4&5})$ & enter matrix elements for each block as a single diagonal element \\\hline \verb|\antidiagonalmatrix| & \verb|\admat{a,b,c,...}| & same as syntax as \verb|\dmat| \\ & \verb|\PTmqty(\admat{1,2,3})| $\rightarrow \PTmqty(\admat{1,2,3})$ & \\\hline \end{longtable} } \subsection{Symbols} \begin{longtable}[c]{ | C{6cm} | C{6cm} | } \hline \verb|\lparen| $\rightarrow\; ($ &\\\hline \verb|\rparen| $\rightarrow\; )$ &\\\hline \verb|\ordersymbol| $\rightarrow \ordersymbol$ & \\\hline \verb|\typical| $\rightarrow \typical$ & \\\hline \verb|\tall| $\rightarrow \tall$ & \\\hline \verb|\grande| $\rightarrow \grande$ & \\\hline \verb|\venti| $\rightarrow \venti$ & \\\hline \verb|\parallelsum| $\rightarrow \parallelsum$ & \\\hline \verb|\calE|$\rightarrow$\verb|\mathcal{E}| & \\\hline \verb|\bbR|$\rightarrow$\verb|\mathbb{R}| & \\\hline \verb|\bbC|$\rightarrow$\verb|\mathbb{C}| & \\\hline \verb|\bbQ|$\rightarrow$\verb|\mathbb{Q}| & \\\hline \verb|\bbN|$\rightarrow$\verb|\mathbb{N}| & \\\hline \verb|\bbZ|$\rightarrow$\verb|\mathbb{Z}| & \\\hline \verb|\bell|$\rightarrow$\verb|\boldsymbol{\ell}| & \\\hline \verb|\Bell|$\rightarrow$\verb|\char"1F514| & the \verb|\bell| command in wasysym, which is a bell symbol \\\hline \verb|\Vtextvisiblespace[width]| $\rightarrow$ \Vtextvisiblespace & \parbox{6cm}{a visible space character, where the optional argument, defaulting to \texttt{.3em}, sets the width of the horizontal rule}\\\hline \end{longtable} \subsection{Arrows and lines} Note that only \verb|\equiv| and \verb|\eqv| work in both math mode and text mode; others are for math mode only. \begin{longtable}[c]{|p{0.4\textwidth}|p{0.4\textwidth}|} \hline \verb|\Leftrightarrow| or \verb|\Lra| & $\Leftrightarrow$ \\\hline \verb|\leftrightarrow| or \verb|\lra| & $\leftrightarrow$ \\\hline \verb|\Rightarrow| or \verb|\Ra| & $\Rightarrow$ \\\hline \verb|\rightarrow| or \verb|\ra| & $\rightarrow$ \\\hline \verb|\Leftarrow| or \verb|\La| & $\Leftarrow$ \\\hline \verb|\leftarrow| or \verb|\la| & $\leftarrow$ \\\hline \verb|\Uparrow| or \verb|\Upa| & $\Uparrow$ \\\hline \verb|\uparrow| or \verb|\upa| & $\uparrow$ \\\hline \verb|\Downarrow| or \verb|\Dna| & $\Downarrow$ \\\hline \verb|\downarrow| or \verb|\dna| & $\downarrow$ \\\hline \verb|\rightleftharpoons| or \verb|\rlh| & $\rightleftharpoons$ \\\hline \verb|\leftrightharpoons| or \verb|\lrh| & $\leftrightharpoons$ \\\hline \verb|\rightharpoonup| or \verb|\rhu| & $\rightharpoonup$ \\\hline \verb|\leftharpoonup| or \verb|\lhu| & $\leftharpoonup$ \\\hline \verb|\rightharpoondown| or \verb|\rhd| & $\rightharpoondown$ \\\hline \verb|\leftharpoondown| or \verb|\lhd| & $\leftharpoondown$ \\\hline \verb|\upharpoonright| or \verb|\uhr| & $\upharpoonright$ \\\hline \verb|\upharpoonleft| or \verb|\uhl| & $\upharpoonleft$ \\\hline \verb|\downharpoonright| or \verb|\dhr| & $\downharpoonright$ \\\hline \verb|\downharpoonleft| or \verb|\dhl| & $\downharpoonleft$ \\\hline \verb|\hookrightarrow| or \verb|\hkra| & $\hookrightarrow$ \\\hline \verb|\hookleftarrow| or \verb|\hkla| & $\hookleftarrow$ \\\hline \verb|\mapsto| or \verb|\mpto| & $\mapsto$ \\\hline \verb|\mapsfrom| or \verb|\mpfr| & $\mapsfrom$ \\\hline \verb|\equiv| or \verb|\eqv| & $\equiv$ \\\hline \verb|\stackrel{\mathrm{def}}{=}| or \verb|\defeq| & $\defeq$ \\\hline \end{longtable} \subsection{Shorthands for Greek alphabet} If the corresponding options are used, the following shorthands will be defined for every uppercase and lowercase Greek letter. Note that these don’t ensure those commands are defined. Take Alpha for example. \begin{longtable}[c]{|p{0.3\textwidth}|p{0.2\textwidth}|p{0.3\textwidth}|} \hline Command & Option & Note\\\hline \verb|\tgAlpha| $\rightarrow$ \verb|\text{\textAlpha}}| & shorttextgreek & accept an optional argument argument in \texttt{\{\}} that is simply skipped \\\hline \verb|\vAlpha| $\rightarrow$ \verb|\varAlpha| & shortvargreek & \\\hline \verb|\uAlpha| $\rightarrow$ \verb|\upAlpha| & shortupgreek & \\\hline \verb|\uvAlpha| $\rightarrow$ \verb|\upvarAlpha| & shortupvargreek & \\\hline \verb|\bAlpha| $\rightarrow$ \verb|\boldsymbol{\Alpha}| & shortboldgreek & \\\hline \end{longtable} \subsection{Shorthands for mathrm alphabet and chemical element symbols} If option \texttt{shortmathrm} is used, the following shorthands will be defined for every uppercase and lowercase English letter and every chemical element symbols. Take A for example. \begin{longtable}[c]{ | C{6cm} | C{6cm} | } \hline \verb|\rmA_a^b| $\rightarrow\mathrm{A}_a^b$ & work in both math mode and text mode \\\hline \end{longtable} which are implemented with: \begin{lstlisting}[language=TeX] \DeclareDocumentCommand{\rmA}{e{_^}}{\ensuremath{\mathrm{A}\IfValueTF{#1}{_{#1}}{}\IfValueTF{#2}{^{#2}}{}}} \end{lstlisting} \subsection{Shorthands for textnormal alphabet} If option \texttt{shorttext} is used, the following shorthands will be defined for every uppercase and lowercase English letter. Take A for example. \begin{longtable}[c]{| l |} \hline \verb|\txA| $\rightarrow$ \verb|\textnormal{A}| \\\hline \end{longtable} \end{document}