2

I know that a backslash will produce a normal-sized space after a period i.e.\ like this and I know that a tilde will produce a non-breaking space, as in Figure~1.

What if I want a non-breaking space after an abbreviating period in the middle of a sentence, like when referring to Eq.\~1?

Until now I have just been using ~ in such circumstances but I've noticed that occasionally there is an inter-sentence space in between Eq. and 1.

  • 1
    Can you provide an example of such an inter-sentence space? ~ should do what you want. – schtandard May 2 at 13:48
1

This demonstrates that the issue is not that the period looks like an end of sentence, but that ~, while non-breaking, is stretchable. If you don't want it to stretch, you can place it in an \mbox, or instead use a \kern. Of course, removing the stretch from ~ will only make it harder to justify the remainder of the line.

In the first example, the ~ is slightly compressed. In the 2nd, it is quite expanded. In the 3rd, I use a \kern to prevent stretch, and in the 4th, I use an \mbox to prevent stretch.

\documentclass{article}
\textwidth1in
\begin{document}
xxxxxx Fig.~1 xxxxxxx

\sloppy

xxxx Fig.~1 xxxxxxx

xxxx Fig.\kern.75ex1 xxxxxxx

xxxx \mbox{Fig.~1} xxxxxxx
\end{document}

enter image description here

Another option is to redefine ~ to a different stretch, for example \renewcommand~{\nobreak\hspace{.75ex minus .5ex}}. In that case, the above MWE with that change becomes

enter image description here

SUPPLEMENT

To answer the OP's comment about whether the sequence .~ can produce end-of-sentence spacing, or merely a stretchable space, this MWE demonstrates that it is the latter. Note that \@ overcomes the end-of-sentence nature of a .

We see that .~ behaves the same as .\@~ rather than . followed by a space.

\documentclass{article}
\begin{document}
x. z

x.~z

x.\@~z
\end{document}

enter image description here

  • ok thanks. Just to be clear then, .~ should produce a period and a stretchable space, but not the extra space that happens in between sentences? If so then the extra space I saw in Eq.~1 may just be due to the line justification, and because the period is a small glyph with lots of room above it! – jms547 May 2 at 14:16
  • @jms547 I believe that is the case. You can always use \@ to overrule the end-of-line period space. So compare x. z x.~z x.\@~z for example. – Steven B. Segletes May 2 at 14:21
0

Essentially, ~ is a shorthand for \nobreakspace{} and \nobreakspace is defined as

% latex.ltx, line 1614:
\DeclareRobustCommand{\nobreakspace}{%
   \leavevmode\nobreak\ }

In turn, \nobreak is the same as \penalty10000; \leavevmode is used to ensure that the penalty is issued in horizontal mode, so as to inhibit any line break at the spot. The glue (space) inserted by \␣ (backslash space) cannot be used as a line break point, because it is preceded by a penalty, which is a discardable item.

The TeXbook, on page 285, specifies

  • \␣. A control-space command appends glue to the current list, using the same amount that a ⟨space token⟩ inserts when the space factor is 1000.

So no extra space is inserted, independently from the space factor code of the preceding character.

Therefore Eq.\ 1 and Eq.~1 are equivalent as far as the amount of inserted space is concerned; the latter disallows a line break between Eq. and 1.

However, the interword glue is usually flexible (stretchable and shrinkable) and will adjust for justification by the same factor as all other spaces in the same line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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