5

How do I get the second alignment marker at the first minus sign in the first line of the following alignat environment? I would like to use it to write the second expression on two lines, aligning the plus sign preceding the sigma notation.

\documentclass{amsart}
\usepackage{amsmath}


\begin{document}


\begin{alignat*}{2}
f(x_{4}) &= (x_{4} &&- x_{1}) + (x_{4} - x_{2}) + (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{4}) \\
&= \bigl[(x_{4} - x_{3}) + (x_{3} - x_{1})\bigr] + \bigl[(x_{4} - x_{3}) + (x_{3} - x_{2})\bigr] + (x_{4} - x_{3}) \\
&&+ \sum_{i=5}^{8} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr] \\
&= (x_{3} - x_{1}) + (x_{3} - x_{2}) - (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{3}) \\
&< (x_{3} - x_{1}) + (x_{3} - x_{2}) + \sum_{i=4}^{8} (x_{i} - x_{3}) \\
&< \sum_{i=1}^{8} \vert x_{i} - x_{3} \vert \\
&= f(x_{3}) ,
\end{alignat*}

\end{document}
5
  • Use \lvert and \rvert, rather than \vert.
    – egreg
    Apr 26, 2017 at 22:25
  • What is the advantage of using \lvert and \rvert to \vert? Apr 27, 2017 at 0:25
  • I am replying to another comment you made to gernot. I don't want to separate my first line into two separate lines. The display for the first two expressions for f(x_{4}) would not be appealing. Apr 27, 2017 at 0:30
  • since you're using amsart, there's no need to add amsmath -- that's automatically loaded. Apr 27, 2017 at 2:46
  • @AgalnamedDesire They are proper opening and closing symbols, whereas \vert is an ordinary one.
    – egreg
    Apr 27, 2017 at 7:59

4 Answers 4

3

I would align the first - in the second expression with the + in +(x_4 - x_3) using aligned inside the align* environment.

\documentclass{amsart}
\usepackage{amsmath}
\begin{document}

\begin{align*}
f(x_{4}) &= (x_{4}-x_{1}) + (x_{4} - x_{2}) + (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{4}) \\
&=\begin{aligned}[t]\bigl[(x_{4} &- x_{3}) + (x_{3} - x_{1})\bigr] + \bigl[(x_{4} - x_{3}) + (x_{3} - x_{2})\bigr] \\
&+(x_{4} - x_{3})+\sum_{i=5}^{8} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr] \end{aligned} \\
&= (x_{3} - x_{1}) + (x_{3} - x_{2}) - (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{3}) \\
&< (x_{3} - x_{1}) + (x_{3} - x_{2}) + \sum_{i=4}^{8} (x_{i} - x_{3}) \\
&< \sum_{i=1}^{8} \vert x_{i} - x_{3} \vert \\
&= f(x_{3}) ,
\end{align*}

\end{document}

enter image description here

1
2

An alignment like this?

enter image description here

\documentclass{amsart}

\begin{document}

\begin{align*}
f(x_4) &= (x_4 - x_1) + (x_4 - x_2) + (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_4) \\
&= \bigl[(x_4 - x_3) + (x_3 - x_1)\bigr] + \bigl[(x_4 - x_3) + (x_3 - x_2)\bigr] + (x_4 - x_3) \\
&\quad+ \sum_{i=5}^8 \bigl[(x_i - x_3) - (x_4 - x_3)\bigr] \\
&= (x_3 - x_1) + (x_3 - x_2) - (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_3) \\
&< (x_3 - x_1) + (x_3 - x_2) + \sum_{i=4}^8 (x_i - x_3) \\
&< \sum_{i=1}^8 \vert x_i - x_3 \vert \\
&= f(x_3)
\end{align*}

\end{document}

Or as suggested by Thruston in the comments, with a \qquad instead of the \quad.

enter image description here


Or as suggested by Enrico, with (x_4-x_3) also moved to the next row.

enter image description here

\documentclass{amsart}
\begin{document}

\begin{align*}
f(x_4) &= (x_4 - x_1) + (x_4 - x_2) + (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_4) \\
&= \bigl[(x_4 - x_3) + (x_3 - x_1)\bigr] + \bigl[(x_4 - x_3) + (x_3 - x_2)\bigr] \\
&\quad + (x_4 - x_3)+ \sum_{i=5}^8 \bigl[(x_i - x_3) - (x_4 - x_3)\bigr] \\
&= (x_3 - x_1) + (x_3 - x_2) - (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_3) \\
&< (x_3 - x_1) + (x_3 - x_2) + \sum_{i=4}^8 (x_i - x_3) \\
&< \sum_{i=1}^8 \vert x_i - x_3 \vert \\
&= f(x_3) ,
\end{align*}

\end{document}

Another try after clarifications in the comments:

enter image description here

\documentclass{amsart}
\begin{document}

\begin{align*}
f(x_4) &= (x_4 - x_1) + (x_4 - x_2) + (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_4) \\
&= \bigl[(x_4 - x_3) + (x_3 - x_1)\bigr] + \bigl[(x_4 - x_3) + (x_3 - x_2)\bigr]+ (x_4 - x_3) \\
&\phantom{{}=(x_4} + \sum_{i=5}^8 \bigl[(x_i - x_3) - (x_4 - x_3)\bigr] \\
&= (x_3 - x_1) + (x_3 - x_2) - (x_4 - x_3) + \sum_{i=5}^8 (x_i - x_3) \\
&< (x_3 - x_1) + (x_3 - x_2) + \sum_{i=4}^8 (x_i - x_3) \\
&< \sum_{i=1}^8 \lvert x_i - x_3 \rvert \\
&= f(x_3)
\end{align*}

\end{document}
7
  • You could make that a \qquad to get a bit of indentation before the carried over \sum
    – Thruston
    Apr 26, 2017 at 21:26
  • @Thruston Thanks for the suggestion, I've added a note.
    – gernot
    Apr 26, 2017 at 21:31
  • After seeing the result, I'd move (x_4-x_3) to the next line: it's left unchanged in the next step, so it belongs with the summation (and this makes the first line shorter).
    – egreg
    Apr 26, 2017 at 22:23
  • @egreg I've added your version.
    – gernot
    Apr 26, 2017 at 22:35
  • @gernot I wanted the second line to be broken into two lines - the plus sign preceding \sum_{i=5}^{8} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr] aligned with the minus sign in (x_{4} - x_{1}) from the first line. Apr 27, 2017 at 0:23
0

Do you mean this?

% arara: pdflatex

\documentclass{amsart}

\begin{document}
\begin{align*}
    f(x_{4})&= (x_{4} - x_{1}) + (x_{4} - x_{2}) + (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{4}) \\
            &= \bigl[(x_{4} - x_{3}) + (x_{3} - x_{1})\bigr] + \bigl[(x_{4} - x_{3}) + (x_{3} - x_{2})\bigr] + (x_{4} - x_{3}) \\
            &\hphantom{{}= (x_{4}} + \mathop{\smash[b]{\sum_{i=5}^{8}}} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr] \\
            &= (x_{3} - x_{1}) + (x_{3} - x_{2}) - (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{3}) \\
            &< (x_{3} - x_{1}) + (x_{3} - x_{2}) + \mathop{\smash{\sum_{i=4}^{8}}} (x_{i} - x_{3}) \\
            &< \sum_{i=1}^{8} \lvert x_{i} - x_{3} \rvert \\
            &= f(x_{3}),
\end{align*}
\end{document}

I would not recomment that, though, as I can not see any reason on why to align to this point. But this looks like what you have tried to do above. I would tend to align to the first, or better second, or even better third sign from the second line. Or to use some \quad or alike, as recommended above, in order to stay consistent over all your formulae.

1
  • I was trying a similar code. It is close to what I want, but you can see that the + preceding \sum_{i=5}^{8} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr] in the second line of the code in my post is not aligned with the - in (x_{4} - x_{1}) from the first line. Apr 27, 2017 at 0:41
0

I would use multlined from mathtools package:

enter image description here

\documentclass{amsart}
\usepackage{mathtools}

\begin{document}
    \begin{align*}
f(x_{4})
    & = (x_{4} - x_{1}) + (x_{4} - x_{2}) + (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{4}) \\
    & = \!\begin{multlined}[t][0.5\linewidth]
        \bigl[(x_{4} - x_{3}) + (x_{3} - x_{1})\bigr]  
        + \bigl[(x_{4} - x_{3}) + (x_{3} - x_{2})\bigr] \\
        + (x_{4} - x_{3})
        + \sum_{i=5}^{8} \bigl[(x_{i} - x_{3}) - (x_{4} - x_{3})\bigr]
        \end{multlined}   \\
    & = (x_{3} - x_{1}) + (x_{3} - x_{2}) - (x_{4} - x_{3}) + \sum_{i=5}^{8} (x_{i} - x_{3}) \\
    & < (x_{3} - x_{1}) + (x_{3} - x_{2}) + \sum_{i=4}^{8} (x_{i} - x_{3}) \\
    & < \sum_{i=1}^{8} \vert x_{i} - x_{3} \vert \\
    & = f(x_{3}) ,
    \end{align*}
\end{document}

You must log in to answer this question.

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