Mathematics, philosophy, programming, in-line skating, and everything in between. More about me…

My Blog

My Latest Tweets

Follow me on Twitter…
English | Czech
Choose your language. I write in English, but I translate most of my articles to Czech as well. Zvolte si jazyk. Píšu anglicky, ale většinu svých článků překládám i do češtiny.

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?

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

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.

II. Loading Greek Language Patterns

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? :-)

Published on December 17, MMIX 7.35 PM and tagged as Miscellaneous. 5 Comments.

5 Comments Add your own…

(avatar) Thijs October 27, MMX 10.55 AM
Great! This worked for me.
I was using \usepackage[utf8]{inputenc} before this, and this package would only allow for example \greek{kuriak`on de~ipnon}.
(avatar) Guillaume Coatalen June 17, MMXI 10.37 AM
I'm desperately trying to do this, cut and paste ancient Greek, on Windows, not Linux, with Texmaker, and it won't typeset the Greek. Any ideas? Thanks a million.
(avatar) Vita June 17, MMXI 1.26 PM
Hi Guillaume,
I'd check that the file is really saved in Unicode and that you have Greek language support installed for TeX. Unfortunately I have never used TeX on Windows so I can't give specific advice. Are you getting any error messages?
(avatar) Vita June 17, MMXI 1.28 PM
[II] I've just found this page on Google: Greek in Latex. Maybe it will help.
(avatar) Guillaume Coatalen July 8, MMXI 2.28 PM
Many thanks vita, I haven't got inputenx, I thought it was inputenc, so I'll download it and see what happens.
Best,
Guillaume

Speak your mind

Allowed HTML tags are a, blockquote, em, code, li, ol, p, pre, strong, ul. Links to other comments in the form “[IV]” or “[4]” are detected automatically.