The Package: Mathspec
The Package: Mathspec
table of contents
1 preamble 1 4.5 Shorthands . . . . . . . . . 6
4.6 A further example . . . . . 7
2 introduction 2
5 greek symbols 7
3 implementation 2
6 glyph bounds 9
4 setting fonts 3
7 compatability 11
4.1 Letters and Digits . . . . . 3
4.2 Symbols . . . . . . . . . . . 4 8 the package 12
4.3 Examples . . . . . . . . . . 4
4.4 Declaring alphabets . . . . 5 9 license 33
1 preamble
This document describes the mathspec package, a package that provides an interface
to select ordinary text fonts for typesetting mathematics with XƎLaTEX. It relies on
fontspec to work and familiarity with fontspec is advised. I thank Will Robertson for
his useful advice and suggestions!
The package is developmental and later versions might to be incompatible with this
version. This version is incompatible with earlier versions. The package requires at least
version 0.9995 of XƎTEX.
*
v0.2b update by Will Robertson ([email protected]).
1
Should you be using this package? If you are using another LaTEX package for some
mathematics font, then you should not (unless you know what you are doing). If you
want to use Asana Math or Cambria Math (or the final release version of the stix fonts)
then you should be using unicode-math.
Some paragraphs in this document are marked advanced. Such paragraphs may be
safely ignored by basic users.
2 introduction
Since Jonathan Kew released XƎTEX, an extension to TEX that permits the inclusion of
system wide Unicode fonts and modern font technologies in TEX documents, users have
been able to easily typeset documents using readily available fonts such as Hoefler Text
and Times New Roman (This document is typeset using Sabon lt Std). Will Robertson’s
XƎLaTEX package fontspec provides an automatic font selection process for such fonts.
Still, mathematics typesetting has not benefited from this development to the same ex-
tent as text typesetting, which is not surprising given the font requirements that are
demanded.
Will Robertson has in development a package unicode-math that is used to typeset
mathematics using some font that has an OpenType mathematics table. Currently, the
only two that are available are Cambria Math, a new design, by Microsoft and Asana
Math, ultimately based on Hermann Zapf’s Palatino, by Apostolos Syropoulos. It is
expected that the stix fonts, based on Times, may also be used.
Thus, it is evident that a book designer is confronted with such narrow variety in
mathematics typefaces, even considering already established LaTEX fonts such as ams
Euler (and Computer Modern, of course!) that are dedicated to providing mathema-
tics typefaces; and the book designer is challenged to find a suitable pair of matching
typefaces for mathematics and body text.
This package provides mathematics alphabets in any of the same typefaces that are
available to XƎTEX, using fontspec as a back end. Other mathematics symbols such as
arrows and operators, whose designs are largely independent of an alphabetic typeface,
can be taken from collections like MnSymbol or Computer Modern and are not covered
by the scope of this package.
3 implementation
\usepackage[⟨mathspec and fontspec options⟩]{mathspec}
2
is loaded anyway. To load fontspec with some options, parse them through mathspec,
for example, \usepackage[quiet]{mathspec} is equivalent to:
\usepackage[quiet]{fontspec}
\usepackage{mathspec}
Actually, mathspec ordinarily loads fontspec with the no-math option. To cancel this,
explicitly use the math option: e.g. \usepackage[math]{mathspec}.
4 setting fonts
4.1 Letters and Digits
\setmathsfont(⟨sets⟩)[⟨shapes, font features⟩]{⟨font name⟩}
\setmathfont(⟨sets⟩)[⟨shapes, font features⟩]{⟨font name⟩}
This single command is used to entirely describe the desired font for some use. For each
character set (Digits, Latin, Greek), there is a (possibly shared) \setmathsfont com-
mand. The command can be used only in the preamble. Then, there can be only one
typeface for each character set in a single document.
For basic use, (⟨sets⟩) is mandatory. [⟨shapes, font features⟩] is optional and may be omit-
ted.
⟨sets⟩ A comma separated value list of any of the following: Digits, Latin, Greek.
advanced ⟨sets⟩ may also take the value Special. (⟨sets⟩) is actually optional and if it is omitted, then (Special)
is asumed. For basic use, it is safe to ignore Special, so (⟨sets⟩) would effectively be a mandatory argument.
If the value of ⟨sets⟩ is Special, then \eu@ScopeSet@Special[⟨font features⟩]{⟨font name⟩} is ex-
ecuted, but this command is provided by mathspec to gobble its arguments (that is, it does noth-
ing). The command \eu@ScopeSet@Special maybe predefined before mathspec is loaded (or re-
defined after mathspec is loaded) to cause the command to do something else. This effectively
means that \setmathsfont(⟨sets⟩)[⟨font features⟩]{⟨font name⟩} is a mathspec command, but
\setmathsfont[⟨font features⟩]{⟨font name⟩} is an external command which another package might
use.
⟨shapes⟩ A comma separated value list of keys and their values. The permitted keys and their
values are:
Uppercase=Regular, Italic, Plain
Lowercase=Regular, Italic, Plain
Arabic=Regular, Italic, Plain
To set the symbols in an upright font, choose Regular. To set the symbols in an italic font,
choose Italic. Choose Plain to indicate that no font is assignment is to be performed
3
table 1 The default shapes for the
symbol sets.
Set Key Default value
Digits Arabic Regular
Latin Uppercase Italic
Latin Lowercase Italic
Greek Uppercase Regular
Greek Lowercase Italic
by mathspec, so that the symbols will remain with their default font (usually Computer
Modern). If a value’s key is omitted, its default value, which depends on the ⟨set⟩, as
shown in table 1 is chosen.
The default values are very good and you would be wise not to change the shapes for
the Latin and Digit sets. The Greek shapes may be changed, if needed, to adhere to
some particular style, for example all Italic or all Regular.
⟨font features⟩ ⟨font features⟩ and ⟨font name⟩ follow directly from fontspec to select the font and its
⟨font name⟩ features. See fontspec’s documentation for details.
Note that if ⟨sets⟩ contains multiple sets, the command is iterated over each set. Each of
these iterations share the same ⟨shapes and font features⟩ and ⟨font name⟩. If you require
that the different sets have individual options and font names, they must be specified in
separate commands. However, if a value’s key is omitted, the individual default values
are still applied.
These same command options follow through to the other commands of this package.
4.2 Symbols
There is currently no way to set the font for general mathematical symbols such as:
=, ×, ↦, ∂, ∅, ∈, ∫, ⊂
You can try the package MnSymbol, which has greater (and more uniform) coverage,
with the package option MnSymbol, e.g. \usepackage[MnSymbol]{mathspec}. Note that
MnSymbol is a third party package by Achim Blumensath, which can only be used if
additionally installed.
4.3 Examples
The following command:
4
\setmathsfont(Digits,Latin,Greek)
[Numbers={Lining,Proportional}]{Minion Pro}
is equivalent to:
\setmathsfont(Digits)[Numbers={Lining,Proportional}]{Minion Pro}
\setmathsfont(Latin)[Numbers={Lining,Proportional}]{Minion Pro}
\setmathsfont(Greek)[Numbers={Lining,Proportional}]{Minion Pro}
and indicates that all digits, Latin and Greek characters are to be set in Minion Pro with
lining, proportional digits, with digits and uppercase Greek in regular and Latin and
lowercase Greek in italic, which are the default shapes.
The following command:
\setmathsfont(Digits,Greek)
[Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]
{GFS Porson}
is equivalent to:
\setmathsfont(Digits)
[Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]{GFS Porson}
\setmathsfont(Greek)
[Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]{GFS Porson}
and indicates that all digits and lowercase Greek charaters are to be set in GFS Por-
son, scaled so that its x-height matches the main font’s, in regular. Uppercase Greek
characters remain unchanged (probably from Computer Modern).
This command defines \mathrm, \mathit, \mathbf and the font for operators like sin and
log.
5
\setmathtt[⟨font features⟩]{⟨font name⟩}
4.5 Shorthands
These commands are useful to save typing the same information multiple times, if the
same font is used for different purposes.
6
\setallmonofonts[⟨font features⟩]{⟨font name⟩}
\setmainfont[Numbers=OldStyle]{Sabon LT Std}
\setallsansfonts[Numbers={OldStyle,Proportional},Scale=MatchLowercase]{Candara}
\setallmonofonts[Numbers=OldStyle,Scale=MatchLowercase]{Consolas}
\setmathsfont(Digits,Latin)[Scale=MatchLowercase]{Bembo MT}
\setmathsfont(Greek)[Scale=MatchLowercase]{STIXGeneral}
\setmathrm{Sabon LT Std}
\exchangeforms{phi}
\setminwhitespace[750]
The main text font is Sabon lt Std with old style figures. The sans serif font is Candara
with old style, proportional figures and the monospaced font is Consolas with old style
figures, both scaled to match Sabon lt Std in x-height.
The mathematics font for digits and Latin symbols is Bembo mt and for Greek sym-
bols STIXGeneral, both scaled to match Sabon lt Std in x-height.
The \mathrm, \mathit and \mathbf alphabets are set in Sabon lt Std.
Finally, the normal and variant forms of Greek lowercase phi are exchanged, see sec-
tion 5 Greek symbols, and the minimum white space on each side of a spaced character
is 750 mmu, see section 6 Glyph bounds.
5 greek symbols
For reference, the Greek alphabet and variant letter forms are given in table 2. Despite
its name, \varsigma ς is not a variant form of \sigma σ , it is the final form. Digamma Ϝ ϝ
is an obsolete letter of the alphabet, originally placed between epsilon Ε ε and zeta Ζ ζ .
advanced Initially, mathspec defines control sequences for the Greek characters that are absent in Computer Mod-
ern, because they are similar in form to Latin characters, from ascii, thus control sequences like \Alpha and
\omicron are defined. Any variant forms that are absent become equivalent to the normal forms. The meanings
of these control sequences are preserved by other control sequences of the same names prefixed with eu@cm@ (e.g.
\eu@cm@alpha), which may be recalled after the Greek mathematics font is changed.
\exchangeforms{⟨list⟩}
7
table 2 The Greek alphabet and variant letter forms with control
sequences.
Uppercase Lowercase Uppercase Lowercase
Α \Alpha α \alpha Ξ \Xi ξ \xi
Β \Beta β \beta Ο \Omicron ο \omicron
Γ \Gamma γ \gamma Π \Pi π \pi
Δ \Delta δ \delta Ρ \Rho ρ \rho
Ε \Epsilon ε \epsilon ς \varsigma
Σ \Sigma
Ζ \Zeta ζ \zeta σ \sigma
Η \Eta η \eta Τ \Tau τ \tau
Θ \Theta θ \theta Υ \Upsilon υ \upsilon
Ι \Iota ι \iota Φ \Phi ϕ \phi
Κ \Kappa κ \kappa Χ \Chi χ \chi
Λ \Lambda λ \lambda Ψ \Psi ψ \psi
Μ \Mu μ \mu Ω \Omega ω \omega
Ν \Nu ν \nu Ϝ \Digamma ϝ \digamma
Normal form Variant form Normal form Variant form
β ϐ \varbeta π ϖ \varpi
ε ϵ \varepsilon ρ ϱ \varrho
θ ϑ \vartheta ϕ φ \varphi
κ ϰ \varkappa Θ ϴ \varTheta
⟨list⟩ A comma separated value list of any of the names for the Greek symbols which have
variant forms: beta, epsilon, theta, kappa, pi, rho, phi, Theta.
Some authors might prefer the normal and variant forms of a symbol to be exchanged.
For example, I prefer \phi to print the orthotic phi ‘ϕ’ and \varphi the cursive phi ‘φ’,
contrary to many text fonts. To exchange the forms of any symbol, include its name in
the list.
\normalisevarforms[⟨list⟩]
\normalizevarforms[⟨list⟩]
⟨list⟩ As above, a comma separated value list of any of the names for the Greek symbols
which have variant forms: beta, epsilon, theta, kappa, pi, rho, phi, Theta.
If [⟨list⟩] is omitted, then [beta,epsilon,theta,kappa,pi,rho,phi,Theta], that is every
such symbol, is assumed.
8
Since not all fonts contain all variant forms, there might be the odd variant letter that
remains in Computer Modern while other Greek letters have changed font. For these
characters, the command \normalisevarforms (or \normalizevarforms) will cause the
listed symbols that are absent from the font to be equivalent to their corresponding
normal forms. If a symbol is listed which is included in the font, then it is ignored.
Note that this command only adjusts the characters that are absent in the font. Of
course, this might mean that, for example, \vartheta and \theta would print the same
glyph, which would be dubious if they are to be used in the same document, with dif-
ferent meanings.
It should be noted that \epsilon prints the lunate epsilon ‘ϵ’ and \varpepsilon prints
the usual (double loop) epsilon ‘ε’ in Plain TEX and LaTEX. This is in contrast to Unicode
text fonts, which contain the lunate style epsilon separately from the Greek alphabet
among variant letter forms and symbols (where Unicode assigns ‘Greek Lunate Epsilon
Symbol’). The definition of \LaTeXe, which prints ‘LaTEX 2ε ’ uses \varepsilon and care
should be taken to ensure that \LaTeXe still uses the usual epsilon either by using one
of the methods that were presented in this section or by redefining \LaTeXe (possibly
using my metalogo package), because ‘LaTEX2ϵ ’ is not as good as ‘LaTEX2ε ’.
6 glyph bounds
In using this package to set text fonts for mathematics, there are issues with glyph
bounds (similar to italic correction), as illustrated in the equations:
\begin{align}
f(x) &= \sum_{n = -\infty}^\infty c_{n}e^{jnx} \\
c_{n} &= \frac�{1}{2}\int_��{-}^{}f(x)e^{-jnx}\,\mathrm dx
\end{align}
∞
∑
f(x) = cn ejnx (1)
n=−∞
∫ π
1
cn = f(x)e−jnx dx (2)
2π −π
where the function f is to close the the parenthesis ( and the exponent jnx is too close
to its base e that there is in fact a collision. The reason is that the font has metrics that
are suitable for use in text, but not for mathematics.
Comparing the alphabets typeset in Computer Modern italic, in table 3, it is shown
that many characters have greater space around them in the mathematics version, which
does not exist in the text version.
9
table 3 Computer Modern Italic in text and
mathematics.
Text abcdefghijklmnopqrstuvwxyz
Mathematics abcdef ghijklmnopqrstuvwxyz
"⟨character⟩
It is necessary to indicate exactly where additional space needs to be inserted. By putting
" before a character, the character will be typeset with additional space inserted on both
sides of it.
\"⟨string⟩"
For multiple adjacent characters, each need not have a " in front of it, but it the characters
may be surrounded by \" before and " after. That is, for example \"abcde" is equivalent
to "a"b"c"d"e.
Note that ⟨character⟩ must be one of the symbols that are listed in table 4. ⟨string⟩ must
one or more such characters adjacent to each other. So \"xyz" and \sin"x is okay, but
\"\sin x" is not because \sin is not a valid character. Also note that with Greek sym-
bols, they can only be used if typed literally, not via control sequences, so \cos"� is okay
but \cos"\theta is not. Use of control sequences for Greek symbols is still perfectly ac-
ceptable because the spacings are built into the defintions of each (for example \alpha
is defined to expand to {"�} automatically).
Use of " and \" in mathematics mode does not interfere with their use in text mode for
quotation marks and umlauts or diæreses: ‘”’ coöperates, even with “Mapping=tex-text”.
\setminwhitespace[⟨number⟩]
Use this command to change the minimum allowed white space around such a spaced
1
character. The unit of ⟨number⟩ is millimu (mmu), that is 1000 mu. Recall 18 mu = 1 em.
10
table 5 Libre Baskerville in text and spaced
mathematics.
Text abcdefghijklmnopqrstuvwxyz
Mathematics abcde f g hi j klmno pqr stuvw x yz
500
The default ⟨number⟩ is 500 which corresponds to 500 mmu = 1000
mu = 0.5 mu =
1
36
em.
Note that this value corresponds to the inserted spaces on both sides for each spaced
character. If two adjacent characters are spaced, then the total minimum white space
between the two characters is twice this value. The effect is shown in table 5.
\begin{align}
"f\left("x\right) &= \sum_{"n = -\infty}^\infty"c_{"n}"e^{\"jnx"} \\
"c_{"n} &= \frac�{1}{2"}\int_��{-"}^""f\bigl("x\bigr)"e^{-\"jnx"}\,\mathrm d"x
\end{align}
∞
∑
f ( x) = c n e jn x (3)
n=−∞
∫ π
1 ( )
cn = f x e − jn x d x (4)
2π −π
Also note that the spacing is improved by replacing (x) with \bigl(x\bigr) (which
you should be doing anyway).
7 compatability
If amsmath is required, it must be loaded earlier than mathspec.
11
8 the package
The package style file is printed in this section.
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{%
12
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}
13
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
14
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
15
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.
16
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
17
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}
18
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}
19
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}
20
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}
21
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
22
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:
23
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
24
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@
25
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}%
26
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@
27
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 %%
28
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
29
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)}
30
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'}
31
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.
32
9 license
This work may be distributed and/or modified under the conditions of the LaTEX Project
Public License, either version 1.3c of this license or (at your option) any later version.
The latest version of this license is in:
http://www.latex-project.org/lppl.txt
33