[XeTeX] alternate text for line-breaking

Roland Kuhn rk at rkuhn.info
Fri Jan 14 21:17:44 CET 2011


Hello Bogdan,

Am 13.01.2011 19:32, schrieb Bogdan Butnaru:
> I was wondering if is it possible to do write a LaTeX command that
> provides text alternatives when the line-breaking algorithm can’t find
> good line breaks. For example, a command that for:
>
>      Pretext \alternate{something}{a  thing} post-text.
>
> runs the line-breaking algorithm for “Pretext something post-text.”
> but if gets bad results (i.e., if it would report
> an underful or overful hbox) tries again with “Pretext a thing
> post-text.” Ideally one could give more than two if necessary,
> alternatives and the best (with least underful/overful) would be
> picked in case none work perfectly.
>
I feel your pain, but someone should say it out loud: what you want is 
not possible in general. \discretionary is not powerful enough, since it 
can only break one word in two, nothing else. And in tradition TeX (also 
pdftex, xetex) there is no hook which is run when line-breaking goes 
south. I am no expert on those newfangled TeX variants involving some 
other (less ideosyncratic) programming languages, but I venture the 
guess that my statement is valid also for them; someone please correct 
me if I'm wrong.

Typography is hard, which is precisely why it is so thrilling.

Regards,

Roland


More information about the XeTeX mailing list