4

I have a long equation that goes over two lines. The first line takes up the full horizontal space and the second line is indented. I use amsmath's split for that.

My problem is that the equation number jumps into the row below the second line. I want it right next to the second line. How can I achieve this?

My formula looks like this (I cannot post the exact same formula, but since I actually use KOMA-Script anyway, I think it is not dependent on the exact spacing): enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{equation}
    \begin{split}
    \max \Biggl\{\sum_{(a,b)\in MW} a_ba_{bc} &- \sum_{(a,b)\in M} a_ba_{bc} - \sum_{a\in A} \sum_{(a,b)\in M} \sum_{(a,b)\in M} a_ba_{bc} - \zeta \sum_{(a,b)\in MW} a_{bc} \\
    &- \sum_{(a,b)\in M} a_ba_{bc} - \sum_{(a,b)\in M} a_b (a^+_b+a^-_b) \Biggr\}
    \end{split}
    \end{equation}
\end{document}
3

I think it can be useful to suggest a trick which is more general, in the sense that it can be applied also in situations where it is not that easy to reformat the equation to fit.

The equation number is moved down because the split environment produces a single block that has the width of the longest of its lines, thus the surrounding equation environment treats it as a single line that, in this case, is too wide to fit together with the number and hence moves it down. However, we see that the number would fit in the second line, if only this line could be regarded as an equation in itself.

Now, from a logical standpoint, the markup in the question is correct, and, generally speaking, is the only one that should be employed: there is one equation, to which the number refers as a whole, and this equation consists of two lines. However, in a case like this, a little trick based on visual markup can solve the problem: specify two equations instead of one, by using an align environment, each, in theory, with its own number; but suppress the number on the first line by means of a \notag command placed at the end of the first “equation”. Here’s the code:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}
\begin{align}
    \max \Biggl\{\sum_{(a,b)\in MW} a_ba_{bc}
        &- \sum_{(a,b)\in M} a_ba_{bc}
            - \sum_{a\in A} \sum_{(a,b)\in M} \sum_{(a,b)\in M} a_ba_{bc}
            - \zeta \sum_{(a,b)\in MW} a_{bc} \notag \\ % \notag suppresses the
                                                        % equation number
        &- \sum_{(a,b)\in M} a_ba_{bc}
            - \sum_{(a,b)\in M} a_b (a^+_b+a^-_b) \Biggr\}
\end{align}
\end{document}

And here’s the output it yields:

Output of the above code

  • I wound up using this solution instead of egreg's, since I don't need to finetune the \raisetag height. – KarlKlammer Mar 28 '16 at 10:00
  • @KarlKlammer: Well, I wrote this answer exactly in order to suggest a “quick-n-dirty” solution, but keep in mind that the solution “in good style” is egreg’s/ – GuM Mar 28 '16 at 12:11
2

You can use the \raisetag feature:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{split}
\max \biggl\{ \sum_{(a,b)\in MW} a_ba_{bc}
  &- \sum_{(a,b)\in M} a_ba_{bc}
   - \sum_{a\in A} \sum_{(a,b)\in M} \sum_{(a,b)\in M} a_ba_{bc}
   - \zeta \sum_{(a,b)\in MW} a_{bc} \\
  &- \sum_{(a,b)\in M} a_ba_{bc}
   - \sum_{(a,b)\in M} a_b (a^+_b+a^-_b)
\biggr\}
\end{split}
\raisetag{2\normalbaselineskip}
\end{equation}
\end{document}

enter image description here

1

A solution is to use the \smashoperator command, from mathtools. Don't load amsmath in that case, since mathtools does it for you. Note you also can use the multline environment, which places the equation number differently.

\documentclass{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
  \begin{split}
    \max \Biggl\{\smashoperator[r]{\sum_{(a,b) \in MW}} a_ba_{bc} &- \smashoperator{\sum_{(a,b) \in M}} a_ba_{bc} - \sum_{a \in A} \sum_{(a,b) \in M} \smashoperator[r]{\sum_{(a,b) \in M}} a_ba_{bc} - \zeta \smashoperator{\sum_{(a,b) \in MW}} a_{bc} \\
    &- \smashoperator{\sum_{(a,b) \in M}} a_ba_{bc} -\smashoperator{ \sum_{(a,b) \in M}} a_b (a^+_b+a^-_b) \Biggr\}
  \end{split}
\end{equation}

\end{document} 

enter image description here

  • The thing is: I obviously don't have an equation with just ones. ;-) And breaking my equation at that specific place also makes sense contentwise. (The equation is an extension of an older equation, and the first line contains the old equation and the second line the new one.) – KarlKlammer Mar 27 '16 at 22:57
  • I could only provide an answer in function of what you've provided – which means a more or less general answer. Could you post your equation? – Bernard Mar 27 '16 at 23:53
  • I specified the formula as much as possible. – KarlKlammer Mar 28 '16 at 0:05
  • Please have a look at a new solution. – Bernard Mar 28 '16 at 0:20

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.