0

This question already has an answer here:

enter image description here

I've seen other solutions but they look rather bold, and messy, and very big. I want something like this, so I can use the code as a template.

marked as duplicate by Zarko, Au101, Stefan Pinnow, Ruben, Maarten Dhondt Jan 3 '17 at 6:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • search for cases environment on this site – percusse Jan 3 '17 at 1:51
3
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\begin{document}
  \begin{equation*}
g(x)=\begin{cases}
          x \quad &\text{if} \, x \in \mathbb{Q} \\
          -x \quad &\text{if} \, x \notin \mathbb{Q} \\
     \end{cases}
  \end{equation*}
\end{document}

enter image description here

  • I usually write \text{if $x \in \mathbb{Q}$} – user94293 Jan 3 '17 at 7:19
5

Please observe variants of position of x and -x. The second and third are suggested ones.

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}

\[
g(x)=
\begin{cases}
x&\text{if }x\in\mathbb{Q}\\
-x&\text{if }x\notin\mathbb{Q}
\end{cases}
\]
or
\[
g(x)=
\begin{cases}
\phantom{-}x&\text{if }x\in\mathbb{Q}\\
-x&\text{if }x\notin\mathbb{Q}
\end{cases}
\]
or
\[
g(x)=\left\{
\begin{array}{rl}
x&\text{if $x\in\mathbb{Q}$}\\
-x&\text{if  $x\notin\mathbb{Q}$}
\end{array}
\right.
\]

\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.