4

So I have the following codes

\begin{dmath}
  P_1=\left\{\begin{matrix}
{P_E} + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
- KI(0,T,S,{B_{11}},{b_{11}}, - 1,r)\\
+ SI(0,T,S,{B_{11}},{b_{11}},1,\delta )\;\text{if }\;S > {B_{11}}\\
K - S\quad \text{if } \;S \le {B_{11}}
\end{matrix}\right.
\end{dmath}


\begin{dmath}
P_2=\left\{\begin{matrix}
{P_E} + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
- KI(0,T/2,S,{B_{21}},{b_{21}}, - 1,r)\\
+ SI(0,T/2,S,{B_{21}},{b_{21}},1,\delta )\\
- KI(T/2,T,S,{B_{21}},{b_{21}}, - 1,r)\\
+ SI(T/2,T,S,{B_{21}},{b_{21}},1,\delta )\quad \text{if }\;S > {B_{22}}\\
K - S\quad \text{if }\;S \le {B_{22}}.
\end{matrix}\right.
\end{dmath}

\begin{dmath}   
P_3=\left\{\begin{matrix}
{P_E} + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
- KI(0,T/3,S,{B_{33}},{b_3}, - 1,r)\\
+ SI(0,T/3,S,{B_{33}},{b_3},1,\delta )\\
- KI(T/3,2T/2,S,{B_{32}},{b_{32}}, - 1,r)\\
+ SI(T/3,2T/3,S,{B_{32}},{b_{32}},1,\delta )\\
- KI(2T/3,T,S,{B_{31}},{b_{31}}, - 1,r)\\
+ SI(2T/3,T,S,{B_{31}},{b_{31}},1,\delta )\quad \text{if }\;S > {B_{33}}\\
K - S\quad \text{if }\;S \le {B_{33}}.\\
\end{matrix}\right.
\end{dmath}

Unfortunetly this produces the following picture

enter image description here

I want it to look more like this enter image description here

2
  • Welcome to TeX - LaTeX! Have you tried to use a cases environment, possibly with an aligned inside? – Andrew Swann May 22 '17 at 16:42
  • no I have not, first time ive heard of it – asdf May 22 '17 at 16:45
5

I would use the cases environment from the amsmath package. I don't know where your matrix and dmath come from.

I think the extra spacing you experience is due to the \left\{.

Example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent
\begin{equation}
P_{1}=
\begin{cases}
P_E + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
{}- KI(0,T,S,{B_{11}},{b_{11}}, - 1,r)\\
{}+ SI(0,T,S,{B_{11}},{b_{11}},1,\delta )\quad\text{if}\; S > {B_{11}}\\
K - S\quad \text{if}\; S \le {B_{11}}.
\end{cases}
\end{equation}

\begin{equation}
P_{2}=
\begin{cases}
P_E + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
{}- KI(0,T/2,S,{B_{21}},{b_{21}}, - 1,r)\\
{}+ SI(0,T/2,S,{B_{21}},{b_{21}},1,\delta )\\
{}- KI(T/2,T,S,{B_{21}},{b_{21}}, - 1,r)\\
{}+ SI(T/2,T,S,{B_{21}},{b_{21}},1,\delta )\quad \text{if}\; S > {B_{22}}\\
K - S\quad \text{if}\; S \le {B_{22}}.
\end{cases}
\end{equation}

\begin{equation}
P_{3}=
\begin{cases}
P_E + K(1 - {e^{ - rT}}) - S(1 - {e^{ - \delta T}})\\
{}- KI(0,T/3,S,{B_{33}},{b_3}, - 1,r)\\
{}+ SI(0,T/3,S,{B_{33}},{b_3},1,\delta )\\
{}- KI(T/3,2T/2,S,{B_{32}},{b_{32}}, - 1,r)\\
{}+ SI(T/3,2T/3,S,{B_{32}},{b_{32}},1,\delta )\\
{}- KI(2T/3,T,S,{B_{31}},{b_{31}}, - 1,r)\\
{}+ SI(2T/3,T,S,{B_{31}},{b_{31}},1,\delta )\quad \text{if}\; S > {B_{33}}\\
K - S\quad \text{if}\; S \le {B_{33}}.
\end{cases}
\end{equation}
\end{document}

enter image description here

3
  • to be precise they are not aligned p1, p2 , p3 but anyway thanx – asdf May 22 '17 at 16:45
  • nvm I solved it. – asdf May 22 '17 at 17:23
  • 1
    You may want to prefix the - and + symbols at the beginnings of lines with {}, to make TeX interpret them as binary rather than as unary operators. – Mico May 22 '17 at 18:14
5

If I understand correctly your intent, you are after something like this:

Output of the following code

The code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{mathtools}



\begin{document}

It's always best to start with some text.
\begin{align}
    P_{1} &=
        \begin{cases*}
            \begin{aligned}[b]
                P_{E} &+ K(1 - e^{-rT}) - S(1 - e^{-\delta T})\\
                & - KI(0,T,S,B_{11},b_{11},-1,r)\\
                & + SI(0,T,S,B_{11},b_{11},1,\delta )
            \end{aligned}
            & if $S > B_{11}$, \\
            K - S & if $S \le B_{11}$.
        \end{cases*}
    \\
    P_{2} &=
        \begin{cases*}
            \begin{aligned}[b]
                P_{E} &+ K(1 - e^{-rT}) - S(1 - e^{-\delta T})\\
                & - KI(0,T/2,S,B_{21},b_{21},-1,r)\\
                & + SI(0,T/2,S,B_{21},b_{21},1,\delta )\\
                & - KI(T/2,T,S,B_{21},b_{21},-1,r)\\
                & + SI(T/2,T,S,B_{21},b_{21},1,\delta )
            \end{aligned}
            & if $S > B_{22}$, \\
            K - S & if $S \le B_{22}$.
        \end{cases*}
    \\
    P_{3} &=
        \begin{cases*}
            \begin{aligned}
                P_{E} &+ K(1 - e^{-rT}) - S(1 - e^{-\delta T})\\
                & - KI(0,T/3,S,B_{33},b_{3},-1,r)\\
                & + SI(0,T/3,S,B_{33},b_{3},1,\delta )\\
                & - KI(T/3,2T/2,S,B_{32},b_{32},-1,r)\\
                & + SI(T/3,2T/3,S,B_{32},b_{32},1,\delta )\\
                & - KI(2T/3,T,S,B_{31},b_{31},-1,r)\\
                & + SI(2T/3,T,S,B_{31},b_{31},1,\delta )
            \end{aligned}
            & if $S > B_{33}$, \\
            K - S & if $S \le B_{33}$.
        \end{cases*}
\end{align}
Text after the equations.

\end{document}

Points to note:

  • The mathtools package (which automatically loads amsmath too) provides a cases* enviroment that typesets the second column in text—as opposed to math—mode. Other choices are also available: see p. 18 of the manual of the mathtools package.

  • I’ve used an aligned environment, with optional argument [b], to wrap long formulas that (I repeat, if I understand correctly) belong to the same logical branch.

  • I’ve also removed a lot of superfluous braces.

  • As a “feature” (;-) , the last equation shows, by way of example, what purpose the [b] argument serves…

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.