# Write case condition on two lines [duplicate]

I have this equation:

which must be inserted in a Office document. But it is too large, so I want to add a line return in the middle of the 2nd and 3rd condition such that the new line starts exactly at the same point as before (not in the left area of the "equation system").

s(g) =
\begin{cases}
q_i / n
& se \; \exists i:1 \leq i \leq k \enspace t.c. \enspace g \in [x_{i-1}, x_i] \\
q_1 / n - P \left(q_1/n, x_0 - g \right)
& se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\; e \;
\left( x_0 - g \right) \leq \left( g - x_k \right) \\
\left q_k / n  - P \left(q_k/n, g - x_k \right)
& se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\; e \;
\left( x_0 - g \right) > \left( g - x_k \right)
\end{cases}

• Welcome to the site. Providing a bit of compileable code in your post will alleviate the need of those who might help you to have to retype everything. – Steven B. Segletes Feb 25 '16 at 14:33
• Can you post a MWE, or at least, the code used to write your equation ? – Jérôme Dequeker Feb 25 '16 at 14:33
• potential duplicate: Split-like environment inside cases environment – barbara beeton Feb 25 '16 at 14:34
• If you have a large block of code, rather than encase it between backticks (inline code highlight mechansim), instead highlight the text and click the {} button at the top of the edit box. It will indent the block by 4 spaces in the edit box, which will display as a code block on the screen. – Steven B. Segletes Feb 25 '16 at 14:41

Are you looking for something like this? I am not sure if "e" and "se" are words or math... if words, then \textrm{e} and \textrm{se} would make proper sense.

REVISED SOLUTION (if only left alignment is required)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$s(g) = \begin{cases} q_i / n & se \; \exists i:1 \leq i \leq k \enspace t.c. \enspace g \in [x_{i-1}, x_i] \\ q_1 / n - P \left(q_1/n, x_0 - g \right) & se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\;\\ & e \; \left( x_0 - g \right) \leq \left( g - x_k \right) \\ q_k / n - P \left(q_k/n, g - x_k \right) & se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\; \\ & e \; \left( x_0 - g \right) > \left( g - x_k \right) \end{cases}$
\end{document}


ORIGINAL SOLUTION

\documentclass{article}
\usepackage{amsmath,stackengine}
\stackMath
\begin{document}
\def\stackalignment{l} s(g) = \begin{cases} q_i / n & se \; \exists i:1 \leq i \leq k \enspace t.c. \enspace g \in [x_{i-1}, x_i] \\ q_1 / n - P \left(q_1/n, x_0 - g \right) & \stackunder{ se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\; }{ e \; \left( x_0 - g \right) \leq \left( g - x_k \right) } \\ q_k / n - P \left(q_k/n, g - x_k \right) & \stackunder{ se \; g \notin [x_{i-1}, x_i] \: \forall i: 1 \leq i \leq k \;\; }{ e \; \left( x_0 - g \right) > \left( g - x_k \right) } \end{cases}
\end{document}


• I'm using Latex in LibreOffice via the extension TextMaths. In the preamble I've added the includes, but it does not show the 2nd and 3rd condition. – Richard Feb 25 '16 at 15:01
• @Richard I have provided an revised solution that only uses amsmath, if that helps. – Steven B. Segletes Feb 25 '16 at 15:06
• The revised solution works perfectly! Thank you! – Richard Feb 25 '16 at 15:10