5

I am trying to type some text to the side of a cases environment. Below is my MWE. I seem to have two issues: Extra space between the numbers of the enumerated list and the contents of said list and the brackets not being large enough. My first attempt (which used the cases environment exclusively) resulted in errors. I saw this somewhere on the web (some tex forum, sorry not sure which one) and tried this.

   \documentclass{article}
   \usepackage[left=1.65cm,right=1.65cm,top=2.45cm,bottom=2.60cm]{geometry}
    \usepackage{amsmath,amssymb,amscd,amsbsy,array,color}
\usepackage{fancyhdr,framed,latexsym,multicol,pstricks,slashed,xcolor,multicol}
    \usepackage{picture}
    \usepackage{indentfirst}
    \usepackage{enumitem}

    \usepackage[amsmath,framed,thmmarks]{ntheorem}


\title{Analysis Notes}
\author{Michael Dykes}

\begin{document}

\maketitle



Prove that: 
    \begin{enumerate}
        \item   \begin{align*}
                    \begin{split}
                        2-x, &\textrm{ if } x \le 1\\
                        \frac{1}{x}, &\textrm{ if } x> 1.
                    \end{split}\;\bigg\} \quad \text{is one-to-one but  not onto $\mathbb{R}$.}
                \end{align*}

        \item   \begin{align*}
            \begin{split}
                x+4, &\textrm{ if } x \le -2\\
                -x, &\textrm{ if } -2 < x < 2\\
                x-4 &\textrm{ if } x \ge 2.
            \end{split}\;\bigg\} \quad \text{is onto $\mathbb{R}$ but not one-to-one.}
        \end{align*}
    \end{enumerate}

\end{document}

I am not sure what to do from here.

-MD

5

To avoid having a gap between the enumeration numerals and the associated formulas, use an inline math environment instead of a display math environment.

To get the correct sizing of the right-hand curly braces, I suggest you use a drcases* environment, which is provided by the mathtools package. (The "r" in "rcases" denotes the fact that the curly brace is placed to the right of the environment. The "starred" version of this environment saves you from having to encase the conditioning material in \text wrappers.)

enter image description here

\documentclass{article}
\usepackage[hmargin=1.65cm,top=2.45cm,bottom=2.6cm]{geometry}
\usepackage{mathtools,amsfonts}

\begin{document}

Prove that: 
\begin{enumerate}
\item \qquad 
$\begin{drcases*}
     2-x, &if $x \le 1$\\
     1/x, &if $x> 1$.
\end{drcases*}$
is one-to-one but  not onto $\mathbb{R}$.

\item \qquad
$\begin{drcases*}
     x+4, &if $x \le -2$  \\
     -x,  &if $-2 < x < 2$\quad\\
     x-4  &if $x \ge 2$.
\end{drcases*}$
is onto $\mathbb{R}$ but not one-to-one.
\end{enumerate}

\end{document}

Addendum to address the OP's follow-up question: If the math-y stuff should be surrounded by curly braces on both sides, it's probably best to set up a custom array environment along the following lines:

enter image description here

\documentclass{article}
\usepackage[hmargin=1.65cm,top=2.45cm,bottom=2.6cm]{geometry}
\usepackage{amsfonts,array}
\newenvironment{myarray}{% custom "array" env.
  \renewcommand\arraystretch{1.33} % mimic spacing of display-style math
  \left\{ \begin{array}{@{\,} >{\displaystyle}l >{$}l<{$} @{\,}}}{%
  \end{array} \right\}}

\begin{document}
Prove that:
\begin{enumerate}
\item \quad
$f(x)=\begin{myarray}
         2-x & if $x \le 1$\\
         1/x & if $x> 1$.
      \end{myarray}$
is one-to-one but not onto $\mathbb{R}$.

\item \quad
$g(x)=\begin{myarray}
         x+4 & if $x \le -2$  \\
         -x  & if $-2 < x < 2$ \\
         x-4 & if $x \ge 2$.
      \end{myarray}$
is onto $\mathbb{R}$ but not one-to-one.
\end{enumerate}
\end{document}
  • I forgot to add that I was supposed to be defining a function each time, and so I wanted to type: f(x) = then the cases structure, so is there a dlcases*??? – Michael Dykes Jan 24 '17 at 14:44
  • @MichaelDykes - I've posted an addendum to my answer, to address your follow-up inquiry. Do let me know if the proposed solution works for you. – Mico Jan 24 '17 at 16:56
  • 1
    the source I was using did not have the curly braces on both sides but I do like the way it looks and it helps to "set-off" the text on the RHS of the cases environment much better. Thanks so much!!! – Michael Dykes Jan 24 '17 at 21:31
3

Here are some options using an array and/or empheq:

enter image description here

\documentclass{article}

\usepackage{amsfonts}% ...for \mathbb
\usepackage{empheq}% Load mathtools, which loads amsmath

\begin{document}

Prove that:
\begin{enumerate}
  \item \mbox{}

  \nobreak
  \vspace{\dimexpr-\baselineskip-\abovedisplayskip-\parskip}
  \[
    \renewcommand{\arraycolsep}{0pt}
    \left.\kern-\nulldelimiterspace
    \begin{array}{ r l }
             2 - x, &\text{ if $x \leq 1$} \\[\jot]
      \dfrac{1}{x}, &\text{ if $x > 1$.}
    \end{array}\right\} \quad \text{is one-to-one but  not onto $\mathbb{R}$.}
  \]

  \item \mbox{}

  \nobreak
  \vspace{\dimexpr-\baselineskip-\abovedisplayskip-\parskip}
  \begin{empheq}[right=\empheqrbrace \quad \text{is onto $\mathbb{R}$ but not one-to-one.}]{align*}
    x + 4, &\text{ if $x \leq -2$} \\
       -x, &\text{ if $-2 < x < 2$} \\
    x - 4, &\text{ if $x \geq 2$.}
  \end{empheq}
\end{enumerate}

\end{document}
  • When I use that Werner, I keep getting: undefined control sequence \end{empheq} – Michael Dykes Jan 24 '17 at 14:38
  • @MichaelDykes: You would need to add \usepackage{empheq} to your preamble. – Werner Jan 24 '17 at 16:17
0

Based on what Mico typed and has here, I have come up with the following, which is what I was looking for.

\documentclass{article}
\usepackage[hmargin=1.65cm,top=2.45cm,bottom=2.6cm]{geometry}
\usepackage{mathtools,amsfonts}

\begin{document}

    Prove that: 
    \begin{enumerate}
        \item \qquad 
        $\begin{aligned}
        f(x) =
        \begin{dcases*}
        2-x, &if $x \le 1$\\
        \frac{1}{x}, &if $x> 1$.
        \end{dcases*}
        \text{is one-to-one but  not onto $\mathbb{R}$.}
        \end{aligned}$

        \item \qquad
        $\begin{aligned}
        f(x) =
        \begin{dcases*}
        x+4, &if $x \le -2$  \\
        -x,  &if $-2 < x < 2$\quad\\
        x-4,  &if $x \ge 2$.
        \end{dcases*}
        \text{is onto $\mathbb{R}$ but not one-to-one.}
        \end{aligned}$
    \end{enumerate}

\end{document}

Thanks to everyone for all your help!!!

-MD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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