1

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{equation}
\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{equation}
\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}
\end{equation}

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!.

4
  • 2
    Welcome to TeX.SE!
    – Mensch
    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 ?
    – Mensch
    Oct 8, 2021 at 18:44

3 Answers 3

2

I would do it with aligned on two lines:

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

\begin{document}

\begin{equation}
\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{equation}

\end{document}

enter image description here

5
  • 1
    @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!
    – Bernard
    Oct 8, 2021 at 20:10
  • @DavidCarlisle; Lol ; o )
    – Bernard
    Oct 8, 2021 at 20:14
  • @Mico: done, mylord! Sorry for the hassle.
    – Bernard
    Oct 8, 2021 at 21:38
  • +1 for equalizing the sizes of the parentheses. :-)
    – Mico
    Oct 8, 2021 at 22:19
1

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.

enter image description here

\documentclass{article}

%\usepackage[long]{optidef}

\usepackage{amsmath}

\begin{document}
\begin{equation}
\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{equation}
\end{document}
1

Something like this, maybe?

enter image description here

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

\begin{document}
\begin{equation}
\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{equation}
\end{document}

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.