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}
  • align right adjust if there's no &, which are used to mark the alignment points. – Bernard Mar 12 '18 at 22:16
  • There were ampersands. – shmuel Mar 12 '18 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 & – David Carlisle Mar 12 '18 at 22:58
  • Or rather right and left?? – Bernard Mar 12 '18 at 22:59
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}
  • I've run some test cases and there are still issues. Please see my edit. Thanks. – shmuel Mar 13 '18 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

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

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.