# Equation numbering overlaps formula when using subequations

I'm trying to create a nicely looking optimization problem in LaTeX using amsmath. Here is a MWE:

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

\begin{subequations}
\begin{alignat}{2}
\text{maximize} \quad & \rlap{some looooooooooooooong objective function of $x,u$ } \\
& \text{constraint 2} & k=0,\ldots N{-}1
\end{alignat}
\end{subequations}
\end{document} I need the \rlap because the 'k=0...' needs to be vertically aligned and I don't want to introduce alignment characters in my objective function.

As you can see, the equation number 1a overlaps the formula in the first line. Is there a clean way to prevent this?

• Maybe this is a naive question but if yout first line doesn't contain any formula as in your example, why would you number it? If it contains a formula, it's up to you to break it with, say, the multlined environment. – Bernard Feb 18 '15 at 17:18
• You're hiding the looooong formula from TeX's computations, so it can't know it's overlong. – egreg Feb 18 '15 at 17:56

I believe this is a solution independent of whether the two constraints have equal size:

\begin{subequations}
\begin{alignat}{3}
\text{maximize} \quad & \text{some looooooo}&&\text{oooooooong objective function of $x,u$} \\
\text{with} \quad & \text{constraint 1} && k=0,\ldots N{-}1 \\
& \text{constraint 2} && k=0,\ldots N{-}1
\end{alignat}
\end{subequations}


with an output: Here is another option without using \rlap, which works as long as the length of constraint 1 is the same than constraint 2.

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

\begin{subequations}
\begin{alignat}{2}
\text{maximize} \quad & \text{some looooooooooooooong objective function of $x,u$} \\ 