2
\[\setlength\arraycolsep{1pt}
\begin{array}{rcccl}
    &S &= &R_0 + R_1 + R_2 + R_3 + R_4 &+ \\
    &  &~ &R_5 + R_6 + R_7 + R_8 + R_9 &~ \\
    &  &= &0   +  1  +  2  +  3  +  4  &~ \\
    &  &~ &5   +  6  +  7  +  8  +  9  &= 45 < 100
\end{array}
\]

generates:

enter image description here

with = signs being correctly aligned. How to make + symbols aligned? Adding extra & signs in front of +:

&S &= &R_0 &+ R_1 + R_2 + R_3 + R_4 &+ \\
&  &~ &R_5 &+ R_6 + R_7 + R_8 + R_9 &~ \\
&  &= &0   &+  1  +  2  +  3  +  4  &~ \\
&  &~ &5   &+  6  +  7  +  8  +  9  &= 45 < 100

gives compile error. Why?

1
  • You have five columns defined (rcccl) but use five &. Add an additional column in the definition of \begin{array}.
    – Skillmon
    Commented Mar 22, 2017 at 17:39

1 Answer 1

5

You can keep using an array environment, but I'd set up a special column type for the binary and relational operators, using the \newcolumntype directive.

enter image description here

\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>{{}}c<{{}}}
\begin{document}
\[
\setlength\arraycolsep{0pt}
\begin{array}{ *{7}{cC} c }
 S &=& R_0&+& R_1&+& R_2&+& R_3&+& R_4 &+  \\
   & & R_5&+& R_6&+& R_7&+& R_8&+& R_9 &   \\
   &=& 0  &+& 1  &+& 2  &+& 3  &+& 4   &+  \\ 
   & & 5  &+& 6  &+& 7  &+& 8  &+& 9   &=& 45&<& 100
\end{array}
\]
\end{document}

You must log in to answer this question.

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