Prevent Line Breaking Inline Formula in TeX/LaTeX

If you ever wrote a document in LaTeX (or TeX) that used inline formulas, you know how frustrating it is when LaTeX insists on breaking your inline formula across two lines. The easiest solution to this problem, in my opinion, is to prevent line breaks in inline formulas at all except under extreme cases. To prevent line breaks in inline formulas, just add the following two lines to your preamble:

relpenalty=9999
binoppenalty=9999

Now I will explain what we did. relpenalty=[number parameter]: the parameter specifies the penalty for breaking a math formula after a relation when the formula appears in a paragraph. Plain TeX sets relpenalty to 500. binoppenalty=[number parameter]: the parameter specifies the penalty for breaking a math formula after a binary operator when the formula appears in a paragraph. Plain TeX sets binoppenalty to 700. Both parameters can be set anywhere from 0 to 10000. If set to 10000, the inline formulas will never break, even in extreme cases. Setting it a bit lower would prevent line breaking except where TeX would encounter extreme cases that must have a line break because of the situation.

4 thoughts on “Prevent Line Breaking Inline Formula in TeX/LaTeX”

  1. Thanks. People connecting to people for help; ain’t that great?; saved me much time as well.

  2. Thanks!

    Though, for my specific case, i had to use 10000 instead of 9999, which should be some care, since 10000 effectively forces LaTeX to do what you want, even if it makes the page look stupid.

Leave a Reply

Your email address will not be published. Required fields are marked *