# [texhax] latex help? ["shortisch formula"]

Uwe Lück uwe.lueck at web.de
Fri Apr 7 17:41:46 CEST 2006

At 23:02 06.04.06, Karl Berry wrote:

>     So what I need is a way of telling latex to write the mbox on a new
>     line if the previous line cannot contain it properly.
>
>I think what's happening is that an unbreakable formula, even a shortish
>formula, is simply a hard thing to break lines around.  When TeX keeps
>it at the end of the line (making a too-long line), I think it's because
>it sees every alternative as worse.  To test this theory, try doing
>\begin{sloppypar}
>\mbox{$V=ZI$}
>... rest of paragraph
>\end{sloppypar}
>
>And see if it moves down.  (I expect the spacing will be pretty awful.)
>
>If this works out, since you don't want to use sloppypar around every
>paragraph, the real solution might be to adjust some of TeX's line
>breaking parameters, notably \tolerance, to allow looser paragraphs in
>general.
>
>By the way, I believe you can prohibit all breaks in formulas by setting
>\relpenalty=10000
>\binoppenalty=10000
>
>However, you probably have other (displayed) equations where you really
>do need to allow breaks at relations and operators, in which case this
>wouldn't be the way to go.

Good that I haven't given an earlier answer, which would have
considered sloppypar only -- I deem sloppypar a worse solution.

\makeatletter
\newcommand{\nobreakf}{\binoppenalty\@M\relpenalty\@M}
\makeatother

(... in the document preamble). Then place that \nobreakf
in each "shortish" formula, i.e., inside $...$ or $$...$$;
you can place it right before the second $or before the \). (Be sure to use \nobreakf', not \nobreak'.) I have tested this (instead of trying to understand the TeXbook; test: \hsize .33em'; then $X=Y\nobreakf\$' does).
It seems to suffice indeed to put \nobreakf anywhere
inside such a formula. Other line breaks (even within the same
paragraph) then seem not to be affected.

Good luck,
Uwe.