Debian Codegraph @

texmf-dist/tex/xelatex/mathspec/mathspec.sty

raw
1 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
2 \ProvidesPackage{mathspec}
3 [2016/12/22 v0.2b LaTeX Package (Mathematics font selection for XeLaTeX)]
4
5 %% Requirements:
6 \RequirePackage{etoolbox}
7 \RequirePackage{amstext}
8
9 \RequirePackage{ifxetex}
10 \RequireXeTeX
11 \ifcsundef{XeTeXglyphbounds}
12 {\PackageError{mathspec}
13 {mathspec requires a more recent version of XeTeX}
14 {Your current vesion of XeTeX is \the\XeTeXversion\XeTeXrevision.\MessageBreak
15 Update your version of XeTeX to at least 0.9995.}}
16 {\relax}
17
18 %% Booleans are created automatically on demand.
19 \newcommand\eu@booltrue[1]{\providebool{#1}\booltrue{#1}}
20 \newcommand\eu@gbooltrue[1]{\providebool{#1}\global\booltrue{#1}}
21 \newcommand\eu@boolfalse[1]{\providebool{#1}\boolfalse{#1}}
22 \newcommand\eu@ifbool[1]{\providebool{#1}\ifbool{#1}}
23
24 %% Some extras:
25 %% \eu@ifbooltrue{<bool>}{<true>}
26 %% \eu@ifboolfalse{<bool>}{<false>}
27 %% \eu@ifsomebooltrue{<bool_1>,...,<bool_n>}{<true>}
28 %% (if <bool_i> is true for some i)
29 %% \eu@ifnumis{x}{x_1,...,x_n}{<true>}{<false>} (if x = x_i for some i)
30 %% \eu@ifnumin{x}{a,b}{<true>}{<false>} (if a ≤ x ≤ b)
31 \newcommand\eu@ifbooltrue[2]{\eu@ifbool{#1}{#2}{\relax}}
32 \newcommand\eu@ifboolfalse[2]{\eu@ifbool{#1}{\relax}{#2}}
33 \newcommand\eu@ifsomebooltrue[1]{%
34 \eu@boolfalse{temp}%
35 \def\do##1{\eu@ifbooltrue{##1}{\eu@booltrue{temp}}}%
36 \docsvlist{#1}%
37 \eu@ifbooltrue{temp}}
38 \newcommand\eu@ifnumis[2]{%
39 \providebool{temp}%
40 \boolfalse{temp}%
41 \def\do##1{\ifnumcomp{#1}{=}{##1}{\booltrue{temp}}{\relax}}%
42 \docsvlist{#2}%
43 \ifbool{temp}}
44 \newcommand\eu@ifnumin[2]{\@eu@ifnumin{#1}#2\@nil}
45 \def\@eu@ifnumin #1#2,#3\@nil{%
46 \providebool{temp}%
47 \booltrue{temp}%
48 \ifnumcomp{#1}{<}{#2}{\boolfalse{temp}}{\relax}%
49 \ifnumcomp{#3}{<}{#1}{\boolfalse{temp}}{\relax}%
50 \ifbool{temp}}
51
52 %% Options:
53 \DeclareOption{normalskips}
54 {\PackageWarning{mathspec}
55 {Package option `normalskips' is deprecated}}
56 \def\eu@zf@math{no-math}
57 \DeclareOption{math}{\def\eu@zf@math{math}}
58 \DeclareOption{no-math}{\relax}
59 \DeclareOption{MnSymbol}{\eu@booltrue{MnSymbol}}
60 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{fontspec}}
61 \ProcessOptions\relax
62
63 %% Requires packages:
64 %% fontspec, xkeyval, mathstyle, etoolbox and maybe MnSymbol
65 \RequirePackage[\eu@zf@math]{fontspec}[2008/08/09]
66 \RequirePackage{xkeyval}
67 \eu@ifbooltrue{MnSymbol}{\RequirePackage{MnSymbol}}
68
69 \providecommand\currentmathstyle{\relax}
70
71 %% @-namespace fontspec variable:
72 \ExplSyntaxOn
73 \def\eu@enc{\g_fontspec_encoding_tl}
74 \ExplSyntaxOff
75 %% This is needed to transition to the TU encoding instead of EU1 (WSPR)
76
77 %% Deprecated commands in fontspec:
78 \ExplSyntaxOn
79 \tl_set:Nn \zf@enc { \g_fontspec_encoding_tl }
80 \cs_set:Npn \zf@fontspec #1 #2
81 {
82 \fontspec_select:nn {#1} {#2}
83 \tl_set:Nn \zf@family { \l_fontspec_family_tl }
84 \tl_set:Nn \zf@basefont { \l_fontspec_font }
85 }
86 \ExplSyntaxOff
87 %% These are still defined in fontspec at time of writing but maybe be removed in the future. (WSPR)
88
89 %% Define the undefined Greek letters. Include all variant forms (same as normal
90 %% forms if variant forms are unavailable). Latin F for digamma is better than
91 %% nothing. If Digamma is available, then Capital and Lowercase the are same.
92 \DeclareMathSymbol{\Alpha}{\mathalpha}{operators}{"41}
93 \DeclareMathSymbol{\Beta}{\mathalpha}{operators}{"42}
94 \DeclareMathSymbol{\Epsilon}{\mathalpha}{operators}{"45}
95 \DeclareMathSymbol{\Zeta}{\mathalpha}{operators}{"5A}
96 \DeclareMathSymbol{\Eta}{\mathalpha}{operators}{"48}
97 \DeclareMathSymbol{\Iota}{\mathalpha}{operators}{"49}
98 \DeclareMathSymbol{\Kappa}{\mathalpha}{operators}{"4B}
99 \DeclareMathSymbol{\Mu}{\mathalpha}{operators}{"4D}
100 \DeclareMathSymbol{\Nu}{\mathalpha}{operators}{"4E}
101 \DeclareMathSymbol{\Omicron}{\mathalpha}{operators}{"4F}
102 \DeclareMathSymbol{\Rho}{\mathalpha}{operators}{"50}
103 \DeclareMathSymbol{\Tau}{\mathalpha}{operators}{"54}
104 \DeclareMathSymbol{\Chi}{\mathalpha}{operators}{"58}
105 \DeclareMathSymbol{\omicron}{\mathord}{letters}{"6F}
106 \let\varbeta\beta
107 \ifdef{\varkappa}{\relax}
108 {\let\varkappa\kappa}
109 \ifdef{\varTheta}{\let\eu@cm@varTheta\varTheta}
110 {\relax}
111 \let\varTheta\Theta
112 \ifdef{\digamma}{\let\Digamma\digamma}
113 {\DeclareMathSymbol{\Digamma}{\mathalpha}{operators}{"46}
114 \DeclareMathSymbol{\digamma}{\mathord}{letters}{"46}}
115
116 %% Preserve old definitions of all Greek letters. \eu@cm@alpha etc.
117 \def\do#1{\csletcs{eu@cm@#1}{#1}}
118 \docsvlist{
119 Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,
120 Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,Digamma,alpha,
121 beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,
122 omicron,pi,rho,varsigma,sigma,tau,upsilon,phi,chi,psi,omega,digamma,
123 varTheta,varbeta,varepsilon,vartheta,varkappa,varpi,varrho,varphi}
124 %% varTheta is done separately because amsmath defines it differently.
125
126 %% Can define/redefine any command using the syntax of
127 %% \newcommand/\renewcommand without error. Some helpers.
128 \newcommand\ernewcommand[1]{\ifdef{#1}{\renewcommand{#1}}{\newcommand{#1}}}
129 \providecommand\expanded[1]{\edef\@tempa{#1}\@tempa}
130 \newcommand\eu@setkeys[3][]{
131 \ifblank{#1}{\relax}{\presetkeys[eu]{#2}{#1}{}}
132 \expanded{\noexpand\setkeys*[eu]{#2}{\expandonce#3\@empty}}}
133 \newcommand\eu@fontspec[2]{
134 \expanded{\noexpand\zf@fontspec{\expandonce#1\@empty}{\expandonce#2\@empty}}}
135
136 %% Deprecated commands.
137 %% \+: Use \"..." or " instead.
138 %% \plaindigits: Digits are no longer selected automatically from either
139 %% the Latin or the Greek mathematics font. Instead, they
140 %% must explicitely be stated. If you want plain digits, just
141 %% don't say you want digits.
142 %5 \normalvarforms: Now called \normalisevarforms
143 %% \varforms: Now called \exchangeforms
144 %% Eventually, documents that use these will compile with error.
145 \newcommand\+{
146 \PackageWarning{mathspec}
147 {\protect\+\space is deprecated, recommend to use\MessageBreak\protect\"..."
148 or "}
149 \eu@plus}
150 \newcommand\setsansfonts{
151 \PackageWarning{mathspec}
152 {\protect\setsansfonts\space is deprecated, recommend to use \protect
153 \setallsansfonts.}
154 \setallsansfonts}
155 \@onlypreamble\setsansfonts
156 \newcommand\setmonofonts{
157 \PackageWarning{mathspec}
158 {\protect\setmonofonts\space is deprecated, recommend to use \protect
159 \setallmonofonts.}
160 \setallsansfonts}
161 \@onlypreamble\setmonofonts
162 \newcommand\plaindigits{
163 \PackageWarning{mathspec}{\protect\plaindigits\space is deprecated}}
164 \@onlypreamble\plaindigits
165 \newcommand\normalvarforms{
166 \PackageWarning{mathspec}
167 {\protect\normalvarforms\space is deprecated, recommend to use
168 \protect\normalisevarforms\space or \protect\normalizevarforms}
169 \normalisevarforms}
170 \@onlypreamble\normalvarforms
171 \newcommand\varforms{
172 \PackageWarning{mathspec}
173 {\protect\varforms\space is deprecated, recommend to use
174 \protect\exchangeforms}
175 \exchangeforms}
176 \@onlypreamble\varforms
177
178 %% I don't want this clogging up my sty file. It will be gone eventually.
179 \def\@ifnext#1#2#3{%
180 \let\@tempd=#1%
181 \def\@tempa{#2}%
182 \def\@tempb{#3}%
183 \futurelet\@tempc\@ifnexta}
184 \def\@ifnexta{%
185 \ifx\@tempc\@tempd%
186 \let\@tempb\@tempa%
187 \fi\@tempb}
188 \def\eu@DeclareRobustCommand{\@star@or@long\eu@declare@robustcommand}
189 \def\eu@declare@robustcommand#1{%
190 \ifx#1\@undefined\else\ifx#1\relax\else
191 \@latex@info{Redefining \string#1}%
192 \fi\fi
193 \edef\reserved@a{\string#1}%
194 \def\reserved@b{#1}%
195 \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
196 \edef#1{%
197 \ifx\reserved@a\reserved@b
198 \noexpand\x@protect
199 \noexpand#1%
200 \fi
201 \noexpand\protect
202 \expandafter\noexpand\csname\expandafter\@gobble\string#1\endcsname}%
203 \let\@ifdefinable\@rc@ifdefinable
204 \expandafter\eu@new@command\csname\expandafter\@gobble\string#1\endcsname}
205 \def\eu@new@command#1{\eu@@testopt{\eu@@newcommand#1}0}
206 \def\eu@@newcommand#1[#2]{\@ifnext[{\@xargdef#1[#2]}{\@argdef#1[#2]}}
207 \long\def\eu@@testopt#1#2{\@ifnext[{#1}{#1[{#2}]}}
208 \eu@DeclareRobustCommand\eu@plus[1][]{}
209
210 %% The main user command (comes in two spellings)
211 %% \setmathsfont(<sets>)[<shapes, font features>]{<font name>}
212 %% \setmathfont(<sets>)[<shapes, font features>]{<font name>}
213 %%
214 %% <set> is a CSV list of any of: Special, Latin, Greek, Digits, Symbols. If
215 %% (<set>) is omitted, then (Special) is assumed. Special is provided to
216 %% hook to some external code (e.g. potentially unicode-math). That is,
217 %% for mathspec purposes, (<sets>) is mandatory. Omit it so that it
218 %% behaves like a different command. See below.
219 %% <shapes> is the keyval list of font shapes for the subset of <set>.
220 %% Valid keys are: Uppercase, Lowercase, Arabic.
221 %% Valid values are: Regular, Italic, Plain.
222 %% <font features>, <font name> follow directly from fontspec.
223 \providecommand\setmathsfont{\eu@setmathsfont}
224 \let\setmathfont\setmathsfont
225 \newcommand\eu@setmathsfont{
226 \@ifnextchar(
227 {\@eu@setmathsfont}
228 {\@eu@setmathsfont(Special)}}
229 \def\@eu@setmathsfont(#1){
230 \edef\eu@setmathsfont@Set{#1}
231 \@@eu@setmathsfont}
232 \newcommand\@@eu@setmathsfont[2][]{
233 \@for\i@for:=\eu@setmathsfont@Set\do
234 {\csname eu@ScopeSet@\i@for\endcsname[#1]{#2}}}
235
236 %% The FIRST branch \setmathsfont(Special)
237 %% Predefine this command before mathspec is loaded (or redefine it) to get
238 %%
239 %% \setmathsfont[<font features>]{<font name>}
240 %%
241 %% to do something else.
242 %%
243 %% Essentially, \setmathsfont(<sets>)[<font features>]{<font name>} is a mathspec
244 %% command, but \setmathsfont[<font features>]{<font name>} is an external
245 %% command.
246 \providecommand\eu@ScopeSet@Special[2][]{\relax}
247
248 %% The SECOND branch \setmathsfont(Digits)
249 \newcommand\eu@ScopeSet@Digits[2][]{
250 \eu@setkeys[Arabic=Regular]{Digits}{#1}
251 \eu@fontspec{\XKV@rm}{#2}
252 \ifcase\eu@DigitsArabic@@value %% If Digits Regular
253 \ernewcommand\eu@DigitsArabic@symfont{Digits:m:n}
254 \let\eu@Digitsmathsfont\zf@family
255 \eu@booltrue{Digits}
256 \or %% If Digits Italic
257 \ernewcommand\eu@DigitsArabic@symfont{Digits:m:it}
258 \let\eu@Digitsmathsfont\zf@family
259 \eu@booltrue{Digits}
260 \or %% If Digits Plain
261 \eu@boolfalse{Digits}
262 \fi
263 \eu@ifsomebooltrue{Digits}
264 {\DeclareSymbolFont{Digits:m:n}{\eu@enc}{\eu@Digitsmathsfont}{m}{n}}
265 \eu@ifbooltrue{Digits}
266 {\fontfamily\eu@Digitsmathsfont\selectfont
267 \DeclareMathSymbol{0}{\mathord}{\eu@DigitsArabic@symfont}{`0}
268 \DeclareMathSymbol{1}{\mathord}{\eu@DigitsArabic@symfont}{`1}
269 \DeclareMathSymbol{2}{\mathord}{\eu@DigitsArabic@symfont}{`2}
270 \DeclareMathSymbol{3}{\mathord}{\eu@DigitsArabic@symfont}{`3}
271 \DeclareMathSymbol{4}{\mathord}{\eu@DigitsArabic@symfont}{`4}
272 \DeclareMathSymbol{5}{\mathord}{\eu@DigitsArabic@symfont}{`5}
273 \DeclareMathSymbol{6}{\mathord}{\eu@DigitsArabic@symfont}{`6}
274 \DeclareMathSymbol{7}{\mathord}{\eu@DigitsArabic@symfont}{`7}
275 \DeclareMathSymbol{8}{\mathord}{\eu@DigitsArabic@symfont}{`8}
276 \DeclareMathSymbol{9}{\mathord}{\eu@DigitsArabic@symfont}{`9}}}
277
278 %% The THIRD branch \setmathsfont(Latin)
279 \newcommand\eu@ScopeSet@Latin[2][]{
280 \eu@setkeys[Uppercase=Italic,Lowercase=Italic]{Latin}{#1}
281 \eu@fontspec{\XKV@rm}{#2}
282 \ifcase\eu@LatinUppercase@@value %% If Latin Uppercase Regular
283 \ernewcommand\eu@LatinUppercase@symfont{Latin:m:n}
284 \let\eu@Latinmathsfont\zf@family
285 \eu@booltrue{LatinUppercase}
286 \or %% If Latin Uppercase Italic
287 \ernewcommand\eu@LatinUppercase@symfont{Latin:m:it}
288 \let\eu@Latinmathsfont\zf@family
289 \eu@booltrue{LatinUppercase}
290 \or %% If Latin Uppercase Plain
291 \eu@boolfalse{LatinUppercase}
292 \fi
293 \ifcase\eu@LatinLowercase@@value %% If Latin Lowercase Regular
294 \ernewcommand\eu@LatinLowercase@symfont{Latin:m:n}
295 \let\eu@Latinmathsfont\zf@family
296 \eu@booltrue{LatinLowercase}
297 \or %% If Latin Lowercase Italic
298 \ernewcommand\eu@LatinLowercase@symfont{Latin:m:it}
299 \let\eu@Latinmathsfont\zf@family
300 \eu@booltrue{LatinLowercase}
301 \or %% If Latin Lowercase Plain
302 \eu@boolfalse{LatinLowercase}
303 \fi
304 \eu@ifsomebooltrue{LatinUppercase,LatinLowercase}
305 {\DeclareSymbolFont{Latin:m:n}{\eu@enc}{\eu@Latinmathsfont}{m}{n}
306 \DeclareSymbolFont{Latin:m:it}{\eu@enc}{\eu@Latinmathsfont}{m}{it}}
307 \eu@ifbooltrue{LatinUppercase}
308 {\fontfamily\eu@Latinmathsfont\selectfont
309 \DeclareMathSymbol{A}{\mathalpha}{\eu@LatinUppercase@symfont}{`A}
310 \DeclareMathSymbol{B}{\mathalpha}{\eu@LatinUppercase@symfont}{`B}
311 \DeclareMathSymbol{C}{\mathalpha}{\eu@LatinUppercase@symfont}{`C}
312 \DeclareMathSymbol{D}{\mathalpha}{\eu@LatinUppercase@symfont}{`D}
313 \DeclareMathSymbol{E}{\mathalpha}{\eu@LatinUppercase@symfont}{`E}
314 \DeclareMathSymbol{F}{\mathalpha}{\eu@LatinUppercase@symfont}{`F}
315 \DeclareMathSymbol{G}{\mathalpha}{\eu@LatinUppercase@symfont}{`G}
316 \DeclareMathSymbol{H}{\mathalpha}{\eu@LatinUppercase@symfont}{`H}
317 \DeclareMathSymbol{I}{\mathalpha}{\eu@LatinUppercase@symfont}{`I}
318 \DeclareMathSymbol{J}{\mathalpha}{\eu@LatinUppercase@symfont}{`J}
319 \DeclareMathSymbol{K}{\mathalpha}{\eu@LatinUppercase@symfont}{`K}
320 \DeclareMathSymbol{L}{\mathalpha}{\eu@LatinUppercase@symfont}{`L}
321 \DeclareMathSymbol{M}{\mathalpha}{\eu@LatinUppercase@symfont}{`M}
322 \DeclareMathSymbol{N}{\mathalpha}{\eu@LatinUppercase@symfont}{`N}
323 \DeclareMathSymbol{O}{\mathalpha}{\eu@LatinUppercase@symfont}{`O}
324 \DeclareMathSymbol{P}{\mathalpha}{\eu@LatinUppercase@symfont}{`P}
325 \DeclareMathSymbol{Q}{\mathalpha}{\eu@LatinUppercase@symfont}{`Q}
326 \DeclareMathSymbol{R}{\mathalpha}{\eu@LatinUppercase@symfont}{`R}
327 \DeclareMathSymbol{S}{\mathalpha}{\eu@LatinUppercase@symfont}{`S}
328 \DeclareMathSymbol{T}{\mathalpha}{\eu@LatinUppercase@symfont}{`T}
329 \DeclareMathSymbol{U}{\mathalpha}{\eu@LatinUppercase@symfont}{`U}
330 \DeclareMathSymbol{V}{\mathalpha}{\eu@LatinUppercase@symfont}{`V}
331 \DeclareMathSymbol{W}{\mathalpha}{\eu@LatinUppercase@symfont}{`W}
332 \DeclareMathSymbol{X}{\mathalpha}{\eu@LatinUppercase@symfont}{`X}
333 \DeclareMathSymbol{Y}{\mathalpha}{\eu@LatinUppercase@symfont}{`Y}
334 \DeclareMathSymbol{Z}{\mathalpha}{\eu@LatinUppercase@symfont}{`Z}}
335 \eu@ifbooltrue{LatinLowercase}
336 {\fontfamily\eu@Latinmathsfont\selectfont
337 \DeclareMathSymbol{a}{\mathalpha}{\eu@LatinLowercase@symfont}{`a}
338 \DeclareMathSymbol{b}{\mathalpha}{\eu@LatinLowercase@symfont}{`b}
339 \DeclareMathSymbol{c}{\mathalpha}{\eu@LatinLowercase@symfont}{`c}
340 \DeclareMathSymbol{d}{\mathalpha}{\eu@LatinLowercase@symfont}{`d}
341 \DeclareMathSymbol{e}{\mathalpha}{\eu@LatinLowercase@symfont}{`e}
342 \DeclareMathSymbol{f}{\mathalpha}{\eu@LatinLowercase@symfont}{`f}
343 \DeclareMathSymbol{g}{\mathalpha}{\eu@LatinLowercase@symfont}{`g}
344 \DeclareMathSymbol{h}{\mathalpha}{\eu@LatinLowercase@symfont}{`h}
345 \DeclareMathSymbol{i}{\mathalpha}{\eu@LatinLowercase@symfont}{`i}
346 \DeclareMathSymbol{j}{\mathalpha}{\eu@LatinLowercase@symfont}{`j}
347 \DeclareMathSymbol{k}{\mathalpha}{\eu@LatinLowercase@symfont}{`k}
348 \DeclareMathSymbol{l}{\mathalpha}{\eu@LatinLowercase@symfont}{`l}
349 \DeclareMathSymbol{m}{\mathalpha}{\eu@LatinLowercase@symfont}{`m}
350 \DeclareMathSymbol{n}{\mathalpha}{\eu@LatinLowercase@symfont}{`n}
351 \DeclareMathSymbol{o}{\mathalpha}{\eu@LatinLowercase@symfont}{`o}
352 \DeclareMathSymbol{p}{\mathalpha}{\eu@LatinLowercase@symfont}{`p}
353 \DeclareMathSymbol{q}{\mathalpha}{\eu@LatinLowercase@symfont}{`q}
354 \DeclareMathSymbol{r}{\mathalpha}{\eu@LatinLowercase@symfont}{`r}
355 \DeclareMathSymbol{s}{\mathalpha}{\eu@LatinLowercase@symfont}{`s}
356 \DeclareMathSymbol{t}{\mathalpha}{\eu@LatinLowercase@symfont}{`t}
357 \DeclareMathSymbol{u}{\mathalpha}{\eu@LatinLowercase@symfont}{`u}
358 \DeclareMathSymbol{v}{\mathalpha}{\eu@LatinLowercase@symfont}{`v}
359 \DeclareMathSymbol{w}{\mathalpha}{\eu@LatinLowercase@symfont}{`w}
360 \DeclareMathSymbol{x}{\mathalpha}{\eu@LatinLowercase@symfont}{`x}
361 \DeclareMathSymbol{y}{\mathalpha}{\eu@LatinLowercase@symfont}{`y}
362 \DeclareMathSymbol{z}{\mathalpha}{\eu@LatinLowercase@symfont}{`z}}}
363
364 %% The FOURTH branch \setmathsfont(Greek)
365 \newcommand\eu@ScopeSet@Greek[2][]{
366 \eu@setkeys[Uppercase=Regular,Lowercase=Italic]{Greek}{#1}
367 \eu@fontspec{\XKV@rm}{#2}
368 \ifcase\eu@GreekUppercase@@value %% If Greek Uppercase Regular
369 \ernewcommand\eu@GreekUppercase@symfont{Greek:m:n}
370 \let\eu@Greekmathsfont\zf@family
371 \eu@booltrue{GreekUppercase}
372 \or %% If Greek Uppercase Italic
373 \ernewcommand\eu@GreekUppercase@symfont{Greek:m:it}
374 \let\eu@Greekmathsfont\zf@family
375 \eu@booltrue{GreekUppercase}
376 \or %% If Greek Uppercase Plain
377 \eu@boolfalse{GreekUppercase}
378 \fi
379 \ifcase\eu@GreekLowercase@@value %% If Greek Lowercase Regular
380 \ernewcommand\eu@GreekLowercase@symfont{Greek:m:n}
381 \let\eu@Greekmathsfont\zf@family
382 \eu@booltrue{GreekLowercase}
383 \or %% If Greek Lowercase Italic
384 \ernewcommand\eu@GreekLowercase@symfont{Greek:m:it}
385 \let\eu@Greekmathsfont\zf@family
386 \eu@booltrue{GreekLowercase}
387 \or %% If Greek Lowercase Plain
388 \eu@boolfalse{GreekLowercase}
389 \fi
390 \eu@ifsomebooltrue{GreekUppercase,GreekLowercase}
391 {\DeclareSymbolFont{Greek:m:n}{\eu@enc}{\eu@Greekmathsfont}{m}{n}
392 \DeclareSymbolFont{Greek:m:it}{\eu@enc}{\eu@Greekmathsfont}{m}{it}}
393 \eu@ifbooltrue{GreekUppercase}
394 {\fontfamily\eu@Greekmathsfont\selectfont
395 \XeTeXDeclareMathSymbol{Α}{\mathalpha}{\eu@GreekUppercase@symfont}{`Α}[\Alpha]
396 \XeTeXDeclareMathSymbol{Β}{\mathalpha}{\eu@GreekUppercase@symfont}{`Β}[\Beta]
397 \XeTeXDeclareMathSymbol{Γ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Γ}[\Gamma]
398 \XeTeXDeclareMathSymbol{Δ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Δ}[\Delta]
399 \XeTeXDeclareMathSymbol{Ε}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ε}[\Epsilon]
400 \XeTeXDeclareMathSymbol{Ζ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ζ}[\Zeta]
401 \XeTeXDeclareMathSymbol{Η}{\mathalpha}{\eu@GreekUppercase@symfont}{`Η}[\Eta]
402 \XeTeXDeclareMathSymbol{Θ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Θ}[\Theta]
403 \XeTeXDeclareMathSymbol{Ι}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ι}[\Iota]
404 \XeTeXDeclareMathSymbol{Κ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Κ}[\Kappa]
405 \XeTeXDeclareMathSymbol{Λ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Λ}[\Lambda]
406 \XeTeXDeclareMathSymbol{Μ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Μ}[\Mu]
407 \XeTeXDeclareMathSymbol{Ν}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ν}[\Nu]
408 \XeTeXDeclareMathSymbol{Ξ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ξ}[\Xi]
409 \XeTeXDeclareMathSymbol{Ο}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ο}[\Omicron]
410 \XeTeXDeclareMathSymbol{Π}{\mathalpha}{\eu@GreekUppercase@symfont}{`Π}[\Pi]
411 \XeTeXDeclareMathSymbol{Ρ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ρ}[\Rho]
412 \XeTeXDeclareMathSymbol{Σ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Σ}[\Sigma]
413 \XeTeXDeclareMathSymbol{Τ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Τ}[\Tau]
414 \XeTeXDeclareMathSymbol{Υ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Υ}[\Upsilon]
415 \XeTeXDeclareMathSymbol{Φ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Φ}[\Phi]
416 \XeTeXDeclareMathSymbol{Χ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Χ}[\Chi]
417 \XeTeXDeclareMathSymbol{Ψ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ψ}[\Psi]
418 \XeTeXDeclareMathSymbol{Ω}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ω}[\Omega]
419 \XeTeXDeclareMathSymbol{Ϝ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Ϝ}[\Digamma]
420 \XeTeXDeclareMathSymbol{ϴ}{\mathalpha}{\eu@GreekUppercase@symfont}{`ϴ}[\varTheta]
421 \eu@fixgreekcs{Α}{Alpha}
422 \eu@fixgreekcs{Β}{Beta}
423 \eu@fixgreekcs{Γ}{Gamma}
424 \eu@fixgreekcs{Δ}{Delta}
425 \eu@fixgreekcs{Ε}{Epsilon}
426 \eu@fixgreekcs{Ζ}{Zeta}
427 \eu@fixgreekcs{Η}{Eta}
428 \eu@fixgreekcs{Θ}{Theta}
429 \eu@fixgreekcs{Ι}{Iota}
430 \eu@fixgreekcs{Κ}{Kappa}
431 \eu@fixgreekcs{Λ}{Lambda}
432 \eu@fixgreekcs{Μ}{Mu}
433 \eu@fixgreekcs{Ν}{Nu}
434 \eu@fixgreekcs{Ξ}{Xi}
435 \eu@fixgreekcs{Ο}{Omicron}
436 \eu@fixgreekcs{Π}{Pi}
437 \eu@fixgreekcs{Ρ}{Rho}
438 \eu@fixgreekcs{Σ}{Sigma}
439 \eu@fixgreekcs{Τ}{Tau}
440 \eu@fixgreekcs{Υ}{Upsilon}
441 \eu@fixgreekcs{Φ}{Phi}
442 \eu@fixgreekcs{Χ}{Chi}
443 \eu@fixgreekcs{Ψ}{Psi}
444 \eu@fixgreekcs{Ω}{Omega}
445 \eu@fixgreekcs{Ϝ}{Digamma}
446 \eu@fixgreekcs{ϴ}{varTheta}}
447 \eu@ifbooltrue{GreekLowercase}
448 {\fontfamily\eu@Greekmathsfont\selectfont
449 \XeTeXDeclareMathSymbol{α}{\mathalpha}{\eu@GreekLowercase@symfont}{`α}[\alpha]
450 \XeTeXDeclareMathSymbol{β}{\mathalpha}{\eu@GreekLowercase@symfont}{`β}[\beta]
451 \XeTeXDeclareMathSymbol{γ}{\mathalpha}{\eu@GreekLowercase@symfont}{`γ}[\gamma]
452 \XeTeXDeclareMathSymbol{δ}{\mathalpha}{\eu@GreekLowercase@symfont}{`δ}[\delta]
453 \XeTeXDeclareMathSymbol{ε}{\mathalpha}{\eu@GreekLowercase@symfont}{`ε}[\epsilon]
454 \XeTeXDeclareMathSymbol{ζ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ζ}[\zeta]
455 \XeTeXDeclareMathSymbol{η}{\mathalpha}{\eu@GreekLowercase@symfont}{`η}[\eta]
456 \XeTeXDeclareMathSymbol{θ}{\mathalpha}{\eu@GreekLowercase@symfont}{`θ}[\theta]
457 \XeTeXDeclareMathSymbol{ι}{\mathalpha}{\eu@GreekLowercase@symfont}{`ι}[\iota]
458 \XeTeXDeclareMathSymbol{κ}{\mathalpha}{\eu@GreekLowercase@symfont}{`κ}[\kappa]
459 \XeTeXDeclareMathSymbol{λ}{\mathalpha}{\eu@GreekLowercase@symfont}{`λ}[\lambda]
460 \XeTeXDeclareMathSymbol{μ}{\mathalpha}{\eu@GreekLowercase@symfont}{`μ}[\mu]
461 \XeTeXDeclareMathSymbol{ν}{\mathalpha}{\eu@GreekLowercase@symfont}{`ν}[\nu]
462 \XeTeXDeclareMathSymbol{ξ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ξ}[\xi]
463 \XeTeXDeclareMathSymbol{ο}{\mathalpha}{\eu@GreekLowercase@symfont}{`ο}[\omicron]
464 \XeTeXDeclareMathSymbol{π}{\mathalpha}{\eu@GreekLowercase@symfont}{`π}[\pi]
465 \XeTeXDeclareMathSymbol{ρ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ρ}[\rho]
466 \XeTeXDeclareMathSymbol{ς}{\mathalpha}{\eu@GreekLowercase@symfont}{`ς}[\varsigma]
467 \XeTeXDeclareMathSymbol{σ}{\mathalpha}{\eu@GreekLowercase@symfont}{`σ}[\sigma]
468 \XeTeXDeclareMathSymbol{τ}{\mathalpha}{\eu@GreekLowercase@symfont}{`τ}[\tau]
469 \XeTeXDeclareMathSymbol{υ}{\mathalpha}{\eu@GreekLowercase@symfont}{`υ}[\upsilon]
470 \XeTeXDeclareMathSymbol{φ}{\mathalpha}{\eu@GreekLowercase@symfont}{`φ}[\phi]
471 \XeTeXDeclareMathSymbol{χ}{\mathalpha}{\eu@GreekLowercase@symfont}{`χ}[\chi]
472 \XeTeXDeclareMathSymbol{ψ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ψ}[\psi]
473 \XeTeXDeclareMathSymbol{ω}{\mathalpha}{\eu@GreekLowercase@symfont}{`ω}[\omega]
474 \XeTeXDeclareMathSymbol{ϝ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϝ}[\digamma]
475 \XeTeXDeclareMathSymbol{ϐ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϐ}[\varbeta]
476 \XeTeXDeclareMathSymbol{ϵ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϵ}[\varepsilon]
477 \XeTeXDeclareMathSymbol{ϑ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϑ}[\vartheta]
478 \XeTeXDeclareMathSymbol{ϰ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϰ}[\varkappa]
479 \XeTeXDeclareMathSymbol{ϖ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϖ}[\varpi]
480 \XeTeXDeclareMathSymbol{ϱ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϱ}[\varrho]
481 \XeTeXDeclareMathSymbol{ϕ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϕ}[\varphi]
482 \eu@fixgreekcs{α}{alpha}
483 \eu@fixgreekcs{β}{beta}
484 \eu@fixgreekcs{γ}{gamma}
485 \eu@fixgreekcs{δ}{delta}
486 \eu@fixgreekcs{ε}{epsilon}
487 \eu@fixgreekcs{ζ}{zeta}
488 \eu@fixgreekcs{η}{eta}
489 \eu@fixgreekcs{θ}{theta}
490 \eu@fixgreekcs{ι}{iota}
491 \eu@fixgreekcs{κ}{kappa}
492 \eu@fixgreekcs{λ}{lambda}
493 \eu@fixgreekcs{μ}{mu}
494 \eu@fixgreekcs{ν}{nu}
495 \eu@fixgreekcs{ξ}{xi}
496 \eu@fixgreekcs{ο}{omicron}
497 \eu@fixgreekcs{π}{pi}
498 \eu@fixgreekcs{ρ}{rho}
499 \eu@fixgreekcs{ς}{varsigma}
500 \eu@fixgreekcs{σ}{sigma}
501 \eu@fixgreekcs{τ}{tau}
502 \eu@fixgreekcs{υ}{upsilon}
503 \eu@fixgreekcs{φ}{phi}
504 \eu@fixgreekcs{χ}{chi}
505 \eu@fixgreekcs{ψ}{psi}
506 \eu@fixgreekcs{ω}{omega}
507 \eu@fixgreekcs{ϝ}{digamma}
508 \eu@fixgreekcs{ϐ}{varbeta}
509 \eu@fixgreekcs{ϵ}{varepsilon}
510 \eu@fixgreekcs{ϑ}{vartheta}
511 \eu@fixgreekcs{ϰ}{varkappa}
512 \eu@fixgreekcs{ϖ}{varpi}
513 \eu@fixgreekcs{ϱ}{varrho}
514 \eu@fixgreekcs{ϕ}{varphi}}}
515 \newcommand\eu@fixgreekcs[2]{
516 \ifcsequal{#2}{eu@cm@#2}
517 {\relax}
518 {\expandafter\def\csname #2\endcsname{{"#1}}}}
519
520 %% The FIFTH branch \setmathsfont(Symbols)
521 %% The symbols are not for now.
522 %% \newcommand\eu@ScopeSet@Symbols[2][]{
523 %% \eu@fontspec{#1}{#2}
524 %% \def\eu@Symbols@symfont{Symbols:m:n}
525 %% \let\eu@Symbolsmathsfont\zf@family
526 %% \eu@booltrue{Symbols}}
527 %%
528 %% The FIFTH branch (REDEFINED) \setmathsfont(Symbols)
529 \newcommand\eu@ScopeSet@Symbols[2][]{\eu@boolfalse{Symbols}}
530
531 %% Just so we know, by "all variant forms" I mean:
532 %% varbeta varpi cursive beta "omega" style pi
533 %% varepsilon varrho lunate epsilon rho with tail hooked under
534 %% vartheta varphi cursive theta cursive phi (or orthotic phi)
535 %% varkappa varTheta cursive kappa Theta with horizontal bar connected
536 %%
537 %% Note that varsigma is not included in this list (varsigma is not a variant
538 %% form, it is a final form).
539
540 %% Some authors might prefer the normal and variant forms to be exchanged. For
541 %% example, I prefer \phi to print the orthotic phi and \varphi the cursive phi,
542 %% contrary to many text fonts.
543 %%
544 %% \exchangeforms{<list>}
545 %% <list> is a CSV list of any of:
546 %% beta, epsilon, theta, kappa, pi, rho, phi, Theta
547 \newcommand\exchangeforms[1]{
548 \AtBeginDocument{
549 \@for\i@for:=#1\do{\eu@booltrue{exchange\i@for forms}}
550 \eu@ifbooltrue{GreekLowercase}
551 {\eu@ifbooltrue{exchangebetaforms}
552 {\XeTeXDeclareMathSymbol{β}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϐ}[\beta]
553 \XeTeXDeclareMathSymbol{ϐ}{\mathalpha}{\eu@GreekLowercase@symfont}{`β}[\varbeta]}
554 \eu@ifbooltrue{exchangeepsilonforms}
555 {\XeTeXDeclareMathSymbol{ε}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϵ}[\epsilon]
556 \XeTeXDeclareMathSymbol{ϵ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ε}[\varepsilon]}
557 \eu@ifbooltrue{exchangethetaforms}
558 {\XeTeXDeclareMathSymbol{θ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϑ}[\theta]
559 \XeTeXDeclareMathSymbol{ϑ}{\mathalpha}{\eu@GreekLowercase@symfont}{`θ}[\vartheta]}
560 \eu@ifbooltrue{exchangekappaforms}
561 {\XeTeXDeclareMathSymbol{κ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϰ}[\kappa]
562 \XeTeXDeclareMathSymbol{ϰ}{\mathalpha}{\eu@GreekLowercase@symfont}{`κ}[\varkappa]}
563 \eu@ifbooltrue{exchangepiforms}
564 {\XeTeXDeclareMathSymbol{π}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϖ}[\pi]
565 \XeTeXDeclareMathSymbol{ϖ}{\mathalpha}{\eu@GreekLowercase@symfont}{`π}[\varpi]}
566 \eu@ifbooltrue{exchangerhoforms}
567 {\XeTeXDeclareMathSymbol{ρ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϱ}[\rho]
568 \XeTeXDeclareMathSymbol{ϱ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ρ}[\varrho]}
569 \eu@ifbooltrue{exchangephiforms}
570 {\XeTeXDeclareMathSymbol{φ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ϕ}[\phi]
571 \XeTeXDeclareMathSymbol{ϕ}{\mathalpha}{\eu@GreekLowercase@symfont}{`φ}[\varphi]}}
572 \eu@ifbooltrue{GreekUppercase}
573 {\eu@ifbooltrue{exhangeThetaforms}
574 {\XeTeXDeclareMathSymbol{Θ}{\mathalpha}{\eu@GreekUppercase@symfont}{`ϴ}[\Theta]
575 \XeTeXDeclareMathSymbol{ϴ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Θ}[\varTheta]}}}}
576 \@onlypreamble\exchangeforms
577
578 %% Some text fonts do not contain all variant forms. For those that don't,
579 %% after defining the Greek mathematics font, the ‘absent’ variant forms will
580 %% still be typeset in Computer Modern (usually).
581 %%
582 %% \normalisevarforms[<list>]
583 %% \normalizevarforms[<list>]
584 %% <list> is a CSV list of any of:
585 %% beta, epsilon, theta, kappa, pi, rho, phi, Theta
586 %%
587 %% This command makes the listed variant forms of Greek symbols equivalent to
588 %% their normal forms, but only if they do not already exist in the font. For
589 %% example, if \varbeta and \eu@cm@varbeta are equivalent, then
590 %% \XeTeXDeclareMathSymbol failed to assign \varbeta to ϐ because ϐ does not
591 %% exist in the font.
592 \newcommand\normalisevarforms[1][beta,epsilon,theta,kappa,pi,rho,phi,Theta]{
593 \AtBeginDocument{
594 \@for\i@for:=#1\do{\eu@booltrue{normalisevar\i@for}}
595 \eu@ifbooltrue{GreekLowercase}
596 {\eu@ifbooltrue{normalisevarbeta}
597 {\ifx\varbeta\eu@cm@varbeta
598 \XeTeXDeclareMathSymbol{ϐ}{\mathalpha}{\eu@GreekLowercase@symfont}{`β}
599 \let\varbeta\beta
600 \fi}
601 \eu@ifbooltrue{normalisevarepsilon}
602 {\ifx\varepsilon\eu@cm@varepsilon
603 \XeTeXDeclareMathSymbol{ϵ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ε}
604 \let\varepsilon\epsilon
605 \fi}
606 \eu@ifbooltrue{normalisevartheta}
607 {\ifx\vartheta\eu@cm@vartheta
608 \XeTeXDeclareMathSymbol{ϑ}{\mathalpha}{\eu@GreekLowercase@symfont}{`θ}
609 \let\vartheta\theta
610 \fi}
611 \eu@ifbooltrue{normalisevarkappa}
612 {\ifx\varkappa\eu@cm@varkappa
613 \XeTeXDeclareMathSymbol{ϰ}{\mathalpha}{\eu@GreekLowercase@symfont}{`κ}
614 \let\varkappa\kappa
615 \fi}
616 \eu@ifbooltrue{normalisevarpi}
617 {\ifx\varpi\eu@cm@varpi
618 \XeTeXDeclareMathSymbol{ϖ}{\mathalpha}{\eu@GreekLowercase@symfont}{`π}
619 \let\varpi\pi
620 \fi}
621 \eu@ifbooltrue{normalisevarrho}
622 {\ifx\varrho\eu@cm@varrho
623 \XeTeXDeclareMathSymbol{ϱ}{\mathalpha}{\eu@GreekLowercase@symfont}{`ρ}
624 \let\varrho\rho
625 \fi}
626 \eu@ifbooltrue{normalisevarphi}
627 {\ifx\varphi\eu@cm@varphi
628 \XeTeXDeclareMathSymbol{ϕ}{\mathalpha}{\eu@GreekLowercase@symfont}{`φ}
629 \let\varphi\phi
630 \fi}}
631 \eu@ifbooltrue{GreekUppercase}{
632 \eu@ifbooltrue{normalisevarTheta}
633 {\ifx\varTheta\eu@cm@varTheta
634 \XeTeXDeclareMathSymbol{ϴ}{\mathalpha}{\eu@GreekUppercase@symfont}{`Θ}
635 \let\varTheta\Theta
636 \fi}}}}
637 \@onlypreamble\normalisevarforms
638 \let\normalizevarforms\normalisevarforms
639 \@onlypreamble\normalizevarforms
640
641 %% xkeyval things
642 \define@choicekey[eu]
643 {Digits}{Arabic}[\eu@DigitsArabic@value\eu@DigitsArabic@@value]
644 {Regular,Italic,Plain}[Regular]{\relax}
645 \define@choicekey[eu]
646 {Latin}{Uppercase}[\eu@LatinUppercase@value\eu@LatinUppercase@@value]
647 {Regular,Italic,Plain}[Italic]{\relax}
648 \define@choicekey[eu]
649 {Latin}{Lowercase}[\eu@LatinLowercase@value\eu@LatinLowercase@@value]
650 {Regular,Italic,Plain}[Italic]{\relax}
651 \define@choicekey[eu]
652 {Greek}{Uppercase}[\eu@GreekUppercase@value\eu@GreekUppercase@@value]
653 {Regular,Italic,Plain}[Regular]{\relax}
654 \define@choicekey[eu]
655 {Greek}{Lowercase}[\eu@GreekLowercase@value\eu@GreekLowercase@@value]
656 {Regular,Italic,Plain}[Italic]{\relax}
657
658 %% Also say Digits has Uppercase and Lowercase keys, and Latin and Greek both
659 %% have Arabic key. So that if a superfluous key is accidently sent through the
660 %% wrong command (possible with \setallmainfonts), then it doesn't blow up.
661 \define@key[eu]{Digits}{Uppercase}{\relax}
662 \define@key[eu]{Digits}{Lowercase}{\relax}
663 \define@key[eu]{Latin}{Arabic}{\relax}
664 \define@key[eu]{Greek}{Arabic}{\relax}
665
666 %% I hope Will doesn't mind if I patch fontspec. Why? Because these keys are
667 %% accidently sent through fontspec (e.g. \setallmainfonts does \setmainfont,
668 %% which is a fontspec command). So I allow fontspec to understand them, but do
669 %% nothing.
670 \define@key[zf]{options}{Arabic}{\relax}
671 \define@key[zf]{options}{Uppercase}{\relax}
672 \define@key[zf]{options}{Lowercase}{\relax}
673
674 %% Fonts have metrics suitable for text, not for mathematics. Need to kern each
675 %% letter individually. Previous version took a trial and error approach with
676 %% \+[<size>] where <size> was determined by trial and error. Now, there is a
677 %% XeTeX primitive \XeTeXglyphbounds which is used to automatically calculate
678 %% the required mkern.
679 %%
680 %% Some register definitions. \three@digits takes a number and, if it is less
681 %% than 100, inserts leading zeroes so that it has three digits.
682 \muskipdef\muskip@\z@
683 \muskipdef\muskip@i\@ne
684 \dimendef\dimen@iv 4\relax
685 \newcounter{eu@}
686 \newcounter{eu@i}
687 \providecommand\three@digits[1]{\ifnum#1<100 0\ifnum#1<10 0\fi\fi\number#1}
688
689 %% \setminwhitespace{<number>}
690 %% Sets the minimum gap between adjacent characters in mathematics.
691 %% <number> is in units of mmu (1/1000 mu). So 1 em = 18000 mmu.
692 %% \eu@minwhitespace is the minimum white space. It's default value is 500
693 %% which corresponds to 0.5 mu or 1/36 em.
694 \newcommand\setminwhitespace[1][500]{\def\eu@minwhitespace{#1}}
695 \setminwhitespace
696
697 %% \eu@mkern operates over some adjacent character tokens
698 %% \@eu@mkern operates over individual character tokens
699 %%
700 %% Unless I've missed something, it is really, really hard to get information
701 %% about the font that a mathematics symbol is typeset in, so I devised a series
702 %% of tests in text mode (\text!) (otherwise the received information will be
703 %% rubbish, related to the text font outside the mathematics). It would be
704 %% neater if I do it inside a box that's not printed, instead of an empty
705 %% \text. The \@eu@mkern algorithm to calculate the mkern might be neater if I
706 %% use e-TeX's \numexpr and \glueexpr. Maybe \gluetomu might be useful? What I
707 %% have here already ought to be sufficient but perhaps inefficient. I think
708 %% optical sizes follow through automatically because \text inherits the
709 %% surrounding size, is that right?
710 \newcommand\eu@mkern[1]{%
711 \@tfor\i@tfor:=#1\do{\expandafter\@eu@mkern\i@tfor}}
712 \def\eu@get@familyseriesshape#1:#2:#3\@nil{%
713 \expandafter\fontfamily\csname eu@#1mathsfont\endcsname\selectfont
714 \ifstrequal{#2}{m}{\mdseries}{\relax}%
715 \ifstrequal{#2}{bx}{\bfseries}{\relax}%
716 \ifstrequal{#3}{n}{\upshape}{\relax}%
717 \ifstrequal{#3}{it}{\itshape}{\relax}}
718 \def\eu@get@familyseriesshape#1:#2:#3\@nil{%
719 \def\eu@family{#1}%
720 \def\eu@series{#2}%
721 \def\eu@shape{#3}}
722 \newcounter{mkern}
723 \newcommand\@eu@mkern[1]{%
724 \setcounter{mkern}{-1}%
725 \eu@boolfalse{domkern}%
726 \eu@ifnumin{`#1}{`0,`9}{\setcounter{mkern}{0}}{\relax}%
727 \eu@ifnumin{`#1}{`A,`Z}{\setcounter{mkern}{1}}{\relax}%
728 \eu@ifnumin{`#1}{`a,`z}{\setcounter{mkern}{2}}{\relax}%
729 \eu@ifnumin{`#1}{`Α,`Ω}{\setcounter{mkern}{3}}{\relax}%
730 \eu@ifnumin{`#1}{`α,`ω}{\setcounter{mkern}{4}}{\relax}%
731 \eu@ifnumis{`#1}{`Ϝ,`ϴ}{\setcounter{mkern}{3}}{\relax}%
732 \eu@ifnumis{`#1}{`ϐ,`ϑ,`ϕ,`ϖ,`ϝ,`ϰ,`ϱ,`ϵ}{\setcounter{mkern}{4}}{\relax}%
733 \text{%
734 \ifnum\the\c@mkern>\m@ne
735 \eu@gbooltrue{domkern}%
736 \fi
737 \ifcase\the\c@mkern\relax % If Digits (0)
738 \ifdef{\eu@DigitsArabic@symfont}%
739 {\expandafter\eu@get@familyseriesshape\eu@DigitsArabic@symfont\@nil}%
740 {\global\boolfalse{domkern}}%
741 \or % If Latin Uppercase (1)
742 \ifdef{\eu@LatinUppercase@symfont}%
743 {\expandafter\eu@get@familyseriesshape\eu@LatinUppercase@symfont\@nil}%
744 {\global\boolfalse{domkern}}%
745 \or % If Latin Lowercase (2)
746 \ifdef{\eu@LatinLowercase@symfont}%
747 {\expandafter\eu@get@familyseriesshape\eu@LatinLowercase@symfont\@nil}%
748 {\global\boolfalse{domkern}}%
749 \or % If Greek Uppercase (3)
750 \ifdef{\eu@GreekUppercase@symfont}%
751 {\expandafter\eu@get@familyseriesshape\eu@GreekUppercase@symfont\@nil}%
752 {\global\boolfalse{domkern}}%
753 \or % If Greek Lowercase (4)
754 \ifdef{\eu@GreekLowercase@symfont}%
755 {\expandafter\eu@get@familyseriesshape\eu@GreekLowercase@symfont\@nil}%
756 {\global\boolfalse{domkern}}%
757 \fi
758 \ifdef{\eu@family}%
759 {\expandafter\fontfamily\csname eu@\eu@family mathsfont\endcsname\selectfont}%
760 {\relax}%
761 \ifdef{\eu@series}%
762 {\expandafter\ifstrequal\expandafter{\eu@series}{m}%
763 {\mdseries}%
764 {\relax}%
765 \expandafter\ifstrequal\expandafter{\eu@series}{bx}%
766 {\bfseries}%
767 {\relax}}%
768 {\relax}%
769 \ifdef{\eu@shape}%
770 {\expandafter\ifstrequal\expandafter{\eu@shape}{n}%
771 {\upshape}%
772 {\relax}%
773 \expandafter\ifstrequal\expandafter{\eu@shape}{it}%
774 {\itshape}%
775 {\relax}}%
776 {\relax}%
777 \global\dimen@\XeTeXglyphbounds\@ne\the\XeTeXcharglyph`#1\relax
778 \global\dimen@iv\XeTeXglyphbounds\thr@@\the\XeTeXcharglyph`#1}
779 \dimen@ii 1em
780 \c@eu@\dimen@
781 \c@eu@i\dimen@ii
782 \multiply\c@eu@ 3000\relax
783 \divide\c@eu@i 6\relax
784 \divide\c@eu@\c@eu@i
785 \c@eu@i\c@eu@
786 \ifnum\number\c@eu@ <\eu@minwhitespace
787 \c@eu@\eu@minwhitespace
788 \fi
789 \advance\c@eu@ -\c@eu@i
790 \c@eu@i\c@eu@
791 \divide\c@eu@i\@m
792 \edef\eu@mkern@left{\number\c@eu@i}
793 \multiply\c@eu@i\@m
794 \advance\c@eu@ -\c@eu@i
795 \edef\eu@mkern@left{\eu@mkern@left.\three@digits{\number\c@eu@}mu}
796 \dimen@\dimen@iv
797 \dimen@ii 1em
798 \c@eu@\dimen@
799 \c@eu@i\dimen@ii
800 \multiply\c@eu@ 3000\relax
801 \divide\c@eu@i 6\relax
802 \divide\c@eu@\c@eu@i
803 \c@eu@i\c@eu@
804 \ifnum\number\c@eu@ <\eu@minwhitespace
805 \c@eu@\eu@minwhitespace
806 \fi
807 \advance\c@eu@ -\c@eu@i
808 \c@eu@i\c@eu@
809 \divide\c@eu@i\@m
810 \edef\eu@mkern@right{\number\c@eu@i}
811 \multiply\c@eu@i\@m
812 \advance\c@eu@ -\c@eu@i
813 \edef\eu@mkern@right{\eu@mkern@right.\three@digits{\number\c@eu@}mu}
814 \eu@ifbool{domkern}
815 {\mkern\eu@mkern@left#1\mkern\eu@mkern@right}
816 {#1}}
817
818 %% Redefine \" and " in maths mode only. Umlaut and quote definitions remain
819 %% in effect in text mode.
820 %%
821 %% " put the " before a character, e.g $"f$, and the character is
822 %% printed with kerns on either side.
823 %% \"..." Surround a series of adjacent characters, e.g. $\"abcde"$ is
824 %% equivalent to $"a"b"c"d"e$.
825 %% Note that the tokens that " and \" operate on MUST be characters because
826 %% they are sent through the XeTeX primitive \XeTeXcharglyph as in:
827 %%
828 %% \XeTeXglyphbounds n \the\XeTeXcharglyph`#1
829 %%
830 %% where n = 1,2,3,4 and #1 is the character (If #1 is not a character, then
831 %% \XeTeXcharglyph`#1 doesn't make sense). Higher level tests are needed to
832 %% avoid this problem.
833 \let\eu@original@quote="
834 \let\eu@original@csquote=\"
835 \mathcode`\"="8000
836 \newcommand\eu@active@quote{%
837 \ifmmode
838 \expandafter\eu@new@quote
839 \else
840 \expandafter\eu@original@quote
841 \fi}
842 \newcommand\eu@active@csquote{%
843 \ifmmode
844 \expandafter\eu@new@csquote
845 \else
846 \expandafter\eu@original@csquote
847 \fi}
848 \begingroup
849 \catcode`\"=\active
850 \global\let"=\eu@active@quote
851 \endgroup
852 \let\"=\eu@active@csquote
853 \newcommand\eu@new@quote[1]{\eu@mkern{#1}}
854 \def\eu@new@csquote#1"{\eu@mkern{#1}}
855
856 %% Redefine LaTeX 2e kernel macros to do Unicode characters too. Add optional
857 %% fifth argument. This is a list of control sequences which will be let equal
858 %% to the symbol if the symbol exists in the font. If the symbol does not exist
859 %% in the font, then the fifth argument is ignored.
860 %%
861 %% e.g. \XeTeXDeclareMathSymbol{≠}{\mathrel}{font}{"2260}[\neq\ne]
862 \def\XeTeXDeclareMathSymbol#1#2#3#4{%
863 \expandafter\in@\csname sym#3\expandafter\endcsname
864 \expandafter{\group@list}%
865 \ifin@
866 \begingroup
867 \if\relax\noexpand#1% is command?
868 \edef\reserved@a{\noexpand\in@{\string\mathchar}{\meaning#1}}%
869 \reserved@a
870 \ifin@
871 \expandafter\XeTeXset@mathsymbol
872 \csname sym#3\endcsname#1#2{#4}%
873 \@font@info{Redeclaring math symbol \string#1}%
874 \else
875 \expandafter\ifx
876 \csname\expandafter\@gobble\string#1\endcsname
877 \relax
878 \expandafter\XeTeXset@mathsymbol
879 \csname sym#3\endcsname#1#2{#4}%
880 \else
881 \@latex@error{Command `\string#1' already defined}\@eha
882 \fi
883 \fi
884 \else
885 \expandafter\XeTeXset@mathchar
886 \csname sym#3\endcsname#1#2{#4}%
887 \fi
888 \endgroup
889 \def\XeTeXDeclareMathSymbol@symbol{#1}%
890 \def\XeTeXDeclareMathSymbol@slot{#4}%
891 \expandafter\XeTeXDeclareMathSymbol@option
892 \else
893 \@latex@error{Symbol font `#3' is not defined}\@eha
894 \expandafter\@gobbleoarg
895 \fi}
896 \@onlypreamble\XeTeXDeclareMathSymbol
897 \def\XeTeXset@mathchar#1#2#3#4{%
898 \global\XeTeXmathcode`#2="\mathchar@type#3#1#4\relax}
899 \@onlypreamble\XeTeXset@mathchar
900 \def\XeTeXset@mathsymbol#1#2#3#4{%
901 \global\XeTeXmathchardef#2"\mathchar@type#3#1#4\relax}
902 \@onlypreamble\XeTeXset@mathsymbol
903 \newcommand\@gobbleoarg[1][]{}
904 \newcommand\XeTeXDeclareMathSymbol@option[1][]{%
905 \ifnum\the\XeTeXcharglyph\XeTeXDeclareMathSymbol@slot>\z@
906 \@tfor\i@tfor #1:=\do%
907 {\expandafter\edef\i@tfor{\expandonce\XeTeXDeclareMathSymbol@symbol}}%
908 \fi}
909
910 %% Some shorthands, so the same information isn't typed out more than once
911 %%
912 %% \setallmainfonts(<sets>)[<shapes, font features>]{<font name>}
913 %% \setprimaryfont[<shapes, font features>]{<font name>}
914 %% \setallsansfonts[<shapes, font features>]{<font name>}
915 %% \setallmonofonts[<shapes, font features>]{<font name>}
916 \newcommand\setallmainfonts{
917 \@ifnextchar(
918 {\eu@setallmainfonts}
919 {\eu@setallmainfonts(Digits,Latin,Greek)}}
920 \def\eu@setallmainfonts(#1){
921 \edef\eu@setmathsfont@Set{#1}
922 \@eu@setallmainfonts}
923 \newcommand\@eu@setallmainfonts[2][]{
924 \setmainfont[#1]{#2}
925 \setmathsfont(\eu@setmathsfont@Set)[#1]{#2}
926 \setmathrm[#1]{#2}}
927 \newcommand\setprimaryfont{\setallmainfonts(Digits,Latin)}
928 \newcommand\setallsansfonts[2][]{
929 \setsansfont[#1]{#2}
930 \setmathsf[#1]{#2}}
931 \newcommand\setallmonofonts[2][]{
932 \setmonofont[#1]{#2}
933 \setmathtt[#1]{#2}}
934
935 %% Set the particular mathematics alphabets
936 \ernewcommand\setmathrm[2][]{
937 \zf@fontspec{#1}{#2}
938 \let\eu@mathrm\zf@family
939 \DeclareMathAlphabet{\mathrm}{\eu@enc}{\eu@mathrm}{m}{n}
940 \SetMathAlphabet{\mathrm}{bold}{\eu@enc}{\eu@mathrm}{bx}{n}
941 \DeclareMathAlphabet{\mathit}{\eu@enc}{\eu@mathrm}{m}{it}
942 \DeclareMathAlphabet{\mathbf}{\eu@enc}{\eu@mathrm}{bx}{n}
943 \SetMathAlphabet{\mathit}{bold}{\eu@enc}{\eu@mathrm}{bx}{it}
944 \DeclareSymbolFont{Operators:m:n}{\eu@enc}{\eu@mathrm}{m}{n}
945 \def\operator@font{\expandafter\mathgroup\csname symOperators:m:n\endcsname}}
946 \ernewcommand\setmathcal[2][]{
947 \zf@fontspec{#1}{#2}
948 \let\eu@mathcal\zf@family
949 \DeclareMathAlphabet{\mathcal}{\eu@enc}{\eu@mathcal}{m}{n}}
950 \ernewcommand\setmathsf[2][]{
951 \zf@fontspec{#1}{#2}
952 \let\eu@mathsf\zf@family
953 \DeclareMathAlphabet{\mathsf}{\eu@enc}{\eu@mathsf}{m}{n}
954 \SetMathAlphabet{\mathsf}{bold}{\eu@enc}{\eu@mathsf}{bx}{n}}
955 \ernewcommand\setmathtt[2][]{
956 \zf@fontspec{#1}{#2}
957 \let\eu@mathtt\zf@family
958 \DeclareMathAlphabet{\mathtt}{\eu@enc}{\eu@mathtt}{m}{n}}
959 \ernewcommand\setmathfrak[2][]{
960 \zf@fontspec{#1}{#2}
961 \let\eu@mathfrak\zf@family
962 \DeclareMathAlphabet{\mathfrak}{\eu@enc}{\eu@mathfrak}{m}{n}}
963 \ernewcommand\setmathbb[2][]{
964 \zf@fontspec{#1}{#2}
965 \let\eu@mathbb\zf@family
966 \DeclareMathAlphabet{\mathbb}{\eu@enc}{\eu@mathbb}{m}{n}}
967
968 %% If amsmath is loaded, it must be loaded before mathspec. Checking for its
969 %% existence \AtBeginDocument is too late because the damage is already done
970 %% (It attempted to define \varTheta when mathspec already defined it). Or
971 %% should I delay the definition of \varTheta until \AtBeginDocument?
972 \let\original@RequirePackage\RequirePackage
973 \renewcommand\RequirePackage[2][]{
974 \ifstrequal{#2}{amsmath}
975 {\PackageError{mathspec}
976 {`amsmath' must be loaded earlier than `mathspec'}
977 {Edit the document so that `amsmath' is required earlier than `mathspec'.}}
978 {\relax}
979 \original@RequirePackage[#1]{#2}}
980 \@onlypreamble\RequirePackage
981 \let\usepackage\RequirePackage
982 \@onlypreamble\usepackage
983
984 %% Any font changes that mathspec has done are reset by LaTeX 2ε at
985 %% \begin{document} using \process@table.
986
987 \endinput
988
989 %% © Andrew Gilbert Moschou 2009
990 %%
991 %% This work may be distributed and/or modified under the
992 %% conditions of the LaTeX Project Public License, either version 1.3c
993 %% of this license or (at your option) any later version.
994 %% The latest version of this license is in:
995 %% http://www.latex-project.org/lppl.txt
996 %% and version 1.3c or later is part of all recent distributions of LaTeX.
997 %%
998 %% This work has the LPPL maintenance status ‘maintained’.
999 %% The Current Maintainer of this work is Andrew Gilbert Moschou.
1000 %% This work consists of the files mathspec.sty and mathspec.tex.
1001