\documentclass{article}
\usepackage{cmap} % fix search and cut-and-paste in PDF
\usepackage{lmodern}
\usepackage{parskip}
\usepackage{booktabs}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[unicode=true]{hyperref}
\usepackage{bookmark}
% \pagestyle{headings}

\usepackage{textalpha}


\begin{document}

\section*{Test the \emph{textalpha} package}

With the \emph{textalpha} package, you can easily write a single Greek
symbol (like \textPsi{} or \textmu{}) or a
\textlambda\textomicron\textgamma\textomicron\textvarsigma{} in non-Greek
text as well as ISO-conforming formulas with upright constants (like
\textpi): $A = \mbox{\textpi} r^2$ vs. $A = \pi r^2$. Input is possible via
LICR macros (\verb+\textalpha+ \ldots \verb+\textOmega+) or (with the utf8
option to \emph{inputenc}) Unicode literals.

\section{Greek alphabet}

Greek letters via Latin transscription in LGR font encoding:

\ensuregreek{A B G D E Z H J I K L M N X O P R S T U F Q Y W}\\
\ensuregreek{a b g d e z h j i k l m n x o p r s c t u f q y w}

Greek letters via default macros in other font encoding (here T1):

\textAlpha{} \textBeta{} \textGamma{} \textDelta{} \textEpsilon{}
\textZeta{} \textEta{} \textTheta{} \textIota{} \textKappa{}
\textLambda{} \textMu{} \textNu{} \textXi{} \textOmicron{} \textPi{}
\textRho{} \textSigma{} \textTau{} \textUpsilon{} \textPhi{}
\textChi{} \textPsi{} \textOmega{}
\\
\textalpha{} \textbeta{} \textgamma{} \textdelta{} \textepsilon{}
\textzeta{} \texteta{} \texttheta{} \textiota{} \textkappa{}
\textlambda{} \textmu{} \textnu{} \textxi{} \textomicron{} \textpi{}
\textrho{} \textsigma{} \textvarsigma{} \texttau{} \textupsilon{}
\textphi{} \textchi{} \textpsi{} \textomega{}

\section{PDF strings}

With \emph{textalpha}, you can get Greek letters in PDF strings, too.

\subsection{\textlambda\textomicron\textgamma\textomicron\textvarsigma{},
         λογος and \ensuregreek{logos}}

The subsection title above uses: text* macros, Unicode input and the LGR
transcription for the Greek word \ensuregreek{logos}. Check the table of
contents in the PDF viewer: text* macros and Unicode literals work fine, the
Latin transscription stays Latin in the PDF metadata.

\section{Limitations}

Because the internal font encoding switch interferes with other work behind
the scenes, kerning, diacritics and up/downcasing show problems if
Greek letters are used without explicit change of the font encoding.
These problems can be avoided by use of babel and the correct language
setting (greek or polutonikogreek) or an explicit font encoding switch.

The \verb+\ensuregreek+ macro ensures the argument is set in a font encoding
supporting Greek. This can be used to fix these problems (without adverse
side-effects if the active font encoding is already LGR).

\subsection{Kerning}

No kerning occures between Greek characters in non-Greek text due to the
internal font encoding switch: compare
\ensuregreek{\textAlpha\textUpsilon\textAlpha} (LGR) to
\textAlpha\textUpsilon\textAlpha (T1). Because of this (and for proper
hyphenation), use of babel and correct language setting is recommended for
Greek text parts.

The \verb+\ensuregreek+ macro is also used for wrapping of composite Unicode
character definitions. Kerning is preserved also between accented
characters if the font encoding is LGR: \ensuregreek{AΫA} vs. AΫA (T1).

\subsection{Diacritics}

Composition of diacritics (like \verb+\accdasia\acctonos+) fails in other
font encodings. Long names (like \verb+\accdasiaoxia+) work, however they do
not select precomposed characters. With LGR, pre-composed glyphs are chosen
if available (the difference becomes obvious if you drag-and-drop text from
the PDF version of this document):
%
\ensuregreek{\<'a \accdasia\acctonos a \accdasiaoxia a
\accdasiaoxia\textalpha} (LGR) vs. \accdasiaoxia\textalpha{} (T1).

Diacritics (except the dialytika) are placed before capital letters in
titlecase and dropped in all-caps:
%
\begin{quote}
  \ensuregreek{%
    \<{\textalpha} \>{\textepsilon} \"'{\textiota} \`>\texteta{}
    \'<{\textomicron} \~<{\textupsilon} \~>{\textomega}
    \\
    \<{\textAlpha} \>{\textEpsilon} \"{\textIota} \`>\textEta{}
    \'<{\textOmicron} \~<{\textUpsilon} \~>{\textOmega}
    \\
    \MakeUppercase{%
      \<{\textalpha} \>{\textepsilon} \"'{\textiota} \`\>\texteta{}
      \'<{\textomicron} \~<{\textupsilon} \~>{\textomega}.
    }
  }
\end{quote}
%
However, this does not work in other font encodings:
\ensuregreek{\<\textAlpha} (LGR) vs. \<\textAlpha (T1).


The dialytika marks a \emph{hiatus} (break-up of a diphthong). It must be
present in UPPERCASE even where it is redundant in lowercase (the hiatus can
also be marked by an accent on the first character of a diphthong). The
auto-hiatus feature works in LGR font encoding only:
\acctonos\textalpha\textupsilon{}, \acctonos\textepsilon\textiota{} $\mapsto$
\MakeUppercase{\ensuregreek{
  \acctonos\textalpha\textupsilon{}, \acctonos\textepsilon\textiota{}
}} vs.
\MakeUppercase{
  \acctonos\textalpha\textupsilon{}, \acctonos\textepsilon\textiota{}%
}.

The CamelCase accent macro names should no longer be used. Support will be
removed in a future version.
\ensuregreek{\Tonos\textalpha, \Tonos\textAlpha,
\MakeUppercase{\Tonos\textalpha}
\DasiaVaria\textalpha{} \DialytikaVaria\textupsilon{}
\MakeUppercase{\DasiaVaria\textalpha{} \DialytikaVaria\textupsilon{}}
} (LGR)
\Tonos\textalpha{}, \Tonos\textAlpha{},
\MakeUppercase{\Tonos\textalpha{}} (T1)
\DasiaVaria\textalpha{} \DialytikaVaria\textupsilon{}.
\DasiaVaria\textalpha{} \DialytikaVaria\textupsilon{}
\MakeUppercase{\DasiaVaria\textalpha{} \DialytikaVaria\textupsilon{}}
(T1).


\section{Greek Unicode characters in non-Greek text}

With the \emph{textalpha} package and inputencoding "utf8", Greek Unicode
characters can be used in text with any font encoding.

Combined Diacritics work ᾅ, diacritics (except diaresis) are dopped with
MakeUppercase (μαΐστρος $\mapsto$ \MakeUppercase{μαΐστρος}),
%
but the Hiatus-detection does not work: Currently, the second vowel of the
diphthong must be given as macro, not Unicode literal:
(\ensuregreek{ἀ\textupsilon{}πνία} $\mapsto$
\ensuregreek{\MakeUppercase{\ensuregreek{ἀ\textupsilon{}πνία}}} vs.
\ensuregreek{\MakeUppercase{\ensuregreek{ἀυπνία}}}).
See \href{greek-unicode.pdf}{greek-unicode} for more details.

\end{document}
