TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using XeTeX from TeXLive-2010-Basic in OSX with plain-format.

My try was to follow the TeXbooks setup for commas et such (which I already have working nicely):

\defaulthyphenchar=`‐% it is Unicode 2010
\font\rm="TeX Gyre Pagella"
\newdimen\hyphang \setbox0=\hbox{‐} \hyphang=\wd0
\catcode`‐=\active \let‐=\hyphen

but it didn't work. TeXbook suggests to use "a special font with zero-width \hyphenchar", but I don't know how one would go about doing that.

Would you have any suggestions on how to achieve this?

share|improve this question
Can you be more explicit? I don't see exactly what you are trying to achieve. Do you want the hypenchar to be a - sticking out in the right margin? – Bruno Le Floch Jan 2 '11 at 13:11
@Bruno Le Floch: I want to get the hyphenation character (whatever that may be) to protrude into the right margin. – morbusg Jan 2 '11 at 13:22
See Konrad's answer below. – Bruno Le Floch Jan 2 '11 at 14:37
By the way, it’s 2011 now. You should adjust your hyphen char. ;-) – Konrad Rudolph Jan 2 '11 at 15:17
@Konrad: Haha, I just knew someone would make that joke! :-D Btw, that would be "non-breaking hyphen" ;-) – morbusg Jan 2 '11 at 15:20
up vote 7 down vote accepted

The example in the TeXbook is obsolete since all current engines support margin kerning without any tricks. For plain XeTeX:

\font\rm="TeX Gyre Pagella"\relax
a a a a a a a a a abbabbabb aabbabbabb abbabb

\XeTeXprotrudechars=2 activates protrusion, the \rpcode line sets the protrusion code of the glyph the hyphen character maps to.

share|improve this answer
Thanks! What does the \font=250 mean? – morbusg Jan 2 '11 at 16:38
@morbusg. \hyphenchar\font=250 means that the hyphenation character for the current font is in position 250 in that font. – Joseph Wright Jan 2 '11 at 19:53
Not quite; that line of code says: set the right protrusion (\rpcode) of the current font (\font) for the character used for hyphenation (\XeTeXcharglyph\hyphenchar\font) to 0.250em (=250). (I know I'm late to the party but just wanted to ensure this didn't confuse anyone down the track…) – Will Robertson Apr 25 '14 at 9:27
In the question, @morbusg creates a box to ensure that the hang depth is equal to the width of the character. This answer hard codes the solution at 0.250em. If the font were to change, this value might not be correct. How would you recover the non-hard-coded size of the question? – Daniel Lyons Jun 15 '15 at 16:30

You can try installing the current beta of the microtype package. Its support of XeTeX is incomplete but protrusion (and hence hanging hyphenation) already works and despite its beta status I haven’t (so far) experienced any difficulties with it.

share|improve this answer
Correct me if I'm wrong, but reading the documentations "getting started"-part, isn't microtype a LaTeX package? – morbusg Jan 2 '11 at 15:13
@morbusg: yes it is. I missed the plain-tex tag on your question and I thought you were just using a TeX solution because LaTeX has no obvious advantage here. – Konrad Rudolph Jan 2 '11 at 15:16
@morbusg. It is, but within it you will doubtless find the appropriate code (although it does seem Philipp has already done that job!) – Joseph Wright Jan 2 '11 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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