Welcome to our community

Be a part of something great, join today!

MathJax LaTeXing a piecewise function

TheBigBadBen

Active member
May 12, 2013
84
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

Administrator
Staff member
Jan 26, 2012
4,040
Hi TheBigBadBen, :)

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

Administrator
Staff member
Feb 24, 2012
13,775
Another approach:

Try the code:

Code:
f(x)=\begin{cases}1 & x\in\mathbb{Q}\\ 0 & x\notin\mathbb{Q} \\ \end{cases}
to get:

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