# Equation number in long equation

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):

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\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{document}


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:

• I wound up using this solution instead of egreg's, since I don't need to finetune the \raisetag height. 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

You can use the \raisetag feature:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\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{document}


• that is a great idea. now how to make it so the tag ends up exactly in the middle of the split, where it would have been if the equation were not too long? i'd like to automate this behavior into a macro. May 15 at 15:55
• @peter If the tag doesn’t fit, how can you make it? May 15 at 19:35
• it's the same situation we see here. there actually is room(blank space), but equation cannot see it because its within the split block. May 16 at 20:05

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{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{document}


• 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.) 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? Mar 27 '16 at 23:53
• I specified the formula as much as possible. Mar 28 '16 at 0:05
• Please have a look at a new solution. Mar 28 '16 at 0:20