# How to typeset this such that they look symmetrical?

I am trying to type

$$\left|\uparrow\right\rangle_A{}_A\left\langle\uparrow\right|$$


But the As in the subscript are not symmetrical. One is upper and another is lower. Is there a way to type this more elegantly?

• Unrelated, but $...$ is preferred over : tex.stackexchange.com/q/503/107497 May 25, 2021 at 11:38
• Why not just use \rangle_{AA}? May 25, 2021 at 17:50
• @md2perpe sometimes I would need them separately with some other stuff between. In such case the asymmetrical typesetting looks weird May 26, 2021 at 2:27

One way is to use \DeclarePairedDelimiter from mathtools package (an extension of amsmath):

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter{\ket}{\lvert}{\rangle}
\DeclarePairedDelimiter{\bra}{\langle}{\rvert}

\begin{document}
$\left|\uparrow\right\rangle_A{}_A\left\langle\uparrow\right|$

$\ket{\uparrow}_{A} {}_{A}\bra{\uparrow}$
\end{document}


## Edit

For fractions or tall expressions as leftaroundabout said in the comments, mathtools provides two options: An optional parameter \ket[size command]{something} and a starred version \ket*{something} that is preceded by \left and \right so they "grow" to match the content inside.

There are more additions to de delimiters, for example \DeclarePairedDelimiterX to be able to use arguments in the definition, as a \newcommand. Some examples from the manual:

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter{\ket}{\lvert}{\rangle}
\DeclarePairedDelimiter{\bra}{\langle}{\rvert}
\DeclarePairedDelimiterX\braket[3]{\langle}{\rangle}%
{#1\,\delimsize\vert\,\mathopen{}#2\,\delimsize\vert\,\mathopen{}#3}

\begin{document}
$\bra[\Big]{\frac{a}{b}}, \quad \ket*{\frac{a}{b}}, \quad \braket*{B}{\sum_{k} f_k}{C}$
\end{document}


For the subindex in this taller delimiters it is still needed \prescript as in leftaroundabout answer.

• Perfect! Thanks! May 25, 2021 at 0:36
• Nice, except that the names are exactly backward from the same constructions provided by the braket package. May 25, 2021 at 0:48
• @barbarabeeton Whoops! My bad, I didn’t remember how is Dirac notation. In a minute I will do the correction. Thanks for pointing that mistake May 25, 2021 at 2:01
• Can this be made to work also with tall expressions in the bra/kets? E.g. \ket{\frac{\uparrow}{\downarrow}}_{A} doesn't scale the delimiters like \left| ... \right\rangle would. May 25, 2021 at 10:57
\documentclass{article}
\usepackage{mathtools}

\begin{document}


% I would use \prescript:

$\left|\uparrow\right\rangle_A\prescript{}{A}{\left\langle\uparrow\right|}$


% Note that this also works when the kets get taller:

$\left|\frac{\uparrow}{\downarrow}\right\rangle_A \prescript{}{A}{\left\langle\frac{\uparrow}{\downarrow}\right|}$


% Shame about the (lack of) kerning. We might hack it to be a bit more snug with some manual spacing adjustments:

$\left|\frac{\uparrow}{\downarrow}\right\rangle_{\!\!A} \: \prescript{}{A}{\!\left\langle\frac{\uparrow}{\downarrow}\right|}$


\end{document}