1

I have just started LaTeX so this may be a silly question, but I am getting a warning "Overfull \hbox(---pt too wide) detected" and the compiled pdf shows this text "if the sum of edge densities in the patch (x', y') is greater than threshold" (line 3 in the code) in a single line and this line is going out of bounds. Ideally that line should've been printed in two lines. I have tried linebreak but that doesn't work here. How to correct this?

\begin{equation}
I^p(x',y') = \left\{\begin{array}{rl}
    1 & \text{if the sum of edge densities in the patch (x', y') is greater than threshold}\\
    0 & \text{otherwise}\\
    \end{array}\right.
\end{equation}
2
  • 1
    you just post a fragment that makes it hard for people to test and hard to suggest changes, In particualar the fragment gives no indication on how wide your text is so if we make a test document it may or may not be overfull depending on what we guess for font size and page size {but you can use a \parbox instead of \text if you need line breaks. Feb 18 '18 at 15:16
  • Also, is there a reason to emulate cases with array? Feb 18 '18 at 15:41
2

You can't break lines in \text, but you can use a \parbox; adjust the width to suit.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}% for mock text

\begin{document}

\lipsum*[3]
\begin{equation}
I^p(x',y') =
\begin{cases}
  1 & \parbox[t]{.5\textwidth}{\raggedright
        if the sum of edge densities in the patch
        $(x', y')$ is greater than threshold
      }\\[4ex]
  0 & \text{otherwise}
\end{cases}
\end{equation}
\lipsum[4]

\end{document}

enter image description here

1

With mathtools and stackengine, you have a very simple code. The cases* takes care of the left brace and the second column of the environment automatically leaves math mode:

\documentclass{article}

\usepackage{mathtools, stackengine}

\begin{document}

\begin{equation}\def\stackalignment{l}
I^p(x',y') =\begin{cases*}
    1 & \stackunder{if the sum of edge densities in the patch}{$(x', y')$ is greater than threshold} \\
    0 & otherwise\\
    \end{cases*}
\end{equation}

\end{document} 

enter image description here

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.