5

I am new to Latex. I am aiming to define a function appropriately using latex, that is to first define the sets, e.g. $f:X \to Y$ and then how the elements map into the image, i.e. $x \to f(x)$. I would like both rows to align well. Below is the code and problem I encountered:

\begin{alignat*}{2}
X \colon T &\rightarrow {}&& \mathcal{D} \\
           t&\mapsto \lim\limits_{n \to \infty}\sum_{\substack{i = 0,...,m}}(f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))\\
           \end{alignat*}

enter image description here

I want the "D" to be just in line with the start of the limit in the "mapsto" row. Could anyone show me how to do this?

3
  • Welcome! Use align (not alginat). \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} X \colon T &\rightarrow \mathcal{D} \\ t&\mapsto \lim\limits_{n \to \infty} \sum_{\substack{i =0,\dots,m}} (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n})) \end{align*} \end{document}
    – user194703
    Mar 18, 2020 at 19:53
  • (Not tested.) @Schrödinger'scat has given a good suggestion. align is the way to go. I'm just going to verbally suggest adjustments. The && you used is what is shifting the \mathcal{D} way off to the right, so get rid of them. But since there is a limit on \lim, the "l" may be a bit to the right of the "D". Rather than trying to shift the \lim expression, if it's needed add a small space before the "D". \, should be more than enough; if it's too much, then \mspace{2mu} should work. (mu is a "math" unit, and a thin space = 3mu.) Mar 18, 2020 at 20:04
  • To explain what happened: the aligning environments line everything up on the & symbols. Since the first row has more & than the second, the extra & come after everything in the second row, and then the \mathcal{D} comes after that.
    – Teepeemm
    Mar 19, 2020 at 4:57

4 Answers 4

8

I want the \mathcal{D} to be just in line with the start of the limit in the \mapsto row.

I would use a top-aligned aligned (pun intended...) environment:

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{mathtools}  % for "\smashoperator" macro
\begin{document}
\[
X \colon \begin{aligned}[t]
          &T\rightarrow \mathcal{D} \\
          &t\mapsto \lim_{n \to \infty}
             \smashoperator[r]{\sum_{i = 0,\dots,m}}
             (f(t_{i,n})-f(t_{i-1,n}))\cdot
             (f(t_{i,n})-f(t_{i-1,n}))
         \end{aligned}          
\]
\end{document}

Addendum: Here's a solution that implements @barbarabeeton's suggestion that the \rightarrow and \mapsto symbols should be aligned as well.

enter image description here

\documentclass{article}
\usepackage{array,mathtools}
\begin{document}
\[
\setlength\arraycolsep{0pt}
X \colon \begin{array}[t]{ r >{{}}c<{{}} >{\displaystyle}l }
          T &\rightarrow &\mathcal{D} \\[0.5ex]
          t & \mapsto    & 
             \smashoperator[l]{\lim_{n \to \infty}}
             \smashoperator[r]{\sum_{i = 0,\dots,m}}
             \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
             \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
         \end{array}          
\]
\end{document}
5
  • Nice, but really, the arrows should also be aligned. Mar 18, 2020 at 20:09
  • @barbarabeeton - That's not what the OP wrote (but I agree with you anyway!).
    – Mico
    Mar 18, 2020 at 20:11
  • Not what s/he wrote, but what it looks like in the visual. Mar 18, 2020 at 20:13
  • @barbarabeeton - Please see the addendum I just posted, with a solution that follows your guidelines.
    – Mico
    Mar 18, 2020 at 20:20
  • 1
    Yes. That does it. Mar 18, 2020 at 20:41
7

Using Vincent's idea of an array, but with some more tricks to keep barbara beeton happy:

\documentclass{article}
\usepackage{amsmath,mathtools,calc}
\usepackage{array}

\begin{document}

\[
\begin{array}{
  @{}
  r
  @{}
  c
  @{}
  >{\displaystyle{}}l
  @{}
}
X \colon{} & T & \to \mathop{\mathmakebox[\widthof{$\lim$}][l]{\mathcal{D}}}_{\hphantom{n\to\infty}} \\[1ex]
           & t & \mapsto 
               \lim_{n \to \infty}\sum_{i=0,\dots,m} \mspace{-9mu}
                  \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)\cdot\bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
\end{array}
\]

\end{document}

enter image description here

On the other hand, I'd simply do

We can define the map $X\colon T\to\mathcal{D}$ by
\begin{equation*}
X(t)=\lim_{n \to \infty}\sum_{i=0,\dots,m} \mspace{-9mu}
      \bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)\cdot\bigl(f(t_{i,n})-f(t_{i-1,n})\bigr)
\end{equation*}

enter image description here

1
  • 4
    +1 for the last advice!
    – pschulz
    Mar 19, 2020 at 14:57
4

After seeing the other answers... I really would like to reiterate my comment and use align here, with all the explanations being contained in barbara's comment (sorry, Mico ;-).

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
X \colon T &\rightarrow \mathcal{D} \\
           t&\mapsto \lim\limits_{n \to \infty}
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}

\emph{Maybe} one could use \verb|\mathclap| to align the $\mathcal{D}$ with
$\lim$ (but I am not coninced).
\begin{align*}
X \colon T &\rightarrow \mathcal{D} \\
           t&\mapsto \lim\limits_{\mathclap{n \to \infty}}\;
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}
Or, in the spirit of barbara beeton's comment.
\begin{align*}
X \colon T &\rightarrow\setbox0\hbox{$\lim\limits_{n \to \infty}$}%
\setbox1\hbox{$\lim$}%
\hspace{\the\dimexpr0.5\wd0-0.5\wd1}\mathcal{D} \\
           t&\mapsto \lim\limits_{n \to \infty}\;
            \sum_{\substack{i =0,\dots,m}}
            (f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}))
\end{align*}
\end{document}

enter image description here

2
  • Looks good. Thanks. (I like the last example best; the gap after the "T" balances the space before the "D", even though that's largely a consequence of shape. To my eyes, the lower limit in the second example looks a bit squeezed next to the arrow.) Mar 18, 2020 at 20:39
  • @barbarabeeton I agree, which is why I wrote that I am not convinced about that one. Even the simpleminded align looks good IMHO,
    – user194703
    Mar 18, 2020 at 20:44
2

I like to use the array environment for these definitions, since the syntax is rather visual.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{array}{r@{\ }c@{\ }c@{\ }l}
X \colon & T & \to     & \mathcal{D} \\
         & t & \mapsto & \displaystyle \smashoperator[l]{\lim_{n \to \infty}} \sum_{i=0,...,m} \bigl( f(t_{i,n})-f(t_{i-1,n})\cdot(f(t_{i,n})-f(t_{i-1,n}) \bigr)
\end{array}
\]
\end{document}

This way everything is aligned correctly. If the \lim_{n\to\infty} appears to be too close to the \mapsto symbol, some spacing could be added (for example with \,) before both the \mathcal{D} and the \lim_{n\to\infty} commands. Of course if this spacing is added but not on both lines, the alignment will be lost.

3
  • This is technically correct, but the "D" isn't lined up with "lim", See my comment on the question. Mar 18, 2020 at 20:08
  • To line up the \mathcal{D} and lim particles, you could load the mathtools package and replace \lim_{n \to \infty} with \smashoperator[l]{\lim_{n \to \infty}}.
    – Mico
    Mar 18, 2020 at 20:10
  • 1
    Thank you both for your suggestions! I corrected the alignment of the \mathcal{D} and the \lim symbols.
    – Vincent
    Mar 18, 2020 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .