Once upon a time, there was a 4 line code. A kid attempted to write it as equation (perhaps a bad idea). But, anyway, the attempt failed.
The code in question had two tricky elements that made life difficult for this kid.
- Cases only for first two lines
- The first two lines and last three lines were aligned, as shown below.
Code so far:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\!\begin{aligned}
\begin{cases}
d_{oo} = 0, \\
d_{ij} = min (&~d_{i-1,j-1} + (if ~a_i = b_j, \text{ then } 0 \text{, else } c_C), \\
&~d_{i-1,j}+c_d,\\
&~d_{i,j-1}+c_i),~ i > 0 \text{ or } j > 0 \\
\end{cases}
\end{aligned}
\end{equation}
\end{document}
output
The problem is to apply cases to only first two lines. Placing \end{cases}
after line 2 disturbs the alignment of lines 2,3 and 4
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\!\begin{aligned}
\begin{cases}
d_{oo} = 0, \\
d_{ij} = min (&~d_{i-1,j-1} + (if ~a_i = b_j, \text{ then } 0 \text{, else } c_c), \\
\end{cases}
&~d_{i-1,j}+c_d,\\
&~d_{i,j-1}+c_i),~ i > 0 \text{ or } j > 0 \\
\end{aligned}
\end{equation}
\end{document}
How to obtain the desired output ? It is not necessary to use \equation
construct. Alternatives are welcome.