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.

In order to make text flushed both left and right, latex adjusts the distance between words, and to a lesser extent, the distance between characters within a word. This is good, however it also adjusts the spacing within mathematical formulae. I don't like this feature - can I reduce its effect, or perhaps turn it off completely?

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

You would have to modify the length registers that allow for stretch/shrink around math operators/relations, namely \medmuskip and \thickmuskip. Their defaults are 4.0mu plus 2.0mu minus 4.0mu and 5.0mu plus 5.0mu. So adding

\setlength{\medmuskip}{1\medmuskip}% Formerly 4.0mu plus 2.0mu minus 4.0mu -> 4.0mu
\setlength{\thickmuskip}{1\thickmuskip}% Formerly 5.0mu plus 5.0mu -> 5.0mu

should work by stripping the glue. For more on math spacing around operators, see How to change default for spacing around binary relations?


Here's a small example:

enter image description here

\documentclass{article}
\begin{document}
Here is some text with an equation in it: $f(x)=x^2+3x_0\cdot\sin x$ 
and the textual content continues into the second line. No other math
content is contained within this paragraph.

%\thinmuskip=3.0mu (without glue)
\setlength{\medmuskip}{1\medmuskip}% Formerly 4.0mu plus 2.0mu minus 4.0mu -> 4.0mu
\setlength{\thickmuskip}{1\thickmuskip}% Formerly 5.0mu plus 5.0mu -> 5.0mu

Here is some text with an equation in it: $f(x)=x^2+3x_0\cdot\sin x$ 
and the textual content continues into the second line. No other math
content is contained within this paragraph.
\end{document}

Since \thinmuskip is already void of glue, no further modifications is required. For a motivation of where these lengths are used, see the mathmode documentation (section 11 Space, subsection 11.1 Math typesetting, p 28).

muskips are not supported by calc, alternate calculations techniques (using plain TeX) are required to manipulate these lengths.

share|improve this answer
1  
\setlength should not be used, because muskips are not supported by package calc. Also there is no need for magic numbers, \medmuskip=1\medmuskip and \thickmuskip=1\thickmuskip will do. –  Heiko Oberdiek Nov 22 '12 at 8:29
add comment

As an alternative to resetting the parameters it is sometimes more convenient to box the expression so it is set to natural width, either with an explicit box, or within the math, just using {}.

enter image description here

Note the math only stretched on the second row in this plain tex example.

X\hbox{words here $a + b$ and here}X

X\hbox spread 1cm{words here $a + b$ and here}X


X\hbox spread 1cm{words here \hbox{$a + b$} and here}X

X\hbox spread 1cm{words here ${a + b}$ and here}X

\bye
share|improve this answer
add comment

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.