[XeTeX] How to make hyphenation work in XeLaTeX?

Nikola Lecic nlecic at EUnet.yu
Mon Jan 22 16:41:08 CET 2007

Yves and Jonathan, thank you so much, hyphenation in both languages is 
working now. XeLaTeX typesetting Ancient Greek and Serbian Cyrillic in 
their real forms (i.e. in Unicode) -- with hyphenation and endless font 
features -- is a form of happiness :) To sum up, these steps led to 
desired output:

(i) I downloaded xu-grahyph4.tex and xu-srhyphc.tex and placed them to 
the 'hyphen' directory (and renamed previously downloaded xgrahyph.tex 
to utf8-grahyph4.tex to match inclusion filename from Greek xu-... version),

(ii) edited language.dat (serbian xu-srhyphc.tex and greek xu-grahyph4.tex),

(iii) run 'fmtutil --byfmt xelatex',

(iv) and arranged XeLaTeX commands like this:

\newcommand{\sr}[1]{{\selectlanguage{serbian}\srfont #1}}
\newcommand{\gr}[1]{{\selectlanguage{greek}\grfont #1}}

And that works.

(By the way, \section{Pythagorean \gr{σύμβολα}} doesn't work due to 
\selectlanguage, while \sr and \gr work properly inside thm or 
\paragraph{...}. That's obviously babel's confusion again, isn't it? 
However, it doesn't matter at all, because one doesn't need hyphenation 
in section names and fontspec language- and script-related features 
still work in \section{Pythagorean \grfont{σύμβολα}}).


Jonathan Kew a écrit :
> If your document declares something like
>    \usepackage[greek,russian,english]{babel}
> then the patterns are available; the main problem is that if you say
>    \selectlanguage{greek}
> to set the hyphenation language, this will *also* mess with your font.
> To work around this, you could say
>    \let\greektext\relax
> after loading the Babel package; this eliminates Babel's hook that  
> changes the font/encoding. So if you've selected Gentium with  
> fontspec, everything should be fine. (As far as hyphenation and font  
> choice are concerned. The Greek text for headings, captions, etc.,  
> won't be right, as the Babel file greek.ldf is non-Unicode.)
> For Russian (or presumably other Cyrillic-script languages), I think  
> you want to say
>    \def\cyrillicencoding{EU1}
> *before* loading Babel, IIRC.
> All this is a bit messy, but until there's a Unicode-aware Babel  
> replacement or update, it should be possible to work around the  
> issues using techniques like this.

Yves Codet a écrit :
> As far as I know XeTeX doesn't set language environments at all. You  
> can set them with Babel but if you do that for Greek, it will use its  
> default font, which isn't what you want and leads to the errors you  
> mention below.
> There's "xu-srhyphc.tex" (in TeX Live 2007, at least), which modifies  
> "srhyphc.tex" so that XeTeX can use it.
> Personally I would do something like this:
> \setromanfont{Doulos SIL} % for the main language (English?)
> \newfontfamily\greekfont{Gentium}
> \newcommand{\gr}[1]{{\language=\greek\greekfont #1}}
> For Serbian I don't know how "xu-srhyphc.tex" can be called without  
> Babel.
> If you mean why doesn't it use "Gentium" instead of "cbgreek", it's  
> not XeLaTeX's but Babel's fault.
> The problem you have, and many other users have, was clearly  
> explained by Bruno Voisin in a previous post (unfortunately I don't  
> have it at hand): we need a replacement for Babel. Perhaps a minimal  
> post-Babel package could only include a way to select hyphenation  
> patterns, which seems to be the most urgent need.

More information about the XeTeX mailing list