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:

\usepackage[protrusion]{microtype} % protrusion option is actually redundant, 
                                   % but I want to be safe!


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


% Show that protrusion _is_ applied "through" the \parfillskip glue:
\showboxbreadth = 1000
\showboxdepth = 5

% 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...)


% ...we don't see any protrusion:
Now, \( \verb|\rightmarginkern1| = \mbox{\rightmarginkern1} \).


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?

  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. Apr 25 '15 at 11:13
  • @MartinSchröder: Thank you (if I may say it!) for your advice. In fact, I was in doubt whether to include the final greeting or not. I would also like to ask if there is a way to preview questions before posting them: by previewing it, I would have spotted the improper use of markup in the title.
    – GuM
    Apr 25 '15 at 12:38
  • @GustavoMezzetti You should just be able to scroll down. Apr 25 '15 at 15:08
  • @SeanAllred: I see. I was typing my question with javascript disabled... (I dont trust javascript very much).
    – GuM
    Apr 25 '15 at 16:10
  • @GustavoMezzetti you can always use a local markdown editor with preview. Apr 25 '15 at 16:14

Yes, I would say this is a bug in pdftex. (It seems related to this bug, which was fixed a couple of years ago.) It appears that \rightmarginkern reports a zero kern if the \parfillskip contains a glue component, while margin kerning itself is applied despite the glue component. Both agree if you set \parfillskip to 0pt.

For the exact rules, I can only refer you to the pdftex source, where the skipable items are defined (in cp_skipable) as:

  • insertions
  • marks
  • adjust nodes
  • penalties
  • whatsits (except images)
  • empty discretionaries
  • empty math nodes
  • zero kerns
  • zero glues (and here is the discrepancy between actual margin kerning and reported margin kerning)
  • empty hboxes

Unfortunately, there doesn't seem to be a bug tracker for pdftex anymore, so I don't know where this could be reported.

  • Yes, I had seen the bug report you mention, and it was precisely this bug that led me to think that another one, related to it, could still be lurking unresolved
    – GuM
    Apr 30 '15 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.