summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx')
-rw-r--r--Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx383
1 files changed, 226 insertions, 157 deletions
diff --git a/Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx b/Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx
index 09490979613..9224df9769f 100644
--- a/Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx
+++ b/Master/texmf-dist/source/generic/babel-greek/babel-greek.dtx
@@ -26,7 +26,7 @@
% and covered by LPPL is defined by the unpacking script (babel-greek.ins)
% which is part of the package.
% \fi
-% \CheckSum{1550}
+% \CheckSum{1547}
%
% \iffalse
% Tell the \LaTeX\ system who we are and write an entry on the
@@ -37,7 +37,7 @@
%<code>\ProvidesLanguage{greek}
%\fi
%\ProvidesFile{babel-greek.dtx}
- [2020/03/17 v1.9j Greek support for the babel system]
+ [2020/11/10 v1.10 Greek support for the babel system]
%\iffalse
%% File `babel-greek.dtx'
%% Greek language Definition File
@@ -56,7 +56,7 @@
\documentclass{ltxdoc}
% \usepackage{lmodern}
\usepackage[utf8]{inputenc}
-\usepackage{hyperref,bookmark}
+\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=black}
\newcommand*{\babel}{\textsf{babel}}
\newcommand*{\note}[1]{}
@@ -127,7 +127,15 @@
% to textalpha.}
% \changes{babel-greek-1.9i}{2020/02/28}{Update test for Unicode fonts.
% Fix accent in seename and alsoname.}
-% \changes{babel-greek-1.9j}{2020/03/17}{Fix ampersand in math.}
+% \changes{babel-greek-1.9j}{2020/03/17}{Fix ampersand in math mode.}
+% \changes{babel-greek-1.10}{2020/11/10}{Use TU as \cs{greekfontencoding}
+% for Xe/LuaTeX. TU is the default font encoding there since 2017/01/01.
+% PDF-string secure implementation of \cs{greeknumeral}
+% (taken from ``hyperref'').
+% Use zig-zagy \cs{textkoppa} for \cs{greeknumeral{90}}.
+% This is what it looked originally and what it looks
+% in current (not classical or medieval) Greek typography.
+% Load ``puenc-greek.def`` (from greek-fontenc_) if used with hyperref.}
%
% \title{Babel support for the Greek language}
% \author{Apostolos Syropoulos, Günter Milde}
@@ -170,8 +178,8 @@
%
% The \href{http://ctan.org/pkg/lm}{Latin Modern} OpenType font that is the
% default font for XeTeX/LuaTeX does not support the Greek script. The user
-% needs to set up an alternative font like Linux Libertine or DejaVu with
-% \pkg{\href{http://www.ctan.org/pkg/fontspec}{fontspec}}.
+% needs to set up an alternative font like CM Unicode, Linux Libertine or
+% DejaVu with \pkg{\href{http://www.ctan.org/pkg/fontspec}{fontspec}}.
%
% \section{Usage}
%
@@ -204,11 +212,11 @@
% \usepackage[greek.ancient,english]{babel}
% \end{verbatim}
%
-% Version 1.9 fixes the activation of hyphenation patterns: By default,
+% By default,
% \pkg{babel-greek} activates the modern Greek monotonic hyphenation;
% the attribute/modifier |polutoniko| activates the modern Greek
% polytonic hyphenation and the attribute/modifier |ancient| activates
-% the ancient Greek hyphenation. 8-bit TeX and XeTeX requires the
+% the ancient Greek hyphenation. 8-bit TeX and XeTeX require the
% hyphenation patterns to be pre-loaded in the format file.
% This is a limitation by TeX, common to all languages.
% The LuaTeX engine loads hyphenation patterns on demand.
@@ -217,9 +225,10 @@
% \DescribeMacro\foreignlanguage
% The Babel core provides two commands to switch the active language:
% The declaration |\selectlanguage{greek}| switches to the Greek language.
-% The macro \verb|\foreignlanguage{greek}{<some text>}| sets its second argument
-% in the Greek language. This is intended for short text parts.
-% For details see the \href{http://www.ctan.org/pkg/babel}{Babel} documentation.
+% The macro \verb|\foreignlanguage{greek}{<some text>}| sets its second
+% argument in the Greek language. This is intended for short text parts.
+% For details see the \href{http://www.ctan.org/pkg/babel}{Babel}
+% documentation.
%
% For backwards compatibility, ``polytonic'' spelling can also be
% selected via the dummy language \Lopt{polutonikogreek}. In this
@@ -467,16 +476,19 @@
% instead of engine}
% \changes{babel-greek-1.9f}{2016/02/04}{Check also for TU font encoding.}
% \changes{babel-greek-1.9i}{2020/02/27}{Update check for Unicode fonts.}
+% \changes{babel-greek-1.10}{2020/11/10}{Use TU with Xe/LuaTeX.}
%
% \DescribeMacro\greekfontencoding
% We test for available font encodings and set |\greekfontencoding|
% and the internal macro |\bbl@greek@fontencdef| with the name of the
-% font definition file with Greek LICR macros. The fallback is LGR.
+% font definition file with Greek LICR macros.
+% The default is LGR for 8-bit TeX engines and TU for Xe/LuaTeX.
+% (TODO: The font encoding definition file was renamed to tuenc-greek.def
+% in \emph{greek-fontenc} 0.14 (2020-02-28).)
% \begin{macrocode}
-\ifdefined \UTFencname % set by "fontspec.sty"
- \providecommand*{\greekfontencoding}{\UTFencname} % TU, EU1, or EU2
- \providecommand*{\bbl@greek@fontencdef}{greek-euenc}
- \renewcommand*{\LastDeclaredEncoding}{\UTFencname}
+\ifdefined \UnicodeEncodingName % set by LaTeX for Unicode-aware engines
+ \providecommand*{\greekfontencoding}{\UnicodeEncodingName}
+ \providecommand*{\bbl@greek@fontencdef}{tuenc-greek}
\else
\providecommand*{\greekfontencoding}{LGR}
\providecommand*{\bbl@greek@fontencdef}{lgrenc}
@@ -484,15 +496,16 @@
% \end{macrocode}
% Ensure that the Greek LICR macros are available:
% \begin{macrocode}
-\@ifl@aded{def}{\bbl@greek@fontencdef}{}{
- \InputIfFileExists{\bbl@greek@fontencdef .def}{}{
- \errhelp{I can't find the \bbl@greek@fontencdef .def file
- for the Greek fonts}%
- \errmessage{Font support for the Greek script missing.^^J
- babel-greek can't typeset Greek.^^J
- Install the "greek-fontenc" package^^J
- or use XeTeX/LuaTeX with polyglossia.}%
- \@@end
+\@ifl@aded{def}{\bbl@greek@fontencdef}{}
+{% else
+ \InputIfFileExists{\bbl@greek@fontencdef .def}{}{% else
+ \bbl@error{Font support for the Greek script missing.\\
+ babel-greek can't typeset Greek.\\
+ Install the "greek-fontenc" package\\
+ or use XeTeX/LuaTeX with polyglossia.}
+ {I can't find the \bbl@greek@fontencdef .def file
+ for the Greek fonts (encoding \greekfontencoding)}
+ \@@end
}
}
% \end{macrocode}
@@ -501,8 +514,7 @@
% encoding to |\greekfontencoding| if the current font encoding does not
% provide a (typically empty) local variant.
% \changes{greek-1.8.1}{2013/12/03}{Set `encodingdefault' in `greekscript'
-% to fix Greek in footnotes etc. with document language Greek.
-% TODO: This is from `greektext' but are there side effects?}
+% to fix Greek in titles, footnotes, etc. with document language Greek.}
% \begin{macrocode}
\ProvideTextCommandDefault{\greekscript}{%
\fontencoding{\greekfontencoding}\selectfont
@@ -519,6 +531,21 @@
% \end{macrocode}
% \end{macro}
%
+% The package hyperref defines the PU font encoding which supports
+% monotonic Greek. Load support for polytonic greek, archaic symbols,
+% and the |\greekscript| and |\ensuregreek| TextCommands:
+% \begin{macrocode}
+\AtBeginDocument{
+ \@ifl@aded{def}{puenc}{
+ \makeatletter % required inside \AtBeginDocument
+ \InputIfFileExists{puenc-greek.def}{}{% else
+ \bbl@warning{I can't find the file puenc-greek.def from "greek-fontenc".}
+ }
+ \makeatother
+ }{}
+}
+% \end{macrocode}
+%
% \subsection{Fixes for the LGR font encoding}
%
% \begin{macrocode}
@@ -886,100 +913,185 @@
% \begin{macrocode}
\addto\extrasgreek{\greekscript}
\addto\noextrasgreek{\latintext}
-% \addto\noextrasgreek{\RestoreFontEncoding} % TODO define \RestoreFontEncoding
% \end{macrocode}
+% TODO restore previous font encoding.
%
-% \begin{macro}{\gr@ill@value}
-% When the argument of |\greeknumeral| has a value outside of the
-% acceptable bounds ($0 < x < 999999$) a warning will be issued
-% (and nothing will be printed).
+% \begin{macro}{\greeknumeral}
+% The command |\greeknumeral| needs to be \emph{fully} expandable
+% in order to get the right information in auxiliary
+% files. It should also be usable in PDF-strings.
+% Therefore we use the implementation from the \cs{HyPsd@GreekPatch}
+% in \href{https://ctan.org/pkg/hyperref}{hyperref}
+% (version 7.00e 2020-05-15).
+% \changes{babel-greek-1.10}{2020/11/10}{PDF-string secure implementation
+% taken from ``hyperref'' (collaboration with Ulrike Fischer).}
% \begin{macrocode}
-\def\gr@ill@value#1{%
- \PackageWarningNoLine{babel}{Illegal value (#1) for greeknumeral}}
+\def\greeknumeral#1{%
+ {\greekscript
+ \bbl@greek@GreekNum\@firstoftwo{#1}}%
+}
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\anw@true}
-% \begin{macro}{\anw@false}
-% \begin{macro}{\anw@print}
-% When a a large number with three \emph{trailing} zero's is to be
-% printed those zeros \emph{and} the numeric mark need to be
-% discarded. As each `digit' is processed by a separate macro
-% \emph{and} because the processing needs to be expandable we need
-% some helper macros that help remember to \emph{not} print the
-% numeric mark (|\anwtonos|).
-%
-% The command |\anw@false| switches the printing of the numeric
-% mark off by making |\anw@print| expand to nothing. The command
-% |\anw@true| (re)enables the printing of the numeric marc. These
-% macro's need to be robust in order to prevent improper expansion
-% during writing to files or during |\uppercase|.
+% \begin{macro}{\Greeknumeral}
+% The command |\Greeknumeral| prints uppercase greek numerals.
% \begin{macrocode}
-\DeclareRobustCommand\anw@false{%
- \DeclareRobustCommand\anw@print{}}
-\DeclareRobustCommand\anw@true{%
- \DeclareRobustCommand\anw@print{\textdexiakeraia}} % \anwtonos
-\anw@true
+\def\Greeknumeral#1{%
+ {\greekscript
+ \bbl@greek@GreekNum\@secondoftwo{#1}}%
+}
% \end{macrocode}
% \end{macro}
-% \end{macro}
-% \end{macro}
%
-% \begin{macro}{\greeknumeral}
-% The command |\greeknumeral| needs to be \emph{fully} expandable
-% in order to get the right information in auxiliary
-% files. Therefore we use a big |\if|-construction to check the
-% value of the argument and start the parsing at the right level.
+% \begin{macro}{\bbl@greek@ill@value}
+% When the argument of |\greeknumeral| has a value outside of the
+% acceptable bounds ($0 < x < 999999$) a warning will be issued
+% (and the argument be printed).
% \begin{macrocode}
-\def\greeknumeral#1{%
+\def\bbl@greek@ill@value#1{%
+ \PackageWarningNoLine{babel}{Illegal value (#1) for greeknumeral}%
+ \@arabic{#1}%
+}
% \end{macrocode}
-% If the value is negative or zero nothing is printed and a warning
-% is issued.
-% \changes{greek-1.3b}{1999/04/03}{Added \cs{expandafter} and
-% \cs{number} (PR3000) in order to make a counter an acceptable
-% argument}
+% \end{macro}
+% \begin{macro}{\bbl@greek@GreekNum}
+% \begin{macro}{\bbl@greek@@GreekNum}
+% \begin{macro}{\bbl@greek@GreekNumI}
+% \begin{macro}{\bbl@greek@GreekNumII}
+% \begin{macro}{\bbl@greek@GreekNumIII}
+% \begin{macro}{\bbl@greek@GreekNumIV}
+% \begin{macro}{\bbl@greek@GreekNumV}
+% \begin{macro}{\bbl@greek@GreekNumVI}
+% The auxiliary macros provide the actual conversion.
+% They are taken from hyperref as well.
% \begin{macrocode}
- \ifnum#1<\@ne\space\gr@ill@value{#1}%
+\def\bbl@greek@GreekNum#1#2{%
+ \ifnum#2<\@ne
+ \bbl@greek@ill@value{#2}%
+ \else
+ \ifnum#2<1000000 %
+ \bbl@greek@@GreekNum#1{#2}%
+ \else
+ \bbl@greek@ill@value{#2}%
+ \fi
+ \fi
+}
+\def\bbl@greek@@GreekNum#1#2{%
+ \ifnum#2<\@m
+ \ifnum#2<10 %
+ \expandafter\bbl@greek@GreekNumI
+ \expandafter\@gobble\expandafter#1\number#2%
+ \else
+ \ifnum#2<100 %
+ \expandafter\bbl@greek@GreekNumII
+ \expandafter\@gobble\expandafter#1\number#2%
+ \else
+ \expandafter\bbl@greek@GreekNumIII
+ \expandafter\@gobble\expandafter#1\number#2%
+ \fi
+ \fi
+ \ifnum#2>\z@
+ \textnumeralsigngreek
+ \fi
\else
- \ifnum#1<10\expandafter\gr@num@i\number#1%
+ \ifnum#2<\@M
+ \expandafter\bbl@greek@GreekNumIV\expandafter#1\number#2%
\else
- \ifnum#1<100\expandafter\gr@num@ii\number#1%
+ \ifnum#2<100000 %
+ \expandafter\bbl@greek@GreekNumV\expandafter#1\number#2%
\else
-% \end{macrocode}
-% We use the available shorthands for 1.000 (|\@m|) and 10.000
-% (|\@M|) to save a few tokens.
-% \begin{macrocode}
- \ifnum#1<\@m\expandafter\gr@num@iii\number#1%
- \else
- \ifnum#1<\@M\expandafter\gr@num@iv\number#1%
- \else
- \ifnum#1<100000\expandafter\gr@num@v\number#1%
- \else
- \ifnum#1<1000000\expandafter\gr@num@vi\number#1%
- \else
-% \end{macrocode}
-% If the value is too large, nothing is printed and a warning
-% is issued.
-% \begin{macrocode}
- \space\gr@ill@value{#1}%
- \fi
- \fi
- \fi
- \fi
+ \expandafter\bbl@greek@GreekNumVI\expandafter#1\number#2%
\fi
\fi
\fi
}
+\def\bbl@greek@GreekNumI#1#2#3{%
+ #1{%
+ \ifnum#3>\z@
+ \textnumeralsignlowergreek
+ \fi
+ }%
+ \expandafter#2%
+ \ifcase#3 %
+ {}{}%
+ \or\textalpha\textAlpha
+ \or\textbeta\textBeta
+ \or\textgamma\textGamma
+ \or\textdelta\textDelta
+ \or\textepsilon\textEpsilon
+ \or\textstigmagreek\textStigmagreek
+ \or\textzeta\textZeta
+ \or\texteta\textEta
+ \or\texttheta\textTheta
+ \else
+ {}{}%
+ \fi
+}
+\def\bbl@greek@GreekNumII#1#2#3#4{%
+ #1{%
+ \ifnum#3>\z@
+ \textnumeralsignlowergreek
+ \fi
+ }%
+ \expandafter#2%
+ \ifcase#3 %
+ {}{}%
+ \or\textiota\textIota
+ \or\textkappa\textKappa
+ \or\textlambda\textLambda
+ \or\textmugreek\textMu
+ \or\textnu\textNu
+ \or\textxi\textXi
+ \or\textomicron\textOmicron
+ \or\textpi\textPi
+ \or\textkoppa\textKoppa
+ \else
+ {}{}%
+ \fi
+ \bbl@greek@GreekNumI#1#2#4%
+}
+\def\bbl@greek@GreekNumIII#1#2#3#4#5{%
+ #1{%
+ \ifnum#3>\z@
+ \textnumeralsignlowergreek
+ \fi
+ }%
+ \expandafter#2%
+ \ifcase#3 %
+ {}{}%
+ \or\textrho\textRho
+ \or\textsigma\textSigma
+ \or\texttau\textTau
+ \or\textupsilon\textUpsilon
+ \or\textphi\textPhi
+ \or\textchi\textChi
+ \or\textpsi\textPsi
+ \or\textomega\textOmega
+ \or\textsampigreek\textSampigreek
+ \else
+ {}{}%
+ \fi
+ \bbl@greek@GreekNumII#1#2#4#5%
+}
+\def\bbl@greek@GreekNumIV#1#2#3#4#5{%
+ \bbl@greek@GreekNumI\@firstofone#1#2%
+ \bbl@greek@@GreekNum#1{#3#4#5}%
+}
+\def\bbl@greek@GreekNumV#1#2#3#4#5#6{%
+ \bbl@greek@GreekNumII\@firstofone#1#2#3%
+ \bbl@greek@@GreekNum#1{#4#5#6}%
+}
+\def\bbl@greek@GreekNumVI#1#2#3#4#5#6#7{%
+ \bbl@greek@GreekNumIII\@firstofone#1#2#3#4%
+ \bbl@greek@@GreekNum#1{#5#6#7}%
+}
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\Greeknumeral}
-% The command |\Greeknumeral| prints uppercase greek numerals.
-% The parsing is performed by the macro |\greeknumeral|.
-% \begin{macrocode}
-\def\Greeknumeral#1{%
- \expandafter\MakeUppercase\expandafter{\greeknumeral{#1}}}
-% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
% \end{macro}
%
% \begin{macro}{\greek@alph}
@@ -1018,62 +1130,6 @@
% \end{macro}
% \end{macro}
%
-% What is left now is the definition of a set of macros to produce
-% the various digits.
-% \begin{macro}{\gr@num@i}
-% \begin{macro}{\gr@num@ii}
-% \begin{macro}{\gr@num@iii}
-% \changes{greek-1.2b}{1997/11/13}{No longer use \cs{\let} in the
-% expansion of the \cs{gr@num@x} macros as they ned to be
-% expandable}
-% As there is no representation for $0$ in this system the zeros
-% are simply discarded. When we have a large number with three
-% \emph{trailing} zero's also the numeric mark is discarded.
-% Therefore these macros need to pass the information to each other
-% about the (non-)translation of a zero.
-% \begin{macrocode}
-\def\gr@num@i#1{%
- \ifcase#1\or \textalpha\or \textbeta\or \textgamma\or \textdelta\or
- \textepsilon\or \textstigma\or \textzeta\or \texteta\or \texttheta\fi
- \ifnum#1=\z@\else\anw@true\fi\anw@print}
-\def\gr@num@ii#1{%
- \ifcase#1\or \textiota\or \textkappa\or \textlambda\or \textmu\or
- \textnu\or \textxi\or \textomicron\or \textpi\or \textqoppa\fi
- \ifnum#1=\z@\else\anw@true\fi\gr@num@i}
-\def\gr@num@iii#1{%
- \ifcase#1\or \textrho\or \textsigma\or \texttau\or \textupsilon\or
- \textphi\or \textchi\or \textpsi\or \textomega\or \textsampi\fi
- \ifnum#1=\z@\anw@false\else\anw@true\fi\gr@num@ii}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\gr@num@iv}
-% \begin{macro}{\gr@num@v}
-% \begin{macro}{\gr@num@vi}
-% The first three `digits' always have the numeric mark, except
-% when one is discarded because it's value is zero.
-% \begin{macrocode}
-\def\gr@num@iv#1{%
- \ifnum#1=\z@\else\textaristerikeraia\fi
- \ifcase#1\or \textalpha\or \textbeta\or \textgamma\or \textdelta\or
- \textepsilon\or \stigma\or \textzeta\or \texteta\or \texttheta\fi
- \gr@num@iii}
-\def\gr@num@v#1{%
- \ifnum#1=\z@\else\textaristerikeraia\fi
- \ifcase#1\or \textiota\or \textkappa\or \textlambda\or \textmu\or
- \textnu\or \textxi\or \textomicron\or \textpi\or \textqoppa\fi
- \gr@num@iv}
-\def\gr@num@vi#1{%
- \textaristerikeraia
- \ifcase#1\or \textrho\or \textsigma\or \texttau\or \textupsilon\or
- \textphi\or \textchi\or \textpsi\or \textomega\or \textsampi\fi
- \gr@num@v}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
%
% \section{Character codes}
%
@@ -1278,10 +1334,15 @@
% because the CB fonts v2.0 do not inlcude certain symbols and so
% the remaining symbol definitions have been moved here}
% \changes{greek-1.5}{2013/06/11}{change symbol macros to aliases}
+% \changes{greek-1.10}{2020/11/10}{Fix: \cs{qoppa} is the legacy name of
+% \cs{textkoppa} not \cs{textqoppa}!
+% Provide fallbacks for makros required for greek numerals
+% (added in greek-fontenc 1.0 2020-09-25).}
% \begin{macrocode}
\providecommand*{\anwtonos}{\textdexiakeraia}
\providecommand*{\katwtonos}{\textaristerikeraia}
-\providecommand*{\qoppa}{\textqoppa}
+\providecommand*{\qoppa}{\textkoppa}
+\providecommand*{\varqoppa}{\textqoppa}
\providecommand*{\stigma}{\textstigma}
\providecommand*{\sampi}{\textsampi}
\providecommand*{\Digamma}{\textDigamma}
@@ -1290,6 +1351,14 @@
\providecommand*{\euro}{\texteuro}
\providecommand*{\permill}{\textperthousand}
% \end{macrocode}
+% TODO remove the following lines once greek-fontenc 1.0 is in common use.
+% \begin{macrocode}
+\@ifl@aded{def}{lgrenc}{%
+ \ProvideTextCommand{\textKoppa}{LGR}{\textkoppa}
+ \ProvideTextCommand{\textmugreek}{LGR}{\textmu}
+}{}
+\ProvideTextCommand{\textmugreek}{\greekfontencoding}{\textmu}
+% \end{macrocode}
%
% \changes{greek-1.3l}{2004/02/19}{Commented these lines out as this
% change has made it into \LaTeX{} itself.}