添加

添加

我想学习如何在乳胶中排版这样的表达式。在此处输入图片描述

谢谢

答案1

假设amsmath这里有一种方法(仅括号部分,其余部分由你决定)

我同意安德鲁的观点,我们不太喜欢这样的问题:“请帮我做这个”,应该付出一些努力。

这里我只给出了基础(memoir无关紧要,只是我的默认课程)

\documentclass[a4paper]{memoir}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
  \left\{
     (D_1,D_2,D_0): 
     \begin{aligned}
       & A \\ & B \\ & C \\ & D  \\ & E \\ & F
     \end{aligned}
  \right\}
\end{equation*}
\end{document}

补充:如果你的文档中有多个集合定义,那么为它制定语法可能是一个好主意。这是对手册中示例的改编mathtools

\documentclass[a4paper]{memoir}
\usepackage{amsmath,mathtools}
\providecommand\given{}
\newcommand\SetSymbol[1][]{:}
% see the mathtools manual for a definition of \SetSymbol that works
% with |
\DeclarePairedDelimiterX\Set[1]\{\}{
  \renewcommand\given{\SetSymbol[\delimsize]}
  #1
}
\begin{document}
\begin{equation*}
  \Set*{
     (D_1,D_2,D_0)
     \given
     \begin{aligned}
       & A \\ & B \\ & C \\ & D  \\ & E \\ & F
     \end{aligned}
  }
\end{equation*}
\end{document}

答案2

第一种可能性:

\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}

\newcommand*{\E}{\mathbb{E}}

\begin{document}
\begin{equation*}
  \renewcommand*{\arraystretch}{1.33333}
  S = \left\{
    (D_1,D_2,D_0) :
    \begin{array}{@{}l@{}}
      \multicolumn{1}{c}{\exists f_{1}, f_{2} \text{ s.t.}} \\ 
      \hat{X}_1 = f_1(Y_1),\\
      \hat{X}_2 = f_2(Y_2),\\
      D_1 \geq \E[d_1(X,\hat{X}_1)],\\
      D_2 \geq \E[d_2(X,\hat{X}_2)],\\
      D_0 \geq \E[d_0(\hat{X}_1,\hat{X}_2)],
    \end{array}
  \right\}
  ,
\end{equation*}
\end{document}

输出为

第一个代码示例的输出

但图片中显示的打印输出可能是由

\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}

\newcommand*{\E}{\mathbb{E}}

\begin{document}
\begin{equation*}
  S \triangleq \left\{
    (D_1,D_2,D_0) :
    \begin{aligned}
      &\exists f_{1}, f_{2} \text{ s.t.} \\ 
      \hat{X}_1 &= f_1(Y_1),\\
      \hat{X}_2 &= f_2(Y_2),\\
      D_1 &\geq \E[d_1(X,\hat{X}_1)],\\
      D_2 &\geq \E[d_2(X,\hat{X}_2)],\\
      D_0 &\geq \E[d_0(\hat{X}_1,\hat{X}_2)],
    \end{aligned}
  \right\}
  ,
\end{equation*}
\end{document}

事实上,这次的输出是

第二个代码示例的输出


添加

只是为了好玩,下面是我将如何实现@daleif 的建议,使用类似通用命令的方法\Set

下面的代码定义了两个“样式声明”:

  • \ColonSets生效时,集合定义的两个部分之间的分隔符是冒号(这是默认的);

  • \MvertSets生效时,分隔符是一条竖线。

\Set命令可以照常使用,即:

  • 以星号形式 (IE, \Set*{...}{...}) 它提供自动调整大小的括号(和垂直线,如果合适的话);

  • 带有可选参数(例如, \Set[\Big]{...}{...}),可以在该参数中传递一个尺寸规范,该规范适用于括号,如果适用的话,也适用于垂直线。

此外,我还遵循了手册第 27 页脚注 9 中的建议mathtools,提供了一个名为的独立命令\SetSuchThat,用于排版分隔符,并带有可选的比例修饰符。

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{mleftright}

\newcommand*{\E}{\mathbb{E}}
\newcommand*{\N}{\mathbb{N}}
\newcommand*{\No}{\N_{0}}

\newcommand*{\SetSuchThat}[1][]{} % reserve the name
\newcommand*{\ColonSets}{%
    \renewcommand*\SetSuchThat[1][]{:}%
}
\newcommand*{\MvertSets}{%
    \renewcommand*\SetSuchThat[1][]{%
        \mathclose{}%
        \nonscript\;##1\vert\penalty\relpenalty\nonscript\;%
        \mathopen{}%
    }%
}
\ColonSets % default
\DeclarePairedDelimiterX \Set [2] {\lbrace}{\rbrace}
    {\,#1\SetSuchThat[\delimsize]#2\,}



\begin{document}

Description of a set: \( X = \Set*{\frac{n-1}{n}}{n\in\No} \).

A ``handmade'' version, which permits line breaks within itself:
\( X = \bigl\{\, \frac{n+1}{n} \SetSuchThat[\big] n\in\No \,\bigr\} \).

Second ``handmade'' version, again unbreakable:
\( X = \mleft\{ \frac{n+2}{n} \SetSuchThat[\middle] n\in\No \mright\} \).

The ``big set'' written first with \texttt{array}
\begin{equation*}
    \renewcommand*{\arraystretch}{1.2}
    S \triangleq
    \Set*{(D_1,D_2,D_0)}{
        \begin{array}{@{}l@{}}
            \multicolumn{1}{c}{\exists f_{1}, f_{2} \text{ s.t.}} \\ 
            \hat{X}_1 = f_1(Y_1), \\
            \hat{X}_2 = f_2(Y_2), \\
            D_1 \geq \E[d_1(X,\hat{X}_1)], \\
            D_2 \geq \E[d_2(X,\hat{X}_2)], \\
            D_0 \geq \E[d_0(\hat{X}_1,\hat{X}_2)]
        \end{array}
    }
    ,
\end{equation*}
and then with \texttt{aligned}
\begin{equation*}
    S \triangleq
    \Set*{(D_1,D_2,D_0)}{
        \begin{aligned}
            &\exists f_{1}, f_{2} \text{ s.t.} \\ 
            \hat{X}_1 &= f_1(Y_1), \\
            \hat{X}_2 &= f_2(Y_2), \\
            D_1 &\geq \E[d_1(X,\hat{X}_1)], \\
            D_2 &\geq \E[d_2(X,\hat{X}_2)], \\
            D_0 &\geq \E[d_0(\hat{X}_1,\hat{X}_2)]
        \end{aligned}
    }
    .
\end{equation*}

Now we'll repeat the whole thing with the \verb|\MvertSets| declaration in
force.

\bigbreak

\MvertSets

Description of a set: \( X = \Set*{\frac{n-1}{n}}{n\in\No} \).

A ``handmade'' version, which permits line breaks within itself:
\( X = \bigl\{\, \frac{n+1}{n} \SetSuchThat[\big] n\in\No \,\bigr\} \).

Second ``handmade'' version, again unbreakable:
\( X = \mleft\{ \frac{n+2}{n} \SetSuchThat[\middle] n\in\No \mright\} \).

The ``big set'' written first with \texttt{array}
\begin{equation*}
    \renewcommand*{\arraystretch}{1.2}
    S \triangleq
    \Set*{(D_1,D_2,D_0)}{
        \begin{array}{@{}l@{}}
            \multicolumn{1}{c}{\exists f_{1}, f_{2} \text{ s.t.}} \\ 
            \hat{X}_1 = f_1(Y_1), \\
            \hat{X}_2 = f_2(Y_2), \\
            D_1 \geq \E[d_1(X,\hat{X}_1)], \\
            D_2 \geq \E[d_2(X,\hat{X}_2)], \\
            D_0 \geq \E[d_0(\hat{X}_1,\hat{X}_2)]
        \end{array}
    }
    ,
\end{equation*}
and then with \texttt{aligned}
\begin{equation*}
    S \triangleq
    \Set*{(D_1,D_2,D_0)}{
        \begin{aligned}
            &\exists f_{1}, f_{2} \text{ s.t.} \\ 
            \hat{X}_1 &= f_1(Y_1), \\
            \hat{X}_2 &= f_2(Y_2), \\
            D_1 &\geq \E[d_1(X,\hat{X}_1)], \\
            D_2 &\geq \E[d_2(X,\hat{X}_2)], \\
            D_0 &\geq \E[d_0(\hat{X}_1,\hat{X}_2)]
        \end{aligned}
    }
    .
\end{equation*}

IMHO\@, the first alternative looks better!

\end{document}

输出如下:

第三个代码示例的输出

评论

我编辑了第三个示例中的代码,以便在“不寻常”的情况下也能实现正确的间距(请参阅添加\mathclose{}和)mathopen{}。此外,应该注意的是,如果您愿意的话,可以很容易地实现 Barbara Beeton 的建议,即在“大集”描述中增加冒号右侧的空格:只需添加一个明确的间距命令即可,例如 \;,位于命令的第二个参数的开头\Set,如下所示:

\Set*{(D_1,D_2,D_0)}{\; % <-- added space
    \begin{array}{@{}l@{}}
        \multicolumn{1}{c}{\exists f_{1}, f_{2} \text{ s.t.}} \\ 
        \hat{X}_1 = f_1(Y_1), \\
        \hat{X}_2 = f_2(Y_2), \\
        D_1 \geq \E[d_1(X,\hat{X}_1)], \\
        D_2 \geq \E[d_2(X,\hat{X}_2)], \\
        D_0 \geq \E[d_0(\hat{X}_1,\hat{X}_2)]
    \end{array}
}

您可能还想在第一个参数的末尾添加类似数量的空格;例如,下面是如何添加一个细空格:

\Set*{(D_1,D_2,D_0)\,}{\; % <-- look here
    \begin{aligned}
        &\exists f_{1}, f_{2} \text{ s.t.} \\ 
        \hat{X}_1 &= f_1(Y_1), \\
        \hat{X}_2 &= f_2(Y_2), \\
        D_1 &\geq \E[d_1(X,\hat{X}_1)], \\
        D_2 &\geq \E[d_2(X,\hat{X}_2)], \\
        D_0 &\geq \E[d_0(\hat{X}_1,\hat{X}_2)]
    \end{aligned}
}

相关内容