Greek with XeTeX

One of my interests is ancient Greek. When I started using \LaTeX it used to be somewhat complicated to switch languages from whichever one I was using to Greek. It is now quite easy if you use XeTeX. This is the way I do it.

The following instructions are specific for the Mac. If you use XeTeX on Windows or Linux, you just need to adapt the commands for choosing fonts to your environment. These instructions also apply to using other ancient or non-Latin languages, provided you use the appropriate font.

The Document Preamble

This very basic preamble works and should get you starting

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
documentclass[12pt]{article}
% \\usepackage{fontspec,xunicode} these two packages are called by xltxtra
\\usepackage{xltxtra}
% Using a main font. You can use Gentium or whatever you need
\\setmainfont{Gentium Plus}
\\newfontfamily{\\sbl}{SBL BibLit}
\\begin{document}
Your text
\\end{document}

To type in Greek:

  • load the appropriate keyboard (see the instructions for your operating system). I simply use the Polytonic Greek keyboard on the Mac.
  • select the font you use to write in Greek (If you use a Unicode font that contains the characters you need you do not even need to change font. For example, Cardo, Gentium, Adobe Garamond Premier Pro, etc., contain most Greek characters you might need.)
  • start typing
  • that’s it!

If you want to avoid typing the Greek text, you can simply copy the text you need from a Unicode source.

If you use a different font for typing Greek text, simply define a little shortcut in the preamble and use it whenever you need to type in Greek. For example, I created a shortcut to use SBL BibLit

\\newfontfamily{\\sbl}{SBL BibLit}, a font which contains just about all the characters in ancient Greek and the symbols for critical editions.

To switch to that font I would insert the Greek text between brackets preceded by \\sbl as in the following example:

I switch to Greek {\\sbl μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην} (beginning of the Iliad) and back to English

That’s pretty much all there is to it.

As I said, you could just use one font for your regular text and your Greek text without calling a separate Greek font with a command. Granted too, framing the Greek text within a call to a different font can be a bit tedious but it offers you the advantage of being able to change the Greek font or its size (or its color, its variant, etc.) after having typed your text in an instant. This is similar to using character styles in your word processor. Furthermore you can write a snippet to use the command and assign the snippet to a keyboard shortcut (see under Edit, Macros in TextMate.

You can actually use parameters with the \\newfontfamily command but I’ll keep it simple for this post. For the rest, you can use all the usual other formatting commands (quotation, verse, tables, etc.). You can find information on hyphenating Greek texts and other typesetting commands in the XeTeX and \LaTeX forums.