I can use ~
to produce a non-breaking space. But it is too large for me, and I would like a non-breaking space of the size of \,
for example. Is it possible ?
[Tex/LaTex] How to typeset a “small” non-breaking space
line-breakingspacing
line-breakingspacing
I can use ~
to produce a non-breaking space. But it is too large for me, and I would like a non-breaking space of the size of \,
for example. Is it possible ?
Best Answer
There are two kinds of spacing that TeX can use: skips and kerns. The first sort of space can be flexible (the interword space is a skip, for instance), while the second one is rigid.
Both disappear at line breaks, but TeX will never break a line at a kern (unless it's followed by a skip), while it's willing to do it at skips. Therefore
would never be broken across lines.
The command
\,
inserts a kern, precisely it's defined (in text mode) as(where 1em is approximately the width of an uppercase "M", whence the name, or near the font size in points); so the space inserted by
\,
is 1/6 of an em.Conversely,
~
is defined as a skip: its definition is\nobreakspace
, which translates into(the last is "backslash+space"). There will be no line break at it, because the skip inserted by
\<space>
is preceded by so high a penalty that breaks are impossible (\nobreak
translates into\penalty 10000
).You can space by inserting
\kern
yourself, but using a macro is preferable. If you need that the space is non breakable and flexible, use the same trick as~
:would insert a space normally equal to 1/6 of an em, but stretchable to 1/4 of an em.
I left out the
\leavevmode
because such spaces should always be inserted between words. LaTeX takes that precaution, because users might use~
in order to indent lines (which is not the best thing to do, though).