2

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

Yorgos
  • 2,694
  • You mustn't load inputenc (and also xltxtra, xunicode and textcomp are unnecessary). – egreg Jul 17 '15 at 09:55
  • ... I tried without these packages, and the result remains the same... – Yorgos Jul 17 '15 at 09:57
  • 1
    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
  • If you define a \greekfont with polyglossia, then that font will be used for Greek (but of course it can't be Hoefler Text). – egreg Jul 17 '15 at 10:32
  • no no... I don't use polyglossia. If in the above MWE use \greektext {kalimera} (after removing the uncessary packages), then the output comes with greek characters and everything is fine (with Hoefler Text font). – Yorgos Jul 17 '15 at 10:35
  • 1
    I get Undefined control sequence \greektext – egreg Jul 17 '15 at 10:38
  • Sorry... you are right... problem solved with polyglossia package – Yorgos Jul 17 '15 at 11:13

2 Answers2

5

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}.

dariok
  • 755
0

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}  
Theo
  • 1