-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcommands.tex
41 lines (35 loc) · 1 KB
/
commands.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
\renewcommand{\vec}[1]{\boldsymbol{\mathbf{#1}}}
% BEGIN COMMANDS FROM LATEX FOR PHYSICISTS
% http://www.dfcd.net/articles/latex/latex.html
\newcommand{\ket}[1]{\left| #1 \right\rangle} % for Dirac bras
\newcommand{\bra}[1]{\left\langle #1 \right|} % for Dirac kets
\newcommand{\bket}[1]{\right| #1 \right\rangle} % for Dirac bras
\newcommand{\bbra}[1]{\left\langle #1 \left|} % for Dirac kets
% Added a braket command that takes either two or three arguments, so that \braket{a}{b} = <a|b> and \braket{a}{b}{c} =
% <a|b|c>
\newcount\seccount
\def\braket{%
\seccount0%
\let\go\secnext\go
}
\def\secnext#1{%
\def\last{\left\langle #1}%
\futurelet\next\secparse
}
\def\secparse{%
\ifx\next\bgroup
\let\go\secparseii
\else
\let\go\seclast
\fi
\go
}
\def\secparseii#1{%
\ifnum\seccount>0| \fi
\advance\seccount1\relax
\last
\def\last{#1}%
\futurelet\next\secparse
}
\def\seclast{ \ifnum\seccount>0{} | \fi\last \right\rangle}%
% END COMMANDS FROM