summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/physics
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/physics
Initial commit
Diffstat (limited to 'macros/latex/contrib/physics')
-rw-r--r--macros/latex/contrib/physics/README25
-rw-r--r--macros/latex/contrib/physics/physics.pdfbin0 -> 249731 bytes
-rw-r--r--macros/latex/contrib/physics/physics.sty764
-rw-r--r--macros/latex/contrib/physics/physics.tex382
4 files changed, 1171 insertions, 0 deletions
diff --git a/macros/latex/contrib/physics/README b/macros/latex/contrib/physics/README
new file mode 100644
index 0000000000..a4a44bcdb7
--- /dev/null
+++ b/macros/latex/contrib/physics/README
@@ -0,0 +1,25 @@
+README for physics.sty
+
+physics 1.3
+Created by Sergio C. de la Barrera
+Updated December 12, 2012
+
+E-mail comments and suggestions to: physics.tex@gmail.com
+
+This material is subject to the LaTeX Project Public License.
+See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for
+the details of that license.
+
+This packages defines simple, yet flexible macros for typesetting equations via:
+*Automatic bracing
+*Vector notation
+*Derivatives
+*Dirac bra-ket notation
+*Matrix macros
+*Additional trig functions and other convenient operators
+*Flat fractions and other useful miscellaneous math macros
+
+The goal of this package is to make typesetting equations for physics simpler,
+faster, and more human-readable. To that end, the commands included in this package
+have names that make the purpose of each command immediately obvious and remove any
+ambiguity while reading and editing code for physics equations. \ No newline at end of file
diff --git a/macros/latex/contrib/physics/physics.pdf b/macros/latex/contrib/physics/physics.pdf
new file mode 100644
index 0000000000..132aeaa78a
--- /dev/null
+++ b/macros/latex/contrib/physics/physics.pdf
Binary files differ
diff --git a/macros/latex/contrib/physics/physics.sty b/macros/latex/contrib/physics/physics.sty
new file mode 100644
index 0000000000..2eafc4940e
--- /dev/null
+++ b/macros/latex/contrib/physics/physics.sty
@@ -0,0 +1,764 @@
+\ProvidesPackage{physics}
+% physics 1.3
+% This material is subject to the LaTeX Project Public License.
+% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license.
+%
+% Handy commands for physicists including macros for vectors, calculus, matrices, and bra-ket (Dirac) notation
+% Requires xparse package, which comes bundled with l3packages and l3kernel
+% This package loads amsmath, which comes standard with most latex distributions
+% The commands defined in this package will silently overwrite previous commands with the same name, if such commands exist
+%
+% Created by Sergio C. de la Barrera
+% Updated on December 12, 2012
+% Uploaded on December 20, 2012
+
+\RequirePackage{xparse}
+\RequirePackage{amsmath}
+
+% Options
+\DeclareOption{trig}{\let\trigopt = 1}
+\DeclareOption{notrig}{\let\trigopt = 0}
+\DeclareOption{uprightdiff}{\def\diffd{\mathrm{d}}} % Upright differentials
+\DeclareOption{italicdiff}{\def\diffd{d}} % Italic differentials
+\DeclareOption{bolddel}{\DeclareDocumentCommand\vnabla{}{\boldsymbol\nabla}} % Vector bold \nabla symbol
+\DeclareOption{arrowdel}{\DeclareDocumentCommand\vnabla{}{\vec{\boldsymbol\nabla}}} % Vector arrow \nabla symbol
+\ExecuteOptions{trig,uprightdiff,bolddel}
+\ProcessOptions\relax
+
+% Symbols
+\ProvideDocumentCommand\varE{}{\mathcal{E}} % Curly 'E'
+\ProvideDocumentCommand\ordersymbol{}{\mathcal{O}} % Order symbol --> O(x^2)
+\ProvideDocumentCommand\lparen{}{(} % Left parenthesis
+\ProvideDocumentCommand\rparen{}{)} % Right parenthesis
+
+% Brackets and braces
+\DeclareDocumentCommand\quantity{}{{\ifnum\z@=`}\fi\@quantity}
+\DeclareDocumentCommand\@quantity{ t\big t\Big t\bigg t\Bigg g o d() d|| }
+{ % Flexible automatic bracketing of an expression in () or [] or {} or ||
+ % Handles manual override of sizing
+ \IfBooleanTF{#1}{\let\ltag\bigl \let\rtag\bigr}{
+ \IfBooleanTF{#2}{\let\ltag\Bigl \let\rtag\Bigr}{
+ \IfBooleanTF{#3}{\let\ltag\biggl \let\rtag\biggr}{
+ \IfBooleanTF{#4}
+ {\let\ltag\Biggl \let\rtag\Biggr}
+ {\let\ltag\left \let\rtag\right}
+ }
+ }
+ }
+ % Handles actual bracketing
+ \IfNoValueTF{#5}{
+ \IfNoValueTF{#6}{
+ \IfNoValueTF{#7}{
+ \IfNoValueTF{#8}
+ {()}
+ {\ltag\lvert{#8}\rtag\rvert}
+ }
+ {\ltag(#7\rtag) \IfNoValueTF{#8}{}{|#8|}}
+ }
+ {\ltag[#6\rtag] \IfNoValueTF{#7}{}{(#7)} \IfNoValueTF{#8}{}{|#8|}}
+ }
+ {\ltag\lbrace#5\rtag\rbrace \IfNoValueTF{#6}{}{[#6]} \IfNoValueTF{#7}{}{(#7)} \IfNoValueTF{#8}{}{|#8|}}
+ \ifnum\z@=`{\fi}
+}
+\DeclareDocumentCommand\qty{}{\quantity} % Shorthand for \quantity
+\DeclareDocumentCommand\pqty{ l m }{\braces#1{\lparen}{\rparen}{#2}}
+\DeclareDocumentCommand\bqty{ l m }{\braces#1{\lbrack}{\rbrack}{#2}}
+\DeclareDocumentCommand\Bqty{ l m }{\braces#1{\lbrace}{\rbrace}{#2}}
+\DeclareDocumentCommand\vqty{ l m }{\braces#1{\lvert}{\rvert}{#2}}
+
+
+\DeclareDocumentCommand\pmqty{m}{\begin{pmatrix}#1\end{pmatrix}}
+\DeclareDocumentCommand\Pmqty{m}{\left\lgroup\begin{matrix}#1\end{matrix}\right\rgroup}
+\DeclareDocumentCommand\bmqty{m}{\begin{bmatrix}#1\end{bmatrix}}
+\DeclareDocumentCommand\vmqty{m}{\begin{vmatrix}#1\end{vmatrix}}
+\DeclareDocumentCommand\matrixquantity{}{{\ifnum\z@=`}\fi\@matrixquantity}
+\DeclareDocumentCommand\@matrixquantity{ s g o d() d|| }
+{
+ \mathord{
+ \IfNoValueTF{#2}
+ {
+ \IfNoValueTF{#3}
+ {
+ \IfNoValueTF{#4}
+ {
+ \IfNoValueTF{#5}
+ {()}
+ {\vmqty{#5}}
+ }
+ {
+ \IfBooleanTF{#1}
+ {\Pmqty{#4}}
+ {\pmqty{#4}}
+ \IfNoValueTF{#5}{}{|#5|}
+ }
+ }
+ {\bmqty{#3} \IfNoValueTF{#4}{}{(#4)} \IfNoValueTF{#5}{}{|#5|}}
+ }
+ {\begin{matrix}#2\end{matrix} \IfNoValueTF{#3}{}{[#3]} \IfNoValueTF{#4}{}{(#4)} \IfNoValueTF{#5}{}{|#5|}}
+ }
+ \ifnum\z@=`{\fi}
+}
+\DeclareDocumentCommand\mqty{}{\matrixquantity} % Shorthand for \matrixquantity
+\DeclareDocumentCommand\matrixdeterminant{m}{\vmqty{#1}} % Matrix determinant
+\DeclareDocumentCommand\mdet{}{\matrixdeterminant} % Shorthand for matrix determinant
+
+\DeclareDocumentCommand\spmqty{m}{\pqty{\begin{smallmatrix}#1\end{smallmatrix}}}
+\DeclareDocumentCommand\sPmqty{m}{\left\lgroup\begin{smallmatrix}#1\end{smallmatrix}\right\rgroup}
+\DeclareDocumentCommand\sbmqty{m}{\bqty{\begin{smallmatrix}#1\end{smallmatrix}}}
+\DeclareDocumentCommand\svmqty{m}{\vqty{\begin{smallmatrix}#1\end{smallmatrix}}}
+\DeclareDocumentCommand\smallmatrixquantity{ s g o d() d|| }
+{
+ \mathord{
+ \IfNoValueTF{#2}
+ {
+ \IfNoValueTF{#3}
+ {
+ \IfNoValueTF{#4}
+ {
+ \IfNoValueTF{#5}
+ {()}
+ {\svmqty{#5}}
+ }
+ {
+ \IfBooleanTF{#1}
+ {\sPmqty{#4}}
+ {\spmqty{#4}}
+ \IfNoValueTF{#5}{}{|#5|}
+ }
+ }
+ {\sbmqty{#3} \IfNoValueTF{#4}{}{(#4)} \IfNoValueTF{#5}{}{|#5|}}
+ }
+ {\begin{smallmatrix}#2\end{smallmatrix} \IfNoValueTF{#3}{}{[#3]} \IfNoValueTF{#4}{}{(#4)} \IfNoValueTF{#5}{}{|#5|}}
+ }
+}
+\DeclareDocumentCommand\smqty{}{\smallmatrixquantity} % Shorthand for \smallmatrixquantity
+\DeclareDocumentCommand\smallmatrixdeterminant{m}{\svmqty{#1}} % Small matrix determinant
+\DeclareDocumentCommand\smdet{}{\smallmatrixdeterminant} % Shorthand for small matrix determinant
+
+\DeclareDocumentCommand\argopen{s}{\IfBooleanTF{#1}{\mathopen{}\mathclose\bgroup}{\mathopen{}\mathclose\bgroup\left}} % Special open grouping for argument of a function
+\DeclareDocumentCommand\argclose{s}{\IfBooleanTF{#1}{\egroup}{\aftergroup\egroup\right}} % Special close grouping for argument of a function
+
+\DeclareDocumentCommand\braces{}{{\ifnum\z@=`}\fi\@braces}
+\DeclareDocumentCommand\@braces{ s t\big t\Big t\bigg t\Bigg m m m }
+{ % General braces with automatic and manual sizing
+ \IfBooleanTF{#1}
+ {\left#6\smash{#8}\right#7\vphantom{#8}}
+ {
+ \IfBooleanTF{#2}{\bigl#6{#8}\bigr#7}{
+ \IfBooleanTF{#3}{\Bigl#6{#8}\Bigr#7}{
+ \IfBooleanTF{#4}{\biggl#6{#8}\biggr#7}{
+ \IfBooleanTF{#5}{\Biggl#6{#8}\Biggr#7}{\left#6{#8}\right#7}
+ }
+ }
+ }
+ }
+ \ifnum\z@=`{\fi}
+}
+
+\DeclareDocumentCommand\fbraces{ s t\big t\Big t\bigg t\Bigg m m m m }
+{ % Function braces with automatic and manual sizing
+ #8
+ \IfBooleanTF{#1}
+ {\argopen#6\smash{#9}\argclose#7\vphantom{#9}}
+ {
+ \IfBooleanTF{#2}{\argopen*\bigl#6{#9}\argclose*\bigr#7}{
+ \IfBooleanTF{#3}{\argopen*\Bigl#6{#9}\argclose*\Bigr#7}{
+ \IfBooleanTF{#4}{\argopen*\biggl#6{#9}\argclose*\biggr#7}{
+ \IfBooleanTF{#5}
+ {\argopen*\Biggl#6{#9}\argclose*\Biggr#7}
+ {\argopen#6{#9}\argclose#7}
+ }
+ }
+ }
+ }
+}
+
+\DeclareDocumentCommand\absolutevalue{ l m }{\braces#1{\lvert}{\rvert}{#2}} % Absolute value/complex modulus
+\DeclareDocumentCommand\abs{}{\absolutevalue} % Shorthand for \absolutevalue
+\DeclareDocumentCommand\norm{ l m }{\braces#1{\lVert}{\rVert}{#2}} % Norm
+\DeclareDocumentCommand\order{ l m }{\fbraces#1{\lparen}{\rparen}{\ordersymbol}{#2}} % Order notation -> O(x^2)
+
+\DeclareDocumentCommand\evaluated{ s g d[| d(| }
+{ % Vertical evaluation bar
+ \IfNoValueTF{#2}
+ {
+ \IfNoValueTF{#3}
+ {
+ \IfNoValueTF{#4}
+ {\argopen.\vphantom{\int}\argclose\rvert}
+ {\IfBooleanTF{#1}{\vphantom{#4}}{}\left(\IfBooleanTF{#1}{\smash{#4}}{#4}\vphantom{\int}\right\rvert}
+ }
+ {\IfBooleanTF{#1}{\vphantom{#3}}{}\left[\IfBooleanTF{#1}{\smash{#3}}{#3}\vphantom{\int}\right\rvert \IfNoValueTF{#4}{}{(#4|}}
+ }
+ {\IfBooleanTF{#1}{\vphantom{#2}}{}\left.\IfBooleanTF{#1}{\smash{#2}}{#2}\vphantom{\int}\right\rvert \IfNoValueTF{#3}{}{[#3|} \IfNoValueTF{#4}{}{(#4|}}
+}
+\DeclareDocumentCommand\eval{}{\evaluated} % Shorthand for evaluated
+
+\DeclareDocumentCommand\poissonbracket{ l m m }{\braces#1{\lbrace}{\rbrace}{#2,#3}} % Poisson bracket [same as anti-commutator]
+\DeclareDocumentCommand\pb{}{\poissonbracket} % Shorthand for \poissonbracket
+
+% Commutators
+\DeclareDocumentCommand\commutator{ l m m }{\braces#1{\lbrack}{\rbrack}{#2,#3}} % Commutator
+\DeclareDocumentCommand\comm{}{\commutator} % Shorthand for \commutator
+\DeclareDocumentCommand\anticommutator{ l m m }{\braces#1{\lbrace}{\rbrace}{#2,#3}} % Anticommutator [same as Poisson bracket]
+\DeclareDocumentCommand\acommutator{}{\anticommutator} % Shorthand for \anticommutator
+\DeclareDocumentCommand\acomm{}{\anticommutator} % Shorthand for \anticommutator
+
+% Vector notation
+\DeclareDocumentCommand\vectorbold{ s m }{\IfBooleanTF{#1}{\boldsymbol{#2}}{\mathbf{#2}}} % Vector bold [star for Greek and italic Roman]
+\DeclareDocumentCommand\vb{}{\vectorbold} % Shorthand for \vectorbold
+
+\DeclareDocumentCommand\vectorarrow{ s m }{\IfBooleanTF{#1}{\vec{\boldsymbol{#2}}}{\vec{\mathbf{#2}}}} % Vector arrow + bold [star for Greek and italic Roman]
+\DeclareDocumentCommand\va{}{\vectorarrow} % Shorthand for \vectorarrow
+
+\DeclareDocumentCommand\vectorunit{ s m }{\IfBooleanTF{#1}{\boldsymbol{\hat{#2}}}{\mathbf{\hat{#2}}}} % Unit vector [star for Greek and italic Roman]
+\DeclareDocumentCommand\vu{}{\vectorunit} % Shorthand for \vectorunit
+
+\DeclareDocumentCommand\dotproduct{}{\boldsymbol\cdot} % Vector dot product symbol
+\DeclareDocumentCommand\vdot{}{\dotproduct} % Shorthand for \dotproduct [note that the command sequence \dp is protected]
+
+\DeclareDocumentCommand\crossproduct{}{\boldsymbol\times} % Vector cross product symbol
+\DeclareDocumentCommand\cross{}{\crossproduct} % Shorthand for \crossproduct
+\DeclareDocumentCommand\cp{}{\crossproduct} % Shorthand for \crossproduct
+
+\DeclareDocumentCommand\gradient{ g o d() }{ % Gradient
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}{\vnabla}{\fbraces{\lparen}{\rparen}{\vnabla}{#3}}
+ }
+ {\fbraces{\lbrack}{\rbrack}{\vnabla}{#2} \IfNoValueTF{#3}{}{(#3)}}
+ }
+ {\vnabla #1 \IfNoValueTF{#2}{}{[#2]} \IfNoValueTF{#3}{}{(#3)}}
+ }
+\DeclareDocumentCommand\grad{}{\gradient} % Shorthand for \gradient
+
+\DeclareDocumentCommand\divergence{ g o d() }{ % Divergence
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}{\vnabla \vdot}{\vnabla \vdot \quantity(#3)}
+ }
+ {\vnabla \vdot \quantity[#2] \IfNoValueTF{#3}{}{(#3)}}
+ }
+ {\vnabla \vdot #1 \IfNoValueTF{#2}{}{[#2]} \IfNoValueTF{#3}{}{(#3)}}
+ }
+\let\divisionsymbol\div % Rename \div [division symbol] in order to free up control sequence for \divergence
+\let\div\relax
+\DeclareDocumentCommand\div{}{\divergence} % Shorthand for \divergence
+
+\DeclareDocumentCommand\curl{ g o d() }{ % Curl
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}{\vnabla \cross}{\vnabla \cross \quantity(#3)}
+ }
+ {\vnabla \cross \quantity[#2] \IfNoValueTF{#3}{}{(#3)}}
+ }
+ {\vnabla \cross #1 \IfNoValueTF{#2}{}{[#2]} \IfNoValueTF{#3}{}{(#3)}}
+ }
+
+\DeclareDocumentCommand\laplacian{ g o d() }{ % Laplacian
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}{\nabla^2}{\fbraces{\lparen}{\rparen}{\nabla^2}{#3}}
+ }
+ {\fbraces{\lbrack}{\rbrack}{\nabla^2}{#2} \IfNoValueTF{#3}{}{(#3)}}
+ }
+ {\nabla^2 #1 \IfNoValueTF{#2}{}{[#2]} \IfNoValueTF{#3}{}{(#3)}}
+ }
+
+% Operators
+\DeclareMathOperator{\trace}{tr} % Trace of a matrix
+\DeclareMathOperator{\Trace}{Tr} % Trace of a matrix (alternate)
+\DeclareMathOperator{\rank}{rank} % Rank of a matrix
+\DeclareMathOperator{\erf}{erf} % Gauss error function
+\DeclareMathOperator{\Residue}{Res} % Residue
+\DeclareDocumentCommand\principalvalue{g}{\IfNoValueTF{#1}{\mathcal{P}}{\mathcal{P}\mathord{#1}}}
+\DeclareDocumentCommand\pv{}{\principalvalue}
+\DeclareDocumentCommand\PV{g}{\IfNoValueTF{#1}{\mathrm{P.V.}}{\mathrm{P.V.}\mathord{#1}}}
+\let\real\Re \DeclareDocumentCommand\Re{g}{\IfNoValueTF{#1}{\operatorname{Re}}{\fbraces{\lbrace}{\rbrace}{\operatorname{Re}}{#1}}}
+\let\imaginary\Im \DeclareDocumentCommand\Im{g}{\IfNoValueTF{#1}{\operatorname{Im}}{\fbraces{\lbrace}{\rbrace}{\operatorname{Im}}{#1}}}
+\DeclareDocumentCommand\opbraces{ m g o d() }
+{
+ \IfNoValueTF{#2}
+ {
+ \IfNoValueTF{#3}
+ {
+ \IfNoValueTF{#4}
+ {#1}
+ {\fbraces{\lparen}{\rparen}{#1}{#4}}
+ }
+ {
+ \fbraces{\lbrack}{\rbrack}{#1}{#3}
+ \IfNoValueTF{#4}{}{(#4)}
+ }
+ }
+ {
+ \fbraces{\lbrace}{\rbrace}{#1}{#2}
+ \IfNoValueTF{#3}{}{[#3]}
+ \IfNoValueTF{#4}{}{(#4)}
+ }
+}
+\DeclareDocumentCommand\trigbraces{ m o d() }
+{
+ \IfNoValueTF{#3}
+ {#1 \IfNoValueTF{#2}{}{[#2]}}
+ {#1 \IfNoValueTF{#2}{}{^{#2}} \argopen(#3\argclose)}
+}
+
+% Trig function and operator redefinitions
+\ifx\trigopt 1
+ \let\sine\sin \DeclareDocumentCommand\sin{}{\trigbraces{\sine}}
+ \let\cosine\cos \DeclareDocumentCommand\cos{}{\trigbraces{\cosine}}
+ \let\tangent\tan \DeclareDocumentCommand\tan{}{\trigbraces{\tangent}}
+ \let\cosecant\csc \DeclareDocumentCommand\csc{}{\trigbraces{\cosecant}}
+ \let\secant\sec \DeclareDocumentCommand\sec{}{\trigbraces{\secant}}
+ \let\cotangent\cot \DeclareDocumentCommand\cot{}{\trigbraces{\cotangent}}
+
+ \let\arcsine\arcsin \DeclareDocumentCommand\arcsin{}{\trigbraces{\arcsine}}
+ \let\arccosine\arccos \DeclareDocumentCommand\arccos{}{\trigbraces{\arccosine}}
+ \let\arctangent\arctan \DeclareDocumentCommand\arctan{}{\trigbraces{\arctangent}}
+ \DeclareMathOperator{\arccosecant}{arccsc}
+ \DeclareDocumentCommand\arccsc{}{\trigbraces{\arccosecant}}
+ \DeclareMathOperator{\arcsecant}{arcsec}
+ \DeclareDocumentCommand\arcsec{}{\trigbraces{\arcsecant}}
+ \DeclareMathOperator{\arccotangent}{arccot}
+ \DeclareDocumentCommand\arccot{}{\trigbraces{\arccotangent}}
+
+ \DeclareMathOperator{\asine}{asin}
+ \DeclareDocumentCommand\asin{}{\trigbraces{\asine}}
+ \DeclareMathOperator{\acosine}{acos}
+ \DeclareDocumentCommand\acos{}{\trigbraces{\acosine}}
+ \DeclareMathOperator{\atangent}{atan}
+ \DeclareDocumentCommand\atan{}{\trigbraces{\atangent}}
+ \DeclareMathOperator{\acosecant}{acsc}
+ \DeclareDocumentCommand\acsc{}{\trigbraces{\acosecant}}
+ \DeclareMathOperator{\asecant}{asec}
+ \DeclareDocumentCommand\asec{}{\trigbraces{\asecant}}
+ \DeclareMathOperator{\acotangent}{acot}
+ \DeclareDocumentCommand\acot{}{\trigbraces{\acotangent}}
+
+ \let\hypsine\sinh \DeclareDocumentCommand\sinh{}{\trigbraces{\hypsine}}
+ \let\hypcosine\cosh \DeclareDocumentCommand\cosh{}{\trigbraces{\hypcosine}}
+ \let\hyptangent\tanh \DeclareDocumentCommand\tanh{}{\trigbraces{\hyptangent}}
+ \DeclareMathOperator{\hypcosecant}{csch}
+ \DeclareDocumentCommand\csch{}{\trigbraces{\hypcosecant}}
+ \DeclareMathOperator{\hypsecant}{sech}
+ \DeclareDocumentCommand\sech{}{\trigbraces{\hypsecant}}
+ \let\hypcotangent\coth \DeclareDocumentCommand\coth{}{\trigbraces{\hypcotangent}}
+
+ \let\exponential\exp \DeclareDocumentCommand\exp{}{\opbraces{\exponential}}
+ \let\logarithm\log \DeclareDocumentCommand\log{}{\trigbraces{\logarithm}}
+ \let\naturallogarithm\ln \DeclareDocumentCommand\ln{}{\trigbraces{\naturallogarithm}}
+ \let\determinant\det \DeclareDocumentCommand\det{}{\opbraces{\determinant}}
+ \let\Probability\Pr \DeclareDocumentCommand\Pr{}{\opbraces{\Probability}}
+ \DeclareDocumentCommand\tr{}{\opbraces{\trace}}
+ \DeclareDocumentCommand\Tr{}{\opbraces{\Trace}}
+ \DeclareDocumentCommand\Res{}{\opbraces{\Residue}}
+\else
+ \DeclareMathOperator{\arccsc}{arccsc}
+ \DeclareMathOperator{\arcsec}{arcsec}
+ \DeclareMathOperator{\arccot}{arccot}
+
+ \DeclareMathOperator{\asin}{asin}
+ \DeclareMathOperator{\acos}{acos}
+ \DeclareMathOperator{\atan}{atan}
+ \DeclareMathOperator{\acsc}{acsc}
+ \DeclareMathOperator{\asec}{asec}
+ \DeclareMathOperator{\acot}{acot}
+
+ \DeclareMathOperator{\csch}{csch}
+ \DeclareMathOperator{\sech}{sech}
+
+ \DeclareDocumentCommand\tr{}{\trace}
+ \DeclareDocumentCommand\Tr{}{\Trace}
+ \DeclareDocumentCommand\Res{}{\Residue}
+\fi
+
+% Quick quad text (math-mode text with \quad spacing)
+\DeclareDocumentCommand\qqtext{ s m }{\IfBooleanTF{#1}{}{\quad}\text{#2}\quad}
+\DeclareDocumentCommand\qq{}{\qqtext}
+
+\DeclareDocumentCommand\qcomma{}{,\quad}
+\DeclareDocumentCommand\qc{}{\qcomma}
+
+\DeclareDocumentCommand\qif{s}{\IfBooleanTF{#1}{}{\quad}\text{if}\quad}
+\DeclareDocumentCommand\qthen{s}{\IfBooleanTF{#1}{}{\quad}\text{then}\quad}
+\DeclareDocumentCommand\qelse{s}{\IfBooleanTF{#1}{}{\quad}\text{else}\quad}
+\DeclareDocumentCommand\qotherwise{s}{\IfBooleanTF{#1}{}{\quad}\text{otherwise}\quad}
+\DeclareDocumentCommand\qunless{s}{\IfBooleanTF{#1}{}{\quad}\text{unless}\quad}
+\DeclareDocumentCommand\qgiven{s}{\IfBooleanTF{#1}{}{\quad}\text{given}\quad}
+\DeclareDocumentCommand\qusing{s}{\IfBooleanTF{#1}{}{\quad}\text{using}\quad}
+\DeclareDocumentCommand\qassume{s}{\IfBooleanTF{#1}{}{\quad}\text{assume}\quad}
+\DeclareDocumentCommand\qsince{s}{\IfBooleanTF{#1}{}{\quad}\text{since}\quad}
+\DeclareDocumentCommand\qlet{s}{\IfBooleanTF{#1}{}{\quad}\text{let}\quad}
+\DeclareDocumentCommand\qfor{s}{\IfBooleanTF{#1}{}{\quad}\text{for}\quad}
+\DeclareDocumentCommand\qall{s}{\IfBooleanTF{#1}{}{\quad}\text{all}\quad}
+\DeclareDocumentCommand\qeven{s}{\IfBooleanTF{#1}{}{\quad}\text{even}\quad}
+\DeclareDocumentCommand\qodd{s}{\IfBooleanTF{#1}{}{\quad}\text{odd}\quad}
+\DeclareDocumentCommand\qinteger{s}{\IfBooleanTF{#1}{}{\quad}\text{integer}\quad}
+\DeclareDocumentCommand\qand{s}{\IfBooleanTF{#1}{}{\quad}\text{and}\quad}
+\DeclareDocumentCommand\qor{s}{\IfBooleanTF{#1}{}{\quad}\text{or}\quad}
+\DeclareDocumentCommand\qas{s}{\IfBooleanTF{#1}{}{\quad}\text{as}\quad}
+\DeclareDocumentCommand\qin{s}{\IfBooleanTF{#1}{}{\quad}\text{in}\quad}
+\DeclareDocumentCommand\qcc{s}{\IfBooleanTF{#1}{}{\quad}\text{c.c.}\quad}
+
+% Derivatives
+\DeclareDocumentCommand\differential{ o g d() }{ % Differential 'd'
+ % o: optional n for nth differential
+ % g: optional argument for readability and to control spacing
+ % d: long-form as in d(cos x)
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}
+ {\diffd\IfNoValueTF{#1}{}{^{#1}}}
+ {\mathinner{\diffd\IfNoValueTF{#1}{}{^{#1}}\argopen(#3\argclose)}}
+ }
+ {\mathinner{\diffd\IfNoValueTF{#1}{}{^{#1}}#2} \IfNoValueTF{#3}{}{(#3)}}
+ }
+\DeclareDocumentCommand\dd{}{\differential} % Shorthand for \differential
+
+\DeclareDocumentCommand\derivative{ s o m g d() }
+{ % Total derivative
+ % s: star for \flatfrac flat derivative
+ % o: optional n for nth derivative
+ % m: mandatory (x in df/dx)
+ % g: optional (f in df/dx)
+ % d: long-form d/dx(...)
+ \IfBooleanTF{#1}
+ {\let\fractype\flatfrac}
+ {\let\fractype\frac}
+ \IfNoValueTF{#4}
+ {
+ \IfNoValueTF{#5}
+ {\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}}}
+ {\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#5\argclose)}
+ }
+ {\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}} #3}{\diffd #4\IfNoValueTF{#2}{}{^{#2}}}}
+}
+\DeclareDocumentCommand\dv{}{\derivative} % Shorthand for \derivative
+
+\DeclareDocumentCommand\partialderivative{ s o m g g d() }
+{ % Partial derivative
+ % s: star for \flatfrac flat derivative
+ % o: optional n for nth derivative
+ % m: mandatory (x in df/dx)
+ % g: optional (f in df/dx)
+ % g: optional (y in d^2f/dxdy)
+ % d: long-form d/dx(...)
+ \IfBooleanTF{#1}
+ {\let\fractype\flatfrac}
+ {\let\fractype\frac}
+ \IfNoValueTF{#4}
+ {
+ \IfNoValueTF{#6}
+ {\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}}}
+ {\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#6\argclose)}
+ }
+ {
+ \IfNoValueTF{#5}
+ {\fractype{\partial \IfNoValueTF{#2}{}{^{#2}} #3}{\partial #4\IfNoValueTF{#2}{}{^{#2}}}}
+ {\fractype{\partial^2 #3}{\partial #4 \partial #5}}
+ }
+}
+\DeclareDocumentCommand\pderivative{}{\partialderivative} % Shorthand for \partialderivative
+\DeclareDocumentCommand\pdv{}{\partialderivative} % Shorthand for \partialderivative
+
+\DeclareDocumentCommand\variation{ o g d() }{ % Functional variation
+ % o: optional n for nth differential
+ % g: optional argument for readability and to control spacing
+ % d: long-form as in d(F(g))
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}
+ {\delta \IfNoValueTF{#1}{}{^{#1}}}
+ {\mathinner{\delta \IfNoValueTF{#1}{}{^{#1}}\argopen(#3\argclose)}}
+ }
+ {\mathinner{\delta \IfNoValueTF{#1}{}{^{#1}}#2} \IfNoValueTF{#3}{}{(#3)}}
+ }
+\DeclareDocumentCommand\var{}{\variation} % Shorthand for \variation
+
+\DeclareDocumentCommand\functionalderivative{ s o m g d() }
+{ % Functional derivative
+ % s: star for \flatfrac flat derivative
+ % o: optional n for nth derivative
+ % m: mandatory (g in dF/dg)
+ % g: optional (F in dF/dg)
+ % d: long-form d/dx(...)
+ \IfBooleanTF{#1}
+ {\let\fractype\flatfrac}
+ {\let\fractype\frac}
+ \IfNoValueTF{#4}
+ {
+ \IfNoValueTF{#5}
+ {\fractype{\variation \IfNoValueTF{#2}{}{^{#2}}}{\variation #3\IfNoValueTF{#2}{}{^{#2}}}}
+ {\fractype{\variation \IfNoValueTF{#2}{}{^{#2}}}{\variation #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#5\argclose)}
+ }
+ {\fractype{\variation \IfNoValueTF{#2}{}{^{#2}} #3}{\variation #4\IfNoValueTF{#2}{}{^{#2}}}}
+}
+\DeclareDocumentCommand\fderivative{}{\functionalderivative} % Shorthand for \functionalderivative
+\DeclareDocumentCommand\fdv{}{\functionalderivative} % Shorthand for \functionalderivative
+
+% Bra-ket notation
+\DeclareDocumentCommand\bra{ s m t\ket s g }
+{ % Bra
+ \IfBooleanTF{#3}
+ { % Contraction
+ \IfBooleanTF{#1}
+ { % Bra has a star: no resize
+ \IfNoValueTF{#5}
+ {\braket*{#2}{} \IfBooleanTF{#4}{*}{}}
+ {\braket*{#2}{#5}}
+ }
+ {
+ \IfBooleanTF{#4}
+ { % Ket has a star: no resize
+ \IfNoValueTF{#5}
+ {\braket{#2}{} *}
+ {\braket*{#2}{#5}}
+ }
+ {\braket{#2}{\IfNoValueTF{#5}{}{#5}}} % Neither term is starred: auto sizing
+ }
+ }
+ { % No contraction
+ \IfBooleanTF{#1}
+ {\vphantom{#2}\left\langle\smash{#2}\right\rvert}
+ {\left\langle{#2}\right\rvert}
+ \IfBooleanTF{#4}{*}{}
+ \IfNoValueTF{#5}{}{#5}
+ }
+}
+
+\DeclareDocumentCommand\ket{ s m }
+{ % Ket
+ \IfBooleanTF{#1}
+ {\vphantom{#2}\left\lvert\smash{#2}\right\rangle} % No resize
+ {\left\lvert{#2}\right\rangle} % Auto sizing
+}
+
+\DeclareDocumentCommand\innerproduct{ s m g }
+{ % Inner product
+ \IfBooleanTF{#1}
+ { % No resize
+ \IfNoValueTF{#3}
+ {\vphantom{#2}\left\langle\smash{#2}\middle\vert\smash{#2}\right\rangle}
+ {\vphantom{#2#3}\left\langle\smash{#2}\middle\vert\smash{#3}\right\rangle}
+ }
+ { % Auto resize
+ \IfNoValueTF{#3}
+ {\left\langle{#2}\middle\vert{#2}\right\rangle}
+ {\left\langle{#2}\middle\vert{#3}\right\rangle}
+ }
+}
+\DeclareDocumentCommand\braket{}{\innerproduct} % Alternative for \innerproduct
+\DeclareDocumentCommand\ip{}{\innerproduct} % Shorthand for \innerproduct
+
+\DeclareDocumentCommand\outerproduct{ s m g }
+{ % Dyad
+ \IfBooleanTF{#1}
+ { % No resize
+ \IfNoValueTF{#3}
+ {\vphantom{#2}\left\lvert\smash{#2}\middle\rangle\!\middle\langle\smash{#2}\right\rvert}
+ {\vphantom{#2#3}\left\lvert\smash{#2}\middle\rangle\!\middle\langle\smash{#3}\right\rvert}
+ }
+ { % Auto resize
+ \IfNoValueTF{#3}
+ {\left\lvert{#2}\middle\rangle\!\middle\langle{#2}\right\rvert}
+ {\left\lvert{#2}\middle\rangle\!\middle\langle{#3}\right\rvert}
+ }
+}
+\DeclareDocumentCommand\dyad{}{\outerproduct} % Alternative for \outerproduct
+\DeclareDocumentCommand\op{}{\dyad} % Shorthand for \outerproduct
+\DeclareDocumentCommand\ketbra{}{\dyad} % Alternative for \outerproduct
+
+\DeclareDocumentCommand\expectationvalue{ s s m g }
+{ % Expectation value
+ \IfNoValueTF{#4}
+ {
+ \IfBooleanTF{#1}
+ {\vphantom{#3}\left\langle\smash{#3}\right\rangle} % Starred implicit form: no resizing
+ {\left\langle{#3}\right\rangle} % Normal implicit form: auto sizing
+ }
+ {
+ \IfBooleanTF{#1}
+ {
+ \IfBooleanTF{#2}
+ {\left\langle{#4}\middle\vert{#3}\middle\vert{#4}\right\rangle} % Double starred explicit form: total auto sizing
+ {\vphantom{#3#4}\left\langle\smash{#4}\middle\vert\smash{#3}\middle\vert\smash{#4}\right\rangle} % Starred explicit form: no resizing
+ }
+ {\vphantom{#3}\left\langle{#4}\middle\vert\smash{#3}\middle\vert{#4}\right\rangle} % Normal explicit form: only resize based on bra/ket arguments
+ }
+}
+\DeclareDocumentCommand\expval{}{\expectationvalue} % Shorthand for \expectationvalue
+\DeclareDocumentCommand\ev{}{\expectationvalue} % Shorthand for \expectationvalue
+\DeclareDocumentCommand\vev{ m }{\expectationvalue{#1}{0}} % Vacuum expectation value
+
+\DeclareDocumentCommand\matrixelement{ s s m m m }
+{ % Matrix element
+ \IfBooleanTF{#1}
+ {
+ \IfBooleanTF{#2}
+ {\left\langle{#3}\middle\vert{#4}\middle\vert{#5}\right\rangle} % Double starred: total resizing
+ {\vphantom{#3#4#5}\left\langle\smash{#3}\middle\vert\smash{#4}\middle\vert\smash{#5}\right\rangle} % Starred: no resizing
+ }
+ {\vphantom{#4}\left\langle{#3}\middle\vert\smash{#4}\middle\vert{#5}\right\rangle} % Normal: only resize based on bra/ket arguments
+}
+\DeclareDocumentCommand\matrixel{}{\matrixelement} % Shorthand for \matrixelement
+\DeclareDocumentCommand\mel{}{\matrixelement} % Shorthand for \matrixelement
+
+% Matrix macros
+\DeclareDocumentCommand\identitymatrix{m}
+{
+ {
+ \newtoks\matrixtoks
+ \global\matrixtoks = {}
+ \newcount\rowcount
+ \newcount\colcount
+ \loop
+ \colcount = 0
+ \advance \rowcount by 1
+ {
+ \loop
+ \advance \colcount by 1
+ \edef\addtoks
+ {
+ \ifnum \colcount = 1 \else & \fi
+ \ifnum \colcount = \rowcount 1 \else 0 \fi
+ }
+ \global\matrixtoks = \expandafter{\the\expandafter\matrixtoks\addtoks}
+ \ifnum \colcount < #1
+ \repeat
+ }
+ \ifnum \rowcount < #1
+ \global\matrixtoks = \expandafter{\the\matrixtoks \\ }
+ \repeat
+ }
+ \the\matrixtoks
+}
+\DeclareDocumentCommand\imat{}{\identitymatrix}
+
+\DeclareDocumentCommand\xmatrix{ s m m m }
+{
+ {
+ \newtoks\matrixtoks
+ \global\matrixtoks = {}
+ \newcount\rowcount
+ \newcount\colcount
+ \loop
+ \colcount = 0
+ \advance \rowcount by 1
+ {
+ \loop
+ \advance \colcount by 1
+ \edef\addtoks{\ifnum \colcount = 1 \else & \fi #2 \IfBooleanTF{#1}{_{\ifnum #3 > 1 \the\rowcount \fi \ifnum #4 > 1 \the\colcount \fi}}{}}
+ \global\matrixtoks = \expandafter{\the\expandafter\matrixtoks\addtoks}
+ \ifnum \colcount < #4
+ \repeat
+ }
+ \ifnum \rowcount < #3
+ \global\matrixtoks = \expandafter{\the\matrixtoks \\ }
+ \repeat
+ }
+ \the\matrixtoks
+}
+\DeclareDocumentCommand\xmat{}{\xmatrix}
+
+\DeclareDocumentCommand\zeromatrix{ m g }{\IfNoValueTF{#2}{\xmatrix{0}{#1}{#1}}{\xmatrix{0}{#1}{#2}}}
+\DeclareDocumentCommand\zmat{}{\zeromatrix}
+
+\DeclareDocumentCommand\paulixmatrix{}{0&1\\1&0}
+\DeclareDocumentCommand\pauliymatrix{}{0&-i\\i&0}
+\DeclareDocumentCommand\paulizmatrix{}{1&0\\0&-1}
+\DeclareDocumentCommand\paulimatrix{m}
+{
+ \let\argin=#1
+ \ifx\argin 0 \identitymatrix{2} \else
+ \ifx\argin 1 \paulixmatrix \else
+ \ifx\argin 2 \pauliymatrix \else
+ \ifx\argin 3 \paulizmatrix \else
+ \ifx\argin x \paulixmatrix \else
+ \ifx\argin y \pauliymatrix \else
+ \ifx\argin z \paulizmatrix \fi\fi\fi\fi\fi\fi\fi
+}
+\DeclareDocumentCommand\pmat{}{\paulimatrix}
+
+\DeclareDocumentCommand\diagonalmatrix{O{} >{\SplitList{,}}m }{\@dmat{#1}#2}
+\DeclareDocumentCommand\@dmat{mmggggggg}
+{
+ \newtoks\matrixtoks
+ \global\matrixtoks = {}
+ \IfNoValueTF{#3}
+ {#2}
+ {
+ \IfNoValueTF{#4}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1\\#1&\mqty{#3}}}
+ {
+ \IfNoValueTF{#5}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1\\#1&\mqty{#3}&#1\\#1&#1&\mqty{#4}}}
+ {
+ \IfNoValueTF{#6}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1&#1\\#1&\mqty{#3}&#1&#1\\#1&#1&\mqty{#4}&#1\\#1&#1&#1&\mqty{#5}}}
+ {
+ \IfNoValueTF{#7}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1&#1&#1\\#1&\mqty{#3}&#1&#1&#1\\#1&#1&\mqty{#4}&#1&#1\\#1&#1&#1&\mqty{#5}&#1\\#1&#1&#1&#1&\mqty{#6}}}
+ {
+ \IfNoValueTF{#8}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1&#1&#1&#1\\#1&\mqty{#3}&#1&#1&#1&#1\\#1&#1&\mqty{#4}&#1&#1&#1\\#1&#1&#1&\mqty{#5}&#1&#1\\#1&#1&#1&#1&\mqty{#6}&#1\\#1&#1&#1&#1&#1&\mqty{#7}}}
+ {
+ \IfNoValueTF{#9}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1&#1&#1&#1&#1\\#1&\mqty{#3}&#1&#1&#1&#1&#1\\#1&#1&\mqty{#4}&#1&#1&#1&#1\\#1&#1&#1&\mqty{#5}&#1&#1&#1\\#1&#1&#1&#1&\mqty{#6}&#1&#1\\#1&#1&#1&#1&#1&\mqty{#7}&#1\\#1&#1&#1&#1&#1&#1&\mqty{#8}}}
+ {\global\matrixtoks = \expandafter{\mqty{#2}&#1&#1&#1&#1&#1&#1&#1\\#1&\mqty{#3}&#1&#1&#1&#1&#1&#1\\#1&#1&\mqty{#4}&#1&#1&#1&#1&#1\\#1&#1&#1&\mqty{#5}&#1&#1&#1&#1\\#1&#1&#1&#1&\mqty{#6}&#1&#1&#1\\#1&#1&#1&#1&#1&\mqty{#7}&#1&#1\\#1&#1&#1&#1&#1&#1&\mqty{#8}&#1\\#1&#1&#1&#1&#1&#1&#1&\mqty{#9}}}
+ }
+ }
+ }
+ }
+ }
+ }
+ \the\matrixtoks
+}
+\DeclareDocumentCommand\dmat{}{\diagonalmatrix}
+
+\DeclareDocumentCommand\antidiagonalmatrix{O{} >{\SplitList{,}}m }{\@admat{#1}#2}
+\DeclareDocumentCommand\@admat{mmggggggg}
+{
+ \newtoks\matrixtoks
+ \global\matrixtoks = {}
+ \IfNoValueTF{#3}
+ {#2}
+ {
+ \IfNoValueTF{#4}
+ {\global\matrixtoks = \expandafter{#1&\mqty{#2}\\\mqty{#3}&#1}}
+ {
+ \IfNoValueTF{#5}
+ {\global\matrixtoks = \expandafter{#1&#1&\mqty{#2}\\#1&\mqty{#3}&#1\\\mqty{#4}&#1&#1}}
+ {
+ \IfNoValueTF{#6}
+ {\global\matrixtoks = \expandafter{#1&#1&#1&\mqty{#2}\\#1&#1&\mqty{#3}&#1\\#1&\mqty{#4}&#1&#1\\\mqty{#5}&#1&#1&#1}}
+ {
+ \IfNoValueTF{#7}
+ {\global\matrixtoks = \expandafter{#1&#1&#1&#1&\mqty{#2}\\#1&#1&#1&\mqty{#3}&#1\\#1&#1&\mqty{#4}&#1&#1\\#1&\mqty{#5}&#1&#1&#1\\\mqty{#6}&#1&#1&#1&#1}}
+ {
+ \IfNoValueTF{#8}
+ {\global\matrixtoks = \expandafter{#1&#1&#1&#1&#1&\mqty{#2}\\#1&#1&#1&#1&\mqty{#3}&#1\\#1&#1&#1&\mqty{#4}&#1&#1\\#1&#1&\mqty{#5}&#1&#1&#1\\#1&\mqty{#6}&#1&#1&#1&#1\\\mqty{#7}&#1&#1&#1&#1&#1}}
+ {
+ \IfNoValueTF{#9}
+ {\global\matrixtoks = \expandafter{#1&#1&#1&#1&#1&#1&\mqty{#2}\\#1&#1&#1&#1&#1&\mqty{#3}&#1\\#1&#1&#1&#1&\mqty{#4}&#1&#1\\#1&#1&#1&\mqty{#5}&#1&#1&#1\\#1&#1&\mqty{#6}&#1&#1&#1&#1\\#1&\mqty{#7}&#1&#1&#1&#1&#1\\\mqty{#8}&#1&#1&#1&#1&#1&#1}}
+ {\global\matrixtoks = \expandafter{#1&#1&#1&#1&#1&#1&#1&\mqty{#2}\\#1&#1&#1&#1&#1&#1&\mqty{#3}&#1\\#1&#1&#1&#1&#1&\mqty{#4}&#1&#1\\#1&#1&#1&#1&\mqty{#5}&#1&#1&#1\\#1&#1&#1&\mqty{#6}&#1&#1&#1&#1\\#1&#1&\mqty{#7}&#1&#1&#1&#1&#1\\#1&\mqty{#8}&#1&#1&#1&#1&#1&#1\\\mqty{#9}&#1&#1&#1&#1&#1&#1&#1}}
+ }
+ }
+ }
+ }
+ }
+ }
+ \the\matrixtoks
+}
+\DeclareDocumentCommand\admat{}{\antidiagonalmatrix}
+
+% Misc
+\DeclareDocumentCommand\flatfrac{ m m }{\left.#1\middle\slash#2\right.}
+\DeclareDocumentCommand\homework{}{ % You can try it
+ \ensuremath{
+ \div{\vb{E}}=\frac{\rho}{\epsilon_0} \qc
+ \div{\vb{B}}=0 \qc
+ \curl{\vb{E}}=-\pdv{\vb{B}}{t}\qc
+ \curl{\vb{B}}=\mu_0\vb{J}+\frac{1}{c^2}\pdv{\vb{E}}{t}\qc
+ H\ket{\Psi}=i\hbar\pdv{}{t}\ket{\Psi},
+ \qq{all else follows.}
+ }
+} \ No newline at end of file
diff --git a/macros/latex/contrib/physics/physics.tex b/macros/latex/contrib/physics/physics.tex
new file mode 100644
index 0000000000..34081efbc5
--- /dev/null
+++ b/macros/latex/contrib/physics/physics.tex
@@ -0,0 +1,382 @@
+\documentclass{article}
+\usepackage{fullpage}
+\usepackage{parskip}
+\usepackage{physics}
+\usepackage{amssymb}
+\usepackage{xcolor}
+\usepackage[colorlinks,urlcolor=blue]{hyperref}
+\usepackage{array}
+\usepackage{longtable}
+\usepackage{multirow}
+
+\newcolumntype{M}{>{$\displaystyle}c<{$}}
+\newcolumntype{L}{>{$\displaystyle}l<{$}}
+
+\newcommand\Vtextvisiblespace[1][.3em]
+{%
+ \mbox{\kern.06em\vrule height.3ex}%
+ \vbox{\hrule width#1}%
+ \hbox{\vrule height.3ex}
+}
+
+\newcommand{\cbox}[2][cyan]
+{\mathchoice
+ {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\displaystyle#2$}}
+ {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\textstyle#2$}}
+ {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\scriptstyle#2$}}
+ {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\scriptscriptstyle#2$}}
+}
+
+\newcommand{\typical}{\cbox{\phantom{A}}}
+\newcommand{\tall}{\cbox{\phantom{A^{\vphantom{x^x}}_x}}}
+\newcommand{\grande}{\cbox{\phantom{\frac{1}{xx}}}}
+\newcommand{\venti}{\cbox{\phantom{\sum_x^x}}}
+
+% physics 1.30
+\title{The \texttt{physics} package}
+\author{Sergio C. de la Barrera \\ \texttt{physics.tex@gmail.com}}
+
+\begin{document}
+\maketitle
+
+\tableofcontents
+
+\section{Before you start}
+\subsection{The purpose of this package}
+The goal of this package is to make typesetting equations for physics simpler, faster, and more human-readable. To that end, the commands included in this package have names that make the purpose of each command immediately obvious and remove any ambiguity while reading and editing \texttt{physics} code. From a practical standpoint, it is handy to have a well-defined set of shortcuts for accessing the long-form of each of these commands. The commands listed below are therefore defined in terms of their long-form names and then shown explicitly in terms of the default shorthand command sequences. These shorthand commands are meant make it easy to remember both the shorthand names and what each one represents.
+
+\subsection{Other required packages}
+The \texttt{physics} package requires \texttt{xparse} and \texttt{amsmath} to work properly in your \LaTeX~document. The \texttt{amsmath} package comes standard with most \LaTeX~distributions and is loaded by \texttt{physics} for your convenience. You may also already have \texttt{xparse} installed on your system as it is a popular package for defining \LaTeX macros, however, if you are unsure 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 you could even just try to use \texttt{physics} without worrying about it. Many modern \LaTeX compilers will locate and offer to download missing packages for you.
+\subsection{Using \texttt{physics} in your \LaTeX~document}
+To use the \texttt{physics} package, simply insert \verb|\usepackage{physics}| in the preamble of your document, before \verb|\begin{document}| and after \verb|\documentclass{class}|:
+\begin{verbatim}
+\documentclass{class}
+...
+\usepackage{physics}
+...
+\begin{document}
+ content...
+\end{document}
+\end{verbatim}
+
+\section{List of commands}
+\subsection{Automatic bracing}
+\begin{longtable}[l]{ l l p{6cm} }
+\verb|\quantity| & \verb|\qty(\typical)| $\displaystyle\rightarrow \qty(\typical)$ & automatic $\qty(\;)$ braces \\
+& \verb|\qty(\tall)| $\displaystyle\rightarrow \qty(\tall)$ & \\
+& \verb|\qty(\grande)| $\displaystyle\rightarrow \qty(\grande)$ & \\
+& \verb|\qty[\typical]| $\rightarrow \qty[\typical]$ & automatic $\qty[\;]$ braces \\
+& \verb+\qty|\typical|+ $\rightarrow \qty|\typical|$ & automatic $\qty|\;|$ braces \\
+& \verb|\qty{\typical}| $\rightarrow \qty{\typical}$ & automatic $\qty{\;}$ braces \\
+& \verb|\qty\big{}| $\rightarrow \qty\big{}$ & \multirow{2}{*}{\parbox{6cm}{manual sizing (works with any of the above bracket types)}} \\
+& \verb|\qty\Big{}| $\rightarrow \qty\Big{}$ & \\
+& \verb|\qty\bigg{}| $\rightarrow \qty\bigg{}$ & \\
+& \verb|\qty\Bigg{}| $\rightarrow \qty\Bigg{}$ & \\
+& \verb|\pqty{}| $\leftrightarrow$ \verb|\qty()| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\
+& \verb|\bqty{}| $\leftrightarrow$ \verb|\qty[]| & \\
+& \verb+\vqty{}+ $\leftrightarrow$ \verb+\qty||+ & \\
+& \verb|\Bqty{}| $\leftrightarrow$ \verb|\qty{}| & \\
+\verb|\absolutevalue| & \verb|\abs{a}| $\rightarrow \abs{a}$ & automatic sizing; equivalent to \verb|\qty| \!\!\texttt{|a|} \\
+& \verb|\abs\Big{a}| $\rightarrow \abs\Big{a}$ & inherits manual sizing syntax from \verb|\qty| \\
+& \verb|\abs*{\grande}| $\displaystyle\rightarrow \abs*{\grande}$ & star for no resize \\
+\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 \\
+\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 \\
+\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 \\
+\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 \\
+\verb|\anticommutator| & \verb|\acomm{A}{B}| $\rightarrow \acomm{A}{B}$ & same as \verb|\poissonbracket| \\
+%& \verb|\acommutator{A}{B}| $\rightarrow \acommutator{A}{B}$ & alternate name \\
+\verb|\poissonbracket| & \verb|\pb{A}{B}| $\rightarrow \pb{A}{B}$ & same as \verb|\anticommutator|
+\end{longtable}
+
+\subsection{Vector notation}
+The default del symbol $\vnabla$ used in \texttt{physics} vector notation can be switched to appear with an arrow $\vec{\vnabla}$ by including the option \texttt{arrowdel} in the document preamble $\rightarrow$ \verb|\usepackage[arrowdel]{physics}|.
+\begin{longtable}[l]{ l l p{6cm} }
+\verb|\vectorbold| & \verb|\vb{a}| $\rightarrow \vb{a}$ & upright/no Greek \\
+& \verb|\vb*{a}|, \verb|\vb*{\theta}| $\rightarrow \vb*{a}$, $\vb*{\theta}$ & italic/Greek \\
+\verb|\vectorarrow| & \verb|\va{a}| $\rightarrow \va{a}$ & upright/no Greek \\
+& \verb|\va*{a}|, \verb|\va*{\theta}| $\rightarrow \va*{a}$, $\va*{\theta}$ & italic/Greek \\
+\verb|\vectorunit| & \verb|\vu{a}| $\rightarrow \vu{a}$ & upright/no Greek \\
+& \verb|\vu*{a}|, \verb|\vu*{\theta}| $\rightarrow \vu*{a}$, $\vu*{\theta}$ & italic/Greek \\
+\verb|\dotproduct| & \verb|\vdot| $\rightarrow \vdot$ as in $\vb{a} \vdot \vb{b}$ & note: \verb|\dp| is a protected \TeX\ primitive \\
+\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 \\
+\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|\qty| but also handles spacing) \\
+& \verb|\grad[\Psi+\tall]| $\displaystyle\rightarrow \grad[\Psi+\tall]$ & \\
+\verb|\divergence| & \verb|\div| $\rightarrow \div$ & note: \texttt{amsmath} symbol $\divisionsymbol$ renamed \verb|\divisionsymbol| \\
+& \verb|\div{\vb{a}}| $\rightarrow \div{\vb{a}}$ & default mode \\
+& \verb|\div(\vb{a}+\tall)| $\displaystyle\rightarrow \div(\vb{a}+\tall)$ & long-form \\
+& \verb|\div[\vb{a}+\tall]| $\displaystyle\rightarrow \div[\vb{a}+\tall]$ & \\
+\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]$ & \\
+\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]$ &
+\end{longtable}
+
+\subsection{Operators}
+The standard set of trig functions is redefined in \texttt{physics} to provide automatic braces that behave like \verb|\qty()|. In addition, an optional power argument is provided. This behavior can be switched off by including the option \texttt{notrig} in the preamble $\rightarrow$ \verb|\usepackage[notrig]{physics}|.
+
+\begin{tabular}[l]{ l l p{8cm} }
+\multicolumn{3}{l}{Example trig redefinitions:} \\
+\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
+\end{tabular}
+
+The full set of available trig functions in \texttt{physics} includes:
+
+\begin{tabular}{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{tabular}$\Rightarrow$
+\begin{tabular}{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{tabular}
+
+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{tabular}{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{tabular}
+
+Similar behavior has also been extended to the following functions:
+
+\begin{tabular}{l>{$}l<{$}ll}
+\verb|\exp(\tall)| & \exp(\tall) & & \verb|\exponential| \\
+\verb|\log(\tall)| & \log(\tall) & & \verb|\logarithm| \\
+\verb|\ln(\tall)| & \ln(\tall) & old definitions $\Rightarrow$ & \verb|\naturallogarithm| \\
+\verb|\det(\tall)| & \det(\tall) & & \verb|\determinant| \\
+\verb|\Pr(\tall)| & \Pr(\tall) & & \verb|\Probability|
+\end{tabular}
+
+\begin{longtable}[l]{ l l p{8cm} }
+\multicolumn{3}{l}{New operators:} \\
+\verb|\trace| or \verb|\tr| & \verb|\tr\rho| $\rightarrow \tr\rho$ also \verb|\tr(\tall)| $\rightarrow \tr(\tall)$ & trace; same bracing as trig functions \\
+\verb|\Trace| or \verb|\Tr| & \verb|\Tr\rho| $\rightarrow \Tr\rho$ & alternate \\
+\verb|\rank| & \verb|\rank M| $\rightarrow \rank M$ & matrix rank \\
+\verb|\erf| & \verb|\erf(x)|$\rightarrow \erf(x)$ & Gauss error function \\
+\verb|\Res| & \verb|\Res[f(z)]|$\rightarrow \Res[f(z)]$ & residue; same bracing as trig functions \\
+\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 \\
+\verb|\Re| & \verb|\Re{z}| $\rightarrow \Re{z}$ & old \verb|\Re| renamed to \verb|\real| $\rightarrow \real$ \\
+\verb|\Im| & \verb|\Im{z}| $\rightarrow \Im{z}$ & old \verb|\Im| renamed to \verb|\imaginary| $\rightarrow \imaginary$
+\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{tabular}[l]{ l l p{6cm} }
+General text: & & \\
+\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
+\end{tabular}
+
+\begin{longtable}[l]{ l l }
+Special macros: & \\
+\verb|\qcomma| or \verb|\qc| $\rightarrow ,$\Vtextvisiblespace[1em] & right \verb|\quad| only \\
+\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] \\
+\verb|\qif| $\rightarrow$\Vtextvisiblespace[1em]$\text{if}$\Vtextvisiblespace[1em] & left and right \verb|\quad| unless starred \verb|\qif*| $\rightarrow \text{if}$\Vtextvisiblespace[1em]
+\end{longtable}
+\begin{longtable}[l]{ l }
+Similar to \verb|\qif|: \\
+\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|
+\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 $\rightarrow$ \verb|\usepackage[italicdiff]{physics}|.
+\begin{longtable}[l]{ l l p{6cm} }
+\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 \\
+\verb|\derivative| & \verb|\dv{x}| $\displaystyle\rightarrow \dv{x}$ & one argument \\
+& \verb|\dv{f}{x}| $\displaystyle\rightarrow \dv{f}{x}$ & two arguments \\
+& \verb|\dv[n]{f}{x}| $\displaystyle\rightarrow \dv[n]{f}{x}$ & optional power \\
+& \verb|\dv{x}(\grande)| $\displaystyle\rightarrow \dv{x}(\grande)$ & long-form; automatic braces, spacing \\
+& \verb|\dv*{f}{x}| $\displaystyle\rightarrow \dv*{f}{x}$ & inline form using \verb|\flatfrac| \\
+\verb|\partialderivative| & \verb|\pderivative{x}| $\displaystyle\rightarrow \pderivative{x}$ & alternate name \\
+& \verb|\pdv{x}| $\displaystyle\rightarrow \pdv{x}$ & shorthand name \\
+& \verb|\pdv{f}{x}| $\displaystyle\rightarrow \pdv{f}{x}$ & two arguments \\
+& \verb|\pdv[n]{f}{x}| $\displaystyle\rightarrow \pdv[n]{f}{x}$ & optional power \\
+& \verb|\pdv{x}(\grande)| $\displaystyle\rightarrow \pdv{x}(\grande)$ & long-form \\
+& \verb|\pdv{f}{x}{y}| $\displaystyle\rightarrow \pdv{f}{x}{y}$ & mixed partial \\
+& \verb|\pdv*{f}{x}| $\displaystyle\rightarrow \pdv*{f}{x}$ & inline form using \verb|\flatfrac| \\
+\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 \\
+\verb|\functionalderivative| & \verb|\fdv{g}| $\displaystyle\rightarrow \fdv{g}$ & functional derivative (works like \verb|\dv|) \\
+& \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|
+\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 specialized macros are both useful and descriptive from the perspective of generating \texttt{physics} code, however, 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 is 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}[l]{ l L p{6cm} }
+\verb|\ket| & \verb|\ket{\tall}| \rightarrow \ket{\tall} & automatic sizing \\
+& \verb|\ket*{\tall}| \rightarrow \ket*{\tall} & no resize \\
+\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} & \\
+\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 \\
+\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 \\
+\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 \\
+\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
+\end{longtable}
+
+\subsection{Matrix macros}
+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 $\smqty{\imat{2}}$ without braces or grouping. This allows the command to also be used within another matrix, as in:
+
+\begin{minipage}{3cm}
+\begin{verbatim}
+\begin{pmatrix}
+\imat{2} \\ a & b
+\end{pmatrix}
+\end{verbatim}
+\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|\matrixquantity| or \verb|\mqty| to effectively convert \verb|\imat{2}| into a single matrix element of a larger matrix:
+
+\begin{minipage}{9cm}
+\begin{verbatim}
+\begin{pmatrix}
+\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e
+\end{pmatrix}
+\end{verbatim}
+\end{minipage}
+\begin{minipage}{6cm}
+\begin{displaymath}
+\Rightarrow\qquad
+\begin{pmatrix}
+\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e
+\end{pmatrix}
+\end{displaymath}
+\end{minipage}
+
+The extra \verb|\mqty| groups were required in this case in order to get the $a$ and $b$ elements to behave as a single element, since \verb|\mqty{\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} macro \verb|\mqty()|, allowing the above example to be written on one line:
+
+\begin{minipage}{9cm}
+\begin{verbatim}
+\mqty(\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e)
+\end{verbatim}
+\end{minipage}
+\begin{minipage}{6cm}
+\begin{displaymath}
+\Rightarrow\qquad
+\mqty(\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e)
+\end{displaymath}
+\end{minipage}
+
+\begin{longtable}[l]{ l L p{6cm} }
+\verb|\matrixquantity| & \verb|\mqty{a & b \\ c & d}| \rightarrow \mqty{a & b \\ c & d} & groups a set of matrix elements into a single object \\
+& \verb|\mqty(a & b \\ c & d)| \rightarrow {\mqty(a & b \\ c & d)} & parentheses \\
+& \verb|\mqty*(a & b \\ c & d)| \rightarrow {\mqty*(a & b \\ c & d)} & alternate parentheses \\
+& \verb|\mqty[a & b \\ c & d]| \rightarrow {\mqty[a & b \\ c & d]} & square brackets \\
+& \verb|\mqty| \texttt{|} \verb|a & b \\ c & d| \texttt{|} \rightarrow {\mqty|a & b \\ c & d|} & vertical bars \\
+& \verb|\pmqty{}| \leftrightarrow \verb|\mqty()| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\
+& \verb|\Pmqty{}| \leftrightarrow \verb|\mqty*()| & \\
+& \verb|\bmqty{}| \leftrightarrow \verb|\mqty[]| & \\
+& \verb|\vmqty{}| \leftrightarrow \verb+\mqty||+ & \\
+\verb|\smallmatrixquantity| & \verb|\smqty{a & b \\ c & d}| \rightarrow \smqty{a & b \\ c & d} & the \texttt{smallmatrix} form of \verb|\mqty| \\
+& \verb|\smqty()| \qor \verb|\spmqty{}| & small version of \verb|\mqty()| \\
+& \verb|\smqty*()| \qor \verb|\sPmqty{}| & small version of \verb|\mqty*()|\\
+& \verb|\smqty[]| \qor \verb|\sbmqty{}| & small version of \verb|\mqty[]| \\
+& \verb+\smqty||+ \qor \verb|\svmqty{}| & small version of \verb+\mqty||+ \\
+\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 \\
+\verb|\identitymatrix| & \verb|\imat{n}| & elements of $n \times n$ identity matrix \\
+& \verb|\smqty(\imat{3})| \rightarrow \smqty(\imat{3}) & formatted with \verb|\mqty| or \verb|\smqty| \\
+\verb|\xmatrix| & \verb|\xmat{x}{n}{m}| & elements of $n \times m$ matrix filled with $x$ \\
+& \verb|\smqty(\xmat{1}{2}{3})| \rightarrow \smqty(\xmat{1}{2}{3}) & formatted with \verb|\mqty| or \verb|\smqty| \\
+& \verb|\smqty(\xmat*{a}{3}{3})| \rightarrow \smqty(\xmat*{a}{3}{3}) & star for element indices \\
+& \verb|\smqty(\xmat*{a}{3}{1})| \rightarrow \smqty(\xmat*{a}{3}{1}) & as a vector with indices \\
+& \verb|\smqty(\xmat*{a}{1}{3})| \rightarrow \smqty(\xmat*{a}{1}{3}) & \\
+\verb|\zeromatrix| & \verb|\zmat{n}{m}| & $n \times m$ matrix filled with zeros \\
+& \verb|\smqty(\zmat{2}{2})| \rightarrow \smqty(\zmat{2}{2}) & equivalent to \verb|\xmat{0}{n}{m}| \\
+\verb|\paulimatrix| & \verb|\pmat{n}| & $n^\text{th}$ Pauli matrix \\
+& \verb|\smqty(\pmat{0})| \rightarrow \smqty(\pmat{0}) & $n\in \lbrace 0,1,2,3$ or $x,y,z \rbrace$ \\
+& \verb|\smqty(\pmat{1})| \rightarrow \smqty(\pmat{1}) & \\
+& \verb|\smqty(\pmat{2})| \rightarrow \smqty(\pmat{2}) & \\
+& \verb|\smqty(\pmat{3})| \rightarrow \smqty(\pmat{3}) & \\
+\verb|\diagonalmatrix| & \verb|\dmat{a,b,c,...}| & \multirow{2}{*}{\parbox{6cm}{specify up to eight diagonal or block diagonal elements}} \\
+& \verb|\mqty(\dmat{1,2,3})| \rightarrow \mqty(\dmat{1,2,3}) & \\
+& \verb|\mqty(\dmat[0]{1,2})| \rightarrow \mqty(\dmat[0]{1,2}) & optional argument to fill spaces \\
+& \verb|\mqty(\dmat{1,2&3\\4&5})| \rightarrow \mqty(\dmat{1,2&3\\4&5}) & \parbox{6cm}{enter matrix elements for each block as a single diagonal element} \\
+\verb|\antidiagonalmatrix| & \verb|\admat{a,b,c,...}| & same as syntax as \verb|\dmat| \\
+& \verb|\mqty(\admat{1,2,3})| \rightarrow \mqty(\admat{1,2,3}) & \\
+\end{longtable}
+
+\end{document} \ No newline at end of file