# How to adjust font size or kerning to fit line width?

I have some text that nearly fits the given line width. I can see that a minimal adjustment of font size or kerning would make the text fit, but how do I tell LaTeX to squeeze the text? Yes, this would be bad typography for an average paragraph, but in my case it is a custom In a custom quotation environment, that has a smaller font size anyway, so it won't look ugly.

-

If you compile your document with pdfLaTeX, use the microtype package and its font expansion feature. Microtype will try to horizontally stretch your font (by default from -2% to +2%), and this will affect line breaks (and in your case, possibly make the text fit).

-
Exactly. But in your case do it locally by defining a context by including something like \SetExpansion[context = sloppy,shrink = 60,...]{encoding = {OT1,T1,TS1} }{} in your preamble. Then you can write something like {\microtypecontext{expansion=sloppy}This line is a smidgen too long...} to kick in the local 'sloppy' context adjustment on just the enclosed text. –  Geoffrey Jones Sep 24 '10 at 12:08
Thanks! The \SetExpansion and \microtypecontext solution did not work form me (I got "pdfTeX error (font expansion): using fonts with different limit of expansion in one paragraph is not allowed."), but \SetTracking solved the issue. I'll play around with more microtype options if needed. –  Jakob Sep 24 '10 at 12:48

Just put the last few words inside an \mbox{...} to discourage breaking the line.

-
Welcome to TeX.sx! A tip: You can use backticks  to mark your inline code as I did in my edit. –  doncherry Aug 23 '12 at 16:34
While this will work, it will still be (possibly very visible) longer than the other lines and cause an overfull hbox warning. –  Tom Bombadil Aug 23 '12 at 20:13
\mbox{} is used to mark a word not to be hyphenated. \sloppy could perhaps help here, better is to use package microtype. –  Kurt Sep 13 '12 at 22:47

One simple thing that one could try is to increase the stretchability of the space between words, i.e.:

\setbox0\hbox{i} \spaceskip=\wd0 plus .15em minus .15em
`

And to keep it inside scope.

-