Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
2  
I would not have guessed that as standard behavior. Good observation! –  Steven B. Segletes Feb 7 at 0:21
add comment

2 Answers

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

enter image description here

\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}
share|improve this answer
    
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 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 at 3:32
add comment

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.

share|improve this answer
    
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 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 at 1:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.