[Tex/LaTex] get full justification for italic text

fontshorizontal alignmentitalicmicrotypeprotrusion

In the TeXbook, Knuth notes that italics can lead to problems with justification:

EXERCISE 14.16
When an entire paragraph is typeset in italic or slanted type, it sometimes appears to be offset on the page with respect to other paragraphs. Explain how you could use \leftskip and \rightskip to shift all lines of a paragraph left by 1pt.

The following text shows that one can even get fluttering margins:

\documentclass{article}
\textwidth=3.85cm
\begin{document}
\it\noindent
This is a small text. If jam is what you like, two fingers up,
or whatever. Under certain conditions you see that the left and
right margins flutter.
\end{document}

The effect is a bit overemphazised by the small \textwidth, but the compilation doesn't show any overfull hboxes. In particular the left margin looks awful in my opinion.

Is there any way to overcome this problem in TeX? I'd prefer a LaTeX answer, but in the end I'm open to any TeX version.

I know that this is actually a font problem; and it happens due to the way the CM italic font is designed. (In fact I have already asked and answered a few questions concerning problems with italics.) Is there an italic font where the problem is less prominent or even non-existent?

Best Answer

With version 2.5 of the microtype package, available on CTAN since 13 March 2013, the simple answer to my question is "use microtype".


Thanks, Herbert and Joseph, for telling me that this can be done with the microtype package. I did know that microtype can do margin kerning, but I had always thought that this is only about punctuation. In reality, one can adjust the margin kerning for every single letter.

What I had been wondering: Why is the output in Herbert's and Joseph's answer a bit better, but still far from good? The answer, of course, is that the margin kerning table provided by microtype just isn't good enough. So I went ahead and went through all the letters ... The output now looks as follows, and I'm quite happy with it:

Here's the code, which essentially consists of the adjusted margin kerning table (that has now been added to the microtype package):

\documentclass{article}
\textwidth=3.85cm
\usepackage{microtype}
\LoadMicrotypeFile{cmr}
\SetProtrusion
   [ name     = cmr-it   ]
   { }
   {
     A = {100,100},
     B = {83,-40},
     C = {165,-75},
     D = {75, -28},
     E = {80,-55},
     F = {85,-80},
     G = {153,-15},
     H = {73,-60},
     I = {140,-120},
     J = {135,-80},
     K = {70,-30},
     L = {87, 40},
     M = {67,-45},
     N = {75,-55},
     O = {150,-30},
     P = {82,-50},
     Q = {150,-30},
     R = {75, 15},
     S = {90,-65},
     $ = {100,-20},
     T = {220,-85},
     U = {230,-55},
     V = {260,-60},
     W = {185,-55},
     X = {70,-30},
     Y = {250,-60},
     Z = {90,-60},
     a = {150,-10},
     b = {170,   },
     c = {173,-10},
     d = {150,-55},
     e = {180, },
     f = { ,-250},
     g = {150,-10},
     h = {100, },
     i = {210, },
     j = { ,-40},
     k = {110,-50},
     l = {240,-110},
     m = {80, },
     n = {115, },
     o = {155, },
     p = { , },
     q = {170,-40},
     r = {155,-40},
     s = {130, },
     t = {230,-10},
     u = {120, },
     v = {140,-25},
     w = {98,-20},
     x = {65,-40},
     y = {130,-20},
     z = {110,-80},
     0 = {170,-85},
     1 = {230,110},
     2 = {130,-70},
     3 = {140,-70},
     4 = {130,80},
     5 = {160, },
     6 = {175,-30},
     7 = {250,-150},
     8 = {130,-40},
     9 = {155,-80},
     . = { ,500},
    {,}= { ,450},
     : = { ,300},
     ; = { ,300},
     & = {130,30},
    \% = {180,50},
     * = {380,20},
     + = {180,200},
     @ = {180,10},
     ~ = {200,150},
     ( = {300, },    ) = {  ,70},
     / = {100,100},
     - = {500,300},
     \textendash       = {500,300},   \textemdash        = {400,170},
     \textquoteleft    = {800,200},   \textquoteright    = {800,-20},
     \textquotedblleft = {540,100},   \textquotedblright = {500,100}
   }

\begin{document}
\noindent\itshape
This is a small text. If jam is what you like, two fingers up,
or whatever. Under certain conditions you see that the left and
right margins flutter.
\end{document}
Related Question