[XeTeX] Preventing a line break at a given set of characters

Paul Isambert zappathustra at free.fr
Sat Jan 7 08:39:37 CET 2012


Shiva Shankar <shivably04sdst at gmail.com> a écrit:
> 
> Hi,
> 
> Is it possible to prevent the linebreak at a given set of characters?
> for example TeX will never break a line at fullstop(.) I mean
> fullstop alone never goto next line (unless there is a space behind
> it). Similarly for comma(,), semicolon(;) etc.

You can always set \lccode to 0 for the characters you want to be
unbreakable, but that will mess with word recognition globally, so you
won't have hyphenation where you don't want it, but you won't have it
either in many places where expected. A solution might be to add a
glue -- preceded by an infinite penalty -- after the character to mark
the legitimate end of a word; you might be able to do that automatically
with interchartoks; that won't solve problem with \right/lefthyphenmin,
though. See e.g.:

    % Normal hyphenation.
    \showhyphens{absolutely}

    % Bad solution.
    \lccode`\t=0
    \showhyphens{absolutely}

    % Better solution.
    \XeTeXinterchartokenstate=1
    \XeTeXcharclass`\t=10
    \XeTeXinterchartoks 10 0 = {\penalty10000\hskip0pt}
    \showhyphens{absolutely}

I'm not sure this is sound.

Of course, you can also declare exceptions with \hyphenation, provided
you don't have too many of them.

Best,
Paul



More information about the XeTeX mailing list