I'm writing a mathematical (linear optimization) problem in Latex and I'm having trouble delimiting all the lines (I'm using $$something$$) so that the formulation looks balanced.

enter image description here

which I've written like:

$$\text{Minimize} \quad V_m(w,lh)=T(wl_{(bottom)}+2lh_{(sides)}+2wh) \quad \text{(tavoitefunktio)}$$<br>
$$\text{subject to} \quad 
    lwh=V \\
    l \geq 0\\
    w \geq 0\\
\end{cases} \text{(rajoitteet)}$$<br>
$$\text{suunnittelumuuttujat} \: w,l \text{ ja } h.$$.

What should I do to get every line (Minimize, subject to, suunnittelumuuttujat) to start from the same position?

  • 6
    You shouldn't use $$, see tex.stackexchange.com/questions/503/why-is-preferable-to. And check the documentation of amsmath for multiline math environments. – Ulrike Fischer Aug 10 '16 at 12:50
  • Of course Ulrike means the multline (no "i") environment ;) – Stefan Pinnow Aug 10 '16 at 12:57
  • 1
    @StefanPinnow - Actually, I think Ulrike was making a generic reference to amsmath's multiline math environments -- one of which, it so happens, is called multline. :-) – Mico Aug 10 '16 at 13:10
  • @Mico, of course. Missed the "s" in environments ;) Sorry for the confusion. – Stefan Pinnow Aug 10 '16 at 19:24

I would do it with an alignat environment. Incidentally, asking for a new line in the cases environment is done with a double backslash, not a single one. Also, the indices in the first row are text, hence they should be introduced by the \text command, otherwise you have math italic (not even text italic), with math spacing between letters.




 & \textrm{Minimize} & & V_m(w,lh)=T(wl_\textrm{(bottom)}+2lh_\textrm{(sides)}+2wh) \quad \textrm{(tavoitefunktio)}\\[1ex]
 & \textrm{subject to} \quad & & \begin{cases} lwh=V \\ h=H\\ l \geq 0\\ w \geq 0 \end{cases} \text{(rajoitteet)}\\
 & \rlap{uunnittelumuuttujat : $ w,l $ ja $ h $.} \end{alignat*}


enter image description here


Since it looks like you're loading the amsmath package (based on the use of the cases environment and the \text macro), I suggest you use a gather* environment and a couple of \intertext directives to structure the material. To pretty-print the material to the right of the curly brace, I further suggest you use an array environment instead of a cases environment.

enter image description here


V_m(w,lh)=T\bigl(wl_{\textrm{(bottom)}}+2lh_{\textrm{(sides)}}+2wh\bigr) \quad \text{(tavoitefunktio)}\\
\intertext{subject to}
\left\{ \begin{array}{r @{} >{{}}c<{{}} @{} l}
    lwh &  = & V \\
    h   &  = & H\\
    l   &\geq& 0\\
    w   &\geq& 0\\
\end{array} \right. 
\text{suunnittelumuuttujat} \quad w,l \text{ ja } h.


Use the align environment

& \text{Minimize} \quad V_m(w,lh)=T(wl_\textrm{(bottom)}+2lh_\textrm{(sides)} \quad \text{(tavoitefunktio)}
&\text{subject to} \quad \begin{cases} lwh=V \ h=H\ l \geq 0\ w \geq 0\ \end{cases} \text{(rajoitteet)}$$
&\text{suunnittelumuuttujat} : w,l \text{ ja } h.

If you want to remove the equation numbers use the align* environment. Note that the lines are aligned to the &, so you can play with that if you want.


  • True. Already corrected. – D G Aug 11 '16 at 10:59

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.