# Splitting a Minimization Equation into More than 2 Lines

I'm working with a particularly hairy minimization problem that I would like to split into at least three lines. Here's some sample code so you can follow me.

\documentclass{article}

\usepackage[long]{optidef}

\usepackage{amsmath}

\begin{document}
$$\begin{split} &\min_{\mathbf{\widetilde H}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \\ &{\left[ \sum\nolimits_{(i,t) \in \mathcal{O}} \frac{1}{|\mathcal{O}|}(Y_{it} -L_{it}-\sum_{p=1}^{P} \sum_{q=1}^{Q}X_{ip}H_{pq}Z_{qt}-\gamma_{i} - \delta_{i} - V_{it}\beta)^2\right]} \end{split}$$
\end{document}


So, what we have here is a decent start. And perhaps I'd accept it, if it were the end of the equation. The full equation is

&\min_{\mathbf{\widetilde H}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \\ &{\left[ \sum\nolimits_{(i,t) \in \mathcal{O}}
\frac{1}
{|\mathcal{O}|}(Y_{it} -L_{it}-\sum_{p=1}^{P} \sum_{q=1}^{Q}X_{ip}H_{pq}Z_{qt}
-\gamma_{i} - \delta_{i} - V_{it}\beta)^2
+ \lambda_{L}\|\mathbf{L}\|_{\ast}+ \lambda_{H}\|\mathbf{H}\|_{1,e} \right]}
\end{split}



The code still compiles, but it still looks awkward. What if I wanted to split it into three lines? Or, what about 5? My next attempt was

&\min_{\mathbf{\widetilde H}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \\ &{\left[ \sum\nolimits_{(i,t) \in \mathcal{O}} \frac{1}{|\mathcal{O}|} \\ &(Y_{it} -L_{it}-\sum_{p=1}^{P} \sum_{q=1}^{Q}X_{ip}H_{pq}Z_{qt}-\gamma_{i} - \delta_{i} - V_{it}\beta)^2+ \lambda_{L}\|\mathbf{L}\|_{\ast}+ \lambda_{H}\|\mathbf{H}\|_{1,e} \right]}


but when I try this, I get ! Missing } inserted. <inserted text> }

What am I missing here? I've tried nesting split and optidef, as well as optidef and multline, but I haven't been able to split this into more than two lines. I know there must be a simple solution to this, but I'm new to LaTex and have never needed to split before. Thanks so much!.

• Welcome to TeX.SE! Oct 8, 2021 at 17:51
• @Mensch happy to be here. Any idea how I can split this equation further? Oct 8, 2021 at 18:13
• you are not using optidef at all, just loading the package. for split like all ams alignments you can have as many lines as you wish, ending each with \\  You have not said what errors you got, perhaps the issue is the spurious {....} that you have around the terms after & which will prevent any line breaking? Oct 8, 2021 at 18:32
• Did you saw the related questions: tex.stackexchange.com/q/383572/16550 ? Oct 8, 2021 at 18:44

I would do it with aligned on two lines:

\documentclass{article}
\usepackage[long]{optidef}
\usepackage{mathtools}

\begin{document}

\begin{aligned} \min_{\mathbf{\widetilde H}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \Biggl[ \sum_{(i,t) \in \mathcal{O}} \frac{1} {|\mathcal{O}|}\biggl(Y_{it} -L_{it}-\sum_{p=1}^{P} \sum_{q=1}^{Q}X_{ip}H_{pq}Z_{qt} -\gamma_{i} - \delta_{i} - V_{it} \beta\biggr)^{\!2} \\[-2ex] {} + \lambda_{L}\|\mathbf{L}\|_{\ast}+ \lambda_{H}\|\mathbf{H}\|_{1,e} \Biggr] \end{aligned}

\end{document}


• @Mico to make it different to mine:-) Oct 8, 2021 at 20:05
• @Mico: I tried both sizes to check which was preferable, and it seems I had a copy-paste accident . As often, I forgot to check. I'll fix it within seconds. Thanks for warning me! Oct 8, 2021 at 20:10
• @DavidCarlisle; Lol ; o ) Oct 8, 2021 at 20:14
• @Mico: done, mylord! Sorry for the hassle. Oct 8, 2021 at 21:38
• +1 for equalizing the sizes of the parentheses. :-)
– Mico
Oct 8, 2021 at 22:19

You don't give much indication of what you want the result to be, here is one possible layout, which like your example code just uses amsmath and not the optidef package.

\documentclass{article}

%\usepackage[long]{optidef}

\usepackage{amsmath}

\begin{document}
\min_{\mathbf{\widetilde H}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \left[ \begin{aligned} & \sum_{(i,t) \in \mathcal{O}} \frac{1} {|\mathcal{O}|}\bigl(Y_{it} -L_{it}-\sum_{p=1}^{P} \sum_{q=1}^{Q}X_{ip}H_{pq}Z_{qt} -\gamma_{i} - \delta_{i} - V_{it}\beta\bigr)^2\\ &+ \lambda_{L}\|\mathbf{L}\|_{\ast}+ \lambda_{H}\|\mathbf{H}\|_{1,e} \end{aligned} \right]
\end{document}


Something like this, maybe?

\documentclass{article}
\usepackage{amsmath} % for 'split' env.

\begin{document}
$$\begin{split} \min_{\widetilde{\mathbf{H}}^\ast, \mathbf{L}^\ast, \delta^\ast,\gamma^\ast } \biggl[ \, \sum_{(i,t) \in \mathcal{O}}\frac{1}{|\mathcal{O}|} \biggl( &Y_{it} -L_{it} - \sum_{p=1}^{P} \sum_{q=1}^{Q} X_{ip}H_{pq}Z_{qt} -\gamma_{i} \\ & -\delta_{i} - V_{it}\beta \biggr)^{\!\!2} + \lambda_{L}\|\mathbf{L}\|_{\ast}+ \lambda_{H}\|\mathbf{H}\|_{1,e} \, \biggr] \end{split}$$
\end{document}