summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-02 23:33:35 +0000
committerKarl Berry <karl@freefriends.org>2012-11-02 23:33:35 +0000
commit89df75aae9d25e94c83fbf99d633236815f26b0f (patch)
tree40ed2c9876769abf61a4178c264e8ed0a3c5f97e
parent3c694dfbf7d9902b827affc7e3b0e2c6322550dc (diff)
physics (2nov12)
git-svn-id: svn://tug.org/texlive/trunk@28153 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/physics/README7
-rw-r--r--Master/texmf-dist/doc/latex/physics/physics.pdfbin206120 -> 220722 bytes
-rw-r--r--Master/texmf-dist/doc/latex/physics/physics.tex92
-rw-r--r--Master/texmf-dist/tex/latex/physics/physics.sty253
4 files changed, 246 insertions, 106 deletions
diff --git a/Master/texmf-dist/doc/latex/physics/README b/Master/texmf-dist/doc/latex/physics/README
index a6eb7ea1521..8e4725a840e 100644
--- a/Master/texmf-dist/doc/latex/physics/README
+++ b/Master/texmf-dist/doc/latex/physics/README
@@ -1,8 +1,11 @@
README for physics.sty
-physics 1.10
+physics 1.20
Created by Sergio C. de la Barrera
-Updated October 11, 2012
+Updated October 31, 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.
diff --git a/Master/texmf-dist/doc/latex/physics/physics.pdf b/Master/texmf-dist/doc/latex/physics/physics.pdf
index e8942cb454b..8e8061b9e0a 100644
--- a/Master/texmf-dist/doc/latex/physics/physics.pdf
+++ b/Master/texmf-dist/doc/latex/physics/physics.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/physics/physics.tex b/Master/texmf-dist/doc/latex/physics/physics.tex
index 6a273fbac0f..5a634b1ee95 100644
--- a/Master/texmf-dist/doc/latex/physics/physics.tex
+++ b/Master/texmf-dist/doc/latex/physics/physics.tex
@@ -5,15 +5,18 @@
\usepackage[colorlinks,urlcolor=blue]{hyperref}
\usepackage{array}
\usepackage{longtable}
+\usepackage{multirow}
\newcommand\Vtextvisiblespace[1][.3em]{%
\mbox{\kern.06em\vrule height.3ex}%
\vbox{\hrule width#1}%
\hbox{\vrule height.3ex}}
-\begin{document}
+% physics 1.20
\title{The \texttt{physics} package}
\author{Sergio C. de la Barrera}
+
+\begin{document}
\maketitle
\tableofcontents
@@ -43,18 +46,22 @@ To use the \texttt{physics} package, simply insert \verb|\usepackage{physics}| i
& \verb|\qty[a+b]| $\rightarrow \qty[a+b]$ & automatic $\qty[\;]$ braces \\
& \verb|\qty| \!\!\texttt{|}\!\! \verb|a+b| \!\!\texttt{|} $\rightarrow \qty|a+b|$ & automatic $\qty|\;|$ braces \\
& \verb|\qty{a+b}| $\rightarrow \qty{a+b}$ & automatic $\qty{\;}$ braces \\
-& \verb|\qty\big{}| $\rightarrow \qty\big{}$ & manual sizing (works with any of the above bracket types) \\
+& \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|\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|\norm| & \verb|\norm{a}| $\rightarrow \norm{a}$ & automatic sizing \\
+& \verb|\norm\Big{a}| $\rightarrow \norm\Big{a}$ & manual sizing \\
+\verb|\evaluated| & \verb|\eval{x}_0^\infty| $\displaystyle\rightarrow \eval{x}_0^\infty$ & automatic right vertical bar for evaluation limits \\
+& \verb|\eval(x)_y| $\displaystyle\rightarrow \eval(x)_y$ & parenthetical form for holding values constant \\
\verb|\order| & \verb|\order{x^2}| $\rightarrow \order{x^2}$ & order symbol; automatic sizing and space handling \\
-\verb|\poissonbracket| & \verb|\pb{A}{B}| $\rightarrow \pb{A}{B}$ & same as \verb|\anticommutator| \\
+& \verb|\order\Big{x^2}| $\rightarrow \order\Big{x^2}$ & manual sizing \\
\verb|\commutator| & \verb|\comm{A}{B}| $\rightarrow \comm{A}{B}$ & automatic sizing \\
\verb|\anticommutator| & \verb|\acomm{A}{B}| $\rightarrow \acomm{A}{B}$ & same as \verb|\poissonbracket| \\
-& \verb|\acommutator{A}{B}| $\rightarrow \acommutator{A}{B}$ &
+& \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}
@@ -70,18 +77,33 @@ To use the \texttt{physics} package, simply insert \verb|\usepackage{physics}| i
& \verb|\cp| $\rightarrow \cp$ as in $\vb{a} \cp \vb{b}$ & alternate name \\
\verb|\vnabla| & \verb|\vnabla| $\rightarrow \vnabla$ versus $\nabla$ & low-level macro for bold version \\
\verb|\gradient| & \verb|\grad| $\rightarrow \grad$ & \\
-& \verb|\grad{\Psi}| $\rightarrow \grad{\Psi}$ & handles spacing \\
-& \verb|\grad*{\Psi+\Phi}| $\rightarrow \grad*{\Psi+\Phi}$ & long-form (handles spacing and brackets) \\
+& \verb|\grad{\Psi}| $\rightarrow \grad{\Psi}$ & default mode \\
+& \verb|\grad(\Psi+\Phi)| $\rightarrow \grad(\Psi+\Phi)$ & long-form (like \verb|\qty| but also handles spacing) \\
+& \verb|\grad[\Psi+\Phi]| $\rightarrow \grad[\Psi+\Phi]$ & \\
\verb|\divergence| & \verb|\div| $\rightarrow \div$ & note \texttt{amsmath} symbol $\divisionsymbol$ renamed \verb|\divisionsymbol| \\
-& \verb|\div{\vb{a}}| $\rightarrow \div{\vb{a}}$ & handles spacing \\
-& \verb|\div*{\vb{a}+\vb{b}}| $\rightarrow \div*{\vb{a}+\vb{b}}$ & long-form \\
+& \verb|\div{\vb{a}}| $\rightarrow \div{\vb{a}}$ & default mode \\
+& \verb|\div(\vb{a}+\vb{b})| $\rightarrow \div(\vb{a}+\vb{b})$ & long-form \\
+& \verb|\div[\vb{a}+\vb{b}]| $\rightarrow \div[\vb{a}+\vb{b}]$ & \\
\verb|\curl| & \verb|\curl| $\rightarrow \curl$ & \\
-& \verb|\curl{\vb{a}}| $\rightarrow \curl{\vb{a}}$ & handles spacing \\
-& \verb|\curl*{\vb{a}+\vb{b}}| $\rightarrow \curl*{\vb{a}+\vb{b}}$ & long-form
+& \verb|\curl{\vb{a}}| $\rightarrow \curl{\vb{a}}$ & default mode \\
+& \verb|\curl(\vb{a}+\vb{b}})| $\rightarrow \curl(\vb{a}+\vb{b})$ & long-form \\
+& \verb|\curl[\vb{a}+\vb{b}]| $\rightarrow \curl[\vb{a}+\vb{b}]$ & \\
+\verb|\laplacian| & \verb|\laplacian| $\rightarrow \laplacian$ & \\
+& \verb|\laplacian{\Psi}| $\rightarrow \laplacian{\Psi}$ & default mode \\
+& \verb|\laplacian(\Psi+\Phi)| $\rightarrow \laplacian(\Psi+\Phi)$ & long-form \\
+& \verb|\laplacian[\Psi+\Phi]| $\rightarrow \laplacian[\Psi+\Phi]$ &
\end{longtable}
\subsection{Operators}
-\begin{longtable}[l]{ l l p{6cm} }
+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. The old definition of each trig function is stored in a long form version as in \verb|\sin| $\rightarrow$ \verb|\sine|, \verb|\cos| $\rightarrow$ \verb|\cosine|, and so on.
+\begin{longtable}[l]{ l l p{8cm} }
+\multicolumn{3}{l}{Trig redefinitions:} \\
+\verb|\sin| & \verb|\sin(x)| $\rightarrow \sin(x)$ & automatic braces; old \verb|\sin| renamed \verb|\sine| \\
+& \verb|\sin[2](x)| $\rightarrow \sin[2](x)$ & optional power \\
+\verb|\cos| & \verb|\cos(x)| $\rightarrow \cos(x)$ & works with all trig functions \\
+\verb|\tan| & \verb|\tan x| $\rightarrow \tan x$ & can still use without an argument \\
+$\quad\vdots$ & & $\qquad\vdots$ \\
+\multicolumn{3}{l}{New operators:} \\
\verb|\tr| & \verb|\tr\rho| $\rightarrow \tr\rho$ & trace \\
\verb|\rank| & \verb|\rank M| $\rightarrow \rank M$ & matrix rank \\
\verb|\erf| & \verb|\erf(x)|$\rightarrow \erf(x)$ & Gauss error function
@@ -98,44 +120,37 @@ General text: & & \\
\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] \\
-\verb|\qthen| & similar to \verb|\qif| \\
-\verb|\qelse| & $\quad\quad\cdot$ \\
-\verb|\qotherwise| & $\quad\quad\cdot$ \\
-\verb|\qunless| & $\quad\quad\cdot$ \\
-\verb|\qgiven| & \\
-\verb|\qusing| & \\
-\verb|\qfor| & \\
-\verb|\qall| & \\
-\verb|\qeven| & \\
-\verb|\qodd| & \\
-\verb|\qinteger| & \\
-\verb|\qand| & \\
-\verb|\qor| & \\
-\verb|\qas| & \\
-\verb|\qin| & \\
-\verb|\qcc| $\rightarrow \qcc$ & complex conjugate \\
+\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}
\begin{longtable}[l]{ l l p{6cm} }
\verb|\differential| & \verb|\dd| $\rightarrow \dd$ & \\
-& \verb|\dd x| $\rightarrow \dd x$ & no extra spacing for braces, fractions \\
+& \verb|\dd x| $\rightarrow \dd x$ & no spacing; use in braces, fractions \\
& \verb|\dd{x}| $\rightarrow \dd{x}$\!\textvisiblespace & proper spacing for typical equations \\
& \verb|\dd[3]{x}| $\rightarrow \dd[3]{x}$\!\textvisiblespace & optional power \\
-& \verb|\dd*{\cos\theta}| $\rightarrow \dd*{\cos\theta}$ & long-argument; automatic braces \\
-\verb|\derivative| & \verb|\dv{}{x}| $\displaystyle\rightarrow \dv{}{x}$ & \\
-& \verb|\dv{f}{x}| $\displaystyle\rightarrow \dv{f}{x}$ & \\
+& \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[n]{f}{x}[x=0]| $\displaystyle\rightarrow \dv[n]{f}{x}[x=0]$ & optional evaluation point \\
-\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}$ & \\
+& \verb|\dv{x}(x^2+x)| $\displaystyle\rightarrow \dv{x}(x^2+x)$ & long-form; automatic braces, spacing \\
+\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[n]{f}{x}[x=0]| $\displaystyle\rightarrow \pdv[n]{f}{x}[x=0]$ & optional evaluation point \\
+& \verb|\pdv{x}(x+y)| $\displaystyle\rightarrow \pdv{x}(x+y)$ & long-form \\
& \verb|\pdv{f}{x}{y}| $\displaystyle\rightarrow \pdv{f}{x}{y}$ & mixed partial \\
-& \verb|\pdv*{f}{x}| $\rightarrow \pdv*{f}{x}$ & shorthand form \\
-& \verb|\pdv*{f}{x}{y}| $\rightarrow \pdv*{f}{x}{y}$ & mixed partial shorthand
+\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
\end{longtable}
\subsection{Dirac bra-ket notation}
@@ -173,5 +188,4 @@ allowing the user to type out complicated quantum mechanical expressions without
\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 \\
\end{longtable}
-
\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/physics/physics.sty b/Master/texmf-dist/tex/latex/physics/physics.sty
index 30205692737..36c23bf66bc 100644
--- a/Master/texmf-dist/tex/latex/physics/physics.sty
+++ b/Master/texmf-dist/tex/latex/physics/physics.sty
@@ -1,5 +1,5 @@
\ProvidesPackage{physics}
-% physics 1.10
+% physics 1.20
% 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.
%
@@ -9,41 +9,12 @@
% 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 October 10, 2012
-% Uploaded on October 11, 2012
+% Updated on October 31, 2012
+% Uploaded on November 1, 2012
\RequirePackage{xparse}
\RequirePackage{amsmath}
-% 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\vnabla{}{\boldsymbol\nabla} % Vector bold \nabla symbol
-\DeclareDocumentCommand\gradient{ s g }{\IfNoValueTF{#2}{\vnabla}{\IfBooleanTF{#1}{\vnabla\!\left(#2\right)}{\vnabla #2}}} % Gradient [star for parentheses]
-\DeclareDocumentCommand\grad{}{\gradient} % Shorthand for \gradient
-
-\DeclareDocumentCommand\divergence{ s g }{\IfNoValueTF{#2}{\vnabla \vdot}{\IfBooleanTF{#1}{\vnabla \vdot \left(#2\right)}{\vnabla \vdot #2}}} % Divergence [star for parentheses]
-\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{ s g }{\IfNoValueTF{#2}{\vnabla \cross}{\IfBooleanTF{#1}{\vnabla \cross \left(#2\right)}{\vnabla \cross #2}}} % Curl [star for parentheses]
-\DeclareDocumentCommand\laplacian{ s g }{\IfNoValueTF{#2}{\nabla^2}{\IfBooleanTF{#1}{\nabla^2\!\left(#2\right)}{\nabla^2 #2}}} % Laplacian [star for parentheses]
-
% Brackets and braces
\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
@@ -64,11 +35,11 @@
{()}
{\ltag\lvert{#8}\rtag\rvert}
}
- {\ltag(#7\rtag) \IfNoValueTF{#8}{}{#8}}
+ {\ltag(#7\rtag) \IfNoValueTF{#8}{}{|#8|}}
}
- {\ltag[#6\rtag] \IfNoValueTF{#7}{}{[#7]} \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}}
+ {\ltag\lbrace#5\rtag\rbrace \IfNoValueTF{#6}{}{[#6]} \IfNoValueTF{#7}{}{(#7)} \IfNoValueTF{#8}{}{|#8|}}
}
\DeclareDocumentCommand\qty{}{\quantity} % Shorthand for \quantity
@@ -76,15 +47,40 @@
\IfBooleanTF{#1}{\quantity\big|#5|}{
\IfBooleanTF{#2}{\quantity\Big|#5|}{
\IfBooleanTF{#3}{\quantity\bigg|#5|}{
- \IfBooleanTF{#4}{\let\sizetag\Bigg}{\quantity|#5|}
+ \IfBooleanTF{#4}{\quantity\Bigg|#5|}{\quantity|#5|}
}
}
}
}
\DeclareDocumentCommand\abs{}{\absolutevalue} % Shorthand for \absolutevalue
-\DeclareDocumentCommand\norm{m}{{\left\lVert{#1}\right\rVert}} % Norm
-\DeclareDocumentCommand\order{g}{{\mathcal{O}\IfNoValueTF{#1}{}{\!\left(#1\right)}}} % Order symbol -> O(x^2)
+\DeclareDocumentCommand\norm{ t\big t\Big t\bigg t\Bigg m }{ % Norm
+ \IfBooleanTF{#1}{\bigl\lVert{#5}\bigr\rVert}{
+ \IfBooleanTF{#2}{\Bigl\lVert{#5}\Bigr\rVert}{
+ \IfBooleanTF{#3}{\biggl\lVert{#5}\biggr\rVert}{
+ \IfBooleanTF{#4}{\Biggl\lVert{#5}\Biggr\rVert}{\left\lVert{#5}\right\rVert}
+ }
+ }
+ }
+}
+\DeclareDocumentCommand\order{ t\big t\Big t\bigg t\Bigg m }{ % Order symbol -> O(x^2)
+ \IfBooleanTF{#1}{\mathcal{O}\IfNoValueTF{#5}{}{\!\quantity\big(#5)}}{
+ \IfBooleanTF{#2}{\mathcal{O}\IfNoValueTF{#5}{}{\!\quantity\Big(#5)}}{
+ \IfBooleanTF{#3}{\mathcal{O}\IfNoValueTF{#5}{}{\!\quantity\bigg(#5)}}{
+ \IfBooleanTF{#4}{\mathcal{O}\IfNoValueTF{#5}{}{\!\quantity\Bigg(#5)}}{\mathcal{O}\IfNoValueTF{#5}{}{\!\quantity(#5)}}
+ }
+ }
+ }
+}
+\DeclareDocumentCommand\evaluated{ g d() }{ % Vertical evaluation bar or parentheses
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}
+ {\rvert}
+ {\quantity(#2)}
+ }
+ {\left.{#1}\right\rvert \IfNoValueTF{#2}{}{(#2)}}
+ }
+\DeclareDocumentCommand\eval{}{\evaluated} % Shorthand for evaluated
\DeclareDocumentCommand\poissonbracket{ m m }{{\left\lbrace{#1},{#2}\right\rbrace}} % Poisson bracket [same as anti-commutator]
\DeclareDocumentCommand\pb{}{\poissonbracket} % Shorthand for \poissonbracket
@@ -96,7 +92,96 @@
\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\vnabla{}{\boldsymbol\nabla} % Vector bold \nabla symbol
+\DeclareDocumentCommand\gradient{ g o d() }{ % Gradient
+ \IfNoValueTF{#1}{
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}{\vnabla}{\vnabla\!\quantity(#3)}
+ }
+ {\vnabla\!\quantity[#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}{\nabla^2\!\quantity(#3)}
+ }
+ {\nabla^2\!\quantity[#2] \IfNoValueTF{#3}{}{(#3)}}
+ }
+ {\nabla^2 #1 \IfNoValueTF{#2}{}{[#2]} \IfNoValueTF{#3}{}{(#3)}}
+ }
+
% Operators
+\let\sine\sin
+\let\cosine\cos
+\let\tangent\tan
+\let\cosecant\csc
+\let\secant\sec
+\let\cotangent\cot
+\let\arcsine\arcsin
+\let\arccosine\arccos
+\let\arctangent\arctan
+\let\hypsine\sinh
+\let\hypcosine\cosh
+\let\hyptangent\tanh
+\let\hypcotangent\coth
+\DeclareDocumentCommand\sin{ o d() }{\IfNoValueTF{#2}{\sine \IfNoValueTF{#1}{}{[#1]}}{\sine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\cos{ o d() }{\IfNoValueTF{#2}{\cosine \IfNoValueTF{#1}{}{[#1]}}{\cosine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\tan{ o d() }{\IfNoValueTF{#2}{\tangent \IfNoValueTF{#1}{}{[#1]}}{\tangent \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\csc{ o d() }{\IfNoValueTF{#2}{\cosecant \IfNoValueTF{#1}{}{[#1]}}{\cosecant \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\sec{ o d() }{\IfNoValueTF{#2}{\secant \IfNoValueTF{#1}{}{[#1]}}{\secant \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\cot{ o d() }{\IfNoValueTF{#2}{\cotangent \IfNoValueTF{#1}{}{[#1]}}{\cotangent \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\arcsin{ o d() }{\IfNoValueTF{#2}{\arcsine \IfNoValueTF{#1}{}{[#1]}}{\arcsine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\arccos{ o d() }{\IfNoValueTF{#2}{\arccosine \IfNoValueTF{#1}{}{[#1]}}{\arccosine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\arctan{ o d() }{\IfNoValueTF{#2}{\arctangent \IfNoValueTF{#1}{}{[#1]}}{\arctangent \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\sinh{ o d() }{\IfNoValueTF{#2}{\hypsine \IfNoValueTF{#1}{}{[#1]}}{\hypsine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\cosh{ o d() }{\IfNoValueTF{#2}{\hypcosine \IfNoValueTF{#1}{}{[#1]}}{\hypcosine \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\tanh{ o d() }{\IfNoValueTF{#2}{\hyptangent \IfNoValueTF{#1}{}{[#1]}}{\hyptangent \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+\DeclareDocumentCommand\coth{ o d() }{\IfNoValueTF{#2}{\hypcotangent \IfNoValueTF{#1}{}{[#1]}}{\hypcotangent \IfNoValueTF{#1}{}{^{#1}} \!\quantity(#2)}}
+
\DeclareMathOperator{\tr}{tr} % Trace and partial trace [w/subscript]
\DeclareMathOperator{\rank}{rank} % Rank of a matrix
\DeclareMathOperator{\erf}{erf} % Gauss error function
@@ -115,6 +200,9 @@
\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}
@@ -127,48 +215,80 @@
\DeclareDocumentCommand\qcc{s}{\IfBooleanTF{#1}{}{\quad}\text{c.c.}\quad}
% Derivatives
-\DeclareDocumentCommand\differential{ s o g }{{ % Differential 'd'
- % s: star for parentheses as in d(cos x)
+\DeclareDocumentCommand\differential{ o g d() }{ % Differential 'd'
% o: optional n for nth differential
% g: optional argument for readability and to control spacing
- \IfNoValueTF{#3}
- {\mathrm{d}\IfNoValueTF{#2}{}{^{#2}}}
- {\IfBooleanTF{#1}
- {\mathrm{d}\IfNoValueTF{#2}{}{^{#2}}\!\left(#3\right)}
- {\mathrm{d}\IfNoValueTF{#2}{}{^{#2}} #3 \,}
+ % d: long-form as in d(cos x)
+ \IfNoValueTF{#2}{
+ \IfNoValueTF{#3}
+ {\mathrm{d}\IfNoValueTF{#1}{}{^{#1}}}
+ {\mathrm{d}\IfNoValueTF{#1}{}{^{#1}}\!\quantity(#3)}
}
- }}
+ {\mathrm{d}\IfNoValueTF{#1}{}{^{#1}} #2 \,}
+ }
\DeclareDocumentCommand\dd{}{\differential} % Shorthand for \differential
-\DeclareDocumentCommand\derivative{ o m m o }{{ % Total derivatives
+\DeclareDocumentCommand\derivative{ o m g d() }{ % Total derivative
% o: optional n for nth derivative
- % m: mandatory (f in df/dx)
% m: mandatory (x in df/dx)
- % o: optional evaluation point
- \IfNoValueTF{#4}{}{\left.}\frac{\dd \IfNoValueTF{#1}{}{^{#1}} #2}{\dd #3\IfNoValueTF{#1}{}{^{#1}}}\IfNoValueTF{#4}{}{\right\rvert_{#4}}
- }}
+ % g: optional (f in df/dx)
+ % d: long-form d/dx(...)
+ \IfNoValueTF{#3}{
+ \IfNoValueTF{#4}
+ {\frac{\dd \IfNoValueTF{#1}{}{^{#1}}}{\dd #2\IfNoValueTF{#1}{}{^{#1}}}}
+ {\frac{\dd \IfNoValueTF{#1}{}{^{#1}}}{\dd #2\IfNoValueTF{#1}{}{^{#1}}} \!\quantity(#4)}
+ }
+ {\frac{\dd \IfNoValueTF{#1}{}{^{#1}} #2}{\dd #3\IfNoValueTF{#1}{}{^{#1}}}}
+ }
\DeclareDocumentCommand\dv{}{\derivative} % Shorthand for \derivative
-\DeclareDocumentCommand\partialderivative{ s o m m g o }{ % Partial derivatives
- % s: star for shorthand curly-d notation [default is Leibniz mode]
- % o: optional n for nth derivative [Leibniz mode]
- % m: mandatory (f in df/dx) [both modes]
- % m: mandatory (x in df/dx) [both modes]
- % g: optional (y in d^2f/dxdy) [both modes]
- % o: optional evaluation point [Leibniz mode]
- \IfNoValueTF{#5}{
- \IfBooleanTF{#1}
- {\partial_{#4} {#3}}
- {\IfNoValueTF{#6}{}{\left.}\frac{\partial\IfNoValueTF{#2}{}{^{#2}} #3}{\partial #4\IfNoValueTF{#2}{}{^{#2}}}\IfNoValueTF{#6}{}{\right\rvert_{#6}}}
+\DeclareDocumentCommand\partialderivative{ o m g g d() }{ % Partial 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(...)
+ \IfNoValueTF{#3}{
+ \IfNoValueTF{#5}
+ {\frac{\partial \IfNoValueTF{#1}{}{^{#1}}}{\partial #2\IfNoValueTF{#1}{}{^{#1}}}}
+ {\frac{\partial \IfNoValueTF{#1}{}{^{#1}}}{\partial #2\IfNoValueTF{#1}{}{^{#1}}} \!\quantity(#5)}
}{
- \IfBooleanTF{#1}
- {\partial_{{#4}{#5}} {#3}}
- {\IfNoValueTF{#6}{}{\left.}\frac{\partial^2 #3}{\partial #4 \partial #5}\IfNoValueTF{#6}{}{\right\rvert_{#6}}}
+ \IfNoValueTF{#4}
+ {\frac{\partial \IfNoValueTF{#1}{}{^{#1}} #2}{\partial #3\IfNoValueTF{#1}{}{^{#1}}}}
+ {\frac{\partial^2 #2}{\partial #3 \partial #4}}
}
}
\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}}}
+ {\delta \IfNoValueTF{#1}{}{^{#1}}\!\quantity(#3)}
+ }
+ {\delta \IfNoValueTF{#1}{}{^{#1}} #2 \,}
+ }
+\DeclareDocumentCommand\var{}{\variation} % Shorthand for \variation
+
+\DeclareDocumentCommand\functionalderivative{ o m g d() }{ % Functional derivative
+ % o: optional n for nth derivative
+ % m: mandatory (g in dF/dg)
+ % g: optional (F in dF/dg)
+ % d: long-form d/dx(...)
+ \IfNoValueTF{#3}{
+ \IfNoValueTF{#4}
+ {\frac{\variation \IfNoValueTF{#1}{}{^{#1}}}{\variation #2\IfNoValueTF{#1}{}{^{#1}}}}
+ {\frac{\variation \IfNoValueTF{#1}{}{^{#1}}}{\variation #2\IfNoValueTF{#1}{}{^{#1}}} \!\quantity(#4)}
+ }
+ {\frac{\variation \IfNoValueTF{#1}{}{^{#1}} #2}{\variation #3\IfNoValueTF{#1}{}{^{#1}}}}
+ }
+\DeclareDocumentCommand\fderivative{}{\functionalderivative} % Shorthand for \functionalderivative
+\DeclareDocumentCommand\fdv{}{\functionalderivative} % Shorthand for \functionalderivative
+
% Bra-ket notation
\DeclareDocumentCommand\bra{ s m t\ket{g} }{ % Bra
\IfBooleanTF{#1}
@@ -219,6 +339,9 @@
\DeclareDocumentCommand\matrixelement{ m m m }{\left\langle{#1}\middle\vert{#2}\middle\vert{#3}\right\rangle} % Matrix element
\DeclareDocumentCommand\matrixel{}{\matrixelement} % Shorthand for \matrixelement
\DeclareDocumentCommand\mel{}{\matrixelement} % Shorthand for \matrixelement
+
+% Misc
+\DeclareDocumentCommand\varE{}{\mathcal{E}} % Curly 'E'
\DeclareDocumentCommand\homework{}{ % You can try it
\ensuremath{
\div{\vb{E}}=\frac{\rho}{\epsilon_0} \qc