[Tex/LaTex] Bra Ket notation using only basic packages

amsmathbraket

I am setting questions onto my university's version of Moodle. This accepts LaTeX commands so I can write most maths into a question, however I can only use the preinstalled packages which does not include the braket package, but does include amsmath etc (there isn't exactly a list anywhere).

So is there a way I can write kets when the \ket{} command does not work?

Using the greater than symbol is not really ideal.

Best Answer

It is possible to put the command at the top of the document body, instead of the preamble.

You want the option to specify the size manually, since a bra and its matching ket should always be the same size. If your preamble includes mathtools, you have an easy way to create new paired delimiters. Otherwise, here's something quick and dirty:

\documentclass{book}
\usepackage{amsmath}

\begin{document}

\newcommand\bra[2][]{#1\langle {#2} #1\rvert}
\newcommand\ket[2][]{#1\lvert {#2} #1\rangle}

\begin{align*}
  \bra{x}                   &\; \ket{y} \\
  \bra[\Big]{x^{c^k}_{a_b}} &\; \ket[\Big]{y}
\end{align*}

\end{document}

Bra-ket sample