案例環境外部和枚舉環境內部的文本

案例環境外部和枚舉環境內部的文本

我正在嘗試在案例環境旁邊輸入一些文字。以下是我的 MWE。我似乎有兩個問題:枚舉清單的數字和所述清單的內容之間有額外的空格,括號不夠大。我的第一次嘗試(僅使用案例環境)導致了錯誤。我在網路上的某個地方看到了這個(一些 tex 論壇,抱歉不確定是哪一個)並嘗試了這個。

   \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}

我不知道從這裡該做什麼。

-MD

答案1

為了避免枚舉數字和關聯公式之間出現間隙,請使用內聯數學環境而不是顯示數學環境。

為了獲得右花括號的正確大小,我建議您使用包包drcases*提供的環境mathtools。 (“rcases”中的“r”表示大括號放置在環境的右側。此環境的“星號”版本使您不必將​​調節材料包裹在\text包裝紙中。)

在此輸入影像描述

\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}

附錄解決OP的後續問題:如果數學內容應該兩邊都用大括號括起來,那麼最好array按照以下方式設定自訂環境:

在此輸入影像描述

\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}

答案2

以下是一些使用array和/或的選項empheq:

在此輸入影像描述

\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}

答案3

根據 Mico 在這裡輸入的內容,我想出了以下內容,這正是我一直在尋找的內容。

\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}

感謝大家的幫忙!

-MD

相關內容