1

I want to prettyprint a multi-line equation. My first thought was to use split inside equation, but it only supports a single insertion point. I tried align, but it right adjusts instead of left adjusting to the alignment point. I considered tabular, but that requires manually calculating the indentations. Other solutions print a number for each line or are not allowed in an equation environment. The effect I'm looking for is something like

A =
    {
      {B,C,D},
      {C,D,E}
    }

Thanks.

These test cases of alignat have two problems

  1. I get multiple equation numbers for a single equation.

  2. I get right alignment unless I add unnatural alignment points

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat} {6}
D = & \{
\\
&& A
\\
&&& \{
\\
&&&& B
\\
&&&&& \{
\\
&&&&&& C
\\
&&&&& \}
\\
&&& \}
\\
& \}
\end{alignat}

\begin{alignat} {2}
D = &
  (
\\
&&
    \{
\\
&&&
      A, B, C
\\
&&
    \},
\\
&&
    \{
\\
&&&
      D, E, F
\\
&&
    \}
\\
&
  )
\end{alignat}

\begin{alignat} {6}
D = &
  (
\\
&&&
    \{
\\
&&&&
      A, B, C
\\
&&&
    \},
\\
&&&
    \{
\\
&&&&
      D, E, F
\\
&&&
    \}
\\
&
  )
\end{alignat}
\end{document}

What I'm looking for is something that is either permitted inside an equation or that generates a single equation number, and that will left adjust at every ampersand rather than at every other ampersand.

As for array, I get unacceptably long indentation if I use, e.g.,

\begin{equation}
\begin{array} {llll}
D \defeq & \bigl \{ 
\\
&& A very long variable name
\\
&& \{
\\
&&& \funcname{i} \maps \set{e^1} \hookrightarrow U^1,
\phi^1 \maps U^1 \toiso V^1,
\funcname{f}_1 \maps  V^1 \to \seqname{C}^2,
\\
 && \}.
\\
&& \{
\\ 
&&& \funcname{f}_0 \maps  U^1 \to U^2,
\phi^2 \maps U^2 \toiso V^2
\\
 && \}
\\
& \bigr \}
\end{array}
\end{equation}
4
  • align right adjust if there's no &, which are used to mark the alignment points.
    – Bernard
    Mar 12, 2018 at 22:16
  • There were ampersands.
    – shmuel
    Mar 12, 2018 at 22:36
  • @shmuel align (like all the ams alignments, including alignat as I used below) uses left alignment and right alignment alternating at each & Mar 12, 2018 at 22:58
  • Or rather right and left??
    – Bernard
    Mar 12, 2018 at 22:59

2 Answers 2

3

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
  A={}&\{\\
  &\quad\{B,C,D\},\\
  &\quad\{C,D,E\}\\
  &\}
\end{alignat*}

or with a number
\begin{equation}
\begin{alignedat}{2}
  A={}&\{\\
  &\quad\{B,C,D\},\\
  &\quad\{C,D,E\}\\
  &\}
\end{alignedat}
\end{equation}
\end{document}
1
  • I've run some test cases and there are still issues. Please see my edit. Thanks.
    – shmuel
    Mar 13, 2018 at 19:11
2

Just use array:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
A=
\begin{array}[t]{@{}ll@{}}
\{ \\
& \{B,C,D\}, \\
& \{C,D,E\} \\
\}
\end{array}
\]

\[
A=
\begin{array}[t]{@{}l@{}l@{}}
\{ \\
& \{B,C,D\}, \\
& \{C,D,E\} \\
\}
\end{array}
\]

\end{document}

enter image description here

2
  • I've run some test cases and there are still issues. Please see my edit. Thanks.
    – shmuel
    Mar 13, 2018 at 19:11
  • @shmuel Not possible. Errors for undefined control sequences.
    – egreg
    Mar 13, 2018 at 20:38

You must log in to answer this question.

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