0

I find myself often converting some inline math like $a < b$ into ${a < b}$ so TeX won't insert a line break after the comparison operator. I would prefer if TeX simply treated my inline math as unbreakable by default, since I almost always use display math for long equations anyway. If I want to break some inline math manually, I can add \allowbreak. Is this configuration possible?

  • 2
    {...} prevents white space stretching and shrinking as well as preventing line breaking, so it isn't usually a good solution. – David Carlisle Dec 3 at 0:43
  • Thanks for bringing that to my attention; I didn't know. – japreiss Dec 3 at 2:12
6

Linebreaks in inline math are only possible around a relation or a binary operator. Setting the corresponding linebreak penalties to a high value (10000 and larger is considered infinite) will suppress the linebreak.

\documentclass{article}

\begin{document}

\fbox{\parbox{45pt}{math $a < b$}}
\fbox{\parbox{40pt}{math $a + b$}}

\binoppenalty=10000
\relpenalty=10000

\fbox{\parbox{45pt}{math $a < b$}}
\fbox{\parbox{40pt}{math $a + b$}}

\fbox{\parbox{45pt}{math $a <\allowbreak b$}}
\fbox{\parbox{40pt}{math $a +\allowbreak b$}}

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