# Dealing with slightly overfull \hbox's

Generally, how do you deal with lines that are slightly overhung, when microtypography is already enabled, and there's no way of hyphenating the hanging word and no desire to put it on the next line, leaving ugly whitespaces (especially if the word on the first line of the paragraph)?

Here's an example with two hanging words:

I can think of two ways out:

• Margin tweaking: I make line width slightly larger.
• Negative tracking: I decrease letterspacing in the relevant line.

Are there any other methods within given constrains? Which one is a better practice?

EDIT: I was able to implement the negative tracking in ConTeXt with \kerncharacters command, and it looks quite nice:

% ConTeXt code
\setuppapersize[A5]
\setupbackgrounds[text] [rightframe=on,framecolor=red,rulethickness=0.1pt]

\setupalign[hz,hanging] % microtypography enabled
\definefontfeature[default][default][protrusion=quality,expansion=quality]

\definetypeface[mainface][rm][specserif][Linux Libertine O] [default]
\setupbodyfont[mainface,14pt]

\mainlanguage[russian]
\setupindenting[yes,medium,first]

\starttext
{ \kerncharacters[-0.02] Здесь будет длинный-предлинный текст, \mbox{в~коем}} никак нельзя перенести строку.
Запрещено {\kerncharacters[-0.01] разрывать телефонные номера, например, \mbox{(000)1234-5678}}, многозначные числа и дефисные написания.
\stoptext
• I try to rephrase at this point. In some cases, I simply ignore the bad box. (If it is not obvious or I'm not working on what will be the final, printed version, for example.) – cfr Jan 12 '16 at 23:09
• Note that microtypography is only fully supported by pdfTeX. LuaTeX and XeTeX have more support than they used to, but not as much as pdfTeX. One of them (Lua?) has significantly better support than the other (Xe?). See the microtype's manual for details. I'm assuming that ConTeXt's support will be the same as LuaTeX's. Also, note that 14pt font on A5 is likely to generate problems of this sort with reasonable frequency. And remember that microtypography works best when using font-specific settings. Generic settings must needs be fairly conservative. – cfr Jan 12 '16 at 23:13
• It may be possible to automate the kerncharacters trick. I remember seeing a ConTeXt demo on Arabic typesetting where such optimizations were performed after TeX had done the linebreaking. I don't remember where I saw that example. You may try searching the mailing list archives or asking on the ConTeXt mailing list. – Aditya Jan 12 '16 at 23:15
• @cfr: assuming I cannot edit the text. And font/page settings were selected for the purpose of demonstration only, of course: I realize that such occurrences would be relatively infrequent at proper size settings, but they still hurt the eye, and I encountered four of just those in 20-page document before asking the question – The_Keeper Jan 12 '16 at 23:22
• @Aditya: oh, that would be gold! I'll try to find it; and if you do, I'll be very grateful – The_Keeper Jan 12 '16 at 23:25

You could combine the slight negative kerning which you already discovered with extreme shrinking in the font expansion.

\setuppapersize[A5]
\setupbackgrounds[text] [rightframe=on,framecolor=red,rulethickness=0.1pt]

\setupfontexpansion
[extremeshrink]
[stretch=2,shrink=4,step=.5,vector=quality,factor=1]

\setupalign[hz,hanging] % microtypography enabled
\definefontfeature[default][default][protrusion=quality,expansion=extremeshrink]

\definetypeface[mainface][rm][specserif][Linux Libertine O] [default]
\setupbodyfont[mainface,14pt]

\mainlanguage[russian]
\setupindenting[yes,medium,first]

\definecharacterkerning [shrinkkern] [factor=-.01]
\setcharacterkerning [shrinkkern]

\starttext
Здесь будет длинный-предлинный текст, \mbox{в~коем} никак нельзя перенести строку.
Запрещено разрывать телефонные номера, например, \mbox{(000)1234-5678}, многозначные числа и дефисные написания.
\stoptext