
%% Operators
\newcommand{\tr}[1]{%
    \mathchoice%
    {\operatorname{Tr}\left[#1\right]}%
    {\operatorname{Tr}[#1]}%
    {}{}%
}
\newcommand{\trr}[1]{\operatorname{Tr}_{r}\left[#1\right]}
\newcommand{\Tr}[2]{\operatorname{Tr}_{#2}\left[#1\right]}
\newcommand{\EW}[1]{\left< #1 \right>}
\newcommand{\rank}[1]{\operatorname{rank}\left(#1\right)}
\newcommand{\corank}[1]{\operatorname{corank}\left(#1\right)}
\newcommand{\diag}[1]{\operatorname{diag}\left(#1\right)}
\newcommand{\on}[1]{\operatorname{#1}}
\newcommand{\spn}[1]{\operatorname{span}\left\{#1\right\}}
\newcommand{\spnsmall}[1]{\operatorname{span}\{#1\}}
\DeclareMathOperator{\sign}{sign}
\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}
\newcommand{\floor}[1]{\lfloor #1 \rfloor}
\newcommand{\atan}{\operatorname{atan}}
\newcommand{\NO}[1]{\vcentcolon\mathrel{#1}\vcentcolon}
\providecommand{\vcentcolon}{\mathrel{\mathop{:}}}
\newcommand{\qmark}{\textsuperscript{?}}
\newcommand{\bigslant}[2]{{\raisebox{.2em}{$#1$}\left/\raisebox{-.2em}{$#2$}\right.}}
\newcommand{\Det}[1]{\det\left(#1\right)}
\newcommand{\Pf}[1]{\operatorname{Pf}\left[#1\right]}
\newcommand{\no}[1]{{:\mathrel{\mspace{1mu}#1\mspace{1mu}}:}}
\newcommand{\lno}{:\mspace{1mu}}
\newcommand{\rno}{\mspace{1mu}:}

%% Quantum Mechanics
\newcommand{\bra}[1]{\langle{#1}|}
\newcommand{\bbra}[1]{\langle\langle{#1}|}
\newcommand{\Bra}{\bra}
\newcommand{\ket}[1]{|{#1}\rangle}
\newcommand{\kket}[1]{|{#1}\rangle\rangle}
\newcommand{\Ket}{\ket}
\newcommand{\braket}[2]{\langle #1 | #2 \rangle}
\newcommand{\bbrakket}[2]{\langle\langle #1 | #2 \rangle\rangle}
\newcommand{\ketbra}[2]{\ket{#1}\bra{#2}}
\newcommand{\braOPket}[3]{\langle #1|\hat{#2}| #3\rangle}
\newcommand{\braOPvket}[3]{\langle #1|\hat{\vec{#2}}| #3\rangle}
\newcommand{\braopket}[3]{\langle #1| #2 | #3\rangle}
\newcommand{\EV}[1]{\langle #1 \rangle}
\newcommand{\rrangle}{\rangle\rangle}
\newcommand{\llangle}{\langle\langle}
\newcommand{\com}[2]{%
    \mathchoice%
    {\left[#1,#2\right]}%
    {[#1,#2]}%
    {}{}%
}
\newcommand{\acom}[2]{%
    \mathchoice%
    {\left\{#1,#2\right\}}%
    {\{#1,#2\}}%
    {}{}%
}

\newenvironment{manualdiagram}{%
\tikzpicture[baseline={([yshift=-.5ex]current bounding box.center)}]\feynman%
}{%
\endfeynman\endtikzpicture%
}

%% Landau O-notation
\newcommand{\bigO}[1]{\mathcal{O}{\left(#1\right)}}
\newcommand\smallO[1]{
    \mathchoice
    {{\scriptstyle\mathcal{O}}}% \displaystyle
    {{\scriptstyle\mathcal{O}}}% \textstyle
    {{\scriptscriptstyle\mathcal{O}}}% \scriptstyle
    {\scalebox{.7}{$\scriptscriptstyle\mathcal{O}$}}%\scriptscriptstyle
    {\left(#1\right)}}

%% Abbreviations
\newcommand{\hc}{\textnormal{h.c.}}
\newcommand{\const}{{\textnormal{const}}}
\newcommand{\h}{\frac{1}{2}}
\newcommand{\ph}{\frac{\pi}{2}}

%% Neighbours
\newcommand{\NN}[2]{\langle#1,#2\rangle}
\newcommand{\NNN}[2]{\llangle#1,#2\rrangle}

%% Modifiers
\newcommand{\wh}{\widehat}
\newcommand{\wt}{\widetilde}
\newcommand{\ora}{\overrightarrow}
\newcommand{\mf}[1]{\mathfrak{#1}}
% \renewcommand{\vec}[1]{\mathbf{#1}}
\newcommand{\ol}{\overline}
% \renewcommand{\vec}[1]{\bm{#1}}
\newcommand{\bvec}[1]{\bm{#1}}
\newcommand{\uvec}[1]{\mathrm{\textbf{#1}}}
\newcommand{\sub}[1]{\mathrm{#1}}
\newcommand{\ssub}[1]{{\footnotesize\mathrm{#1}}}

%% Relations
\newcommand{\est}{\stackrel{\wedge}{=}}

%% Labels
\newcommand{\rs}[1]{\textnormal{\tiny #1}}
\providecommand{\rm}[1]{\textnormal{#1}}

%% Integrals & Differentials
\newcommand{\intdx}{\int\d x}
% \newcommand{\ddx}[1]{\frac{\mathrm d #1}{\mathrm dx}}
% \newcommand{\ddt}[1]{\frac{\mathrm d #1}{\mathrm dt}}
\newcommand{\ddx}{\frac{\mathrm d}{\mathrm dx}}
\newcommand{\ddt}{\frac{\mathrm d}{\mathrm dt}}
\newcommand{\intdt}{\int\d t}
\renewcommand{\d}[1]{\mathop{}\!d#1\,}
\newcommand{\di}{\mathrm{d}}
\newcommand{\FD}[1]{\mathop{}\!\mathcal{D}#1\,}
\newcommand{\dd}[2]{\mathop{}\!d^{#1}\!#2\,}
\newcommand{\ddp}[2]{\frac{\dd{#1}{#2}}{(2\pi)^#1}}
\newcommand{\ds}{\mathrm{d}s}
\newcommand{\du}{\mathrm{d}u}
\newcommand{\diff}[2]{\frac{\mathrm d #1}{\mathrm d #2}}
\newcommand{\pdiff}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\vdiff}[2]{\frac{\delta #1}{\delta #2}}
\newcommand{\pmu}{\partial_\mu}
\newcommand{\pt}{\partial_t}
\newcommand{\px}{\partial_x}
\newcommand{\py}{\partial_y}
\newcommand{\pz}{\partial_z}
\newcommand{\Pmu}{\partial^\mu}
\newcommand{\del}{\partial}

%% Sets
\newcommand{\emptys}{\{\,\}}
\newcommand{\iv}[1]{\left[#1\right]\,}
\newcommand{\smin}[1]{#1_\text{min}}
\newcommand{\smax}[1]{#1_\text{max}}
\newcommand{\rangeLr}[2]{\left[#1,#2\right)}
\newcommand{\rangeLR}[2]{\left[#1,#2\right]}
\newcommand{\rangelR}[2]{\left(#1,#2\right]}
\newcommand{\rangelr}[2]{\left(#1,#2\right)}
\newcommand{\GF}{\ensuremath{\mathbb{F}_2}}
\newcommand{\integers}{\mathbb{Z}}
\newcommand{\naturals}{\mathbb{N}}
\newcommand{\reals}{\mathbb{R}}
\newcommand{\complex}{\mathbb{C}}
\newcommand{\alg}[1]{\mathfrak{#1}}
\newcommand{\group}[1]{\textnormal{#1}}
\newcommand{\LG}{\group{O}(1,3)}
\newcommand{\POLG}{\group{SO}^+(1,3)}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}

%% Special fonts
\renewcommand{\O}{\mathcal{O}}
\renewcommand{\S}{\mathcal{S}}
\newcommand{\D}{\mathcal{D}}
\newcommand{\K}{\mathcal{K}}
\newcommand{\X}{\mathcal{X}}
\renewcommand{\H}{\mathcal{H}}
\renewcommand{\L}{\mathcal{L}}
\newcommand{\V}{\mathcal{V}}
\newcommand{\I}{\mathcal{I}}
\renewcommand{\P}{\mathcal{P}}
\newcommand{\F}{\mathcal{F}}
\newcommand{\T}{\mathcal{T}}
\newcommand{\C}{\mathcal{C}}
\newcommand{\U}{\mathcal{U}}
\newcommand{\fI}{\mathfrak{I}}
\newcommand{\R}{\mathcal{R}}
\newcommand{\J}{\mathcal{J}}
\newcommand{\A}{\mathcal{A}}
\newcommand{\B}{\mathcal{B}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\cmark}{\text{\ding{51}}}%
\newcommand{\xmark}{\text{\ding{55}}}%

%% Shortcuts
\newcommand{\hlf}{\frac{1}{2}}
\newcommand{\vep}{\varepsilon}
\newcommand{\p}{\phi}
\newcommand{\f}{\Psi}
\newcommand{\vev}[1]{\bra{\Omega}#1\ket{\Omega}}
\newcommand{\mel}[3]{\bra{#1}#2\ket{#3}}
\newcommand{\omp}[1]{\omega_{\vec #1}}
\newcommand{\ap}[1]{a_{\vec #1}}
\newcommand{\aps}[2]{a_{\vec #1}^{#2}}
\newcommand{\adps}[2]{a_{\vec #1}^{#2\dag}}
\newcommand{\adp}[1]{a^\dag_{\vec #1}}
\newcommand{\bp}[1]{b_{\vec #1}}
\newcommand{\bps}[2]{b_{\vec #1}^{#2}}
\newcommand{\bdps}[2]{b_{\vec #1}^{#2\dag}}
\newcommand{\bdp}[1]{b^\dag_{\vec #1}}
\newcommand{\vbs}[2]{\ol v^{#1}(#2)}
\newcommand{\vs}[2]{v^{#1}(#2)}
\newcommand{\ubs}[2]{\ol u^{#1}(#2)}
\newcommand{\us}[2]{u^{#1}(#2)}
\newcommand{\Ep}[1]{E_{\vec #1}}
\newcommand{\g}{\gamma}
\newcommand{\bispi}[2]{\begin{pmatrix}#1\\#2\end{pmatrix}}
\newcommand{\rowspi}[2]{\begin{pmatrix}#1 & #2\end{pmatrix}}
\newcommand{\trispi}[3]{\begin{pmatrix}#1\\#2\\#3\end{pmatrix}}
\newcommand{\bicase}[2]{\begin{Bmatrix}#1\\#2\end{Bmatrix}}
\newcommand{\Id}{\mathds{1}}
\newcommand{\gmu}{\gamma^\mu}
\newcommand{\df}[2]{\delta^{(#1)}\left(#2\right)}
\newcommand{\dfs}[1]{\delta\left(#1\right)}
\newcommand{\pip}[1]{\phi^+_I(#1)}
\newcommand{\pim}[1]{\phi^-_I(#1)}
\newcommand{\pol}{\epsilon}
\newcommand{\PP}[2]{\frac{-ig_{#2}}{#1^2+i\vep}}
\newcommand{\PPm}[3]{\frac{-ig_{#3}}{(#1-#2)^2+i\vep}}
\newcommand{\PPp}[3]{\frac{-ig_{#3}}{(#1+#2)^2+i\vep}}
\newcommand{\DP}[1]{\frac{i(\slashed{#1}+m)}{#1^2-m^2+i\vep}}
\newcommand{\DPm}[2]{\frac{i(\slashed{#1}-\slashed{#2}+m)}{(#1-#2)^2-m^2+i\vep}}
\newcommand{\DPp}[2]{\frac{i(\slashed{#1}+\slashed{#2}+m)}{(#1+#2)^2-m^2+i\vep}}
\newcommand{\Log}[1]{\log\left(#1\right)}
\newcommand{\Exp}[1]{\exp\left(#1\right)}

%% Complexity classes
\newcommand{\CClass}[1]{\texttt{#1}}
\newcommand{\SClass}[1]{\textbf{\textsf{#1}}}

\newcommand{\cm}{\bm{\mathfrak{c}}}
\newcommand{\emode}{\bm{\mathfrak{e}}}

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=0.5pt] (char) {#1};}}
