Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}) or hit Ctrl+K. –  Claudio Fiandrino Apr 30 at 6:53
    
Thank you! I was trying to figure out how to do that. –  triested Apr 30 at 6:54
2  
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Apr 30 at 6:55

2 Answers 2

up vote 18 down vote accepted

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}
share|improve this answer
    
Thanks for the incredibly quick answer! It worked beautifully. –  triested Apr 30 at 7:05
1  
@triested In general it is not considered good taste to add comments like this to equal signs etc. it is better to add it to the text, or add a proper comment via \intertext, –  daleif Apr 30 at 8:01
1  
@ daleif I'll keep that in mind. My current professor asks for this abbreviated (H) notation, but then, we usually turn in handwritten work, not formal write-ups. –  triested Apr 30 at 8:21
    
@triested, we see that a lot. People don't really think about what they are doing and end up giving their students bad habits. It is even worse when students start writing things like (2.3) above an = to explain what happens. It is a better exercise to learn to write this is a much more reader friendly form. –  daleif Apr 30 at 9:49

A simpler solution is to use a personal command such as

\newcommand{\Heq}{\overset{\hidewidth(\mathrm{H})\hidewidth}{=}}

With \hidewidth we insert a very large negative space; in this case it's equivalent to \hspace{-1000pt}, so the superscript will take no space. Using \mathrm is more efficient than \text for a single letter.

This requires just amsmath. However, I'd like to suggest also a couple of other improvements.

  • For \abs it's better to use \DeclarePairedDelimiter, that's more powerful (and correct) than always using \left| and \right|).

  • I don't think that \limq{n}{\infty} is better than \lim_{n\to\infty}, but it's just my opinion.

  • This is also a case where smashed fractions are not nice.

\documentclass{article}
\usepackage{mathtools} % also loads amsmath

% this requires mathtools
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
% this requirese amsmath for \overset (better than \stackrel)
\newcommand{\Heq}{\overset{\hidewidth(\mathrm{H})\hidewidth}{=}}

\begin{document}

\begin{align*}
\lim_{n\to\infty} \abs*{\frac{a_{n+1}}{a_n}}
  & =    \lim_{n\to\infty} \abs*{\frac{\dfrac{(n+1)^2}{2^{n+1}}}{\dfrac{n^2}{2^n}}} \\
  & =    \lim_{n\to\infty} \abs*{\frac{(n^2+2n+1)2^n}{(2n^2)2^n}} \\
  & \Heq \lim_{n\to\infty} \abs*{\frac{2n}{4n}} \\
  & = \frac{1}{2}
\end{align*}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.