I am a XeLaTeX user and I often have to typeset english-greek documents. Packages like xgreek or polyglossia are great but in order to apply the correct hyphenation rules you have to declare the text that belongs to the secondary language. On the long run, this can become cumbersome.
In XeLaTeX I am using the XeTeXinterchartoks
mechanism that allows me to change automatically the hyphenation rules and/or the font without explicitingly declaring them. The procedure involves grouping together the glyphs of a Unicode Block and then automatically applying tex commands when transitioning from a group to another one.
For those not familiar with the XeTeXinterchartoks
, more info can be found at xetex-reference pages 13-14.
Lately I got interested in Lua(La)Tex. I want to know if there is a way to achieve similar results in LuaTex. As was pointed in a previous question, in LuaTeX there is not a direct analogue to XeTeXinterchartoks
but it was suggested that there are other, more powerful ways to achieve the same goal.
So the questions are
- How can I change the hyphenation rules/font automatically according to the glyphs used without declaring them?
- Can someone provide a minimum working example or at least point me to some references?
- One of the drawbacks of
XeTeXinterchartoks
is that the settings are global. Is there a way in LuaTeX to set this feature (if it exists) on and off, thus providing more flexibility?
Best Answer
Here is a proof of concept at doing the equivalent of
\XeTeXinterchartoks
in luatex.First, a style file:
And a matching lua file:
And a test document:
Not very pretty, but it proves that it can be done ...