# Preventing line shrinking with raggedright

Sometimes with \raggedright, if a line is too long, but only slighly so, it will be shrunk instead of broken up. Here is an example:

\documentclass{article}
\raggedright
\begin{document}
This is a line that is shrunk to fit the page width despite the use of raggedright.
This is a line that is shrunk to fit the page width despite the use of \ldots
\end{document}


Is there a way to prevent this? In particular, I want all text in my document to be ragged right, and I want to make sure that everywhere in the document, text is never shrunk (neither stretched, but this is never an issue with ragged-right text).

-
I would not have guessed that as standard behavior. Good observation! –  Steven B. Segletes Feb 7 '14 at 0:21

You could fix the inter-word spacing using some ideas from Fixed-width interword space:

\documentclass{article}
\raggedright
\begin{document}
This is a line that is shrunk to fit the page width despite the use of raggedright.

This is a line that is shrunk to fit the page width despite the use of \ldots

\begingroup
\spaceskip=1\fontdimen2\font
\xspaceskip=0pt\relax % just to be sure
This is a line that is shrunk to fit the page width despite the use of raggedright.

This is a line that is shrunk to fit the page width despite the use of \ldots
\endgroup

\end{document}

-
This doesn't exactly answer my question. The proposed solution fixes spaces to one size for every font type and size in the document. –  RaggedRight Feb 7 '14 at 3:11
@RaggedRight: Sure. If you wish, one can add the specifics to \normalfont. However, I've grouped in the example, limiting the scope. If this answer doesn't solve your bigger problem, perhaps consider asking a follow-up question. –  Werner Feb 7 '14 at 3:32

I think I have found a possible answer to my own question. Apparently, TeX uses \pretolerance and \tolerance to decide if line breaking is acceptable. Setting \pretolerance = 0 seems to produce the desired behaviour (setting \tolerance = 0 does not). I am not sure how this works, or whether it will still work for other, more complicated examples, but it seems like an optimal solution for this simple example.

-
There is some discussion about \pretolerance in the TeX Book (Chapter 14: How TeX Breaks Paragraphs into Lines, p 96; alternatively, search for \pretolerance in texbook.tex). –  Werner Feb 7 '14 at 0:55
Setting \pretolerance to 0 imposes stricter limits on badness of lines; it doesn't really guarantee that shrinking of interword spaces is avoided. –  egreg Feb 7 '14 at 1:03