12

I could not find enough information on Google about control space (\). What is the purpose of it? Where should it be used?

9

The following is taken directly from Knuth's TeXbook (Chapter 3: Controlling TeX, p 8):

When a space comes after a control word (an all-letter control sequence), it is ignored by TeX; i.e., it is not considered to be a "real" space belonging to the manuscript that is being typeset. But when a space comes after a control symbol, it's truly a space.

Now the question arises, what do you do if you actually want a space to appear after a control word? We will see later that TeX treats two or more consecutive spaces as a single space, so the answer is not going to be "type two spaces." The correct answer is to type "control space," namely

\␣

(the escape character followed by a blank space); TeX will treat this as a space that is not to be ignored. Notice that control-space is a control sequence of the second kind, namely a control symbol, since there is a single nonletter (␣) following the escape character. Two consecutive spaces are considered to be equivalent to a single space, so further spaces immediately following \␣ will be ignored. But if you want to enter, say, three consecutive spaces into a manuscript you can type \␣\␣\␣. Incidentally, typists are often taught to put two spaces at the ends of sentences; but we will see later that TeX has its own way to produce extra space in such cases. Thus you needn't be consistent in the number of spaces you type.

For example, compare

\TeX\ ignores spaces after control words.

to

\TeX ignores spaces after control words.

enter image description here

7

There are not many uses for it besides after control sequences or to ensure non extended spaces after periods that are not punctuation (but in these cases, a tie ~ would be better).

The tie is defined in terms of : in Plain TeX it is

\def~{\penalty\@M \ } % tie

while in LaTeX we see

\def~{\nobreakspace{}}
\DeclareRobustCommand{\nobreakspace}{\leavevmode\nobreak\ }

By the way, there is a difference between the tie in Plain and in LaTeX: if you have a ~ just after an empty line in a Plain TeX document, the penalty would be inserted in vertical mode (not really a big deal, actually).

Knuth likes, sometimes, to add a “very extended” space. This is the end of chapter 15, on page breaking (taken from texbook.tex):

[...] After the |\output| routine is finished, ^{held-over
insertion} items are placed first on the list of recent contributions, followed
by the vertical list constructed by |\output|, followed by the recent
contributions beginning with the page break. \ (Deep breath.) \ You got that?

These are two interword spaces plus the extra space due to the sentence ending period. Such a double space may be employed in headers.

If \frenchspacing is in force, then and \space would be equivalent, as \space expands to a space token and the space factor wouldn't come into action to make a difference. However, is possibly clearer than \space and they are not equivalent under \nonfrenchspacing.

In the Knuth example above,

break. \space (Deep Breath.)

would produce a wider space, because both space tokens would be extended because of the space factor after . which is 3000.


A tiny quirk: if you have at the end of a line, the space would be removed and replaced by the \endlinechar. Indeed, both Plain and LaTeX define a meaning for \^^M

\def\^^M{\ } % control <return> = control <space>

An input such as

\endlinechar=`S
abc\
def\bye%

would produce

enter image description here

If I find myself in need of at the end of a line, I usually add % and, indeed,

\endlinechar=`S
abc\ %
def\bye%

would produce a space.

  • at the end of your first sentence, i'd say "a tie ~ would usually be better". some people insist on not putting commas after "i.e." or "e.g.", and in those cases, a line break is almost always okay. (i'd prefer the comma, myself, but some authors are adamant, and i prefer to save my energy for dealing with changes in situations where there is real confusion in the original text.) – barbara beeton Nov 19 '14 at 19:37
  • @barbarabeeton I spoke about periods not being punctuation; if I had to avoid a comma after i.e., I'd certainly not want it at the end of a line. – egreg Nov 19 '14 at 20:29
  • i've seen some convoluted sentences where "e.g." has been moved to the end of a sentence, such as "that's because aaa and bbb, e.g." (rather than "for example", which i would find preferable). in that situation, surely you wouldn't want to suppress a line break. (although you may want to severely chastise the author.) in that case, the period after "g" performs two functions -- both the abbreviation and the end of the sentence. (i helped keypunch the brown linguistic corpus, which contained some "dual-function" periods; i remember the discussion, but not the resolution.) – barbara beeton Nov 19 '14 at 20:43
  • @barbarabeeton Sorry, I'm not indulging bad style. ;-) I consider a two function period worse than letterspacing lowercase. – egreg Nov 19 '14 at 20:48

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.