3

I have the following code:

\begin{equation}
\frac {\partial C}{\partial {z_k}}= \begin{cases}
  - \frac {1} {y_i} {y_i} (1-{y_i}) = y_{i} - 1 & k = i \\
   \frac {1} {y_i} {y_{i}^{2}} = y_{i}  &  k \ne i  \\
\end{cases}
\end{equation}

It works fine, but what I want to achieve is to align the = from the first case and the second case. I did not manage to do that.

Any advice?

Thank you!

3

I can be done, using aligned instead, but I am not sure which exact alignment is desirable. Probably the best is to use a second cases for the simplification.

Sample output

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation}
  \frac {\partial C}{\partial {z_k}}
  =
  \left\{
  \begin{aligned}
    - \frac {1} {y_i} {y_i} (1-{y_i})&= y_{i} - 1, &\qquad& k = i, \\
    \frac {1} {y_i} {y_{i}^{2}}&= y_{i},  &&  k \ne i.
  \end{aligned}
  \right.
\end{equation}

\begin{equation}
  \begin{split}
    \frac {\partial C}{\partial {z_k}} &=
    \begin{dcases}
      - \frac {1} {y_i} {y_i} (1-{y_i}),& k = i, \\
      \frac {1} {y_i} {y_{i}^{2}}, & k \ne i,
    \end{dcases}\\
    &=
    \begin{cases}
      y_{i} - 1, &k = i, \\
      y_{i}, & k \ne i.
    \end{cases}
  \end{split}
\end{equation}

\end{document}
  • Thank you for explaining and for giving me multiple options. I tried both (I was inclined to use the first one due in order to not take so much space) but I agree that the second one looks better, so I used that one. – elaRosca Jun 9 '14 at 10:56
0

It will suffice to insert \hspace{3.9em} at the beginning of your fourth line (the exact amount of space depends on the fontsize and the font you have chosen.

  • 1
    Such manual adjustment is generally not advisable. – Andrew Swann Jun 9 '14 at 11:04

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.