It is well known that pdfTeX tries to apply character protrusion in a clever way. When breaking a horizontal list into lines, (implicit) kerns for character protrusion are inserted near the edges of each of the resulting \hbox
'es, for an amount of kerning desumed from the \lpcode
/\rpcode
of the leftmost/rightmost character in the line, even if that character is buried inside nested \hbox
'es or if other glue or kerns, or even empty \hbox
'es, intervene between the character itself and the line edge. The presence of the indentation box, on the other hand, inhibits the "left margin" kern. Thus we see that character protrusion bypasses some types of nodes in a horizontal list but not others.
I have tried to find an exact specification of the rules that govern the insertion of "margin" kerns, but without success. I have noticed, however, that the rules for setting the value of, e.g., \rightmarginkern
are not always "in sync" with those for the insertion of such kerns. Consider, for instance, the following code:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[protrusion]{microtype} % protrusion option is actually redundant,
% but I want to be safe!
\begin{document}
First of all, \( \verb|\parfillskip| = \mbox{\the\parfillskip} \).
Secondarily, the main font is ``\fontname\the\font'': in this font the
\verb|\rpcode| of the character~``.'' is \the\rpcode\font`. \space and the
\verb|\lpcode| of the character~``('' is \the\lpcode\font`( . % paren match )
Now we typeset a paragraph which, while containing the usual \verb|\parfillskip|
glue, whose value is specified above, ends flush with the right margin because
it contains a \verb|\hfill| command:\hfill
(here!).\special{comment:Do you see the kern?}
(Another example for protrusion into the left margin,\hfill using
parentheses.)\linebreak (We force a left parenthesis at the beginning of a
line.)
\begingroup
% Show that protrusion _is_ applied "through" the \parfillskip glue:
\showboxbreadth = 1000
\showboxdepth = 5
\showlists
% But if we ask for the \rightmarginkern of the last line...
\setbox0 = \vbox{\indent
Now we typeset a paragraph which, while containing the usual \verb|\parfillskip|
glue, whose value is specified above, ends flush with the right margin because
it contains a \verb|\hfill| command:\hfill (here!).\par
\global\setbox1 = \lastbox
}
% (...here it is...)
\showbox1
\endgroup
% ...we don't see any protrusion:
Now, \( \verb|\rightmarginkern1| = \mbox{\rightmarginkern1} \).
\end{document}
Examination of the transcript produced by this example shows that character protrusion is applied at the right edge of the last line of the paragraph that begins with "Now we typeset..."; nonetheless, when we ask for the \rightmarginkern
of that line, 0pt
is returned.
Could this be a bug in pdfTeX? And if it is not (if it is a feature), what are, again, the exact rules for setting \leftmarginkern
and \rightmarginkern
?