我需要用 begin{cases} 来显示一个等式,但是文本比我的文章的列大,我找不到强制它换行的方法。
代码:
\[
Match_D =
\begin{cases}
1, & \text{if $D_j$ matches a single detected rectangle,} \\
0, & \text{if $D_j$ does not match any detected rectangle,} \\
f_{sc}(k) & \text{if $D_j$ matches several $(k)$ detected rectangles}
\end{cases}
\]
\[
Match_G =
\begin{cases}
1, & \text{if $G_i$ matches a single detected rectangle,} \\
0, & \text{if $G_i$ does not match any detected rectangle,} \\
f_{sc}(k) & \text{if $G_i$ matches several $(k)$ detected rectangles}
\end{cases}
\]
问候
答案1
您可以使用\parbox
固定宽度:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
Match_D =
\begin{cases}
1, & \parbox{.3\linewidth}{if $D_j$ matches a single detected rectangle,} \\[3ex]
0, & \parbox{.3\linewidth}{if $D_j$ does not match any detected rectangle,} \\[3ex]
f_{sc}(k) & \parbox{.3\linewidth}{if $D_j$ matches several $(k)$ detected rectangles}
\end{cases}
\]
\[
Match_G =
\begin{cases}
1, & \parbox[t]{.3\linewidth}{if $G_i$ matches a single detected rectangle,} \\[3ex]
0, & \parbox[t]{.3\linewidth}{if $G_i$ does not match any detected rectangle,} \\[3ex]
f_{sc}(k) & \parbox[t]{.3\linewidth}{if $G_i$ matches several $(k)$ detected rectangles}
\end{cases}
\]
\end{document}
您可以使用[t]
op 对齐(参见 Match_G)或(默认)[c]
输入对齐(参见 Match_D)。
答案2
两种变体无需测量任何东西:一种是环境empheq
和 tabular
s,另一种是cases*
环境来自mathtools
。第一种方法使您能够根据需要轻松地对每个案例进行编号或子编号。cases*
只是一个cases
环境,其中第二列自动处于文本模式。
它只需要加载empheq
、加载mathtools
、加载amsmath
。
\documentclass{article}
\usepackage{empheq}
\begin{document}
\begin{subequations}
\begin{empheq}[left={\mathrm{Match}_G=\empheqlbrace}]{alignat=2}
& 1 & \quad& \begin{tabular}[t]{l}
if $G_i$ matches a single \\ detected rectangle,
\end{tabular} \\
& 0 & & \begin{tabular}[t]{l}
if $G_i$ does not match \\ any detected rectangle,
\end{tabular} \\
& f_{sc}(k) & & \begin{tabular}[t]{l}
if $G_i$ matches several \\ $(k)$ detected rectangle,
\end{tabular}
\end{empheq}
\end{subequations}
\[
\mathrm{Match}_G =
\begin{cases*}
1, & if $G_i$ matches a single \\[-0.5ex]
& detected rectangle, \\%[0.5ex]
0, & if $G_i$ does not match\\[-0.5ex]
& any detected rectangle, \\%[0.5ex]
f_{sc}(k) & if $G_i$ matches several \\[-0.5ex]
& $(k)$ detected rectangles
\end{cases*}
\]
\end{document}
答案3
我发现了一个更优雅的方法:
\begin{equation}
Match_D =
\begin{cases}
1, & \text{if $D_j$ matches a single detected rectangle,} \\
0, & \text{if $D_j$ does not match any detected} \\&\text{rectangle}, \\
f_{sc}(k) & \text{if $D_j$ matches several $(k)$ detected} \\&\text{rectangles}
\end{cases}
\end{equation}