I have the following code:

\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  \\

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!


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




  \frac {\partial C}{\partial {z_k}}
    - \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.

    \frac {\partial C}{\partial {z_k}} &=
      - \frac {1} {y_i} {y_i} (1-{y_i}),& k = i, \\
      \frac {1} {y_i} {y_{i}^{2}}, & k \ne i,
      y_{i} - 1, &k = i, \\
      y_{i}, & k \ne i.

  • 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

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.