% textalpha: Greek symbols in text
% ********************************
% 
% :Copyright: © 2010 Günter Milde
% :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:  Provide a set of ``\text*`` macros for Greek letters
%             outside math.
% 
% :Identification:
%  ::

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{textalpha}
[2013/05/28 v0.4 macros for Greek letters in text]

%  This package is part of the lgrx_ bundle.
% 
% .. note::
% 
%    The package was renamed from `textgreek` to `textalpha` to prevent
%    confusion with the textgreek_ package by Leonard Michlmayr.
% 
% 
% Changelog:
%   .. class:: borderless
% 
%   ==========  ===== =========================================================
%   2010-06-16  0.1   initial version
%   2012-06-27  0.2   support for compound Unicode definitions outside LGR
%   2013-05-03  0.3   new accent macro names with ``lgrxenc.def`` 0.7
%   2013-05-28  0.4   use ``lgrenc.def`` from greek-fontenc
%   ==========  ===== =========================================================
% 
% Motivation
% ==========
% 
% By default, TeX macros for Greek letters are only valid in mathematical
% mode. This package declares the LGR font encoding as default for Greek LICR
% macros (``\textalpha`` -- ``\textOmega``).
% 
% * Symbols from a Greek text font (e.g. the `CB fonts`_) can be accessed
%   without the need for an explicite font-encoding switch.
% 
% * In combination with ``\usepackage[utf8]{inputenc}`` and ``lgrenc.dfu``
%   from greek-inputenc_, Unicode input of Greek characters is supported in
%   any font encoding.
% 
% * In combination with the ``\text`` macro from amsmath, this can be used to
%   get matching upright and bold upright Greek symbols in math mode.
% 
% Attention
%   The macros work well in any font encoding for single symbols. 
%   
%   However, the automatic font-encoding switches behind the doors interfere
%   with kerning between letters and replacement of accent+character with a
%   pre-composed character. Therefore, Greek text should be written with the
%   help of babel_, setting the language to ``greek`` or wrapped in the
%   provided ensuregreek_ macro. 
% 
% The package uses NFSS default definitions as explained in the fntguide_
% (section 5.3).
% 
% 
% Implementation
% ==============
% 
% Requirements
% ------------
% 
% This package requires the font encoding definitions from greek-fontenc_::

\input{lgrenc.def}

% ensuregreek
% -----------
% 
% The ``\ensuregreek`` command can be used to ensure that its argument is set in
% a font encoding with support for Greek. We define LGR as default encoding for
% Greek text::

\DeclareTextCommandDefault{\ensuregreek}[1]{{\fontencoding{LGR}\selectfont #1}}

% .. The [fntguide_] writes
% 
%      Note that ``\DeclareTextAccentDefault`` can be used on any
%      one-argument encoding-specific command, not just those defined with
%      ``\DeclareTextAccent``.
% 
%    However, the simpler alternative
%    ``\DeclareTextAccentDefault{\ensuregreek}{LGR}`` fails with the table of
%    Unicode characters in the test document `<textalpha-test.tex>`__:
% 
%      ``! You can't use a prefix with `end-group character }'.``
% 
% Eventually, all font encodings supporting Greek script (e.g. LGI, PU, EU1,
% EU2) will declare ``\ensuregreek`` as text command that passes the argument
% unchanged. This way, kerning and selection of precomposed glyphs would work
% also for cases like ``\ensuregreek{\'A}U``.
% 
% .. Do this for PU here? ``\DeclareTextCommand{\ensuregreek}{PU}[1]{#1}``
% 
%    Can lead to infinite recursion (``TeX capacity exeeded``) without the
%    ``unicode=true`` hyperref option.
%    (How about a test whether the PU font encoding is defined?).
% 
%   
% Greek Alphabet
% --------------
% 
% Define the ``text*`` marcos as default for all font encodings::

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

% Additional Greek symbols
% """"""""""""""""""""""""
% 
% Including alias names for compatibility with hyperref's puenc.def.
% 
% Ancient Greek Numbers (Athenian Numerals)::

\DeclareTextSymbolDefault{\textpentedeka}{LGR}    % GREEK ACROPHONIC ATTIC FIFTY
\DeclareTextSymbolDefault{\textpentehekaton}{LGR} % GREEK ACROPHONIC ATTIC FIVE HUNDRED
\DeclareTextSymbolDefault{\textpenteqilioi}{LGR}  % GREEK ACROPHONIC ATTIC FIVE THOUSAND
\DeclareTextSymbolDefault{\textpentemurioi}{LGR}  % GREEK ACROPHONIC ATTIC FIFTY THOUSAND

% Archaic letters::

\DeclareTextSymbolDefault{\textstigma}{LGR}      % ϛ
\DeclareTextSymbolDefault{\textstigmagreek}{LGR} % ϛ (puenc.def)
\DeclareTextSymbolDefault{\textvarstigma}{LGR}   % stigma variant
\DeclareTextSymbolDefault{\textkoppa}{LGR}       % ϟ (greek small letter koppa)
\DeclareTextSymbolDefault{\textkoppagreek}{LGR}  % ϟ (puenc.def)
\DeclareTextSymbolDefault{\textqoppa}{LGR}       % ϙ (archaic koppa)
\DeclareTextSymbolDefault{\textQoppa}{LGR}       % Ϙ (archaic Koppa)
\DeclareTextSymbolDefault{\textStigma}{LGR}      % Ϛ ϹΤ ligature in some fonts
\DeclareTextSymbolDefault{\textStigmagreek}{LGR} % Ϛ (puenc.def)
\DeclareTextSymbolDefault{\textSampi}{LGR}       % Ϡ
\DeclareTextSymbolDefault{\textSampigreek}{LGR}  % Ϡ (puenc.def)
\DeclareTextSymbolDefault{\textsampi}{LGR}       % ϡ
\DeclareTextSymbolDefault{\textsampigreek}{LGR}  % ϡ (puenc.def)
\DeclareTextSymbolDefault{\textanoteleia}{LGR}   % ·
\DeclareTextSymbolDefault{\texterotimatiko}{LGR} % ; (003B is the preferred character) 
\DeclareTextSymbolDefault{\textdigamma}{LGR}     % ϝ
\DeclareTextSymbolDefault{\textDigamma}{LGR}     % Ϝ
\DeclareTextSymbolDefault{\textdigammagreek}{LGR} % ϝ (puenc.def)
\DeclareTextSymbolDefault{\textDigammagreek}{LGR} % Ϝ (puenc.def)

% numeral signs: http://en.wikipedia.org/wiki/Greek_numerals ::

\DeclareTextSymbolDefault{\textnumeralsigngreek}{LGR}      % (puenc.def)
\DeclareTextSymbolDefault{\textnumeralsignlowergreek}{LGR} % (puenc.def)

% Diacritics
% ----------
% 
% Greek diacritics via "named" macros::

\DeclareTextAccentDefault{\accdasia}{LGR}
\DeclareTextAccentDefault{\accpsili}{LGR}
\DeclareTextAccentDefault{\acctonos}{LGR}
\DeclareTextAccentDefault{\accvaria}{LGR}
\DeclareTextAccentDefault{\accperispomeni}{LGR}
\DeclareTextAccentDefault{\accdialytika}{LGR}
\DeclareTextAccentDefault{\<}{LGR}
\DeclareTextAccentDefault{\>}{LGR}
%
\DeclareTextAccentDefault{\accdasiaoxia}{LGR}
\DeclareTextAccentDefault{\accdasiavaria}{LGR}
\DeclareTextAccentDefault{\accdasiaperispomeni}{LGR}
\DeclareTextAccentDefault{\accpsilioxia}{LGR}
\DeclareTextAccentDefault{\accpsilivaria}{LGR}
\DeclareTextAccentDefault{\accpsiliperispomeni}{LGR}
\DeclareTextAccentDefault{\accdialytikatonos}{LGR}
\DeclareTextAccentDefault{\accdialytikavaria}{LGR}
\DeclareTextAccentDefault{\accdialytikaperispomeni}{LGR}

% Postfix accents::

\DeclareTextSymbolDefault{\ypogegrammeni}{LGR} % "small" sub-iota
\DeclareTextSymbolDefault{\prosgegrammeni}{LGR}  % "capital" sub-iota

% Auxiliary macros
% ----------------
% 
% ``\MakeUppercase`` requires two internal commands::

\DeclareTextAccentDefault{\LGR@hiatus}{LGR}
\DeclareTextAccentDefault{\LGR@Dialytika}{LGR}


% .. References
%    ----------
% .. _LaTeX Project Public License: http://www.latex-project.org/lppl.txt
% .. _CB fonts: http://www.ctan.org/pkg/cbgreek-complete
% .. _babel: http://www.ctan.org/cgi-bin/ctanPackageInformation.py?id=babel
% .. _fntguide: http://www.ctan.org/tex-archive/macros/latex/doc/fntguide.pdf
% .. _greek-fontenc: http://www.ctan.org/pkg/greek-fontenc
% .. _greek-inputenc: http://www.ctan.org/pkg/greek-inputenc
% .. _lgrx: http://www.ctan.org/pkg/lgrx
% .. _textgreek: http://www.ctan.org/pkg/textgreek
