Cases with long math equation

by JKHA   Last Updated August 14, 2019 13:23 PM

What would be the best formatting of the following align and cases where the middle case has a very long math equation.

\begin{align*}
      V_{ijk}& = \begin{cases}
          \dfrac{y_u+y_l}2 - \dfrac{x_u+x_l}2,& \text{if }x_u < y_l\\[15pt]
          \dfrac1C \bigg[\dfrac{x_u^3-y_l^3}{6}+\dfrac{y_l^2+x_u^2}{2}x_l + (x_u-y_l)\dfrac{x_l^2}{2}+ \dfrac{y_u^2-x_u^2}{2}(x_u-x_l)& - (y_u-x_u)\dfrac{x_u^2-x_l^2}{2} \bigg],
          \\[12pt]& \text{if }x_u\in\left[y_l,y_u\right]\\[15pt]
          \dfrac1{x_u-x_l}\bigg[\dfrac{(y_u+y_l)^2}6 - \dfrac{y_u+y_l}2 x_l + \dfrac{x_l^2}2\bigg],& \text{otherwise}
      \end{cases}
\end{align*}

The main default of this current workaround which is nearly ok, is that there is an extra space before -(y_u-x_u) that is annoying. Note that I put the second if text under second equation because it would be too width for my memoir otherwise. Please favour simpliest solutions if possible :)



Answers 1


I'm pretty sure it is a duplicate. But it is also easy to solve using aligned

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
  V_{ijk}& = \begin{cases} \dfrac{y_u+y_l}2 - \dfrac{x_u+x_l}2,&
    \text{if }x_u < y_l
    \\[15pt]
    \begin{aligned}[b]
      &\dfrac1C \bigg[\dfrac{x_u^3-y_l^3}{6}+\dfrac{y_l^2+x_u^2}{2}x_l
      + (x_u-y_l)\dfrac{x_l^2}{2}
      \\
      &+ \dfrac{y_u^2-x_u^2}{2}(x_u-x_l) -
      (y_u-x_u)\dfrac{x_u^2-x_l^2}{2} \bigg]
    \end{aligned},
    & \text{if }x_u\in\left[y_l,y_u\right]
    \\[15pt]
    \dfrac1{x_u-x_l}\bigg[\dfrac{(y_u+y_l)^2}6 - \dfrac{y_u+y_l}2 x_l
    + \dfrac{x_l^2}2\bigg],& \text{otherwise}
  \end{cases}
 \end{align*}
\end{document}
daleif
daleif
August 14, 2019 13:00 PM

Related Questions


how to align multi level rcases in latex math

Updated March 16, 2017 10:23 AM

Braces and alignment

Updated December 06, 2018 14:23 PM

How to align nested cases?

Updated June 13, 2017 21:23 PM

How can I typeset determinants of Cramer's rule?

Updated May 27, 2017 06:23 AM

How to make this equations aligned

Updated June 11, 2017 12:23 PM