Alignment within cases
With aligned
(from amsmath
package):
\documentclass[12pt,a4paper]{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\[
ns = \left\{\begin{aligned}\quad
& s + s + \dotsm + s & \text{ ($n$ times) if } n & > 0 \\
& 0 & \text{ if } n & = 0 \\
& (-s) + (-s) + \dotsm + (-s) & \text{ ($n$ times) if } n & < 0
\end{aligned}\right.
\]
\end{document}
There should be a wider separation from “(n times)” to “if” than from the formulas and “(n times)”, in my opinion.
The 0 should be left flush, like the other two terms. I also fixed the math error (it should be |n| in the third line).
\documentclass[12pt,a4paper]{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\begin{equation*}
ns =
\begin{cases}
\begin{alignedat}{3}
&s + s + \dots + s &\quad \text{($n$ times)} &\qquad& \text{if $n > 0$} \\
&0 &\quad &\qquad& \text{if $n = 0$} \\
&(-s) + (-s) + \dots + (-s) &\quad \text{($|n|$ times)} &\qquad& \text{if $n < 0$}
\end{alignedat}
\end{cases}
\end{equation*}
\end{document}
You can use \hphantom
in the second line to move the text over, or alternatively \hfill
, as Mico mentions in a comment.
What's the purpose of the \quad
s anyway?
\documentclass[12pt,a4paper]{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\begin{equation*}
ns =
\begin{cases}
s + s + \dots + s & \text{ ($n$ times) if } n > 0 \\
0 & \text{\hphantom{ ($n$ times)} if } n = 0 \\
(-s) + (-s) + \dots + (-s) & \text{ ($n$ times) if } n < 0
\end{cases}
\end{equation*}
\end{document}
If you want to change the alignment for the columns in cases
, one possibility is to define a new environment with the help of mathtools
, as described in Right aligned first column in a cases environment For example, to have the first column centered, and the second right aligned :
\documentclass[12pt,a4paper]{article}
\usepackage[fleqn]{mathtools}
\makeatletter
\newcases{crcases}{\quad}{%
\hfil$\m@th\displaystyle{##}$\hfil}{\hfil$\m@th\displaystyle{##}$}{\lbrace}{.}
\makeatother
\begin{document}
\begin{equation*}
ns =
\begin{crcases}
s + s + \dots + s & \text{ ($n$ times) if } n > 0 \\
0 & \text{ if } n = 0 \\
(-s) + (-s) + \dots + (-s) & \text{ ($n$ times) if } n < 0
\end{crcases}
\end{equation*}
\end{document}