Further indulging my curiosity with xcoffins, I'm playing with xcoffins-tschichold-example.tex.

In the TeX reconstruction of the front page of Elementare Typographie, the text is slightly misaligned with respect to the rule. This is obviously due to the gap (sorry, I don't know the technical term) between the right-hand edge of the glyph outline and the right-hand edge of its bounding box.

Now, in ``normal'' justified text, this gap is, I think, suppressed. How can I suppress it in this case, without losing the ability of fitting the coffin to the text automagically, and, preferably, not having to worry about wrapping individual letters (such as the n in this case) in TeX commands?

(PS I now know they're called sidebearings; thanks to @egreg.)

Misalignment of text with rule

  • It looks like this is at least partially a function of the chosen font, but the offending sidebearing seems to be "kerned away" in normal justified text. Nov 12, 2011 at 12:54

1 Answer 1


Here's how I got what I wanted (XeTeX only), thanks to a tip from @egreg. First the image, then the code.

enter image description here

\NewDocumentCommand{\WidthOfCoffin}{m}{ \box_wd:N #1 }
\def\kright#1{\leavevmode #1\kern-\XeTeXglyphbounds3 \the\XeTeXcharglyph`#1 }
\def\kleft#1{\leavevmode \kern-\XeTeXglyphbounds1 \the\XeTeXcharglyph`#1 #1}
\NewCoffin \result
\SetHorizontalCoffin \result {}
\NewCoffin \aaa
\SetHorizontalCoffin \aaa {\fontsize{52}{50}\sffamily\bfseries mitteilungen}
\NewCoffin \rulei
\SetHorizontalCoffin \rulei  {\color{red}\rule{\WidthOfCoffin{\aaa}}{1pc}}
\NewCoffin \bbb
\SetHorizontalCoffin \bbb {\fontsize{52}{50}\sffamily\bfseries \kleft{m}itteilunge\kright{n}}
\NewCoffin \ruleii
\SetHorizontalCoffin \ruleii  {\color{red}\rule{\WidthOfCoffin{\bbb}}{1pc}}
\JoinCoffins \result \aaa 
\JoinCoffins \result[\aaa-t,\aaa-l] \rulei [b,l](0pt,2mm)
\JoinCoffins \result[\aaa-b,\aaa-l] \bbb [t,l](0pt,-10mm)
\JoinCoffins \result[\bbb-t,\bbb-l] \ruleii [b,l](0pt,2mm)
\TypesetCoffin \result
  • 1
    Well done! Defining \gid is not necessary, as \kern-\XeTeXglyphbounds1\XeTeXcharglyph`#1 (notice the space) will do as well.
    – egreg
    Nov 12, 2011 at 17:14
  • @egreg: Thanks. You've no idea how happy fixing this has made me. Migliori sono i piaceri semplici Nov 12, 2011 at 17:41

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.