5

I have four lines inside an equation environment, and I'd like to align the first with the third and the second with the fourth. This is what I got so far:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\newcommand{\R}{\mathbb R}
\newcommand{\Rn}{\R^n}

\begin{document}
    \[
        \begin{aligned}
            &\begin{aligned}
                (+)~:&~\ \Rn \times \Rn \longrightarrow \Rn\\
                     &~\ (a_1,\,\dots,\,a_n),\,(b_1,\,\dots,\,b_n) \longmapsto
                    (a_1 + b_1,\,\dots,\,a_n + b_n)
            \end{aligned}\\
            &\begin{aligned}
                (\star)~:&~\ \R \times \Rn \longrightarrow \Rn\\
                         &~\ \lambda,\,(a_1,\,\dots,\,a_n) \longmapsto
                    (\lambda a_1,\,\dots,\,\lambda a_n)
            \end{aligned}
        \end{aligned}
    \]
\end{document}

This is the result:
result

However, I'd like to align the colons instead of the start of the line. Is that possible? I tried to use a tabular environment, but the result was terrible.

4

A single align* (or aligned inside equation*) will suffice.

Note that all of your added spacing commands ~ and \, are wrong. Also \longrightarrow and \longmapsto are, in my opinion, too prominent and add nothing to clarity.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\newcommand{\R}{\mathbb{R}}
\newcommand{\Rn}{\R^n}

\begin{document}

\begin{align*}
(+)\colon& \Rn \times \Rn \rightarrow \Rn \\
         & \bigl( (a_1,\dots,a_n),(b_1,\dots,b_n) \bigr) \mapsto (a_1 + b_1,\dots,a_n + b_n)
\\
(\star)\colon& \R \times \Rn \rightarrow \Rn \\
             & \bigl( \lambda,(a_1,\dots,a_n) \bigr) \mapsto (\lambda a_1,\dots,\lambda a_n)
\end{align*}

\end{document}

enter image description here

A possible refinement is instead adding some vertical space between the two map definitions:

\begin{align*}
(+)\colon& \Rn \times \Rn \rightarrow \Rn \\
         & \bigl( (a_1,\dots,a_n),(b_1,\dots,b_n) \bigr) \mapsto (a_1 + b_1,\dots,a_n + b_n)
\\[1ex]
(\star)\colon& \R \times \Rn \rightarrow \Rn \\
             & \bigl( \lambda,(a_1,\dots,a_n) \bigr) \mapsto (\lambda a_1,\dots,\lambda a_n)
\end{align*}

enter image description here

  • Semantics and clarity bonus: refine \rightarrow to \to. – wchargin Mar 8 '15 at 23:58
  • @WChargin Well, you won't find \to in the LaTeX manual. – egreg Mar 8 '15 at 23:59
  • What do you mean? Even in plain TeX, \show\to gives \to=\mathchar"3221 for me and gives the right output. What am I missing? – wchargin Mar 9 '15 at 0:02
  • @WChargin The command \to, like \gets, is defined, but not documented in the manual. Similarly, \implies, \impliedby and \iff are defined by amsmath, but not documented. – egreg Mar 9 '15 at 0:04
  • Interesting—is there any reason why they aren't documented? e.g., are they deprecated, or is there any reason why we shouldn't use them? – wchargin Mar 9 '15 at 0:07
3

It seems to me that a single alignat* suffices in this case

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\newcommand{\R}{\mathbb R}
\newcommand{\Rn}{\R^n}

\begin{document}
\begin{alignat*}{3}
        &(+)&\colon &\Rn \times \Rn \longrightarrow \Rn\\
        &   &       &(a_1,\dots,a_n),\,(b_1,\dots,b_n) \longmapsto
                     (a_1 + b_1,\dots,a_n + b_n)\\[1ex]
        &(\star)&\colon &\R \times \Rn \longrightarrow \Rn\\
        &       &       &\lambda,(a_1,\dots,a_n) \longmapsto
                         (\lambda a_1,\dots,\lambda a_n)
\end{alignat*}
\end{document}

enter image description here

or a single align*

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\newcommand{\R}{\mathbb R}
\newcommand{\Rn}{\R^n}

\begin{document}
\begin{align*}
        (+)\colon &\Rn \times \Rn \longrightarrow \Rn\\
                  &(a_1,\dots,a_n),(b_1,\dots,b_n) \longmapsto
                   (a_1 + b_1,\dots,a_n + b_n)\\[1ex]
        (\star)\colon &\R \times \Rn \longrightarrow \Rn\\
                      &\lambda,(a_1,\dots,a_n) \longmapsto
                        (\lambda a_1,\dots,\lambda a_n)
\end{align*}
\end{document}

enter image description here

depending on your preferences. Note that \colon instead of : gives the right spacing in these cases.

  • although the baselines are actually equidistant, the lack of anything below the baseline in the first and third lines results in the second and third lines looking like they're closer together. a little extra space between them wouldn't hurt. – barbara beeton Mar 8 '15 at 13:34
  • @barbara you're right, I didn't pay attention to this. Added some spacing. – karlkoeller Mar 8 '15 at 19:59
1

Ithink the horizontal spacing around the colons is too large, and the two groups of equations should be vertically separated. I propose this, simplifying the code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\newcommand{\R}{\mathbb R}
\newcommand{\Rn}{\R^n}

\begin{document}

        \begin{align*}
            (+)&:\begin{aligned}[t]
                &\Rn \times \Rn \longrightarrow \Rn\\[-0.5ex]
                     &(a_1,\,\dots,\,a_n),\,(b_1,\,\dots,\,b_n) \longmapsto
                    (a_1 + b_1,\,\dots,\,a_n + b_n)
            \end{aligned}\\[1ex]
            (\star)&:\begin{aligned}[t]
&\R \times \Rn \longrightarrow \Rn\\[-0.5ex]
                         &(\lambda,\,(a_1,\,\dots,\,a_n)) \longmapsto
                    (\lambda a_1,\,\dots,\,\lambda a_n)
            \end{aligned}
        \end{align*}

\end{document} 

enter image description here

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.