# Cannot produce english-greek document with xelatex

Here is a WME:

\documentclass{article}

\usepackage{fontspec,xltxtra,xunicode,xgreek,textcomp}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text} % Main document font
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{GillSans} % Font for your name at the top
\usepackage[english,greek]{babel}
\usepackage[utf8]{inputenc}

\begin{document}
καλημερα
\end{document}


The output is boxes instead of greek characters. What is wrong?

PS: I could write my document with latin characters and I could produce the greek characters using \selectlanguage{} command, but I would like to avoid it

• You mustn't load inputenc (and also xltxtra, xunicode and textcomp are unnecessary). – egreg Jul 17 '15 at 9:55
• ... I tried without these packages, and the result remains the same... – Yorgos Jul 17 '15 at 9:57
• Neither Hoefler Text nor GillSans support Greek (at least on my machine). You should see Missing character: There is no κ in font Hoefler Text in the log file. – egreg Jul 17 '15 at 10:01
• but how can explain that with \greektext command, everything is fine? – Yorgos Jul 17 '15 at 10:21
• I get Undefined control sequence \greektext – egreg Jul 17 '15 at 10:38

You could use the package polyglossia which allows you to define a main language and additional languages as well as special fonts for each language (you have to make sure the font you want does contain the desired characters at the code points you enter!). It also takes care of selecting the correct hyphenation algorithm for the chosen languages:

\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage[variant=modern]{greek}
\newfontfamily\greekfont{FreeSerif}


and then display the greek text with \textgreek{καλημερα} or, for longer texts, using the corresponding environment: \begin{greek}...\end{greek}.

Same problem here. One thing I discovered: osx-supplied Hoefler Text does indeed produce boxes instead of Greek. But osx-supplied Lucida Grande (and Times New Roman) produce Greek:

%!TEX encoding = UTF-8 Unicode
%!TEX TS-program = xelatex
\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{fontspec}
\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Mapping=tex-text]{Times New Roman}
\setsansfont[Mapping=tex-text]{Helvetica}
\setmonofont{Monaco}

\begin{document}
ποικιλόθρον' ἀθανάτ Ἀφρόδιτα,\\
παῖ Δίος δολόπλοκε, λίσσομαί σε
\end{document}