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

Zdenek Wagner zdenek.wagner at gmail.com
Sat Jan 7 14:50:14 CET 2012


2012/1/7 Paul Isambert <zappathustra at free.fr>:
> 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.
>
This is not a right question. TeX breaks lines:
1. at a glue unless it is preceded by a discardable item
2. at a kern it it is immediatelly followed by a glue
3. at a penalty no matter what follows or precedes
4. at a \discretionary either explicit or resulting from analysis of
hyphenation pattern.

A hyphen is roughly treated as
\penalty\exhyphenpenalty\discretionary{-}{}{-}. Thus there is nothing
in the TeX world as breaking at a character. In order to give good
advice I need to know what exactly you wish to achieve. If you look at
the above rules, you see that if you put \kert0pt in between thwo
characters, TeX will never break there. However, the kern will
suppress any implicit kern that would otherwise be inserted by
examining the font metrics and in addition will create word boundary
so that hyphenation patterns will not match properly the remaining
parts of the word. If you mark feasible hyphenation points with \-,
TeX will not examine hyphenation patterns for that word and used only
\- when optimizing paragraph breaking. The trick with \lccode will
work too because hyphenation works only if the characters have
\catcode equal to 11 and nonzero \lccode.

> 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
>
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
>  http://tug.org/mailman/listinfo/xetex



-- 
Zdeněk Wagner
http://hroch486.icpf.cas.cz/wagner/
http://icebearsoft.euweb.cz



More information about the XeTeX mailing list