summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/babel-greek/test-greeknumeral.tex
blob: f60bcaff75f27597f142de9a21ce5fcc756b4a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
\documentclass[a4paper]{scrartcl}

% Load font packages depending on engine:
\ifdefined\luatexversion 
  \usepackage{fontspec}
\fi
\ifdefined\XeTeXrevision 
  \usepackage{fontspec}
\fi
\ifdefined \UTFencname % set by "fontspec.sty"
  % Latin Modern misses most Greek characters.
  \setmainfont{DejaVu Serif}
  \setsansfont{DejaVu Sans}
\else
  \usepackage[LGR,T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{lmodern}
  % \usepackage{kerkis} % missing glyphs (Qoppa, in sans serif also koppa, Koppa)  
  % \usepackage{dejavu} missing glyphs (qoppa, Qoppa, Sampi)
  % \usepackage{epigrafica} # many missing glyphs
  % \usepackage{gentium} % missing glyphs (Qoppa, Sampi)
  % \usepackage{gfsdidot} % sampi in place of qoppa, missing sampi Sampi
  % \usepackage{gfsartemisia} % sampi in place of qoppa, missing sampi Sampi
  % \usepackage{libertinegc}
  % \usepackage{noto}
  % \usepackage{OldStandard}
  % \usepackage{roboto}
\fi


% Greek script support with textalpha (greek-fontec) or babel-greek:

% \usepackage{textalpha}
\usepackage[greek,english]{babel}

% Save the unpatched version
\let\origgreeknumeral\greeknumeral
\let\origGreeknumeral\Greeknumeral

% uncomment, if you prefer Qoppa for Koppa
% \let\textKoppa\textQoppa
% \let\textkoppa\textqoppa


% Hyperref 
% default PDFstring encoding is PD1 without Greek support:
% \usepackage[unicode]{hyperref}
% With option unicode, there is partial Greek support (no polytonic)
\usepackage[unicode]{hyperref}


\DeclareTextCommand{\greekscript}{PU}{}
\DeclareTextCommand{\ensuregreek}{PU}[1]{#1}
% Greek LICR names from "greek-fontenc"
\DeclareTextCommand{\textdexiakeraia}{PU}{\83\164}% U+0374
\DeclareTextCommand{\textaristerikeraia}{PU}{\83\165}% U+0375
\DeclareTextCommand{\textQoppa}{PU}{\83\330}% U+03D8
\DeclareTextCommand{\textqoppa}{PU}{\83\331}% U+03D9
\DeclareTextCommand{\textStigma}{PU}{\83\332}% U+03DA
\DeclareTextCommand{\textstigma}{PU}{\83\333}% U+03DB
\DeclareTextCommand{\textDigamma}{PU}{\83\334}% U+03DC
\DeclareTextCommand{\textdigamma}{PU}{\83\335}% U+03DD
\DeclareTextCommand{\textKoppa}{PU}{\83\336}% U+03DE
\DeclareTextCommand{\textkoppa}{PU}{\83\337}% U+03DF
\DeclareTextCommand{\textSampi}{PU}{\83\340}% U+03E0
\DeclareTextCommand{\textsampi}{PU}{\83\341}% U+03E1
% TODO: support polytonic Greek (Greek Extended Unicode block)



\begin{document}

% \textuppercase{Grüße}

% \selectlanguage{greek}
% \selectlanguage{english}


\section{Test Hyperref-safe implementation of Greek numerals}

Every number is set in 4 versions:

1: lowercase Babel, 
2: lowercase Hyperref-patched,

3: uppercase Babel,
4: uppercase Hyperref-patched,


\DeclareRobustCommand{\numeraltest}[1]{
  \origgreeknumeral{#1}
  \ensuregreek{\greeknumeral{#1}}\ 
  \origGreeknumeral{#1}
  \ensuregreek{\Greeknumeral{#1}}
}


\noindent single numerals

1-5
\numeraltest{1}
\numeraltest{2}
\numeraltest{3}
\numeraltest{4}
\numeraltest{5}

6-9
\numeraltest{6}
\numeraltest{7}
\numeraltest{8}
\numeraltest{9}

10-50
\numeraltest{10}
\numeraltest{20}
\numeraltest{30}
\numeraltest{40}
\numeraltest{50}

60-90
\numeraltest{60}
\numeraltest{70}
\numeraltest{80}
\numeraltest{90}

100-500
\numeraltest{100}
\numeraltest{200}
\numeraltest{300}
\numeraltest{400}
\numeraltest{500}

600-900
\numeraltest{600}
\numeraltest{700}
\numeraltest{800}
\numeraltest{900}

1000-5000
\numeraltest{1000}
\numeraltest{2000}
\numeraltest{3000}
\numeraltest{4000}
\numeraltest{5000}

6000-9000
\numeraltest{6000}
\numeraltest{7000}
\numeraltest{8000}
\numeraltest{9000}

10 000 - 900 000
\numeraltest{10000}
\numeraltest{20000}
\numeraltest{800000}
\numeraltest{900000}

\noindent compound numbers

123-323
\numeraltest{123}
\numeraltest{223}
\numeraltest{323}

445-645
\numeraltest{445}
\numeraltest{545}
\numeraltest{645}

767-967
\numeraltest{767}
\numeraltest{867}
\numeraltest{967}

967021 \numeraltest{967021}

\noindent outside of bounds

Negative and zero
\greeknumeral{-1}
% \Greeknumeral{-1}
\greeknumeral{0}
%\Greeknumeral{0}

Too large:
\greeknumeral{1000000}
% \Greeknumeral{1000000}

\paragraph{Discussion}

The new implementation gives identical results.

\section{Greek numerals in PDF bookmarks}

\section{
  \numeraltest{1}
  \numeraltest{90}
  \numeraltest{200}
}

\section{
  \numeraltest{1000}
  \numeraltest{90000}
  \numeraltest{200000}
}
\section{
  \numeraltest{24}
  \numeraltest{96}
}

\section{
  \numeraltest{96}
  \numeraltest{263}
}

\section{
  \numeraltest{4695}
}

\section{Original numeral: 
  \greekscript{\origgreeknumeral{1293}}
  % \greekscript{\origGreeknumeral{1293}}
}

Babels original lower case version works fine in text. However, use in a
section heading results in spurious numeral marks (dexia keraia) in the
PDF bookmark. and the warning
\begin{verbatim}
  Package hyperref Warning: Token not allowed in a PDF string (Unicode):
  (hyperref)                removing `\@ifnextchar' on input line 353.
\end{verbatim}

The upper case version fails because MakeUpercase is not defined for
PDFstrings.

\end{document},