[XeTeX] Having correct hyphenation for multiple languages in the same document

Ulrike Fischer news3 at nililand.de
Tue Jul 20 09:29:14 CEST 2010

Am Tue, 20 Jul 2010 02:55:32 +0100 schrieb George:

> I'm trying to compile a document that has both English and Greek text.
> I tried with polyglossia which uses the correct hyphenation for each
> language but ignores my selection for the English font (and not for
> the Greek for some reason). I try with plain xelatex and it uses the
> correct fonts but not the correct hyphenation. My document follows:
> This is the plain xelatex attempt:
> %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> \documentclass[12pt]{article}
> \usepackage{xltxtra}
> \usepackage{fontspec}
> \usepackage[greek,english]{babel}

You shouldn't use babel with xelatex and languages with
"non-western" skripts. greek.ldf of babel switches the font encoding
for greek text to LGR. This breaks the font selection of fontspec. 

> This is the polyglossia attempt:
> %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> \documentclass [12pt] {article}
> \usepackage {polyglossia}
> \usepackage{fontspec}
> \setmainlanguage[variant=mono]{greek}
> \setotherlanguage[variant=american]{english}
> \pagestyle {empty}
> \usepackage [a4paper,margin=1.2in] {geometry}
> \newfontfamily\greekfont{Palatino Linotype}
> \newfontfamily\englishfont{Palatino Linotype}

gloss-english.ldf doesn't use \englishfont. Simply set your fonts
with fontspec. polyglossia will pick them up for "latin" scripts.
(Languages are not symmetric regarding fonts: For latin scripts you
need normally 3 font families (for \rmfamily, \sffamily, \ttfamily)
while greek seems to use only one.)

\documentclass [12pt] {article}
\setmainfont{Times New Roman}
\newfontfamily\greekfont{Palatino Linotype}

\usepackage {polyglossia}

\begin {document}
abc \sffamily cde \ttfamily fgh

Ulrike Fischer 

More information about the XeTeX mailing list