# Prevent LaTeX to break an inline math equation

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.

-
Did you try \hbox'ing the math? –  Joseph Wright Feb 11 '11 at 17:13
@Joseph Wright, the result is the same like with \mbox. You get an overfull box. –  quinmars Feb 11 '11 at 17:41

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}}$


to 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}

-
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.

-
Perhaps better than \maxdimen is 9999, which will avoid it as much as possible, but permit it in extreme cases. From this answer. –  chmullig Dec 16 at 2:45

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

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

-

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}

-
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}

-

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).

-