Debian Codegraph @

texmf-dist/doc/latex/physics/physics.tex

raw
1 \documentclass{article}
2 \usepackage{fullpage}
3 \usepackage{parskip}
4 \usepackage{physics}
5 \usepackage{amssymb}
6 \usepackage{xcolor}
7 \usepackage[colorlinks,urlcolor=blue]{hyperref}
8 \usepackage{array}
9 \usepackage{longtable}
10 \usepackage{multirow}
11
12 \newcolumntype{M}{>{$\displaystyle}c<{$}}
13 \newcolumntype{L}{>{$\displaystyle}l<{$}}
14
15 \newcommand\Vtextvisiblespace[1][.3em]
16 {%
17 \mbox{\kern.06em\vrule height.3ex}%
18 \vbox{\hrule width#1}%
19 \hbox{\vrule height.3ex}
20 }
21
22 \newcommand{\cbox}[2][cyan]
23 {\mathchoice
24 {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\displaystyle#2$}}
25 {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\textstyle#2$}}
26 {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\scriptstyle#2$}}
27 {\setlength{\fboxsep}{0pt}\colorbox{#1}{$\scriptscriptstyle#2$}}
28 }
29
30 \newcommand{\typical}{\cbox{\phantom{A}}}
31 \newcommand{\tall}{\cbox{\phantom{A^{\vphantom{x^x}}_x}}}
32 \newcommand{\grande}{\cbox{\phantom{\frac{1}{xx}}}}
33 \newcommand{\venti}{\cbox{\phantom{\sum_x^x}}}
34
35 % physics 1.30
36 \title{The \texttt{physics} package}
37 \author{Sergio C. de la Barrera \\ \texttt{[email protected]}}
38
39 \begin{document}
40 \maketitle
41
42 \tableofcontents
43
44 \section{Before you start}
45 \subsection{The purpose of this package}
46 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.
47
48 \subsection{Other required packages}
49 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.
50 \subsection{Using \texttt{physics} in your \LaTeX~document}
51 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}|:
52 \begin{verbatim}
53 \documentclass{class}
54 ...
55 \usepackage{physics}
56 ...
57 \begin{document}
58 content...
59 \end{document}
60 \end{verbatim}
61
62 \section{List of commands}
63 \subsection{Automatic bracing}
64 \begin{longtable}[l]{ l l p{6cm} }
65 \verb|\quantity| & \verb|\qty(\typical)| $\displaystyle\rightarrow \qty(\typical)$ & automatic $\qty(\;)$ braces \\
66 & \verb|\qty(\tall)| $\displaystyle\rightarrow \qty(\tall)$ & \\
67 & \verb|\qty(\grande)| $\displaystyle\rightarrow \qty(\grande)$ & \\
68 & \verb|\qty[\typical]| $\rightarrow \qty[\typical]$ & automatic $\qty[\;]$ braces \\
69 & \verb+\qty|\typical|+ $\rightarrow \qty|\typical|$ & automatic $\qty|\;|$ braces \\
70 & \verb|\qty{\typical}| $\rightarrow \qty{\typical}$ & automatic $\qty{\;}$ braces \\
71 & \verb|\qty\big{}| $\rightarrow \qty\big{}$ & \multirow{2}{*}{\parbox{6cm}{manual sizing (works with any of the above bracket types)}} \\
72 & \verb|\qty\Big{}| $\rightarrow \qty\Big{}$ & \\
73 & \verb|\qty\bigg{}| $\rightarrow \qty\bigg{}$ & \\
74 & \verb|\qty\Bigg{}| $\rightarrow \qty\Bigg{}$ & \\
75 & \verb|\pqty{}| $\leftrightarrow$ \verb|\qty()| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\
76 & \verb|\bqty{}| $\leftrightarrow$ \verb|\qty[]| & \\
77 & \verb+\vqty{}+ $\leftrightarrow$ \verb+\qty||+ & \\
78 & \verb|\Bqty{}| $\leftrightarrow$ \verb|\qty{}| & \\
79 \verb|\absolutevalue| & \verb|\abs{a}| $\rightarrow \abs{a}$ & automatic sizing; equivalent to \verb|\qty| \!\!\texttt{|a|} \\
80 & \verb|\abs\Big{a}| $\rightarrow \abs\Big{a}$ & inherits manual sizing syntax from \verb|\qty| \\
81 & \verb|\abs*{\grande}| $\displaystyle\rightarrow \abs*{\grande}$ & star for no resize \\
82 \verb|\norm| & \verb|\norm{a}| $\rightarrow \norm{a}$ & automatic sizing \\
83 & \verb|\norm\Big{a}| $\rightarrow \norm\Big{a}$ & manual sizing \\
84 & \verb|\norm*{\grande}| $\displaystyle\rightarrow \norm*{\grande}$ & star for no resize \\
85 \verb|\evaluated| & \verb|\eval{x}_0^\infty| $\displaystyle\rightarrow \eval{x}_0^\infty$ & vertical bar for evaluation limits \\
86 & \verb|\eval(x| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval(x|_0^\infty$ & alternate form \\
87 & \verb|\eval[x| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval[x|_0^\infty$ & alternate form \\
88 & \verb|\eval[\venti| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval[\venti|_0^\infty$ & automatic sizing\\
89 & \verb|\eval*[\venti| \!\!\texttt{|}\!\! \verb|_0^\infty| $\displaystyle\rightarrow \eval*[\venti|_0^\infty$ & star for no resize \\
90 \verb|\order| & \verb|\order{x^2}| $\rightarrow \order{x^2}$ & order symbol; automatic sizing and space handling \\
91 & \verb|\order\Big{x^2}| $\rightarrow \order\Big{x^2}$ & manual sizing \\
92 & \verb|\order*{\grande}| $\displaystyle\rightarrow \order*{\grande}$ & star for no resize \\
93 \verb|\commutator| & \verb|\comm{A}{B}| $\rightarrow \comm{A}{B}$ & automatic sizing \\
94 & \verb|\comm\Big{A}{B}| $\rightarrow \comm\Big{A}{B}$ & manual sizing \\
95 & \verb|\comm*{A}{\grande}| $\displaystyle\rightarrow \comm*{A}{\grande}$ & star for no resize \\
96 \verb|\anticommutator| & \verb|\acomm{A}{B}| $\rightarrow \acomm{A}{B}$ & same as \verb|\poissonbracket| \\
97 %& \verb|\acommutator{A}{B}| $\rightarrow \acommutator{A}{B}$ & alternate name \\
98 \verb|\poissonbracket| & \verb|\pb{A}{B}| $\rightarrow \pb{A}{B}$ & same as \verb|\anticommutator|
99 \end{longtable}
100
101 \subsection{Vector notation}
102 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}|.
103 \begin{longtable}[l]{ l l p{6cm} }
104 \verb|\vectorbold| & \verb|\vb{a}| $\rightarrow \vb{a}$ & upright/no Greek \\
105 & \verb|\vb*{a}|, \verb|\vb*{\theta}| $\rightarrow \vb*{a}$, $\vb*{\theta}$ & italic/Greek \\
106 \verb|\vectorarrow| & \verb|\va{a}| $\rightarrow \va{a}$ & upright/no Greek \\
107 & \verb|\va*{a}|, \verb|\va*{\theta}| $\rightarrow \va*{a}$, $\va*{\theta}$ & italic/Greek \\
108 \verb|\vectorunit| & \verb|\vu{a}| $\rightarrow \vu{a}$ & upright/no Greek \\
109 & \verb|\vu*{a}|, \verb|\vu*{\theta}| $\rightarrow \vu*{a}$, $\vu*{\theta}$ & italic/Greek \\
110 \verb|\dotproduct| & \verb|\vdot| $\rightarrow \vdot$ as in $\vb{a} \vdot \vb{b}$ & note: \verb|\dp| is a protected \TeX\ primitive \\
111 \verb|\crossproduct| & \verb|\cross| $\rightarrow \cross$ as in $\vb{a} \cross \vb{b}$ & alternate name \\
112 & \verb|\cp| $\rightarrow \cp$ as in $\vb{a} \cp \vb{b}$ & shorthand name \\
113 \verb|\gradient| & \verb|\grad| $\rightarrow \grad$ & \\
114 & \verb|\grad{\Psi}| $\rightarrow \grad{\Psi}$ & default mode \\
115 & \verb|\grad(\Psi+\tall)| $\displaystyle\rightarrow \grad(\Psi+\tall)$ & long-form (like \verb|\qty| but also handles spacing) \\
116 & \verb|\grad[\Psi+\tall]| $\displaystyle\rightarrow \grad[\Psi+\tall]$ & \\
117 \verb|\divergence| & \verb|\div| $\rightarrow \div$ & note: \texttt{amsmath} symbol $\divisionsymbol$ renamed \verb|\divisionsymbol| \\
118 & \verb|\div{\vb{a}}| $\rightarrow \div{\vb{a}}$ & default mode \\
119 & \verb|\div(\vb{a}+\tall)| $\displaystyle\rightarrow \div(\vb{a}+\tall)$ & long-form \\
120 & \verb|\div[\vb{a}+\tall]| $\displaystyle\rightarrow \div[\vb{a}+\tall]$ & \\
121 \verb|\curl| & \verb|\curl| $\rightarrow \curl$ & \\
122 & \verb|\curl{\vb{a}}| $\rightarrow \curl{\vb{a}}$ & default mode \\
123 & \verb|\curl(\vb{a}+\tall)| $\displaystyle\rightarrow \curl(\vb{a}+\tall)$ & long-form \\
124 & \verb|\curl[\vb{a}+\tall]| $\displaystyle\rightarrow \curl[\vb{a}+\tall]$ & \\
125 \verb|\laplacian| & \verb|\laplacian| $\rightarrow \laplacian$ & \\
126 & \verb|\laplacian{\Psi}| $\rightarrow \laplacian{\Psi}$ & default mode \\
127 & \verb|\laplacian(\Psi+\tall)| $\displaystyle\rightarrow \laplacian(\Psi+\tall)$ & long-form \\
128 & \verb|\laplacian[\Psi+\tall]| $\displaystyle\rightarrow \laplacian[\Psi+\tall]$ &
129 \end{longtable}
130
131 \subsection{Operators}
132 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}|.
133
134 \begin{tabular}[l]{ l l p{8cm} }
135 \multicolumn{3}{l}{Example trig redefinitions:} \\
136 \verb|\sin| & \verb|\sin(\grande)| $\displaystyle\rightarrow \sin(\grande)$ & automatic braces; old \verb|\sin| renamed \verb|\sine| \\
137 & \verb|\sin[2](x)| $\rightarrow \sin[2](x)$ & optional power \\
138 & \verb|\sin x| $\rightarrow \sin x$ & can still use without an argument
139 \end{tabular}
140
141 The full set of available trig functions in \texttt{physics} includes:
142
143 \begin{tabular}{llll}
144 \verb|\sin(x)| & \verb|\sinh(x)| & \verb|\arcsin(x)| & \verb|\asin(x)| \\
145 \verb|\cos(x)| & \verb|\cosh(x)| & \verb|\arccos(x)| & \verb|\acos(x)| \\
146 \verb|\tan(x)| & \verb|\tanh(x)| & \verb|\arctan(x)| & \verb|\atan(x)| \\
147 \verb|\csc(x)| & \verb|\csch(x)| & \verb|\arccsc(x)| & \verb|\acsc(x)| \\
148 \verb|\sec(x)| & \verb|\sech(x)| & \verb|\arcsec(x)| & \verb|\asec(x)| \\
149 \verb|\cot(x)| & \verb|\coth(x)| & \verb|\arccot(x)| & \verb|\acot(x)|
150 \end{tabular}$\Rightarrow$
151 \begin{tabular}{MMMM}
152 \sin(x) & \sinh(x) & \arcsin(x) & \asin(x) \\
153 \cos(x) & \cosh(x) & \arccos(x) & \acos(x) \\
154 \tan(x) & \tanh(x) & \arctan(x) & \atan(x) \\
155 \csc(x) & \csch(x) & \arccsc(x) & \acsc(x) \\
156 \sec(x) & \sech(x) & \arcsec(x) & \asec(x) \\
157 \cot(x) & \coth(x) & \arccot(x) & \acot(x)
158 \end{tabular}
159
160 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:
161
162 \begin{tabular}{llll}
163 \verb|\sine| & \verb|\hypsine| & \verb|\arcsine| & \verb|\asine| \\
164 \verb|\cosine| & \verb|\hypcosine| & \verb|\arccosine| & \verb|\acosine| \\
165 \verb|\tangent| & \verb|\hyptangent| & \verb|\arctangent| & \verb|\atangent| \\
166 \verb|\cosecant| & \verb|\hypcosecant| & \verb|\arccosecant| & \verb|\acosecant| \\
167 \verb|\secant| & \verb|\hypsecant| & \verb|\arcsecant| & \verb|\asecant| \\
168 \verb|\cotangent| & \verb|\hypcotangent| & \verb|\arccotangent| & \verb|\acotangent|
169 \end{tabular}
170
171 Similar behavior has also been extended to the following functions:
172
173 \begin{tabular}{l>{$}l<{$}ll}
174 \verb|\exp(\tall)| & \exp(\tall) & & \verb|\exponential| \\
175 \verb|\log(\tall)| & \log(\tall) & & \verb|\logarithm| \\
176 \verb|\ln(\tall)| & \ln(\tall) & old definitions $\Rightarrow$ & \verb|\naturallogarithm| \\
177 \verb|\det(\tall)| & \det(\tall) & & \verb|\determinant| \\
178 \verb|\Pr(\tall)| & \Pr(\tall) & & \verb|\Probability|
179 \end{tabular}
180
181 \begin{longtable}[l]{ l l p{8cm} }
182 \multicolumn{3}{l}{New operators:} \\
183 \verb|\trace| or \verb|\tr| & \verb|\tr\rho| $\rightarrow \tr\rho$ also \verb|\tr(\tall)| $\rightarrow \tr(\tall)$ & trace; same bracing as trig functions \\
184 \verb|\Trace| or \verb|\Tr| & \verb|\Tr\rho| $\rightarrow \Tr\rho$ & alternate \\
185 \verb|\rank| & \verb|\rank M| $\rightarrow \rank M$ & matrix rank \\
186 \verb|\erf| & \verb|\erf(x)|$\rightarrow \erf(x)$ & Gauss error function \\
187 \verb|\Res| & \verb|\Res[f(z)]|$\rightarrow \Res[f(z)]$ & residue; same bracing as trig functions \\
188 \verb|\principalvalue| & \verb|\pv{\int f(z) \dd{z}}|$\rightarrow \pv{\int f(z) \dd{z}}$ & Cauchy principal value \\
189 & \verb|\PV{\int f(z) \dd{z}}|$\rightarrow \PV{\int f(z) \dd{z}}$ & alternate \\
190 \verb|\Re| & \verb|\Re{z}| $\rightarrow \Re{z}$ & old \verb|\Re| renamed to \verb|\real| $\rightarrow \real$ \\
191 \verb|\Im| & \verb|\Im{z}| $\rightarrow \Im{z}$ & old \verb|\Im| renamed to \verb|\imaginary| $\rightarrow \imaginary$
192 \end{longtable}
193
194 \subsection{Quick quad text}
195 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}.
196
197 \begin{tabular}[l]{ l l p{6cm} }
198 General text: & & \\
199 \verb|\qqtext| & \verb|\qq{}| & general quick quad text with argument \\
200 & \verb|\qq{word or phrase}| $\rightarrow$\Vtextvisiblespace[1em]$\text{word or phrase}$\Vtextvisiblespace[1em] & normal mode; left and right \verb|\quad| \\
201 & \verb|\qq*{word or phrase}| $\rightarrow \text{word or phrase}$\Vtextvisiblespace[1em] & starred mode; right \verb|\quad| only
202 \end{tabular}
203
204 \begin{longtable}[l]{ l l }
205 Special macros: & \\
206 \verb|\qcomma| or \verb|\qc| $\rightarrow ,$\Vtextvisiblespace[1em] & right \verb|\quad| only \\
207 \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] \\
208 \verb|\qif| $\rightarrow$\Vtextvisiblespace[1em]$\text{if}$\Vtextvisiblespace[1em] & left and right \verb|\quad| unless starred \verb|\qif*| $\rightarrow \text{if}$\Vtextvisiblespace[1em]
209 \end{longtable}
210 \begin{longtable}[l]{ l }
211 Similar to \verb|\qif|: \\
212 \verb|\qthen|, \verb|\qelse|, \verb|\qotherwise|, \verb|\qunless|, \verb|\qgiven|, \verb|\qusing|, \verb|\qassume|, \verb|\qsince|, \\
213 \verb|\qlet|, \verb|\qfor|, \verb|\qall|, \verb|\qeven|, \verb|\qodd|, \verb|\qinteger|, \verb|\qand|, \verb|\qor|, \verb|\qas|, \verb|\qin|
214 \end{longtable}
215
216 \subsection{Derivatives}
217 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}|.
218 \begin{longtable}[l]{ l l p{6cm} }
219 \verb|\differential| & \verb|\dd| $\rightarrow \dd$ & \\
220 & \verb|\dd x| $\rightarrow \dd x$ & no spacing (not recommended) \\
221 & \verb|\dd{x}| $\rightarrow$ \textvisiblespace\,$\dd{x}$\textvisiblespace & automatic spacing based on neighbors \\
222 & \verb|\dd[3]{x}| $\rightarrow \dd[3]{x}$ & optional power \\
223 & \verb|\dd(\cos\theta)| $\rightarrow \dd(\cos\theta)$ & long-form; automatic braces \\
224 \verb|\derivative| & \verb|\dv{x}| $\displaystyle\rightarrow \dv{x}$ & one argument \\
225 & \verb|\dv{f}{x}| $\displaystyle\rightarrow \dv{f}{x}$ & two arguments \\
226 & \verb|\dv[n]{f}{x}| $\displaystyle\rightarrow \dv[n]{f}{x}$ & optional power \\
227 & \verb|\dv{x}(\grande)| $\displaystyle\rightarrow \dv{x}(\grande)$ & long-form; automatic braces, spacing \\
228 & \verb|\dv*{f}{x}| $\displaystyle\rightarrow \dv*{f}{x}$ & inline form using \verb|\flatfrac| \\
229 \verb|\partialderivative| & \verb|\pderivative{x}| $\displaystyle\rightarrow \pderivative{x}$ & alternate name \\
230 & \verb|\pdv{x}| $\displaystyle\rightarrow \pdv{x}$ & shorthand name \\
231 & \verb|\pdv{f}{x}| $\displaystyle\rightarrow \pdv{f}{x}$ & two arguments \\
232 & \verb|\pdv[n]{f}{x}| $\displaystyle\rightarrow \pdv[n]{f}{x}$ & optional power \\
233 & \verb|\pdv{x}(\grande)| $\displaystyle\rightarrow \pdv{x}(\grande)$ & long-form \\
234 & \verb|\pdv{f}{x}{y}| $\displaystyle\rightarrow \pdv{f}{x}{y}$ & mixed partial \\
235 & \verb|\pdv*{f}{x}| $\displaystyle\rightarrow \pdv*{f}{x}$ & inline form using \verb|\flatfrac| \\
236 \verb|\variation| & \verb|\var{F[g(x)]}| $\rightarrow \var{F[g(x)]}$ & functional variation (works like \verb|\dd|) \\
237 & \verb|\var(E-TS)| $\rightarrow \var(E-TS)$ & long-form \\
238 \verb|\functionalderivative| & \verb|\fdv{g}| $\displaystyle\rightarrow \fdv{g}$ & functional derivative (works like \verb|\dv|) \\
239 & \verb|\fdv{F}{g}| $\displaystyle\rightarrow \fdv{F}{g}$ & \\
240 & \verb|\fdv{V}(E-TS)| $\displaystyle\rightarrow \fdv{V}(E-TS)$ & long-form \\
241 & \verb|\fdv*{F}{x}| $\displaystyle\rightarrow \fdv*{F}{x}$ & inline form using \verb|\flatfrac|
242 \end{longtable}
243
244 \subsection{Dirac bra-ket notation}
245 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.}
246 \begin{displaymath}
247 \verb|\bra{\phi}\ket{\psi}| \rightarrow \bra{\phi}\ket{\psi} \qq{as opposed to} \bra{\phi} \ket{\psi}
248 \end{displaymath}
249 whereas a similar construction with higher-level macros will not contract in a robust manner
250 \begin{displaymath}
251 \verb|\bra{\phi}\dyad{\psi}{\xi}| \rightarrow \bra{\phi}\dyad{\psi}{\xi}.
252 \end{displaymath}
253 On the other hand, the correct output can be generated by sticking to the fundamental commands,
254 \begin{displaymath}
255 \verb|\bra{\phi}\ket{\psi}\bra{\xi}| \rightarrow \bra{\phi}\ket{\psi}\bra{\xi}
256 \end{displaymath}
257 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.
258 \begin{longtable}[l]{ l L p{6cm} }
259 \verb|\ket| & \verb|\ket{\tall}| \rightarrow \ket{\tall} & automatic sizing \\
260 & \verb|\ket*{\tall}| \rightarrow \ket*{\tall} & no resize \\
261 \verb|\bra| & \verb|\bra{\tall}| \rightarrow \bra{\tall} & automatic sizing \\
262 & \verb|\bra*{\tall}| \rightarrow \bra*{\tall} & no resize \\
263 & \verb|\bra{\phi}\ket{\psi}| \rightarrow \bra{\phi}\ket{\psi} & automatic contraction \\
264 & \verb|\bra{\phi}\ket{\tall}| \rightarrow \bra{\phi}\ket{\tall} & contraction inherits automatic sizing \\
265 & \verb|\bra{\phi}\ket*{\tall}| \rightarrow \bra{\phi}\ket*{\tall} & \multirow{2}{*}{\parbox{6cm}{a star on either term in the contraction prohibits resizing}} \\
266 & \verb|\bra*{\phi}\ket{\tall}| \rightarrow \bra*{\phi}\ket{\tall} & \\
267 & \verb|\bra*{\phi}\ket*{\tall}| \rightarrow \bra*{\phi}\ket*{\tall} & \\
268 \verb|\innerproduct| & \verb|\braket{a}{b}| \rightarrow \braket{a}{b} & two-argument braket \\
269 & \verb|\braket{a}| \rightarrow \braket{a} & one-argument (norm) \\
270 & \verb|\braket{a}{\tall}| \rightarrow \braket{a}{\tall} & automatic sizing \\
271 & \verb|\braket*{a}{\tall}| \rightarrow \braket*{a}{\tall} & no resize \\
272 & \verb|\ip{a}{b}| \rightarrow \ip{a}{b} & shorthand name \\
273 \verb|\outerproduct| & \verb|\dyad{a}{b}| \rightarrow \dyad{a}{b} & two-argument dyad \\
274 & \verb|\dyad{a}| \rightarrow \dyad{a} & one-argument (projector) \\
275 & \verb|\dyad{a}{\tall}| \rightarrow \dyad{a}{\tall} & automatic sizing \\
276 & \verb|\dyad*{a}{\tall}| \rightarrow \dyad*{a}{\tall} & no resize \\
277 & \verb|\ketbra{a}{b}| \rightarrow \ketbra{a}{b} & alternative name \\
278 & \verb|\op{a}{b}| \rightarrow \op{a}{b} & shorthand name \\
279 \verb|\expectationvalue| & \verb|\expval{A}| \rightarrow \expval{A} & implicit form \\
280 & \verb|\expval{A}{\Psi}| \rightarrow \expval{A}{\Psi} & explicit form \\
281 & \verb|\ev{A}{\Psi}| \rightarrow \ev{A}{\Psi} & shorthand name \\
282 & \verb|\ev{\grande}{\Psi}| \rightarrow \ev{\grande}{\Psi} & default sizing ignores middle argument \\
283 & \verb|\ev*{\grande}{\tall}| \rightarrow \ev*{\grande}{\tall} & single star does no resizing whatsoever \\
284 & \verb|\ev**{\grande}{\Psi}| \rightarrow \ev**{\grande}{\Psi} & double star resizes based on all parts \\
285 \verb|\matrixelement| & \verb|\matrixel{n}{A}{m}| \rightarrow \matrixel{n}{A}{m} & requires all three arguments \\
286 & \verb|\mel{n}{A}{m}| \rightarrow \mel{n}{A}{m} & shorthand name \\
287 & \verb|\mel{n}{\grande}{m}| \rightarrow \mel{n}{\grande}{m} & default sizing ignores middle argument \\
288 & \verb|\mel*{n}{\grande}{\tall}| \rightarrow \mel*{n}{\grande}{\tall} & single star does no resizing whatsoever \\
289 & \verb|\mel**{n}{\grande}{m}| \rightarrow \mel**{n}{\grande}{m} & double star resizes based on all parts
290 \end{longtable}
291
292 \subsection{Matrix macros}
293 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:
294
295 \begin{minipage}{3cm}
296 \begin{verbatim}
297 \begin{pmatrix}
298 \imat{2} \\ a & b
299 \end{pmatrix}
300 \end{verbatim}
301 \end{minipage}
302 \begin{minipage}{6cm}
303 \begin{displaymath}
304 \Rightarrow\qquad
305 \begin{pmatrix}
306 \imat{2} \\ a & b
307 \end{pmatrix}
308 \end{displaymath}
309 \end{minipage}
310
311 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:
312
313 \begin{minipage}{9cm}
314 \begin{verbatim}
315 \begin{pmatrix}
316 \mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e
317 \end{pmatrix}
318 \end{verbatim}
319 \end{minipage}
320 \begin{minipage}{6cm}
321 \begin{displaymath}
322 \Rightarrow\qquad
323 \begin{pmatrix}
324 \mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e
325 \end{pmatrix}
326 \end{displaymath}
327 \end{minipage}
328
329 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:
330
331 \begin{minipage}{9cm}
332 \begin{verbatim}
333 \mqty(\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e)
334 \end{verbatim}
335 \end{minipage}
336 \begin{minipage}{6cm}
337 \begin{displaymath}
338 \Rightarrow\qquad
339 \mqty(\mqty{\imat{2}} & \mqty{a\\b} \\ \mqty{c & d} & e)
340 \end{displaymath}
341 \end{minipage}
342
343 \begin{longtable}[l]{ l L p{6cm} }
344 \verb|\matrixquantity| & \verb|\mqty{a & b \\ c & d}| \rightarrow \mqty{a & b \\ c & d} & groups a set of matrix elements into a single object \\
345 & \verb|\mqty(a & b \\ c & d)| \rightarrow {\mqty(a & b \\ c & d)} & parentheses \\
346 & \verb|\mqty*(a & b \\ c & d)| \rightarrow {\mqty*(a & b \\ c & d)} & alternate parentheses \\
347 & \verb|\mqty[a & b \\ c & d]| \rightarrow {\mqty[a & b \\ c & d]} & square brackets \\
348 & \verb|\mqty| \texttt{|} \verb|a & b \\ c & d| \texttt{|} \rightarrow {\mqty|a & b \\ c & d|} & vertical bars \\
349 & \verb|\pmqty{}| \leftrightarrow \verb|\mqty()| & \multirow{2}{*}{\parbox{6cm}{alternative syntax; robust and more \LaTeX-friendly}} \\
350 & \verb|\Pmqty{}| \leftrightarrow \verb|\mqty*()| & \\
351 & \verb|\bmqty{}| \leftrightarrow \verb|\mqty[]| & \\
352 & \verb|\vmqty{}| \leftrightarrow \verb+\mqty||+ & \\
353 \verb|\smallmatrixquantity| & \verb|\smqty{a & b \\ c & d}| \rightarrow \smqty{a & b \\ c & d} & the \texttt{smallmatrix} form of \verb|\mqty| \\
354 & \verb|\smqty()| \qor \verb|\spmqty{}| & small version of \verb|\mqty()| \\
355 & \verb|\smqty*()| \qor \verb|\sPmqty{}| & small version of \verb|\mqty*()|\\
356 & \verb|\smqty[]| \qor \verb|\sbmqty{}| & small version of \verb|\mqty[]| \\
357 & \verb+\smqty||+ \qor \verb|\svmqty{}| & small version of \verb+\mqty||+ \\
358 \verb|\matrixdeterminant| & \verb|\mdet{a & b \\ c & d}| \rightarrow {\mdet{a & b \\ c & d}} & matrix determinant \\
359 & \verb|\smdet{a & b \\ c & d}| \rightarrow {\smdet{a & b \\ c & d}} & small matrix determinant \\
360 \verb|\identitymatrix| & \verb|\imat{n}| & elements of $n \times n$ identity matrix \\
361 & \verb|\smqty(\imat{3})| \rightarrow \smqty(\imat{3}) & formatted with \verb|\mqty| or \verb|\smqty| \\
362 \verb|\xmatrix| & \verb|\xmat{x}{n}{m}| & elements of $n \times m$ matrix filled with $x$ \\
363 & \verb|\smqty(\xmat{1}{2}{3})| \rightarrow \smqty(\xmat{1}{2}{3}) & formatted with \verb|\mqty| or \verb|\smqty| \\
364 & \verb|\smqty(\xmat*{a}{3}{3})| \rightarrow \smqty(\xmat*{a}{3}{3}) & star for element indices \\
365 & \verb|\smqty(\xmat*{a}{3}{1})| \rightarrow \smqty(\xmat*{a}{3}{1}) & as a vector with indices \\
366 & \verb|\smqty(\xmat*{a}{1}{3})| \rightarrow \smqty(\xmat*{a}{1}{3}) & \\
367 \verb|\zeromatrix| & \verb|\zmat{n}{m}| & $n \times m$ matrix filled with zeros \\
368 & \verb|\smqty(\zmat{2}{2})| \rightarrow \smqty(\zmat{2}{2}) & equivalent to \verb|\xmat{0}{n}{m}| \\
369 \verb|\paulimatrix| & \verb|\pmat{n}| & $n^\text{th}$ Pauli matrix \\
370 & \verb|\smqty(\pmat{0})| \rightarrow \smqty(\pmat{0}) & $n\in \lbrace 0,1,2,3$ or $x,y,z \rbrace$ \\
371 & \verb|\smqty(\pmat{1})| \rightarrow \smqty(\pmat{1}) & \\
372 & \verb|\smqty(\pmat{2})| \rightarrow \smqty(\pmat{2}) & \\
373 & \verb|\smqty(\pmat{3})| \rightarrow \smqty(\pmat{3}) & \\
374 \verb|\diagonalmatrix| & \verb|\dmat{a,b,c,...}| & \multirow{2}{*}{\parbox{6cm}{specify up to eight diagonal or block diagonal elements}} \\
375 & \verb|\mqty(\dmat{1,2,3})| \rightarrow \mqty(\dmat{1,2,3}) & \\
376 & \verb|\mqty(\dmat[0]{1,2})| \rightarrow \mqty(\dmat[0]{1,2}) & optional argument to fill spaces \\
377 & \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} \\
378 \verb|\antidiagonalmatrix| & \verb|\admat{a,b,c,...}| & same as syntax as \verb|\dmat| \\
379 & \verb|\mqty(\admat{1,2,3})| \rightarrow \mqty(\admat{1,2,3}) & \\
380 \end{longtable}
381
382 \end{document}