You could use braket
, where the commands \bra
, \ket
and \braket
have the “automatic extended” variants \Bra
, \Ket
and \Braket
.
Or you can make your own commands. Here each of the \bra
, \ket
and \braket
command accepts an optional size argument (\big
, \Big
, \bigg
or \Bigg
), or a *
for the automatically extensible version.
\documentclass{article}
\usepackage{mathtools,xparse}
\DeclarePairedDelimiterX{\bra}[1]{\langle}{\rvert}{#1\,}
\DeclarePairedDelimiterX{\ket}[1]{\lvert}{\rangle}{\,#1}
\DeclarePairedDelimiterX{\makebraket}[1]{\langle}{\rangle}{#1}
\NewDocumentCommand{\braket}{som}{%
\begingroup\activatebraketbar
\IfBooleanTF{#1}
{\makebraket*{#3}}
{\IfNoValueTF{#2}{\makebraket{#3}}{\makebraket[#2]{#3}}}%
\endgroup
}
\makeatletter
\newcommand{\braketbar}{%
\,\delimsize\vert\@ifnextchar|{\!}{\,}%
}
\makeatother
\newcommand{\activatebraketbar}{%
\begingroup\lccode`~=`|\lowercase{\endgroup\let~}\braketbar
\mathcode`|="8000
}
\begin{document}
\begin{gather*}
\bra{x}+\ket{\psi(t)}+
\bra[\big]{x}+\ket[\big]{\psi(t)}+
\bra[\Big]{x}+\ket[\Big]{\psi(t)} \\
\braket{x|\psi(t)}\quad\braket{x|y|\psi(t)} \\
\braket[\big]{x|\psi(t)}\quad\braket[\big]{x|y|\psi(t)} \\
\braket[\Big]{x|\psi(t)}\quad\braket[\Big]{x|y|\psi(t)} \\
\braket*{\frac{x}{y}|z}+\braket*{x|\frac{a}{b}|z} \\
\braket{a||b}
\end{gather*}
\end{document}

braket
package? – egreg Apr 9 '19 at 17:42