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.

This question already has an answer here:

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.

share|improve this question
    
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
2  
\mbox{$...$} would prevent stretching or shrinking (but also line-breaking...) –  cgnieder 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‌​} –  cgnieder Aug 24 '13 at 11:57
show 3 more comments

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 2 down vote accepted

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.

Sample output

\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

share|improve this answer
    
Very good illustration with the text-paragraph. Thank you. –  user14857 Aug 24 '13 at 17:48
add comment

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