alphabeta: Greek symbols in text and math


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.

  [2020/02/28 v0.14 macros for Greek letters in text and math]


Use \alpha, \beta, ... for Greek letters in text and math mode.




initial version



new accent macro names with lgrxenc.def 0.7



use lgrenc.def from greek-fontenc,

enable Unicode input in math mode.



move to greek-fontenc, support XeTeX/LuaTeX.



Support for variant symbols.



Support for standard Unicode text font encoding “TU” (new in fontspec v2.5a).



rename alphabeta-euenc.def to alphabeta-tuenc.def.


By default, the \alpha, \beta, ... macros for Greek letters are only valid in mathematical mode.

With this package, the math macros are redefined to work in both, text and math mode, so that Greek letters can be specified with the established command names in text, too.

If used together with the utf8 option of inputenc, literal Unicode characters can be used for Greek symbols in mathematical formulas.


The macros work well in any font encoding for single symbols. However, with 8-bit TeX, 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 or polyglossia (setting the language to greek) or wrapped in the provided ensuregreek macro. Using babel or polyglossia also helps to ensure proper hyphenation.



The greek-inputenc package provides support for Unicode (utf-8) input of Greek characters with 8-bit TeX and the inputenc package:



alphabeta does not work if the utf8x input encoding is selected. (utf8x is an interface to the ucs package which uses a non-compatible definition of \DeclareUnicodeCharacter.)

For details see alphabeta-doc.tex and alphabeta-doc.pdf.



This package extends the textalpha package. Package options are passed on to textalpha:


Just like alphabeta, textalpha is part of greek-fontenc.

This package requires the e-TeX extensions (i.e. a not too old TeX distribution) for the \ifdefined test.

It uses the \TextOrMath test from the fixltx2e standard LaTeX package. fixltx2e is loaded by default since TeXLive 2015. In case of an \TextOrMath undefined error, load it in the document preamble via


Postpone the re-definitions

To prevent other packages overwriting the re-defined commands we postpone the next steps until the start of the document body:


Save math macros

Provide an alias for the standard math commands:

% ``\digamma`` is defined by amsmath, provide a fallback

% \varkappa and \varbeta are defined by some math packages
\ifdefined\varkappa % e.g. with newtxmath

Commands to access Greek letters by name

For letters defined in math mode, the commands work in both, text and math.

Some Greek letters look identical to Latin letters and can therefore not be used as variable symbols in math formulas. These letters are not defined in TeX’s math mode, we provide an alias to the corrsponding \text... command.

Mathematical notation distinguishes variant shape symbols for pi, phi, rho, theta (small and capital), beta, and kappa (characters for the latter three symbols are not included in TeX’s math fonts). These variations have no syntactic meaning in Greek text and are not given code-points in the LGR encoding while Unicode defines separate code points for the symbol variants.

Greek Alphabet:

Macros keep their meaning in mathematical mode (i.e. use the same shape as without this package) and refer to GREEK LETTER … in text. For \epsilon and phi, this means that the selected symbol variant differs in text vs. math mode. Use \varepsilon and \varphi (see section variant shape symbols below) to select the GREEK LETTER …” in both, text and math mode.

\renewcommand*{\epsilon}{\TextOrMath{\textepsilon}{\mathepsilon}} % ε/ϵ
\renewcommand*{\phi}{\TextOrMath{\textphi}{\mathphi}}             % ϕ/φ

Archaic letters

\renewcommand*{\digamma}{\TextOrMath{\textdigamma}{\mathdigamma}} % ϝ
\providecommand*{\Digamma}{\textDigamma}     % Ϝ
\providecommand*{\stigma}{\textstigma}       % ϛ
\providecommand*{\varstigma}{\textvarstigma} % stigma variant (CB.enc, teubner)
\providecommand*{\koppa}{\textkoppa}         % ϟ (greek small letter koppa)
\providecommand*{\qoppa}{\textqoppa}         % ϙ (archaic koppa)
\providecommand*{\Qoppa}{\textQoppa}         % Ϙ (archaic Koppa)
\providecommand*{\Stigma}{\textStigma}       % Ϛ (in some fonts ϹΤ ligature)
\providecommand*{\Sampi}{\textSampi}         % Ϡ
\providecommand*{\sampi}{\textsampi}         % ϡ

Variant shape symbols

TeX’s concept of “standard” vs. “variant” math symbols does not map to the distinction between GREEK LETTER … vs. GREEK … SYMBOL in the Unicode standard (see tuenc-greek-doc.pdf).

The \...symbol macros select the GREEK … SYMBOL in both, text and math mode. For \epsilonsymbol and \phisymbol this is the default shape in math mode. The \var... macros select the shape used by TeX math (or, if not supported, the SYMBOL shape):

% ..symbol == var..
\renewcommand*{\varpi}{\TextOrMath{\textpisymbol}{\mathvarpi}}          % ϖ
\providecommand*{\pisymbol}{\varpi}                                     % ϖ
\renewcommand*{\varrho}{\TextOrMath{\textrhosymbol}{\mathvarrho}}       % ϱ
\providecommand*{\rhosymbol}{\TextOrMath{\textrhosymbol}{\mathvarrho}}  % ϱ
\renewcommand*{\vartheta}{\TextOrMath{\textthetasymbol}{\mathvartheta}} % ϑ
\providecommand*{\thetasymbol}{\vartheta}                               % ϑ
% ..symbol != var..
\renewcommand*{\varepsilon}{\TextOrMath{\textepsilon}{\mathvarepsilon}} % ε
\providecommand*{\epsilonsymbol}{\TextOrMath{\textepsilonsymbol}{\mathepsilon}} % ϵ
\renewcommand*{\varphi}{\TextOrMath{\textphi}{\mathvarphi}}             % φ
\providecommand*{\phisymbol}{\TextOrMath{\textphisymbol}{\mathphi}}     % ϕ
% only text (in standard 8-bit TeX, may be defined with additional packages):
  \renewcommand*{\varbeta}{\TextOrMath{\textbetasymbol}{\mathvarbeta}}  % ϐ
\ifdefined\mathvarkappa                                                 % ϰ
% \Theta/\varTheta are not a symbol variants but upright/italic shape of Theta
\providecommand*{\Thetasymbol}{\textThetasymbol}                        % ϴ

TextCompositeCommands for the generic macros

The NFSS TextComposite mechanism looks for the next token without expanding it. In order to let compositions like \ensuregreek{\'\Alpha} or \ensuregreek{\>"\alpha} work as expected we define TextComposites with the letter name commands. (Composition only works if the active font encoding is LGR).

\else % 8-bit TeX

Re-definition for Greek Unicode input in math mode

Check with \ifdefined for the definition of \DeclareUnicodeCharacter. In contrast to \@ifdefined, this works without side-effects. It makes the package dependent on the e-TeX extensions but these are standard in all current TeX distributions anyway.

Map Greek characters that are also defined in math mode to the generic macros:

  \DeclareUnicodeCharacter{0393}{\Gamma}         % Γ
  \DeclareUnicodeCharacter{0394}{\Delta}         % Δ
  \DeclareUnicodeCharacter{0398}{\Theta}         % Θ
  \DeclareUnicodeCharacter{039B}{\Lambda}        % Λ
  \DeclareUnicodeCharacter{039E}{\Xi}            % Ξ
  \DeclareUnicodeCharacter{03A0}{\Pi}            % Π
  \DeclareUnicodeCharacter{03A3}{\Sigma}         % Σ
  \DeclareUnicodeCharacter{03A5}{\Upsilon}       % Υ
  \DeclareUnicodeCharacter{03A6}{\Phi}           % Φ
  \DeclareUnicodeCharacter{03A8}{\Psi}           % Ψ
  \DeclareUnicodeCharacter{03A9}{\Omega}         % Ω

  \DeclareUnicodeCharacter{03B1}{\alpha}         % α
  \DeclareUnicodeCharacter{03B2}{\beta}          % β
  \DeclareUnicodeCharacter{03B3}{\gamma}         % γ
  \DeclareUnicodeCharacter{03B4}{\delta}         % δ
  \DeclareUnicodeCharacter{03B5}{\varepsilon}    % ε textepsilon/varepsilon
  \DeclareUnicodeCharacter{03B6}{\zeta}          % ζ
  \DeclareUnicodeCharacter{03B7}{\eta}           % η
  \DeclareUnicodeCharacter{03B8}{\theta}         % θ
  \DeclareUnicodeCharacter{03B9}{\iota}          % ι
  \DeclareUnicodeCharacter{03BA}{\kappa}         % κ
  \DeclareUnicodeCharacter{03BB}{\lambda}        % λ
  \DeclareUnicodeCharacter{03BC}{\mu}            % μ
  \DeclareUnicodeCharacter{03BD}{\nu}            % ν
  \DeclareUnicodeCharacter{03BE}{\xi}            % ξ
  \DeclareUnicodeCharacter{03C0}{\pi}            % π
  \DeclareUnicodeCharacter{03C1}{\rho}           % ρ
  \DeclareUnicodeCharacter{03C2}{\varsigma}      % ς
  \DeclareUnicodeCharacter{03C3}{\sigma}         % σ
  \DeclareUnicodeCharacter{03C4}{\tau}           % τ
  \DeclareUnicodeCharacter{03C5}{\upsilon}       % υ
  \DeclareUnicodeCharacter{03C6}{\varphi}        % φ textphi/varphi
  \DeclareUnicodeCharacter{03C7}{\chi}           % χ
  \DeclareUnicodeCharacter{03C8}{\psi}           % ψ
  \DeclareUnicodeCharacter{03C9}{\omega}         % ω

  \DeclareUnicodeCharacter{03D1}{\thetasymbol}   % ϑ
  \DeclareUnicodeCharacter{03D5}{\phisymbol}     % ϕ $\phi$
  \DeclareUnicodeCharacter{03D6}{\pisymbol}      % ϖ
  \DeclareUnicodeCharacter{03DD}{\digamma}       % ϝ
  \DeclareUnicodeCharacter{03F1}{\rhosymbol}     % ϱ
  \DeclareUnicodeCharacter{03F5}{\epsilonsymbol} % ϵ $\epsilon$

} % close the \AtBeginDocument macro