4

Suppose somewhere in the text, I have the following two sentences:

This is one sentence. Another sentence is this.

If we write 'sentence.~Another', we get too short a space. The same with 'sentence@.~Another'.

How can I make sure that the line doesn't break between the period and the 'A', but in such a way that

  1. the space between the period and the 'A' is the correct interword spacing, including its stretchability;
  2. LaTeX would be able to hyphenate 'sentence' and break the line at the hyphen. The same for 'Another'.

In short, how can I get a tie that is like '~' but for connecting the last word of one sentence and the first word of the next?

My guess is that \hspace* would work. Something like

'This is one sentence.\hspace*{\StandardInterspace plus \StandardInterspacePlus minus \StandardInterspaceMinus}Another sentence is this.

provided one uses the correct values for the lengths \StandardInterspace, StandardInterspacePlus, and \StandardInterspaceMinus.

Is that correct, and if it is, how can one find out the correct values to use for one's LaTeX class and font? (I guess \StandardInterspace should be set according to one of the answers here.)

  • 1
    Really, why on Earth would you prefer hyphenating either "sentence" or "Another" over breaking at the end of the sentence? – Hagen von Eitzen Feb 14 '24 at 17:37
  • @HagenvonEitzen Your suspicions are correct—the motivation for this question was not an actual situation in which one would prefer hyphenating either "sentence" or "Another" over breaking at the end of the sentence. It was mere curiosity about TeX. It started with my trying to emulate the look of a certain text. LaTeX often wanted to line break in different places than the original. Eventually, partially via this, I started inserting ~'s in key places to force linebreaks. – linguisticturn Feb 14 '24 at 19:24
  • @HagenvonEitzen And some of these key places were right between sentences. Of course, here we actually don't want hyphenation of the two words surrounding the period. Moreover, it became obvious that LaTeX will never typeset even a single line the way the original text does, so one might as well use \mbox{} to prevent line breaks. But by that point, it was too late—I'd become curious about whether there is an analog of ~ for inter-sentence space. – linguisticturn Feb 14 '24 at 19:24

2 Answers2

6

enter image description here

Use a normal space, prefixed by \nolinebreak{}

\documentclass{article}

\begin{document}

\hrule \bigskip

\makebox[8cm][s]{This is one sentence. Another sentence is this.}

\makebox[8cm][s]{This is one sentence.~Another sentence is this.}

\makebox[8cm][s]{This is one sentence.\ Another sentence is this.}

\makebox[8cm][s]{This is one sentence.\nolinebreak{} Another sentence is this.} \end{document}

The example just demonstrates the sentence space, it can't actually linebreak within a box.

David Carlisle
  • 757,742
3

The (active) ~ is defined to give \nobreakspace, which in turn is

\leavevmode\nobreak\ %

where I used a % to underline that the final item is “control-space”. This is a TeX primitive that does two things:

  1. it resets the space factor to 1000;
  2. it produces a space.

The \leavevmode is just in case you happen to have ~ at the beginning of a paragraph; \nobreak is shorthand for \penalty10000, which prohibits a line break.

Thus .~ will not produce end-of-sentence widened space (when \nonfrenchspacing is in force, of course). One of the main usages of ~ is after initials:

D.~E.~Knuth

where the period would not be sentence ending anyway, but some use abbreviations such as “i.e.” without a following comma and a line break after it would be bad and it should be coded as i.e.~something, so the space factor (which is 3000 after the period) is reset before producing a space.

I'm not sure why you want a nonbreaking space after the end of a sentence, but it's now clear that ~ isn't good for the job.

Define

\newcommand{\st}{\nolinebreak\space}

for this rare case. But, in my opinion, a sentence-ending period is always a good place for a line break.

\documentclass{article}

\newcommand{\st}{\nolinebreak\space}% sentence tie

\begin{document}

This is one sentence. Another sentence is this. (good)

This is one sentence.\st Another sentence is this. (good)

This is one sentence.~Another sentence is this. (bad)

\end{document}

enter image description here

Or just issue \frenchspacing in the preamble and forget about the old-fashioned widened space after punctuation, so you can just use ~.

egreg
  • 1,121,712
  • Are there situations where your \st would behave differently from David Carlisle's \nolinebreak{} (see his answer to this question)? – linguisticturn Feb 13 '24 at 23:44
  • @linguisticturn I'd say they're essentially the same, but packaging the code in a command is better, in my opinion: when you'll change your mind, you'll just change the definition into \newcommand{\st}{ } and the document would still run flawlessly. – egreg Feb 13 '24 at 23:51
  • True! Now, just for completeness (and I can make that a separate question if you think that would be more appropriate), if I want a nonbreaking space after some other non-sentence-ending punctuation (comma, colon, semi-colon, ending double quotes, ending single quotes), is it OK to use '~', or should one use something else? – linguisticturn Feb 14 '24 at 00:00
  • 1
    @linguisticturn \st will work anywhere. However, punctuation is always a good break point (periods used in abbreviations aren’t punctuation). – egreg Feb 14 '24 at 08:46