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 hope this question was not asked before. At least I haven't found it. I have an inline math equation and LaTeX is breaking it into two parts. In this case I'd prefer to have the whole and short equation in one line. Is there any way I can do that? I already tried to put it into a \mbox but that destroyed the whole layout. Here is an example:

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
A text with an inline equation which is broken in to two parts
but is not wanted right here $v_{initial} = \SI{1000}{m/s}$.
\end{document}

Here the result would be:

A text with an inline equation which is broken in to two parts but is not wanted right here v_{initial} =
1000m/s.
share|improve this question
1  
Did you try \hbox'ing the math? –  Joseph Wright Feb 11 '11 at 17:13
1  
@Joseph Wright, the result is the same like with \mbox. You get an overfull box. –  quinmars Feb 11 '11 at 17:41

6 Answers 6

up vote 41 down vote accepted

put it into braces {...}, then it will be a math atom and not broken at the end of the line.

${v_{initial} = \SI{1000}{m/s}}$

the prevent an overfull box use \sloppy:

\documentclass{article}
\usepackage{siunitx}
\begin{document}

{\sloppy
A text with an inline equation which is broken in to two parts
but is not wanted right here ${v_{initial} = \SI{1000}{m/s}}$.}
\end{document}
share|improve this answer
4  
Thanks, that was what I was looking for. But LaTeX is splitting it for good reason, maybe I'm going to re-arrange the sentence. –  quinmars Feb 11 '11 at 17:43

As other answers have mentioned you may use an extra set of {} however this is essentially equivalent to using \mbox{......} and like all such boxing does two things. It prevents line breaking but it also freezes all white space at its natural size and prevents stretching or shrinking, this makes it even harder to fit the unbreakable box into the paragraph.

It is usually better to prevent line breaks without freezing the white space. TeX will break after binary operators and relations and the penalty for breaking in those places are set by default in LaTeX to

\binoppenalty=700
\relpenalty=500

So if you set

\binoppenalty=\maxdimen
\relpenalty=\maxdimen

Then Line breaking will be prevented for the rest of the document (or environment) without needing to add markup to each inline expression and allowing TeX to stretch or shrink white space to fit the expression into the surrounding paragraph.

share|improve this answer

Line breaking will not occur inside a part of a formula that is enclosed in braces:

${v_{initial} = \SI{1000}{m/s}}$
share|improve this answer

You can simply include a line break (\\).

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
A text with an inline equation which is broken in to two parts
but is not wanted right here \\ $v_{initial} = \SI{1000}{m/s}$.
\end{document}
share|improve this answer
3  
But then the first line won't be justified. (Not that it would look good if it's justified, but unjustified may be even worse.) –  Hendrik Vogt Feb 11 '11 at 21:42

You can prevent the linebreak by using braces. But you will then get an overfull box:

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
A text with an inline equation which is broken in to two parts
but is not wanted right here ${v_{initial} = \SI{1000}{m/s}}$.
\end{document}
share|improve this answer

TeX thinks an equals sign is a good place to break an inline equation. Putting \nolinebreak right after the equals sign avoids the break (you do get an overfull box, though).

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.