How can I easily tell Latex to prevent line-breaks inside a part of an inline formula, without affecting inter-word spacing?
Writing something like $ab(c+d)$ in Latex is bad: Latex might put a line break after +. But I do not want to disable line breaks after a + globally; it is perfectly fine to have a line break in $abc+def$. Therefore I have followed the approach mentioned in this thread: simply add extra braces.
In principle, this is great. I can write things like ${ab(c+d)}$ and $abc+{de(f+g)}$ to control which parts of an inline equation are "atomic" in the sense that Latex must not add line breaks inside them.
Unfortunately, there seems to be an unwanted side effect: Latex typesets ${a+b}$ and $a+b$ in the middle of a fully-justified line of text in different ways. If I write $a+b$, Latex seems to add "flexible" spaces around +: just like regular inter-word spaces, Latex can slightly adjust the spacing so that a fully-justified paragraph looks good. However, if I write ${a+b}$, Latex seems to use fixed-width spaces around +.
This answer mentions that one possible approach is to write something like $a+\nobreak b$, but this gets tedious and error-prone, even with some macros. I would like to "mark" a certain part of an inline equation as a "nobreak-zone". How can I do that, with the least amount of extra code?
Ideally, I would like to write something like $abc + \x{de(f+g)}$, where \x is a macro that prevents line breaks but allows flexible spacing.
An example:
\documentclass[a4paper]{article}
\begin{document}
Foobar $aaaa+bbbb+cccc+dddd+eeee+ffff+gggg$ foobar foobar foobar foobar
foobar $aaaa+bbbb+cccc+dddd+eeee+ffff+gggg$ foobar foobar foobar.
Foobar ${aaaa+bbbb+cccc+dddd+eeee+ffff+gggg}$ foobar foobar foobar foobar
foobar ${aaaa+bbbb+cccc+dddd+eeee+ffff+gggg}$ foobar foobar foobar.
\end{document}
Produces:

${a+b}$and$a+b$is typeset in the same way, except that the first one cannot have a linebreak inside – May 15 '11 at 19:34${a+b}$the space is "frozen"; as the TeXbook says, a subformula in braces is typeset without stretching or shrinking. – egreg May 15 '11 at 20:45\thinmuskipto the fixed length of 2mu inside${a+b}$– May 16 '11 at 09:04$a+b$and${a+b}$are typeset differently, unless spaces are not stretched or shrinked in the former formula, which is unlikely in a normal paragraph. Around binary operators TeX uses\medmuskip, which usually has stretch and shrink components (that are ignored in a braced subformula). – egreg May 16 '11 at 09:22