\documentclass[a4paper]{article}
% \usepackage{textcomp}
\usepackage{hyperref}
% \usepackage{bookmark}
\usepackage{parskip}

% Declare the font encoding and Greek LICR definitions:
\usepackage[LGR]{fontenc}

% Set up Latin Modern OpenType unicode font
\usepackage{fontspec}

\usepackage[greek,english]{babel}
% \languageattribute{greek}{polutoniko}
% \languageattribute{greek}{ancient}

% use LGR (8-bit CB-fonts) instead of Unicode fonts for Greek:
\addto{\extrasgreek}{\greektext}
% Alternative:
% \renewcommand*{\greekscript}{\fontencoding{LGR}\selectfont}

\begin{document}

\title{XeTeX/LuaTeX with LGR fonts}
\author{Günter Milde}
\date{2020/11/10}
\maketitle

The babel option «greek» activates the support for the Greek language
defined in «greek.ldf» (source «greek.dtx»).

Typesetting Greek texts requires a font containing Greek letters. With the
XeTeX or LuaTeX engines, the user must ensure that the selected font
contains the required glyphs (the default Latin Modern fonts miss them).

Latin Modern can be combined with the matching CB-Greek 8-bit font. For the
setup, see the preamble of this document \texttt{test-unicode-lgr.tex}

Caveat: Currently, hyphenation does not work with this setup. Use it only
for short Greek quotes or as a last ressort.

\section{Language Switch}

The declaration \verb|\selectlanguage| switches between languages. With
XeTeX or LuaTeX and LGR as \verb|\greekfontencoding|, Unicode input is not
possible. Instead, use the Latin transliteration or LICR macros:

\begin{quote}
  \selectlanguage{greek}
  T'i f'hic? <Id`wn >enj'ede pa~id'' >eleuj'eran\\
  t`ac plhs'ion N'umfac stefano~usan, S'wstrate,\\
  >er~wn 'ap~hljec e>uj'uc?
\end{quote}

The macro \verb|\foreignlanguage| sets its second argument in the specified
language. This is intended for short text parts like
\foreignlanguage{greek}{Biblioj'hkh}.

\section{Font Encoding}

Switching to a font encoding supporting the Greek script is possible without
switching the text language using the declarations \verb|\greekscript| or
\verb|\greektext| (always LGR) and the macros \verb|\ensuregreek| or
\verb|\textgreek|. These commands do not start a new paragraph.

The Babel core defines the declaration \verb|\latintext| and the command
\verb|\textlatin| to switch to the T1 or OT1 font encoding or typeset the
argument using this encoding. \texttt{greek.ldf} adds a test for the Unicode
font encodings TU, EU1, and EU2. Here, \verb|\latinencoding| is
\latinencoding.

With Unicode fonts, the macros \verb|\greektext| and \verb|\textgreek| are
only defined, if the LGR font encoding is loaded via the \texttt{fontenc}
package (see test-unicode-lgr.tex).

% don't change the font encoding.
With LGR, Latin characters in Greek text parts are typeset as Greek characters
according to the Latin transcription defined in LGR.%

\begin{quote}
  \greektext F\'ilwn to\~u \textlatin{TeX} (EFT) --
  \latintext{Friends (\textgreek{F\'ilwn}) of TeX.}%
\end{quote}

\section{MakeUppercase, MakeLowercase}

Capital Greek letters have diacritics (except the dialytika and sub-iota) to
the left (instead of above) and drop them in uppercase.

Tonos and dasia mark a \emph{hiatus} (break-up of a diphthong) if placed on
the first vowel of a diphthong (\textgreek{\'ai, \'au, \'ei, \'>ai, \'>au,
\'>ei}). A dialytika must be placed on the second vowel if they are dropped.
(\foreignlanguage{greek}{\MakeUppercase{\'ai, \'au, \'ei, \'>ai, \'>au,
\'>ei}}).

\section{LICR Macros}

Babel defines macros for several autogenerated strings so that they may
appear in the choosen language. \emph{babel-greek} uses LICR macros in
order to let the string macros work independent of the font encoding.

If \texttt{fontspec} is loaded before babel, babel-greek loads Greek LICR
for TU from the file \texttt{tuenc-greek.def} provided with
\emph{greek-fontenc} since version~0.14 (2020-02-28).

\subsection{Hiatus}

The «hiatus» feature works with macro input:

\selectlanguage{greek}
% from teubner: άυλος/ΑΫΛΟΣ
\acctonos\textalpha\textupsilon\textlambda\textomicron\textfinalsigma{}
$\mapsto$
\MakeUppercase{\acctonos\textalpha\textupsilon\textlambda\textomicron\textfinalsigma},
\'>\textalpha\textupsilon\textlambda\textomicron\textfinalsigma{} $\mapsto$
\MakeUppercase{\'>\textalpha\textupsilon\textlambda\textomicron\textfinalsigma},
% from http://diacritics.typo.cz/index.php?id=69  μάινα -> ΜΑΪΝΑ
\textmu\acctonos\textalpha\textiota\textnu\textalpha{} $\mapsto$
\MakeUppercase{\textmu\acctonos\textalpha\textiota\textnu\textalpha},
% from  http://de.wikipedia.org/wiki/Neugriechische_Orthographie#Das_Trema
% κέικ, ἀυπνία/αϋπνία
\textkappa\acctonos\textepsilon\textiota\textkappa $\mapsto$
\MakeUppercase{\textkappa\acctonos\textepsilon\textiota\textkappa},
\accpsili\textalpha\textupsilon\textpi\textnu\'\textiota\textalpha{} $\mapsto$
\MakeUppercase{\accpsili\textalpha\textupsilon\textpi\textnu\'\textiota\textalpha}.
\selectlanguage{english}

\subsection{Captions}

\selectlanguage{greek}
\prefacename,
\refname,
\abstractname,
\bibname,
\chaptername,
\appendixname,
\contentsname,
\listfigurename ,
\listtablename,
\indexname,
\figurename,
\tablename,
\partname,
\enclname,
\ccname,
\headtoname,
\pagename,
\seename,
\alsoname,
\proofname,
\glossaryname
\selectlanguage{english}

Test correct upcasing (dropping of accents):

\selectlanguage{greek}
\MakeUppercase{
\prefacename,
\refname,
\abstractname,
\bibname,
\chaptername,
\appendixname,
\contentsname,
\listfigurename,
\listtablename,
\indexname,
\figurename,
\tablename,
\partname,
\enclname,
\ccname,
\headtoname,
\pagename,
\seename,
\alsoname,
\proofname,
\glossaryname
}
\selectlanguage{english}

\subsection{Months}

\selectlanguage{greek}
\newcounter{foo}
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\stepcounter{foo} \month=\value{foo} \today \\
\selectlanguage{english}

\section{Greek Numerals}

See greek.pdf for the formation rules of Greek numerals.
Some examples:

\selectlanguage{greek}

\greeknumeral{1},
\greeknumeral{2},
\greeknumeral{3},
\greeknumeral{4},
\greeknumeral{5},
\greeknumeral{6},
\greeknumeral{7},
\greeknumeral{8},
\greeknumeral{9},
\greeknumeral{10},
\greeknumeral{11},
\greeknumeral{12},
\greeknumeral{20},
\greeknumeral{345},
\greeknumeral{500},
\greeknumeral{1997},
\greeknumeral{2013},

\Greeknumeral{1},
\Greeknumeral{2},
\Greeknumeral{3},
\Greeknumeral{4},
\Greeknumeral{5},
\Greeknumeral{6},
\Greeknumeral{7},
\Greeknumeral{8},
\Greeknumeral{9},
\Greeknumeral{10},
\Greeknumeral{11},
\Greeknumeral{12},
\Greeknumeral{20},
\Greeknumeral{345},
\Greeknumeral{500},
\Greeknumeral{1997},
\Greeknumeral{2013},


\selectlanguage{english}
Enumerated lists use Greek characters/numerals in the second and fourth level:

\selectlanguage{greek}
\begin{enumerate}
  \item \textlatin{item} 1
  \begin{enumerate}
    \item \textlatin{item} 1.1
    \begin{enumerate}
      \item \textlatin{item} 1.1.1
       \begin{enumerate}
         \item \textlatin{item} 1.1.1.1
         \item \textlatin{item} 1.1.1.2
       \end{enumerate}
      \item \textlatin{item} 1.1.2
    \end{enumerate}
  \end{enumerate}
\end{enumerate}
\selectlanguage{english}

\end{document}
