Mathematics, philosophy, code, travel and everything in between. More about me…

English | Czech

# Mixing English and Ancient Greek in LaTeX

This took me a while to figure out. Greek letters in LaTeX can be easily output in math mode, but can you imagine writing several Greek words as $\Pi\rho\omega\tau\alpha$…? I mean, don’t we have this “Unicode” thing?

## I. Source Files in UTF-8

Writing input files in UTF-8 is no problem with the inputenx package:

\usepackage[utf8x]{inputenx}


Or, I used to think so. Unfortunately, it seems that LaTeX has some problems with rendering large character subsets of Unicode at once (and Ancient Greek with standard Latin alphabet together form a large subset indeed). I admit I didn’t research the details. The solution, plain and simple, is to explicitly tell LaTeX when it should expect Greek instead of English. Proper font switching takes place somewhere behind the scenes.

In Debian/Ubuntu, you need to install the texlive-lang-greek package. I suppose that similar packages are available in other distributions as well.

# apt-get install texlive-lang-greek


In your document, you load the language like so:

\usepackage[polutonikogreek,english]{babel}


The last specified language (English here) is considered primary for the document. For modern Greek, specify greek instead of polutonikogreek.

## III. Switching Between the Languages

You switch between languages with the \selectlanguage command, like so:

{\selectlanguage{polutonikogreek}Ξενοφάνης} is famous for his critique
of antropomorphic gods.

% OR

\selectlanguage{polutonikogreek}Ξενοφάνης\selectlanguage{english} is
famous for his critique of antropomorphic gods.


To save myself some writing, I’ve created this custom command:

\newcommand{\greek}[1]{{\selectlanguage{polutonikogreek}#1}}


### IV. The Complete Example

\documentclass[a4paper]{article}

\usepackage[polutonikogreek,english]{babel}
\usepackage[utf8x]{inputenx}

\newcommand{\greek}[1]{{\selectlanguage{polutonikogreek}#1}}

\begin{document}

Protagoras (\greek{Πρωταγόρας}) says that Man is the measure of all things''
(\greek{Ἄνθρωπος μέτρον}), meaning that there is no objective truth. One
opinion can be better than another, but it cannot be \emph{truer}.

\end{document}


By the way, do you agree with Protagoras?

December 17, MMIX — Miscellaneous.