\documentclass{article}
\usepackage{cmap} % fix search and cut-and-paste in PDF
\usepackage{lmodern}
\usepackage{parskip}
\usepackage{textcomp}
\usepackage{textalpha}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\hypersetup{unicode=true}
\usepackage{bookmark}

\newcommand{\LGR}{\fontencoding{LGR}\selectfont}
\newcommand{\Latin}{\fontencoding{T1}\selectfont}

\providecommand{\greektext}{%
  \fontencoding{LGR}\selectfont\def\encodingdefault{LGR}%
}
\providecommand*{\textgreek}[1]{\leavevmode{\greektext #1}}

\DeclareTextCommand{\TextGreek}{LGR}[1]{#1}
\DeclareTextCommandDefault{\TextGreek}[1]{\textgreek{#1}}

\pagestyle{empty}
\setcounter{secnumdepth}{0}

\begin{document}

\subsection{Greek alphabet}

Greek letters via Latin transscription in LGR font encoding:

\LGR 
\MakeUppercase{a b g d e z h j i k l m n x o p r s t u f q y w}

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

\Latin
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{}

So you can easily write a single Greek symbol (like \textPsi{} or
\textmu{}) or
\textlambda\textomicron\textgamma\textomicron\textvarsigma{} in
non-Greek text or ISO-conforming formulas with an upright pi symbol
like $A = \mbox{\textpi} r^2$ instead of $A = \pi r^2$.

However, kerning is broken in other font encodings: compare
\textgreek{AUA} (LGR) to \textAlpha\textUpsilon\textAlpha (T1).
Because of this (and for proper hyphenation), use of babel and correct
language setting is recommended for Greek quotes.

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

The subsection title above uses: text* macros, Unicode input and the LGR
transcription for the Greek word \TextGreek{logos}. The last variant (Latin
transscription) is written in Latin letters in the PDF bookmark.

On 2010-11-05, Heiko Oberdiek wrote in comp.text.tex:

\begin{quote}
   \textbackslash 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}
  
\subsection{Diacritics}

In LGR encoding, shortcuts as well as named macros are set up for use with
the Latin transcription. 

Composition of diacritics (like \verb+\Dasia\Tonos+) fails in other
font encodings. Long names (like \verb+\DasiaOxia+) work, however they
do not select precomposed characters (the difference becomes obvious
if you drag-and-drop text from the PDF version of this document):
%
LGR: \LGR \<'a \Dasia\Tonos a \DasiaOxia a \DasiaOxia\textalpha \Latin \\
Latin: \DasiaOxia\textalpha

Diacritics (except the dialytika) should placed
before capital letters and dropped with MakeUppercase:

\LGR 
\<{\textalpha} \>{\textepsilon} \"'{\textiota} \`>{\texteta}
\'<{\textomicron} \~<{\textupsilon} \~>{\textomega}
\\
\<{\textAlpha} \>{\textEpsilon} \"'{\textIota} \`>{\textEta}
\'<{\textOmicron} \~<{\textUpsilon} \~>{\textOmega}
\\
\MakeUppercase{%
 \<{\textalpha} \>{\textepsilon} \"'{\textiota} \`>\texteta{}
 \'<{\textomicron} \~<{\textupsilon} \~>{\textomega}
}

\Latin However, in other font encodings, this does not work:

No kerning: (\textgreek{ΑΥΑ} vs. ΑΥΑ), misplaced multiple (\textgreek{ἅ} vs.
ἅ) or Titlecase accents (\textgreek{Ά Έ Ή Ί} vs. Ά Έ Ή Ί) and errors with
MakeUppercase.

Therefore, we would need to define macros for all Unicode characters
that we want to access without explicit font-encoding change.

Alternative: A \verb+\TextGreek+ TextCommandDefault that wraps the argument in
the equivalent of Babel's \verb+\textgreek+ with an LGR TextCommand that
just passes the argument. This is done in the preamble of this document.

This works with the Babel transscription (\TextGreek{logos}), 
keeps kerning (if the kerning pair is inside the argument,
\TextGreek{\textAlpha\textUpsilon\textAlpha}),
and allows iterative accent macros where pre-composed characters are
selected (\TextGreek{\DasiaOxia\textalpha} or
\TextGreek{\Dasia\Tonos\textalpha}).

TODO: Use this definition for multi-macro definitions in the Unicode
definition file?

\end{document}
