Take the 2-minute tour ×
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.

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
\def\hyphen{‐\kern-\hyphang\kern\hyphang}
\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
add comment

2 Answers

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:

\XeTeXprotrudechars=2
\font\rm="TeX Gyre Pagella"\relax
\rm
\rpcode\font\XeTeXcharglyph\hyphenchar\font=250
\hsize=20mm
a a a a a a a a a abbabbabb aabbabbabb abbabb
\bye

\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
1  
@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
add comment

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
add comment

Your Answer

 
discard

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.