4

I would like to layout an equation in the following form:

x=5+3-4
     -4+3+5
 =8-8+8
 =8

In words: I want to split the equation at two points; one where the first equation splits over two splits and the minus signs align, and the other where the equal signs align.

I've tried using \equation{} and \split{}, either with two separate ones or trying to nest them, but nothing appears to work! Any ideas?

5

I can use an \alignCenterstack here because the column alignment is rlrl. If it were other, I could always use a \tabularCenterstack.

\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\[
\TABbinary
\setstackaligngap{0pt}
\alignCenterstack{
 x=& 5 + 3 &-& 4\\
   &       &-& 4 + 3 + 5\\
   & 8 - 8 &+& 8\\
  =& 8     & &
}
\]
\end{document}

enter image description here

By default in tabstackengine, one can think of & tabs as being "replaced" with {}&, so that all cells have an empty group on the right. This helps spacing if relations and binary relations are placed at the right side of a cell and unary relations are placed at the left. In this case, however, I need the + and - to behave as binary in column 3, so \TABbinary instead "replaces" the & with {}&{}, so that all cell boundaries are padded with an empty group.

The \setstackaligngap{} sets the horizontal gap introduced after left-aligned columns of the align-stack, which here I want as 0pt.

The tabular stack equivalent is

\documentclass{article}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\[
\TABbinary
\setstacktabulargap{0pt}
\tabularCenterstack{rll}{
 x=& 5 + 3 &- 4\\
   &       &- 4 + 3 + 5\\
   & 8 - 8 &+ 8\\
  =& 8     & 
}
\]
\end{document}
8

You can use standard amsmath tools:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{split}
x&=\begin{aligned}[t]
   5+3&-4 \\
      &-4+3+5
   \end{aligned} \\
 &=8-8+8 \\
 &=8
\end{split}
\end{equation}

\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.