# lock spacing in math mode [duplicate]

Is it possible to "lock", or protect, the spacing of a math formula displayed in-text, so that latex will not stretch and squeeze the formula?

I would not like to do this globally for all formulas, but I have one formula ($(-+++)$) that appears repeatedly. Is it possible force latex to always display it with the same spacing?

Update: I now realise that the problem in rendering $(-+++)$ was not due to stretching/squeezing in a paragraph, but due to the special role of + and - in latex formulas. The first - and + are presumably treated as delimiters between terms in a formula, and the latter two two are rendered differently with a shorter spacing. The solution $({-}{+}{+}{+})$ given by cgnieder solves this spacing problem, and gives equal spaces between all +:s and -:s. How to remove such spaces has been asked before: Removing spaces between "words" in math mode.

-

## marked as duplicate by egreg, Kurt, Qrrbrbirlbel, cmhughes, Heiko OberdiekAug 24 '13 at 16:26

Welcome to TeX.SE! Please provide an example of a formula whose (horizontal?) spacing you're looking to protect. Some of the methods available to preserve the basic spacing settings work differently depending on the "math atoms" (letters, commas, equal signs, plus signs, symbols, etc) present in the formula. –  Mico Aug 24 '13 at 11:43
\mbox{$...$} would prevent stretching or shrinking (but also line-breaking...) –  clemens Aug 24 '13 at 11:49
I have updated the question. Yes. I am referring to horizontal spacing. –  user14857 Aug 24 '13 at 11:49
@cgnieder: Both $(-+++)$ and \mbox{$(-+++)$} will have different spacings between the different plus signs. –  user14857 Aug 24 '13 at 11:54
@user14857 No, they don't: \documentclass{article}\begin{document}$(-+++)$\par\mbox{$(-+++)$}\end{document‌​} –  clemens Aug 24 '13 at 11:57

Spacing in (sub)formulae may be frozen by using {...}. In the following

$$x+y = z$$


is used in the first paragraph, and stretches as appropriate, whereas

$${x+y = z}$$


gets fixed spacing.

\documentclass{article}

\begin{document}

Here is an example formula $$x+y = z$$ which we repeat at several
times during the paragraph.  Notice that the spacing changes on
different uses $$x+y = z$$ depending on how much the line is
stretch.  This is useful as it helps with even spacing of the whole
paragraph despite the presence of formulae $$x+y = z$$.  Stretchable
spacing in the mathematics $$x+y = z$$ is often to be preferred.

Using braces \verb!{}! around the forumla $${x+y = z}$$ freezes the
spacing.  It also prevents line breaks occuring in the middle of the
formula $${x+y = z}$$.  This prevention of line breaks can also be
used in subformals, but we are demonstrating that in the case of $${x+y = z}$$.  I expect to see that the spacing in this paragraph is
not as good as the previous because of the lack of flexibility
associated to the formula $${x+y = z}$$.

\end{document}


You'll find this behaviour described in the TeXbook, p. 173

-
Very good illustration with the text-paragraph. Thank you. –  user14857 Aug 24 '13 at 17:48