5

I need to include a single Greek word in my document and the preferred font has, as they say, no Greek. Package {textgreek} to the rescue? Maybe not. Here's a MWE:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}
\usepackage{geometry}                
\geometry{letterpaper}                  
\usepackage[euler]{textgreek}

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

\begin{document}

Here is some text. 
There should be a greek word \texttau\textrho\textepsilon\textiota\textvarsigma here. 

Let’s see if unicode compiles:

τρείς



\end{document}   

Does anyone have any idea what I'm doing wrong? The textgreek package is supposed to have its own fonts. The documentation says that if you're using anything other than CM or LM you "may" (!!) have to modify font tables, but doesn't say how.

(I'm guessing the Unicode Greek word won't display properly since Hoefler Text has no Greek support.

user26732
  • 1,785
  • 2
  • 22
  • 35
  • Remove the \usepackage{xunicode}. That solved it for me. And btw: You do not need to load fontspec, because it is loaded by xltxtra. – TeXnician Mar 16 '17 at 13:02
  • The line now reads **\usepackage{fontspec}\ Same behavior, there are only square boxes where the Greek letters should be. – user26732 Mar 16 '17 at 13:08

1 Answers1

4

Load neither xunicode nor xltxtra.

\documentclass{article}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguage{greek}

\setmainfont{Hoefler Text}
\setsansfont{Gill Sans}[
  Scale=MatchLowercase,
]
\setmonofont{Andale Mono}[
  Scale=MatchLowercase,
]

\newfontfamily{\greekfont}{GFSDidot}[
  Extension=.otf,
  UprightFont=*,
  ItalicFont=*Italic,
  BoldFont=*Bold,
  BoldItalicFont=*BoldItalic,
  Scale=MatchLowercase,
]

\begin{document}

Here is some text.
There should be a greek word \textgreek{τρείς}

\end{document}

Instead of GFS Didot, you can use whatever font supporting Greek you prefer.

enter image description here

If you have just a few Greek words, it makes sense to use ucharclasses.

\documentclass{article}

\usepackage{fontspec}
\usepackage[Latin,Greek]{ucharclasses}

\setmainfont{Hoefler Text}
\setsansfont{Gill Sans}[
  Scale=MatchLowercase,
]
\setmonofont{Andale Mono}[
  Scale=MatchLowercase,
]

\newfontfamily{\greekfont}{GFSDidot}[
  Extension=.otf,
  UprightFont=*,
  ItalicFont=*Italic,
  BoldFont=*Bold,
  BoldItalicFont=*BoldItalic,
  Scale=MatchLowercase,
]

\setTransitionsForGreek{\begingroup\greekfont}{\endgroup}

\begin{document}

Here is some text.
There should be a greek word τρείς

\end{document}
egreg
  • 1,121,712
  • {ucharclasses} is in lieu of a different font? – user26732 Mar 16 '17 at 13:13
  • @user26732 With it you can switch to a different font for characters in the Greek block without the need of markup as in the previous code. – egreg Mar 16 '17 at 13:15
  • I was trying to figure out if your code (following) was necessary for the answer; looks like it is. I wonder why \texttau, etc. doesn't work. – user26732 Mar 16 '17 at 13:23
  • \newfontfamily{\greekfont}{GFSDidot}[ Extension=.otf, UprightFont=, ItalicFont=Italic, BoldFont=Bold, BoldItalicFont=BoldItalic, Scale=MatchLowercase, ]

    \setTransitionsForGreek{\begingroup\greekfont}{\endgroup}

    – user26732 Mar 16 '17 at 13:24
  • @user26732 What makes you think that textgreek is compatible with fontspec and XeLaTeX? – egreg Mar 16 '17 at 13:59
  • Because there was nothing in the documentation that said, "don't use this package with XeLaTeX." You'd expect that, don't you think? – user26732 Mar 16 '17 at 14:34
  • Also, the "Comprehensive LaTeX Symbol List" by Scott Pakin, under \textgreek, reads as follows: "textgreek tries to use a Greek font that matches the body text...The symbols in this table are intended to be used sporadically throughout a document (e.g., in phrases such as “β-decay”)." There is no mention of XeLaTeX incompatibility. – user26732 Mar 18 '17 at 06:05
  • @user26732 It is very possible that the author of textgreek didn't even think to test compatibility with XeLaTeX, as the package is clearly aimed to pdflatex. – egreg Mar 18 '17 at 09:00