summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/physics/physics.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/physics/physics.sty')
-rw-r--r--Master/texmf-dist/tex/latex/physics/physics.sty231
1 files changed, 231 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/physics/physics.sty b/Master/texmf-dist/tex/latex/physics/physics.sty
new file mode 100644
index 00000000000..30205692737
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/physics/physics.sty
@@ -0,0 +1,231 @@
+\ProvidesPackage{physics}
+% physics 1.10
+% 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, 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 October 10, 2012
+% Uploaded on October 11, 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
+ \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}}
+ }
+\DeclareDocumentCommand\qty{}{\quantity} % Shorthand for \quantity
+
+\DeclareDocumentCommand\absolutevalue{ t\big t\Big t\bigg t\Bigg m }{ % Absolute value/complex modulus
+ \IfBooleanTF{#1}{\quantity\big|#5|}{
+ \IfBooleanTF{#2}{\quantity\Big|#5|}{
+ \IfBooleanTF{#3}{\quantity\bigg|#5|}{
+ \IfBooleanTF{#4}{\let\sizetag\Bigg}{\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\poissonbracket{ m m }{{\left\lbrace{#1},{#2}\right\rbrace}} % Poisson bracket [same as anti-commutator]
+\DeclareDocumentCommand\pb{}{\poissonbracket} % Shorthand for \poissonbracket
+
+% Commutators
+\DeclareDocumentCommand\commutator{ m m }{\left[{#1},{#2}\right]} % Commutator
+\DeclareDocumentCommand\comm{}{\commutator} % Shorthand for \commutator
+
+\DeclareDocumentCommand\anticommutator{ m m }{\left\lbrace{#1},{#2}\right\rbrace} % Anticommutator [same as Poisson bracket]
+\DeclareDocumentCommand\acommutator{}{\anticommutator} % Shorthand for \anticommutator
+\DeclareDocumentCommand\acomm{}{\anticommutator} % Shorthand for \anticommutator
+
+% Operators
+\DeclareMathOperator{\tr}{tr} % Trace and partial trace [w/subscript]
+\DeclareMathOperator{\rank}{rank} % Rank of a matrix
+\DeclareMathOperator{\erf}{erf} % Gauss error function
+
+% 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\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{ s o g }{{ % Differential 'd'
+ % s: star for parentheses as in d(cos x)
+ % 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 \,}
+ }
+ }}
+\DeclareDocumentCommand\dd{}{\differential} % Shorthand for \differential
+
+\DeclareDocumentCommand\derivative{ o m m o }{{ % Total derivatives
+ % 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}}
+ }}
+\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}}}
+ }{
+ \IfBooleanTF{#1}
+ {\partial_{{#4}{#5}} {#3}}
+ {\IfNoValueTF{#6}{}{\left.}\frac{\partial^2 #3}{\partial #4 \partial #5}\IfNoValueTF{#6}{}{\right\rvert_{#6}}}
+ }
+ }
+\DeclareDocumentCommand\pderivative{}{\partialderivative} % Shorthand for \partialderivative
+\DeclareDocumentCommand\pdv{}{\partialderivative} % Shorthand for \partialderivative
+
+% Bra-ket notation
+\DeclareDocumentCommand\bra{ s m t\ket{g} }{ % Bra
+ \IfBooleanTF{#1}
+ {\left\lvert{#2}\right\rangle \IfNoValueTF{#4}{}{#4}} % Complex conjugate
+ {\IfBooleanTF{#3}{\braket{#2}{\IfNoValueTF{#4}{}{#4}}}{\left\langle{#2}\right\rvert \IfNoValueTF{#4}{}{#4}}} % No star --- allow contraction
+ }
+
+\DeclareDocumentCommand\ket{ s m }{ % Ket
+ \IfBooleanTF{#1}
+ {\left\langle{#2}\right\rvert} % Complex conjugate
+ {\left\lvert{#2}\right\rangle} % No star
+ }
+
+\DeclareDocumentCommand\innerproduct{ s m g }{ % Inner product
+ \IfNoValueTF{#3}
+ {\left\langle{#2}\vert{#2}\right\rangle}
+ { % Two arguments
+ \IfBooleanTF{#1}
+ {\left\langle{#3}\middle\vert{#2}\right\rangle} % Complex conjugate
+ {\left\langle{#2}\middle\vert{#3}\right\rangle} % No star
+ }
+ }
+\DeclareDocumentCommand\braket{}{\innerproduct} % Shorthand for \innerproduct
+\DeclareDocumentCommand\ip{}{\innerproduct} % Shorthand for \innerproduct
+
+\DeclareDocumentCommand\outerproduct{ s m g }{ % Dyad
+ \IfNoValueTF{#3}
+ {\left\lvert{#2}\middle\rangle\!\middle\langle{#2}\right\rvert}
+ { % Two arguments
+ \IfBooleanTF{#1}
+ {\left\lvert{#3}\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{ m g }{ % Expectation value
+ \IfNoValueTF{#2}
+ {\left\langle{#1}\right\rangle}
+ {\left\langle{#2}\middle\vert{#1}\middle\vert{#2}\right\rangle}
+ }
+\DeclareDocumentCommand\expval{}{\expectationvalue} % Shorthand for \expectationvalue
+\DeclareDocumentCommand\ev{}{\expectationvalue} % Shorthand for \expectationvalue
+\DeclareDocumentCommand\vev{ m }{\expectationvalue{#1}{0}} % Vacuum expectation value
+
+\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
+\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