3

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.

  • 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
3

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}
  • {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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.