3

I know that TeX (and thus LaTeX) uses boxes and glue to lay out text, but I can't find how to control the glue dimensions.

Specifically, I have one troublesome paragraph that doesn't justify well because the last word on a line is too long and unhyphenable (it's "``What"), and I want to increase the interword glue flexibility to allow very large interword spaces to get the offending last word to move onto the next line.

I only want to relax the interword spacing for that one paragraph. How to do that in LaTeX? (XeLaTeX specifically?)

4
  • you could use \begin{sloppypar}....\end{sloppypar} but many people find that loosens things too much, {\setlength\emergencystretch{1em} your text\par} gives more control where you can make 1em as small as possible to fix the problem. Commented Apr 28, 2013 at 11:30
  • Traditionally, a typesetter's options for problems like this include one that, for some reason, is often overlooked these days: modifying the text, i.e. insert, delete or move things around. Sometimes the difference of one tiny character does the trick.
    – Nils L
    Commented Apr 28, 2013 at 11:34
  • @DavidCarlisle: Great, that works! Please post it as an answer so I can accept it!
    – Kerrek SB
    Commented Apr 28, 2013 at 11:35
  • @NilsL: Sorry, isn't my own text, and I have to reproduce it faithfully! (And more generous spacing works great, and is hardly noticeable at all. The biggest problem is XeTeX's lack of microtype, I think.)
    – Kerrek SB
    Commented Apr 28, 2013 at 11:35

1 Answer 1

6

You could use \begin{sloppypar}....\end{sloppypar} but many people find that loosens things too much, {\setlength\emergencystretch{1em} your text\par} gives more control where you can make 1em as small as possible to fix the problem.

3
  • Suppose my document is finished and all fine, with the exception of a few of such rogue long lines. Would it be better to only change the spacing for each offending paragraph, or would I get the same result if I set the emergencystretch to something loose globally?
    – Kerrek SB
    Commented Apr 28, 2013 at 11:43
  • 1
    @KerrekSB If you change it globally it's likely to change more than you expect. In theory all the good paragraphs will be set normally and so be unaffected as only bad paragraphs do the final trial setting with emergencystretch but there are bound to be edge cases where you accept the result but it is in fact slightly over tolerance and the emergencystretch changes things Commented Apr 28, 2013 at 11:47
  • OK, cool, thanks. I only needed a handful of interventions to get rid of the last overful lines, and sometimes I even managed to trade an awkward hyphenation for a slightly bigger interword spacing, and it definitely looks better. Thanks!
    – Kerrek SB
    Commented Apr 28, 2013 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .