[Tex/LaTex] Stacked symbol doesn’t align properly. Why

alignhorizontal alignmentmath-mode

A modified equals sign used represent use of L'Hopital's Rule isn't aligning well with other equals signs. How would I fix that? I'd prefer to do so without manually fiddling with spaces, if possible.

My code is as follows:

\documentclass{article}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{commath} % Absolute value with /abs{}

\newcommand{\limq}[2]{\displaystyle\lim_{#1 \to #2}}

\begin{document}

\begin{align*}
\limq{n}{\infty} \abs{\frac{a_{n+1}}{a_n}} & = \limq{n}{\infty}\abs{\frac{\frac{(n+1)^2}{2^{n+1}}}{\frac{n^2}{2^n}}} \\
& = \limq{n}{\infty} \abs{\frac{(n^2+2n+1)2^n}{(2n^2)2^n}} \\
& \stackrel{\text{(H)}}{=}  \limq{n}{\infty} \abs{\frac{2n}{4n}} \\
& = 1/2
\end{align*}

\end{document}

The output:

Pesky L'Hopital's Rule

I tried moving the ampersand to the right of each symbol, but that just ended up shifting the (H) slightly to the left of the ordinary equals signs.

Best Answer

This is because (H) is wider than =, causing the entire stacked symbol to be wider than the rest of the alignment characters. you can remove the width of (H) by using \mathclap from mathtools:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\newcommand{\limq}[2]{\lim_{#1 \rightarrow #2}}
\newcommand{\abs}[1]{\left|#1\right|}
\begin{document}

\begin{align*}
    \limq{n}{\infty} \abs{\frac{a_{n+1}}{a_n}} & = \limq{n}{\infty} \abs{\frac{\frac{(n+1)^2}{2^{n+1}}}{\frac{n^2}{2^n}}} \\
                        & = \limq{n}{\infty} \abs{\frac{(n^2+2n+1)2^n}{(2n^2)2^n}} \\
                        & \stackrel{\mathclap{\text{(H)}}}{=}  \limq{n}{\infty} \abs{\frac{2n}{4n}} \\
                        & = 1/2
\end{align*}
\end{document}
Related Question