Skip to main content

Module protrusion

Module protrusion 

Source
Expand description

Character protrusion (margin kerning): \protrudechars, \lpcode, \rpcode, margin kern nodes, \leftmarginkern and \rightmarginkern.

A character at the start (end) of a line may stick out into the left (right) margin by \lpcode (\rpcode) thousandths of the font’s quad. With \protrudechars > 0, the post-line-break pass puts a margin kern of minus that amount at the start (end) of each line; with \protrudechars > 1 the line breaker counts the protrusion when it measures candidate lines (LuaTeX manual, protrusion; Hàn Thế Thành’s thesis, chapter 3).

Which character counts as “at the edge” was established by black-box tests against LuaTeX 1.22. Searching from the line end inwards, these nodes are passed over (the list in the LuaTeX manual): glue without width, stretch and shrink, penalties, empty discretionaries, font kerns and kerns of width zero, rules of zero width, height and depth, math nodes without surround, direction and local paragraph nodes, empty zero-sized hlists, inserts, marks, adjusts, boundaries and whatsits. A non-empty hlist is searched recursively; at the left edge, when it has no character, only a character right after it continues. Anything else ends the search without a protruding character.

The line breaker searches a little differently from the post-line-break pass:

  • at the start of a line it first skips what the post-line-break pass will prune (glue, explicit kerns, penalties and math nodes after the break), starting at the break node itself;
  • after a break at a discretionary, the post-break text counts only if it starts with a character (nothing in it is skipped); an empty post-break text continues the search at the discretionary node, which only an empty discretionary lets through;
  • before a break at a discretionary, likewise the pre-break text counts only if it ends with a character; an empty one continues before the discretionary;
  • the last line of a paragraph gets no right protrusion in line breaking, whatever \parfillskip is (the post-line-break pass still adds its margin kern).

Constants§

LEFT_SIDE
Subtype of a left margin kern node.
RIGHT_SIDE
Subtype of a right margin kern node.