2

The following code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{cases}
   Af &=g \quad \text{if} \ c,\\
   f&=0 \quad \text{if} \ d.
\end{cases}$
\end{document}

gives enter image description here

How to align the two f's vertically (so that they are both in the same distance from the '=' sign)?

  • I don't see the reason for \quad there. In the second line, write \phantom{A}f to get the fs aligned. – Manuel Mar 23 '16 at 9:02
  • @Manuel Yes, that is what I wanted. But is there not any other solution, like specifying the alignment requirements in the options of 'cases'? – wondering Mar 23 '16 at 9:05
  • Ah, I see, in {cases}, the & is there to separate columns, not before the equal. – Manuel Mar 23 '16 at 9:06
  • @Manuel Sorry, I don't get what you mean and how it can help me. – wondering Mar 23 '16 at 9:11
  • You are not supposed to write &= inside a {cases} environment. – Manuel Mar 23 '16 at 10:22
5

Use aligned instead of cases. If you wonder, why there is \! after \left\{, see Why is there a \, space at the beginning of the “aligned” environment?.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\left\{\!\begin{aligned}
   Af &=g && \text{if} \ c,\\
   f &=0 && \text{if} \ d.
\end{aligned}\right.$
\end{document}

enter image description here

4
\documentclass{scrartcl}
\usepackage{mathtools}
\begin{document}
\[
  \begin{cases}
    Af=g & \text{if} \ c, \\
    \phantom{A}f = 0 & \text{if} \ d.
  \end{cases}
\]
\end{document}

Altough I tend to prefer

\begin{cases*}
  Af=g & if $c$, \\
  \phantom{A}f = 0 & if $d$.
\end{cases*}

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.