3

I want to write an equation with one curly brace ({) on the right hand side and, next to the curly, two statements in two different lines. How can i do it using TeX or Latex? Thanks.enter image description here

4
  • 1
  • 1
    I don't know about moodle, if it can read TeX commands. What you need is the case environment. – Sigur Jan 16 '17 at 16:44
  • AFAIK moodle uses plain TeX in the backend. therefore you might try if $$...$$ works. – naphaneal Jan 16 '17 at 17:07
  • 1
    Moodle does not support cases package, but only array one! The solution is:\[ f(x) = \left\lbrace \begin{array}{cc} (x+2)^{2} & x<-2 \\ 4-x^{2} & x\ge -2 \end{array}\right. \] – Moshe Gueta Nov 15 '20 at 9:44
3

I don't know about Noodle but, using the amsmath package you can simply use

\[
f(x) = 
\begin{cases}
 (x+2)^{2}\,, & x<-2 \\
 4-x^{2}\,, & x\ge -2
\end{cases}
\]
2
  • Why using \,? – Sigur Jan 16 '17 at 17:45
  • That adds a small amount of space before the comm to give some separation from the expressions. – Herb Schulz Jan 16 '17 at 18:22
1

I'll add a few other possibilities, defined by mathtools, an extension of amsmath which it loads, by empheq (which loads mathtools) or by the cases package. Some of them can be individually numbered:

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{empheq}
\usepackage{cases} %

\begin{document}


\begin{align*}
\shortintertext{With \texttt{cases} and \texttt{dcases}:}
    & f(x) = \begin{cases}
    (2x +1)^2& \text{if } x < - \frac{1}{2}\\
   1-4x^2 & \text{if } x \ge -\frac{1}{2}
   \end{cases}
    &  & f(x) = \begin{dcases}
    (2x +1)^2& \text{if } x < - \frac{1}{2}\\
   1-4x^2 & \text{if } x \ge -\frac{1}{2}
   \end{dcases}
\end{align*}

\begin{align*}
\shortintertext{With \texttt{rcases} and \texttt{drcases}:}
    & f(x) = \begin{rcases}
    (2x +1)^2& \text{if } x < - \frac{1}{2}\\
   1-4x^2 & \text{if } x \ge -\frac{1}{2}
   \end{rcases}
    &  & f(x) = \begin{drcases}
    (2x +1)^2& \text{if } x < - \frac{1}{2}\\
   1-4x^2 & \text{if } x \ge -\frac{1}{2}
   \end{drcases}
\end{align*}

With \texttt{numcases}:
    \begin{subnumcases}{f(x) = }
    (2x +1)^2& if $ x < - \frac{1}{2} $\\
   1-4x^2 & if $ x \ge -\frac{1}{2} $
   \end{subnumcases}

With \texttt{empheq};
\begin{subequations}
  \begin{empheq}[left = {f(x) = \empheqlbrace}]{alignat = 2}
      & (2x +1)^2 & \quad & \text{if } x < - \frac{1}{2}\\[1ex]
    & 1-4x^2 & & \text{if } x \ge -\frac{1}{2}
  \end{empheq}
\end{subequations}

    \end{document} 

enter image description here

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