# Aligning Equation with cases

What is required to make this equation look better? I have tried my skills but the 0 does not align well.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
R^* = \begin{cases} 0 & \dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+\frac{y^2u}{{\pi}}\right)}{y
\lambda_{T}}+\dfrac{u}{\lambda_{X}}\leq 0 \\ \sqrt{\dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{T}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{T}}+\dfrac{u}{\lambda_{T}}} & \dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{X}}+\dfrac{u}{\lambda_{X}} > 0 \end{cases}.
\end{align}

\end{document}

• Give us at leats a MWE. :-) Jul 21, 2020 at 16:25
• Please post the complete content, typically from \documentclass{..} to \end{document}
– hola
Jul 21, 2020 at 16:33
• Thanks for your comments. I just did that Jul 21, 2020 at 16:34
• What would you want the zero to align with? It's left aligned as it should be. Jul 21, 2020 at 16:50
• The zero seems to fall close to the center of the curly braces which doesn't make the output look nice Jul 21, 2020 at 22:47

Maybe you can move the 0 a bit to the right, but the formula is awful to begin with, because the same complicated formula is typeset over and over again.

I suggest a much more economical version, under the assumption that all T's should be X's. Fix it, because the original doesn't seem correct.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$$R^* = \begin{cases} \quad 0 & \dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+ \frac{y^2u}{{\pi}}\right)}{y\lambda_{T}}+\dfrac{u}{\lambda_{X}}\leq 0 \\[4ex] \sqrt{\dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{T}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{T}} +\dfrac{u}{\lambda_{T}}} & \dfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{X}} +\dfrac{u}{\lambda_{X}} > 0 \end{cases}.$$

$$R^*=\sqrt{\max\left\{ 0, \dfrac{1}{y\lambda_{X}}\ln\left(\frac{yuv}{\pi\lambda_{X}}+\frac{y^2u}{\pi}\right) +\dfrac{u}{\lambda_{X}} \right\}}$$

\end{document}


• Yes, all T's should be X! That's a mistake on my part. I guess Eq. (2) is your proposed version. It looks so nice. Jul 21, 2020 at 22:48
• @Abdulhameed Right so! We can use the big formula just once, with the “max” trick. Jul 22, 2020 at 7:23

I propose to use medium-sized fractions, defined in nccmath, and eqparbox to centre the 0 w.r.t. the below square root:

\documentclass{article}
\usepackage{nccmath, mathtools}
\usepackage{eqparbox, booktabs}
\newcommand\eqmathbox[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\begin{document}

\begin{align}
R^* = \begin{cases} \eqmathbox{0} & \text{if } \mfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+\frac{y^2u}{{\pi}}\right)}{y
\lambda_{T}}+\mfrac{u}{\lambda_{X}}\leq 0 ,\\ \addlinespace[2ex] \eqmathbox{\sqrt{\mfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{T}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{T}}+\mfrac{u}{\lambda_{T}}}} & \text{if }\mfrac{\ln\left(\frac{yuv}{{\pi}\lambda_{X}}+\frac{y^2u}{{\pi}}\right)}{y \lambda_{X}}+\mfrac{u}{\lambda_{X}} > 0 . \end{cases}
\end{align}

\end{document}