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.

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":

\documentclass[reqno,12pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\addtolength{\jot}{3em}

\begin{document}

\begin{flalign*}
    &\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 =&
\end{flalign*}
\end{document}

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

share|improve this question

2 Answers 2

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

\documentclass[12pt]{article}
\newcommand\mylim[2]{%
    \begin{array}[t]{@{}l@{}}
     \lim #1 \\[-1ex] \scriptstyle #2 
    \end{array}
}
\begin{document}
\[ \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}  =
   \end{array} 
\]
\end{document}

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.,

\newcommand\nlim[1]{\smashoperator{\lim_{#1}}}

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

\documentclass[12pt]{article}
\usepackage{mathtools} % for \smashoperator macro
\newcommand\nlim[1]{\smashoperator{\lim_{#1}}}
\begin{document}
\[ \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 =
   \end{array} 
\]
\end{document}

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.

share|improve this answer
    
Or use \smashoperator from mathtools, though not 100% what the OP asks for –  daleif Aug 28 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 at 6:11
    
@AbbasJaffary - I've written an addendum to address your follow-up comment. –  Mico Aug 28 at 7:01

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.

\documentclass[12pt]{article}
\usepackage{tabstackengine}
\stackMath
\newcommand\mylim[3][3pt]{%
 \def\stackalignment{l}\ensurestackMath{\stackunder[#1]{\lim #2}{\scriptstyle #3}}%
}
\newcommand\myclim[3][3pt]{%
 \def\stackalignment{c}\ensurestackMath{\stackunder[#1]{\lim #2}{%
  \makebox[0pt]{$\scriptstyle #3$}}}%
}
\newcommand\myclimB[3][3pt]{%
 \setbox0=\hbox{$\lim$}%
 \setbox1=\hbox{$\scriptstyle #3$}%
 \ifdim\wd1>\wd0\kern.5\wd0\kern-.5\wd1\fi%
 \def\stackalignment{c}\mathop{\ensurestackMath{\stackunder[#1]{\lim}{%
  \scriptstyle #3}}}#2%
}
\begin{document}
\[
  \setstackgap{L}{2\baselineskip}\def\stackalignment{l}\TABbinary
     \tabbedCenterstack{
     \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
}
\quad...\quad
\tabbedCenterstack{
     \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
}
\quad...\quad
\tabbedCenterstack{
     \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
}
\]
\end{document}

enter image description here

share|improve this answer
    
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 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 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 at 23:32
    
@Mico No slight taken. I bow to your superior intellect. –  Steven B. Segletes Aug 29 at 9:44
    
@StevenB.Segletes - I'm blushing furiously! :-) –  Mico Aug 29 at 9:45

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.