2

I need to show an equation with begin{cases} however the text is bigger than the column of my article and I couldn't find a way to force it to break the line.

Code:

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

Regards

  • You should input \mathit{Match} rather than Match: try it and see the difference. Or \mathrm{Match}, depending on your preferences. – egreg Jul 27 '18 at 21:58
2

You can use a \parbox of fixed width:

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

You can use [t]op alignment (see Match_G) or (the default) [c]entered alignment (see Match_D).

result

2

Two variants without having to measure whatever: one with the empheqenvironment and tabulars, another with the cases* environment from mathtools. The first way enables you to easily number or subnumber each case if you wish. cases*is just a cases environment in which the 2nd column is automatically in text mode.

It require only loading empheq, which loads mathtools, which loads 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} 

enter image description here

  • I believe this answer is correct too but I just tested the other – Claudio Jul 27 '18 at 23:31

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.