3

my goal

Hi all,

I want to write my equation which is like the attached picture. I tried to write this code below but I couldn't make "Hp" starting from the same positions.

How should I write code to have the picture like this.

\begin{eqnarray} \label{eq:5}
Se & = & \left\{
                \begin{array}{ll}
                  \frac{1}{{[1+|\alpha H_{p}|^{n}]}^{m}}     & \quad H_{p}<0\\
                  1  & \quad H_{p} \geq0
                \end{array}
              \right.   \nonumber
 \\
 \theta & = & \left\{
                \begin{array}{ll}
                  \theta_{r}+Se(\theta_{s}-\theta_{r})  & \quad H_{p}<0\\
                  \theta_{s}     & \quad H_{p} \geq0 
                \end{array}
              \right. 
\\  
C & = & \left\{
                \begin{array}{ll}
                  \frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})Se^{\frac{1}{m}}\left(1-Se^{\frac{1}{m}}\right)^{m}    & \quad H_{p}<0\\
                  0     & \quad H_{p} \geq0
                \end{array}
              \right.   \nonumber   
\\  
k_{r} & = & \left\{
                \begin{array}{ll}
                  Se^{l}\left[1-\left(1-Se^{\frac{1}{m}}\right)^{m} \right]^2   & \quad H_{p}<0\\
                  1     & \quad H_{p} \geq0
                \end{array}
              \right.   \nonumber                                            
\end{eqnarray}
2

Please do not use eqnarray! It is deprecated since years. For such things, there are cases from amsmath or the newer mathtools. Just put everything inside of an align. The trick in order to align the most right column is to use an \hphantom here. I hope, this is what you wanted to have.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\newcommand{\Se}{\operatorname{\mathit{S\kern-.15em e}}}

\begin{document}
\begin{align*}
    \theta &=  
    \begin{dcases}
        \theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\ 
        \mathrlap{\theta_{s}}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0 
    \end{dcases}\\
    \Se &=  
    \begin{dcases}
        \frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\ 
        \mathrlap{1}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0 
    \end{dcases} \\
    C &=
    \begin{dcases} 
        \frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} & H_{p}<0 \\ 
        0 & H_{p} \geq 0 
    \end{dcases} \\
    k_{r} &= 
    \begin{dcases}
        \Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\ 
        \mathrlap{1}\hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}} & H_{p} \geq 0 
    \end{dcases}
\end{align*}
\end{document}

enter image description here


As recommended by daleif, you could also define some certain width and put your lower rows in a mathmakebox with left alignment. This would look like:

\begin{align*}
    \theta &=  
    \begin{dcases}
        \theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\ 
        \mathmakebox[5cm][l]{\theta_{s}} & H_{p} \geq 0 
    \end{dcases}\\
    \Se &=  
    \begin{dcases}
        \frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\ 
        \mathmakebox[5cm][l]{1} & H_{p} \geq 0 
    \end{dcases} \\
    C &=
    \begin{dcases} 
        \frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} & H_{p}<0 \\ 
        \mathmakebox[5cm][l]{0} & H_{p} \geq 0 
    \end{dcases} \\
    k_{r} &= 
    \begin{dcases}
        \Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\ 
        \mathmakebox[5cm][l]{1} & H_{p} \geq 0 
    \end{dcases}
\end{align*}
  • Many thanks for answer, but it is equation that I didn't put it in my screenshot. It is just one equation in total. so, how is it possible to write and having equation number? – Sepideh Mar 17 '16 at 12:42
  • @Sepideh You mean for every line? – LaRiFaRi Mar 17 '16 at 12:49
  • @Sepideh Just remove the asterisk and do something like here: tex.stackexchange.com/q/17528 if you want just one number. – LaRiFaRi Mar 17 '16 at 12:56
  • No, actually for all of these four functions create one equation in my thesis. – Sepideh Mar 17 '16 at 12:57
  • 1
    @Sepideh Replace align* with aligned, and then wrap it in an equation environment, so you have \begin{equation}\begin{aligned} <all the four equations> \end{aligned}\end{equation}. – Torbjørn T. Mar 17 '16 at 13:01
2

Here's a solution that uses four dcases environments placed inside an aligned environment contained in an equation environment. I would actually not bother providing a common alignment of the four pairs of conditioning statements. Instead, I'd concentrate on (a) not letting some of the individual lines become too tall, e.g., by writing ...^{1/m} rather than ...^\frac{1}{m} and (b) providing a bit more vertical whitespace between the four sets of subequations.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'dcases'  environment
\newcommand\Se{\textit{Se}}
\begin{document}
\begin{equation} \label{eq:5}
\begin{aligned}
\Se  &= \begin{dcases}
        \frac{1}{[1+\lvert\alpha H_p \rvert^{n}]^{m}} & H_p<0\\
        1  &  H_p\geq0
        \end{dcases}  \\[2ex]
\theta &= \begin{dcases}
          \theta_{r}+\Se (\theta_{s}-\theta_{r})  & H_p<0\\
          \theta_{s}     & H_p\geq0
          \end{dcases}\\[2ex]
C &= \begin{dcases}
     \frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se ^{1/m} \bigl(1-\Se ^{1/m}\bigr)^{m}    & H_p<0\\
     0     & H_p\geq0
     \end{dcases}\\[2ex]
k_{r} &= \begin{dcases}
         \Se^{l}\bigl[1-(1-\Se ^{1/m})^{m} \bigr]^2   & H_p<0\\
         1     & H_p\geq0
         \end{dcases}
\end{aligned}
\end{equation}
\end{document} 

Addendum: If you believe it's preferable to align the four conditioning pairs as well, here's a straightforward way to achieve this goal: (a) Save the longest term in the equations to a macro named, say, \longestterm and measure its width; (b) place one term each of subequations 1, 2, and 4 in a \parbox whose width is that of \longestterm.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'dcases'  environment
\newcommand\Se{\textit{Se}}

\newlength\mylen
\newcommand\longestterm{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se ^{1/m} (1-\Se ^{1/m}) ^{m}}
\settowidth\mylen{$\displaystyle\longestterm$}

\begin{document}
\begin{equation} \label{eq:5}
\begin{aligned}
\Se    &= \begin{dcases}
          \frac{1}{[1+\lvert\alpha H_p\rvert^{n}]^{m}} & H_p<0\\
          \parbox{\mylen}{$1$}  &  H_p\geq0
          \end{dcases}  \\[2ex]
\theta &= \begin{dcases}
          \theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_p<0\\
          \parbox{\mylen}{$\theta_{s}$} & H_p\geq0
          \end{dcases}\\[2ex]
C      &= \begin{dcases}
          \longestterm & H_p<0\\
          0 & H_p\geq0
          \end{dcases}\\[2ex]
k_{r}  &= \begin{dcases}
          \Se^{l}\bigl[1-(1-\Se^{1/m})^{m} \bigr]^2 & H_p<0\\
          \parbox{\mylen}{$1$}  & H_p\geq0
          \end{dcases}
\end{aligned}
\end{equation}
\end{document} 
1

This is just a supplement to LaRiFaRis solution, doing the same thing with less code

\documentclass{article}
\usepackage{mathtools}
\newcommand{\Se}{\operatorname{\mathit{S\kern-.15em e}}}

\newcommand\mybox[1]{}
\begin{document}
% jsut to make this function for this patciluar case 
\renewcommand\mybox[1]{
  \mathrlap{#1}
  \hphantom{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}}
}
\begin{align*}
    \theta &=  
    \begin{dcases}
        \theta_{r}+\Se(\theta_{s}-\theta_{r}) & H_{p}<0 \\ 
        \mybox{\theta_{s}} & H_{p} \geq 0 
    \end{dcases}\\
    \Se &=  
    \begin{dcases}
        \frac{1}{{\bigl[1+\lvert\alpha H_{p}\rvert^{n}\bigr]}^{m}} & H_{p}<0 \\ 
        \mybox{1} & H_{p} \geq 0 
    \end{dcases} \\
    C &=
    \begin{dcases} 
        \frac{\alpha
          m}{1-m}(\theta_{s}-\theta_{r})\Se^{\frac{1}{m}}\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m}
        & H_{p}<0 \\ 
        % this is the widest, so no need to do it here, but we do for
        % completness 
        \mybox{0} & H_{p} \geq 0 
    \end{dcases} \\
    k_{r} &= 
    \begin{dcases}
        \Se^{l}\Bigl[1-\bigl(1-\Se^{\frac{1}{m}}\bigr)^{m} \Bigr]^2 & H_{p}<0 \\ 
        \mybox{1} & H_{p} \geq 0 
    \end{dcases}
\end{align*}
\end{document}
0

A simple solution with eqparbox: I define an \eqmathbox command, which makes all commands with the same tag have length equal to the longest contents (two compilations required):

\documentclass{article}
\usepackage{mathtools} % for 'dcases' environment
\usepackage{eqparbox}
\newcommand\eqmathbox[2][M]{\eqmakebox[#1][l]{$\displaystyle#2$}}
\newcommand\Se{\textit{Se}}

\begin{document}

\begin{equation} \label{eq:5}
\begin{aligned}
\Se &= \begin{dcases}
          \eqmathbox{\frac{1}{[1+\lvert\alpha H_p\rvert^{n}]^{m}}} & H_p<0\\
          1 & H_p\geq0
          \end{dcases} \\[2ex]
\theta &= \begin{dcases}
          \eqmathbox{\theta_{r}+\Se(\theta_{s}-\theta_{r})}
          & H_p<0\\
            \theta_{s} & H_p\geq0
          \end{dcases}\\[2ex]
C &= \begin{dcases}
          \eqmathbox{\frac{\alpha m}{1-m}(\theta_{s}-\theta_{r})Se^{\frac{1}{m}}\left(1-Se^{\frac{1}{m}}\right)^{m}} & H_p<0\\
          0 & H_p\geq0
          \end{dcases}\\[2ex]
k_{r} &= \begin{dcases}
          \eqmathbox{\Se^{l}\bigl[1-(1-\Se^{1/m})^{m} \bigr]^2} & H_p<0\\
           1 & H_p\geq0
          \end{dcases}
\end{aligned}
\end{equation}

\end{document} 

enter image description here

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.