# How to split parts of an equation over two lines?

I have a question concerning equations in Latex. Let's assume there is a simple piecewise function as below (the actual one has terms which are much longer):

As each line runs on for quite a bit, I would like to split the selector over two lines however still aligned with the case. Is this possible?

$$\label{eqn:c(n)} { c(n) = \begin{cases} f(x)), & if n=0 where x=1 \$1em] f(x), & if n\textgreater0 where x=c(n-1)+n \\ \end{cases} }$$  This is what I have so far. • Welcome to TeX.SE. – Mico Nov 3, 2021 at 17:52 ## 2 Answers I would like to suggest that you employ a cases environment (provided by the amsmath package) and embed in it two array environments. \documentclass{article} % or some other suitable document class \usepackage{amsmath} % for 'cases' environment \usepackage{booktabs} % for '\addlinespace' macro \begin{document} \[ C(n)= \begin{cases} f(x), & \begin{array}{@{}l@{}} n=0\\ \text{where x=1} \end{array} \\ \addlinespace % increase the vertical separation f(x), & \begin{array}{@{}l@{}} n>0\\ \text{where x=c(n-1)+n} \end{array} \end{cases}$
\end{document}

• Perfect, thanks very much :) Nov 3, 2021 at 18:07

I can think of two approaches to this. I'll use the amsmath cases environment to simplify things, but this would work just as well if you were building things up manually with array on your own.

Option 1 (less typing), use an empty cell in the left column (see lines marked ❶_ to make things line up:

$C(n)= \begin{cases} f(x), &n=0\\ &\textrm{where x=1}\\ % ❶ f(x), &n>0\\ &\textrm{where x=c(n-1)+n % ❶ \end{cases}$


Note that I opted for \textrm rather than \text as the latter will inherit the formatting of the surrounding text which can lead to unexpected results in, e.g., the text of a theorem.

Option 2 (perhaps better aesthetics).

First, we'll define a command \stackmath to build up a single-column array.

\NewDocumentCommand{\stackmath}{m}
{
\begin{array}{@{} l @{}} % ❷
#1
\end{array}
}


Note that we put @{} at the sides of the array ❷ to avoid the extra spacing LaTeX puts there by default. This is a generally useful command in that it will let us typeset left-justified math in multiple lines anywhere in math mode by typing something like:

\stackmath{x<0\\x>0}


to get the lines stacked up.

Then we can write

$C(n)= \begin{cases} f(x), &\stackmath{n=0\\ \textrm{where x=1}}\\ % ❸ f(x), &\stackmath{n>0\\ \textrm{where x=c(n-1)+n} \end{cases}$


You may find yourself wanting to use the optional argument on \\ at ❸ to open things up a bit, writing, e.g., \\[5pt] to get some extra space between lines in the cases environment.