[XeTeX] How to make hyphenation work in XeLaTeX?

Yves Codet ycodet at club-internet.fr
Mon Jan 22 10:24:30 CET 2007


Hello.

Le 21 janv. 07 à 23:47, Nikola Lecic a écrit :

> I'd like to take part in this discussion and ask: "What is the real,
> proper Xe(La)TeX (utf8-based) way to enable hyphenation and to access
> utf8 hyphenation files"? I personally want to typeset documents
> containing English, Serbian (Cyrillic) and Ancient Greek, with  
> frequent
> mixing of all three languages, often in the same line. XeLaTeX should
> hyphenate a line according to the rule of language which happens to
> occupy the end of line. I actually don't understand XeTeX's way of
> setting language environments.

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.

> 1. As for Ancient Greek, I downloaded files from
>
> (a) http://tug.ctan.org/tex-archive/macros/xetex/hyphenation/greek/
> (b) http://tug.ctan.org/tex-archive/macros/xetex/hyphenation/grchyph/
>
> and placed them to XeTeX's hypenation directory. As for Cyrillic
> Serbian, there is a plainTeX-style file (srhyphc.tex) without utf8
> equivalent.

There's "xu-srhyphc.tex" (in TeX Live 2007, at least), which modifies  
"srhyphc.tex" so that XeTeX can use it.

> 2. Now, what is the proper XeLaTeX way to say: {This is 'Ancient  
> Greek'
> here and do everything -- hyphenation, font features, etc. -- having
> that in mind}? First, I did something like this:
>
> \usepackage{fontspec}
> \newcommand{\gr}[1]{\fontspec[Script=Greek,Language=Greek]{Gentium}  
> #1}}
> \newcommand{\sr}[1]{\fontspec[Script=Cyrillic,Language=Serbian]{Doulos
> SIL} #1}}
...
> (i) example from (b), adding "\language=\greek" _inside_ \gr command,
> but XeLaTeX reported that "\language=\greek" is "Undefined control
> sequence";

Maybe you haven't recompiled your XeLaTeX format after editing  
"language.dat", to include hyphenation patterns and the above  
command. Incidentally, when I want to do that, I have to use:
	fmtutil --all
I've tried:
	fmtutil --byfmt xelatex.fmt
but it doesn't do anything. Does anybody know what's wrong with the  
last command?

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.

> (iii) Jonathan's reccomendation from the same thread (with
> \AtBeginDocument), with the same result. Invoking babel with any
> language order (and using \SelectLanguage{greek} inside \gr command)
> leads to "kpathsea: Running mktexmf grmn1095.mf, name = grmn1095,
> rootname = grmn, pointsize = 1095, mktexmf: empty or non-existent
> rootfile! Cannot find grmn1095.mf"-like errors.

This happens because Babel uses its own font instead of the font you  
specified. But with the above commands you don't need Babel (for Greek).

> (iv) (Probably interesting for Mojca) If I try these things using  
> Latin
> Serbian (which shares the most of its character set with Slovenian
> language), I get similar results as he did: hyphenation almost works,
> but obviously based on English rules.

The default (English) patterns are used if no other patterns are  
specified. You need a way to include Serbian or Slovenian patterns in  
a \sr or \sl command, but unfortunately I can't help with this.

> So, what should be done? How to tell XeLaTeX what language I need
> _inside_ \gr and \sr commands -- and why XeLaTeX simply doesn't follow
> language font settings -- which should be the most elegant, in my  
> humbe
> opinion? (And by the way, I'd especially like to do all these things
> without babel, if possible.)

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.

Best wishes,

Yves



More information about the XeTeX mailing list