5

Just a package that allows me to write something like προσθαφαίρεσις without needing to do the annoying \pi \rho ...etc. Surely it should be supported - I imagine there are Greek and Russian (Cyrillic) people to use LaTeX and need to type in their alphabets seamlessly.

9
  • 4
    that is possible out of the box with lualatex or xelatex and should work in pdflatex if you tell it you are using Greek so it sets up suitable fonts and input encoding. (That is for textual greek, \pi, \rho are commands for mathematical Greek symbols so rather different) Jun 15, 2021 at 11:30
  • What about TexShop? That is what I am using
    – user71207
    Jun 15, 2021 at 11:32
  • 1
    TeXShop is just the editor you are using to write the file. it does not actually typeset the document. Jun 15, 2021 at 11:34
  • Huh I did not know that. What typesets the document then?
    – user71207
    Jun 15, 2021 at 11:35
  • 1
    @user71207 I suggest you read an article on TeX engines, e.g. Overleaf’s — you may find it very helpful. (I know reading about this helped me when I was starting out with LaTeX!)
    – bradrn
    Jun 16, 2021 at 12:16

4 Answers 4

6

In my thesis I do it with

\usepackage[LGR,T1]{fontenc}
  \newcommand{\textgreek}[1]{\begingroup\fontencoding{LGR}\selectfont#1\endgroup}

in the preamble. In the text it looks like

\textgreek{ἐὰν δὲ δῆμοσ ἢ φράτορεσ ἢ ἱερῶν ὀργίων ἢ ναῦται ἢ σύσσιτοι ἢ ὁμόταφοι ἢ θιασῶται ἢ ἐπὶ λείαν οἰχόμενοι ἢ εἰσ ἐμπορίαν, ὅτι ἂν τούτων διαθῶνται πρὸσ ἀλλήλουσ, κύριον εἶναι, ἐὰν μὴ ἀπαγορεύσῃ δημόσια γράμματα.}

using a greek keyboard for this part. I just use LaTeX to compile.

2
  • 1
    Why did you get downvoted? This worked for me!
    – user71207
    Jun 15, 2021 at 11:54
  • I wonder, is it possible to change the font? It's interesting to see what the Computer Modern version of Greek looks like though!
    – user71207
    Jun 15, 2021 at 11:55
11

Assuming you are using pdfLaTeX, you can load babel and things will 'just work'

\documentclass{article}
\usepackage[greek]{babel}

\begin{document}
    
προσθαφαίρεσις

\end{document}

For Greek in an otherwise English document, you can use \textgreek from babel

\documentclass{article}
\usepackage[greek,english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
Some text
\textgreek{προσθαφαίρεσις}

\end{document}

On the other hand, if you are using XeLaTeX or LuaLaTeX, all you need to do is pick a font that covers the appropriate glyphs

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
Some text
προσθαφαίρεσις
\end{document}
3
  • Oh! This turned my entire document into Greek. Sorry if my question was unclear, I want to type in both English and Greek
    – user71207
    Jun 15, 2021 at 11:52
  • Thank you! What does the [T1]fontenc package do?
    – user71207
    Jun 15, 2021 at 11:56
  • 1
    @user71207 It switches from an older to a newer font encoding for pdfTeX: not strictly required for English, but I'd strongly recommend it for any document using pdfLaTeX.
    – Joseph Wright
    Jun 15, 2021 at 11:58
6

The other answers all require the use of a command such as \textgreek. You can eliminate this command, too.

If you are using a modern engine such as LuaTeX or XeTeX, and you do not need to hyphenate Greek words, just load a font that contains Greek letters, such as

\usepackage{newcomputermodern}

or

\usepackage{libertinus}

The Greek Font Society has a large collection of them.

If you either need hyphenation, or to enable the Greek OpenType font feature (as some fonts require), this gets a little more complicated. The code in LuaLaTeX is:

\documentclass{article}
\tracinglostchars=2 % Warn if the current font is missing a glyph
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX
\usepackage[english]{babel}
\usepackage{unicode-math}
\usepackage{uninormalize} % Some packages can only handle ancient Greek in NFC form.
\usepackage{microtype} % Font expansion and protrusion

\babelprovide[import=el-polyton, onchar=ids fonts]{greek}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }
\babelfont{rm}
          [Ligatures={Common,Discretionary}, Language=Default, Scale=1.0]{Libertinus Serif}
\babelfont{sf}
          [Ligatures={Common,Discretionary}, Language=Default]{Libertinus Sans}
\babelfont{tt}
          [Language=Default]{Libertinus Mono}
\setmathfont{Libertinus Math}

\begin{document}
Homer’s \textit{Ὀδύσσεια} begins, “ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς
μάλα πολλὰ πλάγχθη.”
\end{document}

Libertinus Serif font sample

And in XeLaTeX, it is:

\documentclass{article}
\tracinglostchars=2 % Warn if the current font is missing a glyph
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX
\usepackage[english]{babel}
\usepackage{unicode-math}
\usepackage[GreekAndCoptic, GreekExtended]{ucharclasses}

\babelprovide[import=el-polyton]{greek}

\setDefaultTransitions{\selectlanguage{english}}{\selectlanguage{english}}
\setTransitionTo{GreekAndCoptic}{\selectlanguage{greek}}
\setTransitionTo{GreekExtended}{\selectlanguage{greek}}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }
\babelfont{rm}
          [Ligatures={Common,Discretionary}, Language=Default, Scale=1.0]{Libertinus Serif}
\babelfont{sf}
          [Ligatures={Common,Discretionary}, Language=Default]{Libertinus Sans}
\babelfont{tt}
          [Language=Default]{Libertinus Mono}
\setmathfont{Libertinus Math}

\begin{document}
Homer’s \textit{Ὀδύσσεια} begins, “ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς
μάλα πολλὰ πλάγχθη.”
\end{document}

Here is the code for PDFTeX. In this engine, you must make sure that your source file is saved in NFC form, that is, using precomposed and not combining characters. Legacy 8-bit TeX cannot understand combining characters.

\documentclass{article}
\tracinglostchars=2 % Warn if the current font is missing a glyph
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX
\usepackage[LGR,T1]{fontenc} %  Enable Greek and Latin font encodings.
\usepackage{textgreek} % For \textalpha, \textbeta, etc.
\usepackage[polutonikogreek, english]{babel}
\usepackage{libertinus}
\usepackage{microtype}

%Bug fix for missing symbol declaration in textgreek:
\DeclareTextSymbolDefault{\textomicron}{LGR}

\begin{document}
Homer’s \textit{Ὀδύσσεια} begins, “ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς
μάλα πολλὰ πλάγχθη.”
\end{document}
2
  • 1
    There is a typo in usepaackage
    – Martin R
    Jun 16, 2021 at 12:25
  • @MartinR Thanks!
    – Davislor
    Jun 16, 2021 at 13:30
2

If you have just occasional Greek words, you can use alphabeta. If you need longer chunks of Greek text, it's better to use the babel framework for changing languages.

\documentclass{article}
\usepackage{alphabeta}

\begin{document}

This document is in English with words
such as προσθαφαίρεσις occasionally
embedded in the text.

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .