jsa@edg1.UUCP (J. Stephen Adamczyk) (11/08/90)
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.) Any advice would be appreciated, by email or by posting to this newsgroup. Steve Adamczyk (jsa@edg.com or uunet!edg1!jsa; 201-744-2620)
eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (11/09/90)
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 [example deleted] >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? Yes, yes, yes. As infinity is finite in TeX, one very bad line is better than a number of somewhat-less-but-still-very bad lines. Sloppypar sets parameters so that everything will be accepted. I used to set \spaceskip=.33em plus .66em in that sort of paragraphs. It makes the spaces very stretchable. Experiment around lowering the .66 to see what the optimal result is. >(I'm using TeX C Version 3.0 and LaTeX Version 2.09 on a Sun 3/50 running >SunOS 3.5.) Ah! TeX 3.0 was made for you! Try \emergencystretch=1em, or a larger value if this doesn't work. This parameter was introduced in version 3.0, and it brings the just-out-of-reach solutions into reach. Good luck trying. V.
teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) (11/09/90)
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
rusty@belch.Berkeley.EDU (rusty wright) (11/10/90)
In _Graphic Design for the Electronic Age_ by Jan V. White he spends several pages listing the advantages of using ragged-right instead of justified text. One is that it's easier to read, another is that you don't usually have line-breaking problems like you're getting. After reading this book I've switched over to ragged-right exclusively. Here are the macros that I use that someone sent me. I use it with latex; name it ragright.sty and then use \documentstyle[ragright]{...} ... \ragright. % This is recommended in the TeXbook, and is probably a good % idea, though you really need to use it for every single font % used in your ragged-right text. It may not be worth the bother. % turn off stretchability for \raggedright setting %\fontdimen3\tenrm=0pt \fontdimen4\tenrm=0pt %\fontdimen3\tenit=0pt \fontdimen4\tenit=0pt %\fontdimen3\sevrm=0pt \fontdimen4\sevrm=0pt %\fontdimen3\sevit=0pt \fontdimen4\sevit=0pt % The rest of the message (down to the .signature) is an excerpt % from my personal LaTeX .sty file. Since it contains private % LaTeX macro names, it must be part of a .sty file, or enclosed % in \makeatletter ... \makeatother. % % I do not redefine the \raggedright command, because it has a % purpose (alongside \raggedleft and \centering). Note also that % immediately after defining \@ragright, I execute it (because I % want my text to be ragged-right by default). You may want to % take that line out. % % \raggedskip is the amount of glue to add at the right edge of % each line; my default (0pt plus4em) gives a decent right edge % without requiring too many unfortunate hyphenations, at least % using the typeface I use with the usual LaTeX \hsize. % % ragged-right % \newskip\raggedskip \raggedskip=\z@ plus4em % % \@ragright: like \raggedright, but % set \@rightskip to something reasonable instead of \@flushglue % and leave \parindent alone! (from latex.tex) % \newcommand\@ragright{\let\\=\@centercr\@rightskip\raggedskip \rightskip\@rightskip \leftskip\z@} % % civilize \@arrayparboxrestore (from latex.tex) % \def\@arrayparboxrestore{\let\par\@@par \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii \parindent\z@ \parskip\z@ \everypar{}\linewidth\hsize \@totalleftmargin\z@ \leftskip\z@ \@rightskip\raggedskip\rightskip\@rightskip \parfillskip\@flushglue \lineskip\normallineskip \baselineskip\normalbaselineskip\sloppy} % ersatz ragged-right \newcommand{\ragright}{% \fontdimen3\elvrm=0pt\relax% \fontdimen4\elvrm=0pt\relax% \fontdimen3\elvit=0pt\relax% \fontdimen4\elvit=0pt\relax% \fontdimen3\elvsl=0pt\relax% \fontdimen4\elvsl=0pt\relax% \fontdimen3\elvbf=0pt\relax% \fontdimen4\elvbf=0pt\relax% \@ragright}
eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (11/10/90)
teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) writes: >\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. Someone informed my that a value of 1em was usually sufficient. From a typographical point of view this also makes a lot more sense. It may very well be that the above setting allows quite horrible solutions. Victor.
teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) (11/11/90)
In article <1990Nov9.225739.19636@csrd.uiuc.edu> eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) writes: >teexdwu@ioe.lon.ac.uk (DOMINIK WUJASTYK) writes: > >>\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. > >Someone informed my that a value of 1em was usually >sufficient. From a typographical point of view this also >makes a lot more sense. It may very well be that the >above setting allows quite horrible solutions. Look, one of us needs to sit down and play with this for a while. I put .25\hsize because Knuth says "By setting \emergencystretch high enough (based on \hsize) you can be sure that the \tolerance is never exceeded;...". In my opinion his explanation of \emergencystretch is not very easy to interpret in practical terms, so let's dust off our TeXs and start getting empirical. Dominik