The following environment, copied from this website about dealing with overfull hboxes, allows one to change the \tolerance
parameter for just the paragraph(s) it encloses:
\newenvironment{tolerant}[1]{%
\par\tolerance=#1\relax
}{%
\par
}
Unfortunately, the website does not specify a similar environment for locally changing \emergencystretch
. Since much of the code in the definition above (notably, the commands \par
and \relax
) is currently outside my understanding, I would not know how to go about making a similar environment for locally setting \emergencystretch
–but I'm sure someone on TeX.SE would know.
How would one write an environment that changes the value of \emergencystretch
locally (and makes sure the changes get applied)?
Best Answer
Change
\tolerance
to\emergencystretch
and pass in a length rather than a number.\par
means end of paragraph and is same as a blank line.\relax
is a primitive command which does nothing but it stops the scan for a number in case the text started with a digit.sets tolerance to 1 and typesets a 2 but without the
\relax
or a space thenwould set it to 12 and not typeset the 2.