答案1
这个问题有四种常用方法,你可以随意选择,而且用得非常多。当然,一些不常见的软件包也可能提供不同的方法,我不建议使用,因为它们可能更复杂,而且用得很少。
cases
通过包中的正常环境amsmath
。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{cases}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{cases}
\end{equation}
\end{document}
- 通过
\left\{ \right.
代码和包array
中的环境amsmath
。你可以添加 1 到 3\!
来调整左括号后或右括号前的空格。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\left\{
\begin{array}{ll}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{array}
\right.
\end{equation}
\begin{equation}
\left.
\begin{array}{ll}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{array}
\right\}
\end{equation}
\begin{equation}
\left\{
\begin{array}{ll}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{array}
\right\}
\end{equation}
\end{document}
- 通过包中的
\left\{ \right.
代码和环境。aligned
amsmath
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\left\{
\begin{aligned}
&\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
&\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{aligned}
\right.
\end{equation}
\begin{equation}
\left.
\begin{aligned}
&\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
&\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{aligned}
\right\}
\end{equation}
\begin{equation}
\left\{
\begin{aligned}
&\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
&\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{aligned}
\right\}
\end{equation}
\end{document}
- 通过包中的
dcases
或环境dcases*
mathtools
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\begin{dcases}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{dcases}
\end{equation}
\begin{equation}
\begin{dcases*}
\hat{y}_{i}^{k} = 0 &if ${S}_{i}^{k} < \tau$ \\
\hat{y}_{i}^{k} = 1 &if ${S}_{i}^{k} > \tau$
\end{dcases*}
\end{equation}
\begin{equation}
\begin{rcases}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{rcases}
\end{equation}
\begin{equation}
\begin{rcases*}
\hat{y}_{i}^{k} = 0 &if ${S}_{i}^{k} < \tau$ \\
\hat{y}_{i}^{k} = 1 &if ${S}_{i}^{k} > \tau$
\end{rcases*}
\end{equation}
\end{document}
答案2
正如我所评论的,您需要cases
环境。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{cases}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{cases}
\end{equation}
\end{document}
编辑:要在右侧放置括号,您可以使用\Biggr\}
(由@barbarabeeton 提供)命令。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{cases}
\hat{y}_{i}^{k} = 0 & \text{if } {S}_{i}^{k} < \tau \\
\hat{y}_{i}^{k} = 1 & \text{if } {S}_{i}^{k} > \tau
\end{cases}\Biggr\}
\end{equation}
\end{document}
答案3
您的问题不清楚。如果您想要一个模仿您发布的屏幕截图的解决方案,请使用cases
,例如@Imran 的回答。
相反,如果您想将两行表达式括在高大括号中,我建议您使用两列array
环境或Bmatrix*[l]
环境。
下面的屏幕截图说明了这两种可能性。
\documentclass{article}
\usepackage{mathtools} % for 'matrix*[l]' env.
\begin{document}
\begin{equation}
\begin{cases}
\hat{\mathcal{Y}}_{k}^{i} = 0 & \text{if ${\mathcal{S}}_{k}^{i} < \tau$,} \\
\hat{\mathcal{Y}}_{k}^{i} = 1 & \text{if ${\mathcal{S}}_{k}^{i} > \tau$.}
\end{cases}
\end{equation}
\begin{equation}
\begin{Bmatrix*}[l]
\hat{\mathcal{Y}}_{k}^{i} = 0 & \text{if ${\mathcal{S}}_{k}^{i} < \tau$} \\[0.75ex]
\hat{\mathcal{Y}}_{k}^{i} = 1 & \text{if ${\mathcal{S}}_{k}^{i} > \tau$}
\end{Bmatrix*}
\end{equation}
\end{document}
答案4
alignedat
和包的另一种可能性empheq
:
\documentclass{article}
\usepackage{empheq}
\begin{document}
\begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{equation} \begin{alignedat}{2}
\hat{y}_{i}^{k} & = 0 &\quad & \text{ if } S_{i}^{k} < \tau \\
\hat{y}_{i}^{k} &= 1 & & \text{ if }S_{i}^{k} > \tau
\end{alignedat}
\end{empheq}
\end{document}