Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!educ-isis!teexdwu From: teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) Newsgroups: comp.text.tex Subject: Re: Sloppy line-breaking: I didn't want it THAT sloppy! Message-ID: <1990Nov9.141914.22787@ioe.lon.ac.uk> Date: 9 Nov 90 14:19:14 GMT References: <944@edg1.UUCP> Reply-To: teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) Organization: Institute of Education University of London Lines: 58 In article <944@edg1.UUCP> jsa@edg1.UUCP (J. Stephen Adamczyk) writes: >When one writes paragraphs that include many verbatim names, line-breaking >becomes difficult, and it's understandable that LaTeX/TeX would complain >about that. What's surprising (to me, anyway) is that TeX, which is >so fastidious about line-breaking, becomes so sloppy about it if one uses >\begin{sloppypar}/\end{sloppypar}. Here's an example: > >\begin{sloppypar} >For \verb|DATA| statement scanning, \verb|data_constant| is called to >scan an optional repeat count followed by a signed constant, and >\verb|change_constant_to_required_type| is called to convert the >constant to the type of the variable being initialized. >\end{sloppypar} > >This is formatted as > > For DATA statement scanning, data_constant is called to scan an optional >repeat count followed >by a signed constant, and change_constant_to_required_type is called to >convert the constant to the type of the variable being initialized. > >... with, not surprisingly, a warning about an underfull \hbox. What >seems to have been done here is to create one really awful line and >several good lines, instead of several fair lines. > >Is that the way it's supposed to be? Is sloppypar the wrong thing to use? >Is there a better way? > >(I'm using TeX C Version 3.0 and LaTeX Version 2.09 on a Sun 3/50 running >SunOS 3.5.) Dear Steve, Yes, this is a genuine problem when one cranks up the \tolerance to 10000 so as to avoid overfull boxes. (This is what \sloppy does.) Luckily you are using TeX 3.0, so you have access to the new \emergencystretch command. Read the TeXbook, seventeenth printing (paper) or ninth printing (hard), page 107 for a description of how to use \emergencystretch. I am none too clear on how to use it intelligently. The idea is that one says, I suppose, something like \emergencystretch=0.25\hsize, and then TeX will make another pass over the paragraph, pretending that every line has .25\size more stretchability than it had before. So you would want to add something like this to your LaTeX header: \newenvironment{bettersloppy} {\begin{sloppy}\emergencystretch=0.25\textwidth } {\end{sloppy}} This is conjectural, and you should play with the 0.25 until you get something that works. I'm talking out of my hat, here, because in my brief toying with \emergencystretch I haven't really got it doing anything I understood fully. So let us know your findings. Dominik