30

How do I type upright Greek letters? I have tried upgreek but it uses specific fonts (Euler or Adobe Symbol).

I want to use the upright Greek letters in the actual font being used. I'm thinking of the following solutions:

  1. XeTeX
  2. Direct ASCII code input
  3. \alpha, beta, \mu, etc. but in text mode

I am inclined to #3. Hopefully it doesn't require inputenc modifications. But of course any solution is welcome.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
Kit
  • 16,430

4 Answers4

33

You can pass the options [greek,english] to the babel package. Then you can switch between them using \greektext and \latintext.

\documentclass{article}
\usepackage[greek,english]{babel}
\begin{document}

\greektext A whole paragraph in greek letters \latintext

% If we only want a single letter, it might make sense to define commands:

\newcommand{\ga}{\greektext a\latintext} \newcommand{\gA}{\greektext A\latintext}

\gA lph\ga \end{document}

greek and english letters

egreg
  • 1,121,712
Jake
  • 232,450
  • 4
    Good answer and you can use "polutoniko" as a babel option to get accents if you wish. – yannisl Jan 18 '11 at 16:45
  • This does not work for me. If I try something like this, greek mode appears in many more places. – Raphael Sep 06 '13 at 14:48
  • @Raphael: It's probably best if you open a new question for this. – Jake Sep 06 '13 at 14:51
  • @Jake I have not been able to come up with a MFE, so it was probably some weird interaction of packages. Luckily, I found another solution. – Raphael Sep 06 '13 at 15:02
  • 4
    There's also \textgreek that takes an argument and is better than switching languages back and forth. And, of course, \textlatin. So \textgreek{A}lph\textgreek{a} might be better. – egreg Sep 06 '13 at 15:06
  • With the most recent version of babel, one can only directly input Greek characters, using UTF-8 and the relative option to inputenc; \textgreek or \greektext are still necessary if the main language is not Greek. – egreg Sep 06 '13 at 15:33
9

Package textgreek seems to work without any hassle. It provides commands like \textalpha and allows you to choose between fonts cbgreek, euler and artemisia.

Raphael
  • 5,983
4

Two solutions involving XeLaTeX

Polyglossia

With Polyglossia the hyphenations rules are loaded correctly for all the declared languages.

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage[variant=mono]{greek}

% Fonts
\setmainfont[Mapping=tex-text]{Linux Libertine O}

\begin{document}
\section{Τίτλος Κεφαλαίου}
English text.  % Main language doesn't need declaration.

\begin{greek} % Secondary languages need to be declared.
Ελληνικό κείμενο.
\end{greek}

\end{document}

You could probably define a shortcut for the greek environment, like

\newcommand{\gr}[1]{\begin{greek}#1\end{greek}}
...
\gr{Και άλλο ελληνικό κείμενο}
...

xgreek

With xgreek you can use upright letters for both languages out of the box. Keep in mind that this package is mainly used for the typesetting of greek texts. If the main language of your documents is english, better stick with polyglossia.

In your case, the main problems with xgreek is that in order to have hyphenation in english, you must explicitly declare the text as english one and that chapters, sections, captions etc would be translated in greek.

\documentclass{article}
\usepackage{fontspec}
\usepackage{xgreek}
\setmainfont{Linux Libertine O}

% This command allows the use of both english and greek text with correct hyphenation.
% English text must be placed in braces. Example:
% Ελληνικό κείμενο. \en{English text.} Ελληνικό κείμενο.
\newcommand{\en}[1]{\setlanguage{american}#1\setlanguage{monogreek}}

\begin{document}
    \en{I want to use the upright Greek letters in the actual font being used and I want the hyphenation rules to work correctly!}

    Οι ελληνικοί κανόνες συλλαβισμού δουλεύουν χωρίς προβλήματα.
\end{document}
pmav99
  • 6,060
1

Method 3 is easy to achieve with the "alphabeta" package from greek-fontenc:

\documentclass{article}
\usepackage{alphabeta}
\begin{document}
You may use literal Unicode characters or the macros known
from math mode.

Beware of \gamma-rays, \pi-mesons and \beta-carotin.

Beware of γ-rays, π-mesons and β-carotin.

\end{document}

Mind, that the symbol variants are not supported with 8-bit Greek text fonts (see http://mirrors.ctan.org/language/greek/greek-fontenc/alphabeta-doc.pdf).

G. Milde
  • 259
  • 1
    Please, avoid the minimal class for examples like this. It's not meant for such usage. – egreg Jan 30 '23 at 23:25