6

The effect I'm trying to achieve is illustrated here:

enter image description here

The blue line indicates the desired alignment axis. Specifically, I want to align the arrows but also have a curly brace to the left of the mapping expressions. I'd like to do this as simply as possible and without manual adjustment.

I've tried a number of things, mostly nesting alignment environments from amsmath. The obvious problem with that approach is this: by encapsulating the ‘maps-to’ expressions in their own box (to embrace them on the left), they become isolated from the outer aligning environment.

I provide this MWE to spare the reader some typing, but with the expectation that little I did is useful toward a solution.

\documentclass{minimal}
\usepackage{mathtools}

\begin{document}

\begin{align*}
  f \colon \{\,\text{long expr}\,\} &\rightarrow B\\
  \left\{
    \begin{aligned}
      a_1 &\mapsto b_1\\
      a_2 &\mapsto b_2
    \end{aligned}
  \right.
\end{align*}

\end{document}
  • 1
    Please, don't use the minimal class for examples. It's for testing package option loading, not for testing documents. – egreg Nov 3 '19 at 17:38
  • Thanks. I'll take that advice moving forward. I seem to remember reading somewhere, perhaps in the LaTeX SE FAQ that minimal and article are preferred. Perhaps I'm mistaken, and it wasn't minimal, but I'm bothered by the ghost of a recollection that there is some class specifically for these types of MWEs. Am I mistaken? – Timtro Nov 4 '19 at 12:54
  • 1
    Unfortunately some sites suggest minimal, but they're wrong; article is better for minimal examples, unless the example uses specific features of another class. – egreg Nov 4 '19 at 14:27
5

enter image description here

Bit of a cheat, but as all the lines have standard height

\documentclass{minimal}
\usepackage{mathtools}

\begin{document}

\begin{align*}
  f \colon \{\,\text{long expr}\,\} &\rightarrow B\\
  \left\{
    \begin{aligned}
      a_1 \\
      a_2 
    \end{aligned}
  \right.&
    \begin{aligned}
      &\mapsto b_1\\
      &\mapsto b_2
    \end{aligned}
\end{align*}

\end{document}
|improve this answer|||||
  • Thanks. Your solution produces nice spacing, and I've happily adopted it. For my own personal satisfaction, I'd love to know what a more general solution looks like, as this one appears to rely on the LHS of all being the same height as the RHS for vertical alignment. – Timtro Nov 4 '19 at 13:05
  • 1
    @Timtro yes alignments (like matrices) use struts so all reasonable sized expressions have the same line height so the left can be XXX and the right ... and they will align, but if you put a big nested fraction on one side you would have to use a \vphantom on the other side to force it to have the same height – David Carlisle Nov 4 '19 at 18:14
4

Here's a solution that uses nested array environments.

enter image description here

\documentclass{article}
\usepackage{newtxtext,newtxmath,array,amsmath}
\begin{document}
\[
\begin{array}{r@{\,}l}
f\colon\{\text{ long expr }\} & \to B \\
\left\{\begin{array}{@{}r@{}} a_1 \\ a_2 \end{array}\right. &
\begin{array}{@{}l@{}} \mapsto b_1 \\ \mapsto b_2\end{array}
\end{array}
\]
\end{document}
|improve this answer|||||
  • 1
    Thanks. Your solution coincides with @David Carlisle's, but his use of the aligned environment produces better spacing than array. That's the only reason I accepted his over yours, but your answer is appreciated all the same. – Timtro Nov 4 '19 at 13:09

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.