LaTeX sometimes puts too much or too little space after periods

Latex

Latex Problem Overview


LaTeX tries to guess whether a period ends a sentence, in which case it puts extra space after it. Here are two examples where it guesses wrong:

I watched Superman III. Then I went home. 

(Too little space after "Superman III.".)

After brushing teeth etc. I went to bed.

(Too much space after "etc.".)

Note that it doesn't matter how much whitespace you use in the LaTeX source since LaTeX ignores that.

Latex Solutions


Solution 1 - Latex

I found the answer here: <http://john.regehr.org/latex/>;. Excerpt:

When a non-sentence-ending period is to be followed by a space, the space must be an explicit blank. So the second example should be:

After brushing teeth etc.\ I went to bed.

The converse of this problem happens when a capital letter precedes a sentence-ending period in the input, as in the first example. In this case LaTeX assumes that the period terminates an abbreviation and follows it with inter-word space rather than inter-sentence space. The fix is to put "\@" before the period. So the first example should be

I watched Superman III\@. Then I went home.

A handy way to find this error is:

grep '[A-Z]\.' *.tex

Solution 2 - Latex

You can sidestep the spacing issue if you prefer single spaces at the end of sentences: put \frenchspacing on (for older versions of Latex this was a fragile command). Knuth was following the traditional naming in calling it French spacing, although calling double spacing after sentences French spacing has become dominant in publishing.

Dirk Margulis wrote a nice post summarising some of the reasons for the prevalance of single spacing: Space between sentences.

Solution 3 - Latex

I like the answer from dreeves and the handy search he suggests too. I don't have the Stackoverflow "rep" points to comment, but...

Since lines in raw *.tex tend to be very long, the output from grep can be overwhelming (i.e., entire paragraphs); I suggest a variation to only display the words ending in '[A-Z].' (followed by one or more space, followed by a new capitalized word). It is,

grep -o -E '[A-Z]+\. +[A-Z]+[A-Za-z]+' *.tex

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondreevesView Question on Stackoverflow
Solution 1 - LatexdreevesView Answer on Stackoverflow
Solution 2 - LatexCharles StewartView Answer on Stackoverflow
Solution 3 - LatexboringusernameView Answer on Stackoverflow