# Align subscripts in math mode

Is there an easy way (maybe provided by mathtools that aligns normal subscripts)?

I know that I can do this manually with \vphantom, but I was looking for a better way.

\documentclass{article}

\usepackage{mathtools}

\begin{document}
$T_\theta T_\theta^{-1} = \begin{pmatrix*}[r] \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
$\adjustlimits T_\theta T_\theta^{-1} = \begin{pmatrix*}[r] \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
vphantom does work
$T_\theta^{\vphantom{-1}} T_\theta^{-1} = \begin{pmatrix*}[r] \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
\end{document}


• Have you tried ^{} ? Feb 21 '17 at 7:58
• @daleif Sorry, at first I didn't understand that you intended ^{} instead of ^{\vphantom{-1}}. However, it doesn't work... Feb 21 '17 at 8:10

Try \mathstrut, which is exactly a \vphantom(, and always put subscripts within {}.

Edit: The Master says that \vphantom{-} is conceptually better, I've created a new command for convenience:

\documentclass{article}
\usepackage{mathtools}
\newcommand{\egreg}{\vphantom{-}}% new command for alignment adjustment (you can choose another name, of course!)
\begin{document}
\noindent egreg's version:
$T_{\theta}^{\egreg}\, T_{\theta}^{-1} = \begin{pmatrix*}[r] % I've added also a little space \, \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
\noindent My previous version:
$T_{\theta}^{\mathstrut}\, T_{\theta}^{-1} = \begin{pmatrix*}[r] % I've added also a little space \, \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
\end{document}


• \vphantom{-} would be conceptually better; the minus sign has a depth (equal to +) and is responsible for the fact that ^{} is not enough, which it would be for T_{\theta}^{}T_{\theta}^{2} Feb 21 '17 at 9:51
• @egreg I've added your version, please let me know if I acted correctly! Feb 21 '17 at 10:13

You could adjust the fontdimens accordingly.

\documentclass{article}

\usepackage{mathtools}

\begin{document}
$% Regular subscript positon \fontdimen16\textfont2=\dimexpr \fontdimen17\textfont2 % subscript position in presence of superscript + \fontdimen19\textfont2 % subscript drop in presence of superscript \relax T_\theta T_\theta^{-1} = \begin{pmatrix*}[r] \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
\end{document}


• In the screenshot, the two "\theta" subscripts aren't at the same depth. Is this intentional?
– Mico
Feb 21 '17 at 10:30

Another manual workaround is to separate subscripts from superscripts by using braces:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\noindent
$T_{\theta}\, {T_{\theta}}^{-1} = \begin{pmatrix*}[r] % I've also added also a little space \, \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix*}\begin{pmatrix*}[r] \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta \end{pmatrix*} = \begin{pmatrix}1&0\\0&1\end{pmatrix} = I$
\end{document}


In the final output, the subscripts are aligned. The result is slightly different from the first solution:

• If you go this route, it would probably be a good idea to also (a) snug up the \theta subscript to the letter T, say, T_{\!\theta}, and (b) to snug up the superscript -1 to the material that precedes it, say, {...}{\!-1}`.
– Mico
Feb 21 '17 at 10:25