8

Let's assume that you write American English and put commas after “i.e.” and “e.g.”.
It has long been known that when you have a closing parenthesis after such an abbreviation, as in “Take an arbitrary cat (a Siamese cat, e.g.) and try to understand which kind of fuel it needs. To this end, …”, you better put a \@ right after “e.g.” because your sentence may be used in the \nonfrenchspacing context and you don't want to have an inter-sentence spacing in the middle of a sentence:

Take an arbitrary cat (a Siamese cat, e.g.\@) and try to understand which kind of fuel it needs.  To this end, \ldots.

The same goes when you have a closing bracket:

Take an arbitrary cat [a Siamese cat, e.g.\@] and try to understand which kind of fuel it needs.  To this end, \ldots.

But when “e.g.” is followed by a comma, or a right brace, or an old-style slash bracket, no \@ is needed; all three choices below produce the same result:

To this end, take a can of fuel /gasoline, e.g./ and a funnel.  Then, \ldots.\\

To this end, take a can of fuel /gasoline, e.g.\@/ and a funnel.  Then, \ldots.\\

To this end, take a can of fuel /gasoline, e.g./\ and a funnel.  Then, \ldots.\\

I have not tested chevrons, quotation marks, or any other symbols — I have no idea what the result would be.

  1. Why is there such a difference when using different symbols after the period?

  2. Can you safely write … , e.g., … in all contexts in the middle of a sentence or do you need to say … , e.g.\@, … (in some circumstances currently unknown to me)? Example:

    Then, call up the cat, e.g., by saying ``here kitty-kitty.''
    

(P.S. The text about cats is absolutely imaginary; don't actually do this.)

9
  • Basically, are you asking why TeX inserts an after-sentence-end space after ) and ], e.g., "Come here. (Yes, now.) Move it." but not after symbols such as , say, "..., e.g., ...")?
    – Mico
    Jun 10, 2021 at 19:15
  • @Mico I assume you mean “when a period comes right before the symbol (), ], ,, /, \}, …)”? I'm even not sure whether TeX does exactly this: taking a look at the next symbol and deciding which space to use. You can imagine, e.g., that we have more than one noncontrol, nonspace, and nonalphanumeric symbol after the period, though I wouldn't know any usage of it. The most common case for me is really the "e.g., ", that is, the comma and the space.
    – user224332
    Jun 10, 2021 at 19:31
  • 2
    You may be interested in chapter 20 of TeX by Topic. In short the spacing is controlled by the spacefactor. Parentheses have spacefactor code 0, which means they are essentially invisible for spacefactor purposes. The , has spacefactor code 1000 or 1250, which means that it won't get enlarged spaces (but it might be slightly more stretchable).
    – moewe
    Jun 10, 2021 at 19:33
  • 2
    Yes. Unless someone messes with the space factor codes of the characters involved you won't need a \@ before the comma in those examples.
    – moewe
    Jun 10, 2021 at 19:56
  • 1
    As far as I can see core babel only sets space factor codes to the 'standard values' Eijkhout lists in TeX by Topic (e.g. 1000 in French and 1250 in non-French for the comma). I would expect most languages modules to leave this alone, but I obviously didn't check them all.
    – moewe
    Jun 10, 2021 at 20:21

2 Answers 2

10

When typesetting lines, TeX maintains an internal parameter called \spacefactor. The rules are simple:

  1. each character has an associated \sfcode (an integer);
  2. after a character is added to the horizontal list, the \spacefactor becomes the \sfcode of that character, except in two cases;
  3. if the character's \sfcode is 0, no change is made to \spacefactor;
  4. if the current \spacefactor is less than 1000 and the new character's \sfcode is > 1000, the \spacefactor is set to 1000.

The space factor can also be set manually, with the instruction \spacefactor<integer> and indeed, LaTeX’s \@ is an abbreviation for \spacefactor 1000.

The normal setting (under \nonfrenchspacing) is that

  • uppercase letters have \sfcode 999;
  • closing parentheses, quotes and brackets have \sfcode 0;
  • punctuation signs (comma, colon, semicolon, period, question mark, exclamation mark) have \sfcode larger than 1000 (depending on the “strength” of the punctuation sign);
  • every other character has \sfcode 1000.
the sfcode of ! is 3000
the sfcode of ' is 0
the sfcode of ( is 1000
the sfcode of ) is 0
the sfcode of * is 1000
the sfcode of + is 1000
the sfcode of , is 1250
the sfcode of - is 1000
the sfcode of . is 3000
the sfcode of / is 1000
the sfcode of 0 is 1000
the sfcode of 1 is 1000
the sfcode of 2 is 1000
the sfcode of 3 is 1000
the sfcode of 4 is 1000
the sfcode of 5 is 1000
the sfcode of 6 is 1000
the sfcode of 7 is 1000
the sfcode of 8 is 1000
the sfcode of 9 is 1000
the sfcode of : is 2000
the sfcode of ; is 1500
the sfcode of < is 1000
the sfcode of = is 1000
the sfcode of > is 1000
the sfcode of ? is 3000
the sfcode of @ is 1000
the sfcode of A is 999
[...]
the sfcode of Z is 999
the sfcode of [ is 1000
the sfcode of ] is 0
the sfcode of ` is 1000
the sfcode of a is 1000
[...]
the sfcode of z is 1000
the sfcode of { is 1000
the sfcode of | is 1000
the sfcode of } is 1000

Under \frenchspacing, punctuation signs have \sfcode 1000 and so the \spacefactor has no bearing at all.

Indeed, TeX adds some stretchability if a space is found when \spacefactor is larger than 1000 and even extra space if it is ≥ 2000. But beware, there's a catch! (There's always a catch, you know.) The primitive command “backslash-space” inserts a space that's not influenced by the current space factor.

The idea of \nonfrenchspacing is to obtain larger space after a punctuation sign, but this should not be influenced by quotes or parentheses.

So, with (Gotcha!) the space factor after the closing parenthesis would be 3000, exactly as if the parenthesis was missing. Similarly with ``Gotcha.''.

Typing e.g.\@, is redundant and e.g., would have the same effect: in either case the space factor after the comma would be 1250.

The \@ is important if you don't have a comma after e.g. so with e.g.\@ the period would not be considered sentence-ending (no extra space or extra stretching). Hence, in the case of

Take an arbitrary cat (a Siamese cat, e.g.\@) and

you do need \@, because ) is “transparent” to the space factor.

5
  • Thanks a lot! Both yours and Mico's answer are great; I have no idea on whom to give the checkmark, as both deserve it.
    – user224332
    Jun 10, 2021 at 20:31
  • In texmf-dist/doc/latex/base/usrguide3.tex we see etc.\@,. The way I read your answer, the \@ in this position is redundant, and the fragment can be safely replaced with etc.,. Is this correct, or is “LATEX3 methods for authors” so nonstandard that it really profits from \@ there?
    – AlMa1r
    Feb 3 at 11:04
  • @AlMa1r Yes, it's redundant. But it may be a good idea to always type etc.\@, so you never have to worry about what happens next.
    – egreg
    Feb 3 at 11:45
  • 1
    Thank you! Yes, and when you wish to search for text inside LaTeX documents, the less clutter you have, the easier the search …
    – AlMa1r
    Feb 3 at 11:54
  • Also recall Lamport's answer to “Three LATEX mistakes that people should stop making?”: “1. Worrying too much about formatting and not enough about content. 2. Worrying too much about formatting and not enough about content. 3. Worrying too much about formatting and not enough about content.” (Source: TUGboat, Volume 22 (2001), No. 1/2.)
    – AlMa1r
    Feb 3 at 18:30
4

Your main question would appear to be about the why, not about the what or how.

The premise is that \nonfrenchspacing is in effect, so that TeX is set to insert a bit more whitespace after a sentence-ending period (aka full stop), question mark, and exclamation mark than it'll do for ordinary interword whitespace.

A moment's reflection reveals that -- in English and in many other languages -- an entire sentence can occur inside a pair of (usually round) parentheses. E.g., with apologies to Julius Caesar, consider the following two fragments:

  I came. I hesitated.
  (I came.) I hesitated.

Thus, if TeX is supposed to insert extra whitespace after "came.", it should also do so after "came.)", right?

To the best of my knowledge, a period, question mark, or exclamation mark that's followed by a non-letter character other than ), ], and some quotation marks cannot end a sentence. Hence, TeX should therefore not insert extra whitespace after, say, e.g., and i.e.,, right?

Does this answer your why question? The "how" and "what" issues are explained very nicely in @moewe's comments.

7
  • 1
    Thanks, Mico! Well, I agree that “why” questions are tricky, and you nevertheless did the best job of explaining the Why to me in such a way that I understand it.
    – user224332
    Jun 10, 2021 at 20:25
  • Both yours and egreg's answer are great; I have no idea on whom to give the checkmark, as both deserve it.
    – user224332
    Jun 10, 2021 at 20:31
  • 1
    In the past times of machines without parentheses (I think, en.wikipedia.org/wiki/Typewriter#/media/… or en.wikipedia.org/wiki/Typewriter#/media/File:MEK_II-327.jpg), slashes were used instead, and then a slash could end a sentence. I guess, we'd encounter this case if we were to retype an old text exactly as it was typed originally. It'd be a pretty rare use of TeX.
    – user224332
    Jun 10, 2021 at 21:01
  • 1
    @GeekestGeek - I suppose you're right. Hence, if one were to implement a TeX-based document setup in which / can take the roles of ( and ), one would have to modify the \sfactor rules to make / "transparent" to the space factor rules. I will confess to never having had to contemplate such a contingency so far... Tsk, tsk.
    – Mico
    Jun 10, 2021 at 21:16
  • 1
    @user224332 The USB connector on the photo is hilarious! An imaginary example could be retyping Теперь, о кроликах. /Кролики — это не только ценный мех, но и три–четыре килограмма диетического, легкоусвояемого мяса./ Рассмотрим … produced by the above typing machine with LaTeX. I don't know a good example in English.
    – AlMa1r
    Feb 3 at 10:45

You must log in to answer this question.