# MathJaxLaTeXing a piecewise function

##### Active member
I was trying to type a piecewise function, and then this happened:

$$\displaystyle f(x)=\left{ \begin{array}{ccc} 1 & x \in \mathbb{Q} \\ 0 & x \notin \mathbb{Q} \end{array} \right$$

What's going on, and how do I fix it?

#### Jameson

Staff member

There are two small things to fix and it works just fine. The first is when you want to add brackets {} using Mathjax you need to add another slash before it. So it should read "\left \{". The other thing is at the end of "\right" you need to add a period. If you do those two things this is what renders.

$$\displaystyle f(x)=\left\{ \begin{array}{ll} 1 & x \in \mathbb{Q} \\ 0 & x \notin \mathbb{Q} \end{array} \right.$$

#### MarkFL

f(x)=\begin{cases}1 & x\in\mathbb{Q}\\ 0 & x\notin\mathbb{Q} \\ \end{cases}
$$\displaystyle f(x)=\begin{cases}1 & x\in\mathbb{Q}\\ 0 & x\notin\mathbb{Q} \\ \end{cases}$$