I am trying to align several limit expressions at varying x-values. It seems that align treats the "limit" portion together with its subscript as an entire object, then aligns these limits, which produces expressions aligned at "x" rather than "lim":



    &\lim_{x \to -2} x =&\\
    &\lim_{x \to -1} x =&\\
    &\lim_{\phantom{-}x \to 0} x =&\\
    &\lim_{\phantom{-}x \to 1} x =&\\
    &\lim_{\phantom{-}x \to 2} x =&\\
    &\lim_{\phantom{-}x \to \infty} x =&\\
    &\lim_{x \to -\infty} x =&

I've tried to place the align marker in other places, and also fudge it using phantoms, (which isn't nice but much better than without). Is there a way around this so that each expression aligns at "l" in "lim"?

enter image description here


Many thanks for posting a full MWE.

Rather than redefine \lim directly to handle your special alignment objective, it is preferable to define a new command called, say, \mylim. Modifying directly the ways that LaTeX use to place the argument of a "math operator" such as \lim may end up breaking all kinds of things...

The \mylim macro defined below takes two arguments: the item that the limit is taken over, and the subscript argument of \lim. Note that the arguments are encased in curly braces -- no subscript symbol is used. In the example code below, the outer array environment and the vertical bar are used merely to illustrate that "lim" and the subscript argument are both aligned flush-left.

enter image description here

     \lim #1 \\[-1ex] \scriptstyle #2 
\[ \begin{array}{|@{}l}
     \mylim{x}{x \to -2}  =\\
     \mylim{x}{x \to -1}  =\\
     \mylim{x}{x \to 0}  =\\
     \mylim{x}{x \to 1}  =\\
     \mylim{x}{x \to 2}  =\\
     \mylim{y}{y \to \infty}  =\\
     \mylim{k}{k \to -\infty}  =

Addendum to address the OP's follow-up question: If the objective is to make LaTeX ignore -- for the purpose of horizontal alignment, that is -- whatever may be in the subscript below "lim", while still centering that material below "lim", you could make use of the comment provided by @daleif and employ the \smashoperator macro of the mathtools package:

\smashoperator{\lim_{x\to-2}} f(x)

If you have a lot of these expressions and wish to economize on typing (and reduce the number of typos...), you could define a shortcut macro, e.g.,


and then type \nlim{x\to-2} f(x). Note that if the material in the subscript is sufficiently wide, it will "protrude" into the space to the left and to right of "lim". I think two-sided protrusion is what you're after. However, if you want the subscript material to protrude only on the left but not on the right, use the option [l], i.e., write

\smashoperator[l]{\lim{k\to-\infty}} k

enter image description here

\usepackage{mathtools} % for \smashoperator macro
\[ \begin{array}{|@{}l}
     \nlim{x \to -2} x =\\
     \nlim{x \to -1} x =\\
     \nlim{x \to 0} x =\\
     \nlim{x \to 1} x =\\
     \nlim{x \to 2} x =\\
     \nlim{y \to \infty} y =\\
     \nlim{k \to -\infty} k =

A comment on the aesthetics produced by \mylim and \nlim: If you're going to make the effort to align various rows on the string "lim", you shouldn't risk marring the overall look by letting lim's subscript material protrude to the left of the string. In my opinion, then, you should go with \mylim rather than with \nlim to achieve your alignment objective.

  • Or use \smashoperator from mathtools, though not 100% what the OP asks for – daleif Aug 28 '14 at 6:07
  • This is wonderful. Thank you! So my next question would be whether it is possible to center the subscripts, as latex does, yet still align the "lim"? – Abbas Jaffary Aug 28 '14 at 6:11
  • @AbbasJaffary - I've written an addendum to address your follow-up comment. – Mico Aug 28 '14 at 7:01
  • Thank you again. Along with Steven's solution proposed below, I would agree that the subscripts aligned at the left look best. But, it is very nice to have these various options! – Abbas Jaffary Oct 1 '14 at 16:53
  • @Mico I get a situation with $\mylim{\dfrac{x+3}{x^2 - x - m}}{x \to \pm\infty}$ Can you help me? – minhthien_2016 Apr 24 '18 at 8:40

This approach, using stacks, permits an optional argument that specifies the gap (default 3pt) between the "lim" line and the subscript, as demonstrated on the lim y line.

In this case \mylim (column 1) aligns the argument to the left, while \myclim (column 2) aligns the subscript to the center, while keeping the overall alignment with the word "lim". Finally \myclimB (column 3) accounts for the subscript width when placing the argument to the limit.

REVISED SOLUTION to align not only "lim"s but also equals and what follows.

 \def\stackalignment{l}\ensurestackMath{\stackunder[#1]{\lim #2}{\scriptstyle #3}}%
 \def\stackalignment{c}\ensurestackMath{\stackunder[#1]{\lim #2}{%
  \makebox[0pt]{$\scriptstyle #3$}}}%
 \setbox1=\hbox{$\scriptstyle #3$}%
  \scriptstyle #3}}}#2%
     \mylim{x}{x \to -2}  &=&0\\
     \mylim{x}{x \to -1}  &=&0\\
     \mylim{x}{x \to 0}  &=&0\\
     \mylim{x}{x \to 1}  &=&0\\
     \mylim{x}{x \to 2}  &=&0\\
     \mylim[4pt]{y}{y \to \infty}  &=&0\\
     \mylim{k}{k \to -\infty}  &=&0
     \myclim{x}{x \to -2}  &=&0\\
     \myclim{x}{x \to -1}  &=&0\\
     \myclim{x}{x \to 0}  &=&0\\
     \myclim{x}{x \to 1}  &=&0\\
     \myclim{x}{x \to 2}  &=&0\\
     \myclim[4pt]{y}{y \to \infty}  &=&0\\
     \myclim{k}{k \to -\infty}  &=&0
     \myclimB{x}{x \to -2}  &=&0\\
     \myclimB{x}{x \to -1}  &=&0\\
     \myclimB{x}{x \to 0}  &=&0\\
     \myclimB{x}{x \to 1}  &=&0\\
     \myclimB{x}{x \to 2}  &=&0\\
     \myclimB[4pt]{y}{y \to \infty}  &=&0\\
     \myclimB{k}{k \to -\infty}  &=&0

enter image description here

  • I would say that the optimal solution would keep the same spacing and relative placements as \lim_{k\to-\infty}k while aligning at the \lim. Would that be achievable using your approach? – Bruno Le Floch Aug 28 '14 at 15:34
  • @BrunoLeFloch I am not sure I understand exactly what you are asking. Adding words like "horizontal" and "vertical" to your question might help, as well as describing "alignment" relative to what. – Steven B. Segletes Aug 28 '14 at 16:36
  • @BrunoLeFloch Does my revised solution (aligning the equal signs and what follows, too) have anything to do with your question? – Steven B. Segletes Aug 28 '14 at 23:32
  • @Mico No slight taken. I bow to your superior intellect. – Steven B. Segletes Aug 29 '14 at 9:44
  • @StevenB.Segletes - I'm blushing furiously! :-) – Mico Aug 29 '14 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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