\title{Greek and hyperref}
\author{Günter Milde}
\date{2020/10/30}
\maketitle
\tableofcontents
\noindent
On 2010-11-05, Heiko Oberdiek wrote in comp.text.tex:
%
\begin{quote}
\cs{pdfstringdef} (converting TeX code to PDF strings for
bookmarks) supports NFSS2 and needs active characters. Encoding
stuff based on the internal font machinery of TeX (letters with
catcode 11 or 12, ligatures) does not work, because the strings
don't reach TeX's stomach.
\end{quote}
%
The \emph{greek-fontenc} package allows input of Greek characters in a way
that ``reaches TeX's stomach'' and hence works in both, the main document as
well as in PDF strings (e.g. bookmarks). Hyperref's ``puenc.def`` font
encoding file defines LICR macros for monotonic Greek (Greek characters of
the ``Greek and Coptic'' unicode block).
All utf8-encoded literal Unicode characters work in PDF strings. With
\emph{greek-fontenc} and \emph{greek-inputenc}, this enables use of all
Greek character in text and PDF strings.
With the \emph{textalpha} package, Greek letters can be used without
explicit change of the font encoding or Babel language (with some caveats,
see textalpha-doc.pdf).
For correct hyphenation and other fixes, mark Greek text parts with the
Babel language \texttt{greek}. There should be no space around a language
switch: |\foreignlanguage{greek}{λογος}|.
\emph{Babel-Greek} or \emph{textalpha} package with \cs{textalpha} …
\cs{textomega} macros; \emph{alphabeta} package with
\cs{alpha} … \cs{Omega} macros.
With 8-bit TeX (pdflatex), literal Greek Unicode characters are
converted to LICR Macros, too.
Works, if the \texttt{unicode} or \texttt{pdfencoding=auto} option is given
to \emph{hyperref}.%
\footnote{With the ``xpdf'' viewer, Greek letters are not shown
in PDF bookmarks.}
Kerning is impeded if the font encoding is switched for every single
character. To fix this, wrap the Greek part in a command switching to a font
encoding supporting Greek, either \verb+\ensuregreek{...}+ (with package
\emph{textalpha} or \emph{Babel}) or \verb+\foreignlanguage{greek}{...}+
(with \emph{Babel}).
\section{Literal Unicode input}
The following subsection headings contain all characters from the ``Greek
and Coptic'' and ``Greek Extended'' Unicode Blocks that are supported by the
LGR font encoding.
\subsection{ʹ͵ͺ; ΄ ΅ Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝ}
\subsection{ΞΟΠΡΣΤΥΦΧΨΩΪΫϘϚϜϠ}
Greek and Coptic Unicode block: punctuation and uppercase letters
According to Greek typesetting conventions,
diacritics (except the dialytika) are dropped in UPPERCASE.
The LaTeX \cs{Makeuppercase} implementation changed fundamentally
with the release in 06/2022.\footnote{%
This change cannot be reverted with the rollback mechanism
``for technical reasons''.}
Since the change, \cs{Makeuppercase} is also supported in PDF-strings.
Greek typesetting rules are ony applied if the text language is
set to \texttt{greek} with Babel's \cs{setlanguage} or
\cs{foreignlanguage}.
The changes broke the support for upcasing of polutonic Greek (combined
accents) with LICR input and of Greek with the LGR Latin transliteration.
Support is restored as of 2023-09-07, some issues remain with PDF strings.
\ifdefined \AddToNoCaseChangeList
% skip \MakeUppercase tests for LaTeX older than 2022/6
\subsection{Literal Unicode input}
\subsubsection{\MakeUppercase{ʹ͵ͺ; ΄ ΅ Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝ}}
Text language English --- diacritics not dropped.
\subsubsection{\foreignlanguage{greek}{%
\MakeUppercase{ʹ͵ͺ; ΄ ΅ Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝ}}}
Language set to Greek inside the \cs{subsection} command --
diacritics dropped in the text and ToC but not in the PDF sidebar (sic!).
In PDF strings, the hiatus feature only works with literal input.
\section{Conclusion}
For Greek text parts in section headers use either literal Unicode characters%
\footnote{Combining Unicode characters do not work
with inputenc and 8-bit LaTeX. (This is a general restriction.)
Use pre-composed Unicode characters or accent macros
for letters with diacritics. }
or macros. For proper kerning und upcasing in the main document, set the
text language of Greek text parts to \texttt{greek}. If you use polytonic
Greek, set the \texttt{polutoniko} language attribute.