Greek text with the LGR font encoding

Licence

This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or any later version.

Abstract

The LGRx bundle provides packages and definitions for typesetting Greek text with fonts in the LGR encoding, the de-facto standard set by babel. It includes a comprehensive font definition file, support for Unicode input and macros for Greek letters in non-Greek text.

Contents

1 State of the Art

Up to now, there is no agreement on a Greek standard font encoding (reserved name T7) because the restrictions for general text encodings are too severe for typesetting polytonic Greek.

The LGR font encoding is the de-facto standard for typesetting Greek with (8-bit) LaTeX. Fonts in this encoding include the CB fonts (matching CM), grtimes (Greek Times), Kerkis (matching URW Bookman), and the GFS font collection. Setup of these fonts as Greek variant to matching Latin fonts is facilitated by the substitutefont package.

The LGR font encoding generates Greek characters via an ASCII transliteration. This enables simple input with a Latin keyboard. Characters with diacritics are selected by ligature definitions in the font (see greek-usage.pdf, teubner-doc.pdf, or The CB Greek fonts).

The name LGR does not reflect status of this font encoding due to historical reasons. The encguide classifies encodings starting with L as "local". Indeed, LGR started as a local encoding for the CB Greek fonts by Claudio Beccari. Later, Apostolos Syropoulos advanced it to the default font encoding for the Babel package's greek option. The correct name would be OT7:

  • It is an 'old' encoding.

  • It implements a Latin transscription for a non-Latin script like the OT2 encoding.

  • It is not confined to 128 bit but OT4 shows that this is no absolute requirement for an OT encoding.

However, due to the fact that this font encoding has been used under its current name for a long time, the name will not change for compatibility reasons.

2 Problems

  1. Ligatures with prefix notation prevent kerning (see the examples linked below or the LGR documentation linked above).

  2. Sub-optimal results with the standard accent macros:

    • no combined accents,

    • accents above (instead of before) capital letters,

    • pre-composed characters are not used.

  3. The tilde character ~ is used for a non-breaking space by default. Therefore the transliteration for the perispomeni accent is not available without re-definition of this character.1

  4. The polutonikogreek Babel option redefines both, ~ and \~ to produce accents via input ligatures (restricted to the language setting instead of the font encoding). This prevents the placing of a tilde-accent on non-supported characters like in niño if the language is set to polytonic Greek, even if \textlatin is used.2

  5. There is no Unicode support with inputenc's utf8 option.

    The ucs package contributed by Dominique Unruh provides Unicode support with the utf8x option. A babel patch by Werner Lemberg for Greek Unicode support never got applied.)

  6. The LGR transliteration does not work for PDF bookmarks.

1
(1, 2)

Problem 3 can be solved by the simple one-liner

\DeclareTextSymbol{\~}{LGR}{126}

which results in \~ inserting a plain tilde character if the font encoding is LGR.

Drawback: you cannot place a ~-accent on Greek characters except the ones supported by an input ligature.

2

Fortunately, LaTeX saves copies of the accent macros: \~ is an alias of \a~ (which is an alias of \@tabacckludge~), so it can be restored after loading Babel with:

\addto\extraspolutonikogreek{\renewcommand*{\~}{\a~}}
\addto\extrasgreek{\renewcommand*{\~}{\a~}}

With this addition, both the comprehensive font encoding definitions and the workaround1 also work with the polutonikogreek Babel option.

3 lgrxenc.def: Comprehensive font encoding definitions

lgrxenc.def is an alternative to the rudimentary LGR font definition file lgrenc.def which comes with Babel's Greek support. It defines accent macros for the LGR font encoding that select pre-composed glyphs if possible and places the diacritics according to Greek typesetting rules else. Combined accents can be specified as backslash + transliteration (\~>a) or iteratively (\~\>{a}).

Source

lgrxenc.def, lgrxenc.def.html

Doc

lgrxenc.tex, lgrxenc.pdf

Tests

lgrxenc-test.tex, lgrxenc-test.pdf

Usage

To prevent confusion with Babel's lgrenc.def, this file is named lgrxenc.def. Load it by calling fontenc with the LGRx option.

Example:

Select font encodings T1 (as default) and LGR (with the comprehensive font encoding definitions)

\usepackage[LGRx,T1]{fontenc}

Attention!

The name of the font encoding defined by the option LGRx is not LGRx but LGR. Therefore, LGRx may not be the last option (as fontenc uses the last option to select the default font encoding). To set LGR as as default font encoding specify both, LGRx and LGR, e.g.

\usepackage[LGRx,T1,LGR]{fontenc}

4 lgrenc.dfu: Greek Unicode support

Standards-compatible UTF-8 support for Greek based on the comprehensive font encoding definitions.

Cooperates with hyperref to enable Greek characters in section headers and PDF bookmarks without the need for \texorpdfstring.

Source

lgrenc.dfu, lgrenc.dfu.html

Example

greek-unicode.tex, greek-unicode.pdf

Usage

Requires comprehensive font encoding definitions from lgrxenc.def:

\usepackage[LGRx,T1]{fontenc} % define LGR and T1 encodings \usepackage[utf8]{inputenc} % standard UTF-8 input encoding

Unless combined with the textalpha package, text containing Greek Unicode characters must be marked as requiring the LGR font encoding (either directly or by setting the language to greek or polutonikogreek). This is a feature of inputenc's standard utf8 support, similar to the behaviour for, e.g., Cyrillic characters.

5 textalpha.sty: Macros for Greek in text

Macros for Greek letters in text that work in any font encoding (see the example below for limitations) and alias macros for compatibility with existing packages.

Cooperates with hyperref and bookmark to enable Greek characters in section headers and PDF bookmarks without the need for \texorpdfstring.

Note

The package was renamed from textgreek to textalpha to prevent confusion with the textgreek package by Leonard Michlmayr.

Source

textalpha.sty, textalpha.sty.html

Example

textalpha-test.tex, textalpha-test.pdf

Bookmarks

greekhyperref.tex, greekhyperref.pdf