# Single digit on the next line (another 'I thought LaTeX wouldn't do that')

While writing a paper, a sentence in the middle of a paragraph was ending with "as seen in table \ref{table-foo}.", in this case the table number was 1. The PDF ended up with the word table ending a line and "1. Here comes the next sentence bla bla" on the next. That is, the PDF looks like this:

bla bla bla bla as seen in table
1. Bla bla bla bla.


I'm happy with LaTeX overall, but I really thought its default rules would prevent such an occurrence (I previously another question along the same line, but a different case: http://tex.stackexchange.com/questions/3129/widow-word-on-a-page-i-thought-latex-wouldnt-do-that). I'm also baffled because compressing a line so there's room for an extra "1." shouldn't be a problem.

I can fix this particular problem by using ~ instead of a space, but this is not a good solution (text edits will change the possible place of occurrence).

Is there a declarative way to avoid such cases? To re-emphasize, this was happening inside a paragraph, so it's not a widow/orphan case.

The relevant packages I used are given below. What was invoked was: "pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8) (preloaded format=pdflatex 2010.9.21)" from within WinEDT with the default settings.

\documentclass[12pt,titlepage]{article}

% page margins
\usepackage[letterpaper]{geometry}
\geometry{top=1.0in, bottom=1.0in, left=1.1in, right=1.0in}

%set line spacing of document
\usepackage{setspace}
\setstretch{1.6}

% typographical improvements
\usepackage[final,babel]{microtype}

\frenchspacing

-
I'm not sure what "text edits will change the possible place of occurrence" is supposed to mean, but inserting non-breakable space where you want to prohibit line breaking is the way to do it, that is why there is non-breakable space. –  Khaled Hosny Oct 8 '10 at 5:47
@Khaled see my comment to Lev's answer. That's what I meant. –  wishihadabettername Oct 8 '10 at 5:58

-
The problem with non-breaking space is that if the text has some revisions, other non-breaking spaces must be inserted where the non-aesthetic line breaks occur now. This happens to be a short text, but for longer texts, it's kind of annoying to have to proof read the line breaks (they are less easy to spot than widow/orphans because they can occur within paragraphs). Isn't it possible to tell LaTeX "do not put single characters on a new line when they are part of a statement"? –  wishihadabettername Oct 8 '10 at 5:57
@user564: You shouldn't do this by proof reading but by default: Always type table~1, or also table~723 if you have a table with this number. In the latter case, the use of ~ is inevitable, I think. –  Hendrik Vogt Oct 8 '10 at 6:13
@user564: LateX couldn't do it automatically because inserting the correct ties requires some understand the meaning of the sentence. Compare "...a string of length~3." with "...a string of length 3~or more." or "The number of dogs is~3 and the number of cats is~9" vs "There are 3~times as many cats as dogs". As @Hendrik says, just get in the habit of typing the ties every time and there will be no need to worry about revisions to the text introducing bad breaks. –  Lev Bishop Oct 8 '10 at 7:38
Actually, you could set \parfillskip to something like 0pt plus .5\hsize and there would not be any such lines. (But that does not solve the general issue with bad line breaks so I don't think it is worth posting as a regular answer) –  Taco Hoekwater Oct 8 '10 at 9:00
True, but only if the xyz 1. occurs at the end of the paragraph; in the example here, there's more text after the troubling sentence. –  Will Robertson Oct 8 '10 at 10:48