I wish to write an inline equation using $%math...$, but the current line is too long, so the equation is broken into two parts, first one in the original line, and the other in a new line. I don't want this situation; I want a whole line, and after it the equation. I don't want to use \newline{} or something like that, because it stops the line in the middle and doesn't do the indenting (the spacing which makes all the lines to end on the same vertical line). What can I do?
2 Answers
LaTeX can break inline formulas after a relational or a binary symbol. If you don't want this to happen you can explicitly prevent it by setting:
\relpenalty=10000
\binoppenalty=10000
LaTeX will then always try to keep the $...$ within one line, but as a result you may end up with overfull hboxes if the paragraph doesn't have enough flexibility to allow for some acceptable line breaking. In that case xou then have to place an explicit linebreak (or an optional one) manually into the formula using \linebreak (with or without an optional argument).
The alternative (as a one-time change) is that you place an explicit linebreak just before the formula (via \linebreak) which will then force a linebreak at that point with a justified line in fron of the formula. Again this only works with enough flexibility in the paragraph.
The other possibility for a one-time change is to put the above parameter settings inside the $...$in which case they only apply to that equation.
What you should not do (normally) is to surround the whole equation by, say an \mbox. In practive this will also prevent LaTeX from breaking it over a line, but it has the additional effect of making the spacing within the formula rigid, i.e., the formula will not be queezed or spread in line with the rest of the paragraph material.
The only other alternative is to go for displayed formula as mentioned in the comment.
- 77,146
You have many things to try; the simplest one is to write
some text \linebreak[1] $x+y=z$
that will invite TeX to push the equation on the next line; if this doesn't work, then modify the optional argument to \linebreak:
\linebreak[0] % just a marker
\linebreak[1] % this is a nice point for a break
\linebreak[2] % this is a good point for a break
\linebreak[3] % this is a quite good point for a break
\linebreak[4] % break here, no discussion
Try starting from 1, because this will give you a measure of how bad the lines will be typeset: a higher value corresponds to more badness.
Another strategy is to mark the places where you don't want a break in the formula, for example
some text $x+\nobreak y=z$
as a break after the = is generally more acceptable than a break after +. Of course one should see the formula to decide what are the acceptable break points.
- 1,121,712
\begin{equation} .... \end{equation}or\[ %math.... \]? – percusse Jan 06 '12 at 15:22\linebreakbefore the formula. – egreg Jan 06 '12 at 15:43