Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
So do you want to use \begin{equation} .... \end{equation} or \[ %math.... \]? –  percusse Jan 6 '12 at 15:22
    
But then the continuation (of text) is in another line, I still want to write after the equation. –  Jon Jan 6 '12 at 15:24
1  
Is it a very large equation? If an equation looks bad when breaking over two lines then this is likely to be the case, and I urge you to consider promoting it to an unnumbered equation instead. –  qubyte Jan 6 '12 at 15:26
    
No, it's just that the line before it takes almost the whole line, and my equation is only a few characters, but it doesn't fit. –  Jon Jan 6 '12 at 15:34
    
Put \linebreak before the formula. –  egreg Jan 6 '12 at 15:43

2 Answers 2

up vote 12 down vote accepted

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.

share|improve this answer
    
The first method works fine for me. Thanks! –  Jon Jan 6 '12 at 15:42

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.