summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sansmathfonts/sansmathfonts.sty
blob: 32551153609ad456cf02ceb6c384f7c2871a5c3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
% sansmathfonts.sty
%
% Provides complete sans serif math fonts
%
% author: Ariel Barton
%
% Copyright Ariel Barton, 2013--2024
%
% 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 the license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2003/06/01 or later.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The complete list of files considered part of this work is in
% the file `sansmathfonts.pdf' and its source code `sansmathfonts.tex'.
%


%Feedback to submitter: (delete this)
%
%   For your _next_ update please make the following changes in
%   sansmathfonts.tex :
%    -> update or delete the old date in line 25
%    -> append ‘c’ to ‘1.3’ in line 479 to make the license statements
%       consistent throughout the package.
%
%   Also the copyright statements could/should be extended to the
%   current year.
%
%   Finally: The most practical and least error-prone access to CTAN’s
%   upload page is via https://ctan.org/pkg/sansmathfonts, clicking on
%   the “Upload” button at the top.  This way, many of the fields are
%   already prefilled correctly.


\ProvidesPackage{sansmathfonts}[2024/10/15]

\newif \ifmath@sansmathfonts \math@sansmathfontstrue
\newif \iftext@sansmathfonts \text@sansmathfontstrue
\newif \ifI@sansmathfonts \I@sansmathfontsfalse

\DeclareOption{notmath} {\math@sansmathfontsfalse}
\DeclareOption{onlytext}{\math@sansmathfontsfalse}
\DeclareOption{onlymath}{\text@sansmathfontsfalse}
\DeclareOption{nottext} {\text@sansmathfontsfalse}
\DeclareOption{I}{\I@sansmathfontstrue}
\DeclareOption{AMS}{
	\newcommand\sanshbar{\hbar}
	\newcommand\sanshslash{\hslash}
	\newcommand\sansmho{\mho}
	\newcommand\sanseth{\eth}
	\newcommand\sansbackepsilon{\backepsilon}
}
\DeclareOption{letters}{
	\newcommand\sansalpha{\alpha}
	\newcommand\sansbeta{\beta}
	\newcommand\sansgamma{\gamma}
	\newcommand\sansdelta{\delta}
	\newcommand\sansepsilon{\epsilon}
	\newcommand\sanszeta{\zeta}
	\newcommand\sanseta{\eta}
	\newcommand\sanstheta{\theta}
	\newcommand\sansiota{\iota}
	\newcommand\sanskappa{\kappa}
	\newcommand\sanslambda{\lambda}
	\newcommand\sansmu{\mu}
	\newcommand\sansnu{\nu}
	\newcommand\sansxi{\xi}
	\newcommand\sanspi{\pi}
	\newcommand\sansrho{\rho}
	\newcommand\sanssigma{\sigma}
	\newcommand\sanstau{\tau}
	\newcommand\sansupsilon{\upsilon}
	\newcommand\sansphi{\phi}
	\newcommand\sanschi{\chi}
	\newcommand\sanspsi{\psi}
	\newcommand\sansomega{\omega}
	\newcommand\sansvarepsilon{\varepsilon}
	\newcommand\sansvartheta{\vartheta}
	\newcommand\sansvarpi{\varpi}
	\newcommand\sansvarrho{\varrho}
	\newcommand\sansvarsigma{\varsigma}
	\newcommand\sansvarphi{\varphi}
	\newcommand\sansstar{\star}
	\newcommand\sanspartial{\partial}
	\newcommand\sansflat{\flat}
	\newcommand\sansnatural{\natural}
	\newcommand\sanssharp{\sharp}
	\newcommand\sanssmile{\smile}
	\newcommand\sansfrown{\frown}
	\newcommand\sansell{\ell}
	\newcommand\sanswp{\wp}
}

\ProcessOptions

\def\OTOne@sansmathfonts{OT1}
\def\TOne@sansmathfonts{T1}
\def\U@sansmathfonts{U}

\ifx\OTOne@sansmathfonts \f@encoding \else
\ifx\U@sansmathfonts \f@encoding \else
	\I@sansmathfontsfalse
	\PackageWarning{sansmathfonts}
		{The [I] package option is only 
		compatible with the OT1 and U font encodings. 
		To use the [I] option, please use the fontenc 
		package with OT1 encoding: \string\usepackage[OT1]\string{fontenc\string}}
	\ifx\TOne@sansmathfonts \f@encoding \else 
		\text@sansmathfontsfalse
		\PackageWarning{sansmathfonts}
		{Sans serif text fonts are only provided for OT1, T1, and U font 
			encodings. I will not change the sans serif text font.}
	\fi
\fi\fi

\let\sfdefault@sansmathfonts\sfdefault
\def\Usfdefault@sansmathfonts{cmss}
\iftext@sansmathfonts
	\def\sfdefault@sansmathfonts{xcmss}
	\def\Usfdefault@sansmathfonts{xcmss}
	\ifI@sansmathfonts
		\def\sfdefault@sansmathfonts{cmsmf}%
		\def\Usfdefault@sansmathfonts{cmsmf}%
	\fi
\fi

\ifmath@sansmathfonts

	% Turn off Beamer math replacements
	\@ifpackageloaded{beamerbasefont}{\usefonttheme{professionalfonts}}{}
	
	% Sans serif math
	% Code borrowed from fontmath.ltx 
	% (edited; cmr->cmsmf, cmm->cmssm, cmsy->cmsssy, cmex->cmssex)
	\DeclareFontSubstitution{OML}{cmssm}{m}{it}
	\DeclareFontSubstitution{OMS}{cmsssy}{m}{n}
	\DeclareFontSubstitution{OMX}{cmssex}{m}{n}
	\DeclareFontSubstitution{U}{\Usfdefault@sansmathfonts}{m}{n}
	\DeclareSymbolFont{operators}   {OT1}{cmsmf} {m}{n}
	\DeclareSymbolFont{letters}     {OML}{cmssm} {m}{it}
	\DeclareSymbolFont{symbols}     {OMS}{cmsssy}{m}{n}
	\DeclareSymbolFont{largesymbols}{OMX}{cmssex}{m}{n}
	\SetSymbolFont{operators}{bold}{OT1}{cmsmf} {bx}{n}
	\SetSymbolFont{letters}  {bold}{OML}{cmssm} {b}{it}
	\SetSymbolFont{symbols}  {bold}{OMS}{cmsssy}{b}{n}
	
	% Code borrowed from concmath.sty (amsfonts/amssymb option)
	\AtBeginDocument{%
		\@ifpackageloaded{amsfonts}{%
			\DeclareSymbolFont{AMSa}{U}{ssmsa}{m}{n}
			\DeclareSymbolFont{AMSb}{U}{ssmsb}{m}{n}
		}{
			\ifdefined\sansmho
				\PackageError{sansmathfonts}
				{Please load the {amsfonts} package if you want AMS symbols.}
				{The [AMS] package option for {sansmathfonts} is primarily 
					designed for use with the [onlytext]/[notmath] options, 
					and expects you to load an AMS package if you want
					AMS symbols that match surrounding math.}
			\fi
		}%
		\@ifpackageloaded{esint}{%
		\DeclareSymbolFont{largesymbolsA}{U}{ssesint}{m}{n}
		}{}
		%
		\ifx\OTOne@sansmathfonts \f@encoding \else 
		\ifx\U@sansmathfonts \f@encoding \else 
			\ifI@sansmathfonts
				\PackageError{sansmathfonts}
				{The [I] package option is only compatible with 
					the OT1 and U font encodings. To use the [I] option,
					please use the fontenc package with OT1 encoding:
					\string\usepackage[OT1]\string{fontenc\string}}
				{Please do not use the [I] option for the sansmathfonts 
					package, or select your font encoding before you load 
					the sansmathfonts package.}
			\fi
			\ifx\TOne@sansmathfonts \f@encoding \else 
			\iftext@sansmathfonts
				\PackageError{sansmathfonts}
					{Sans serif text fonts are only
						provided for OT1, T1, and U font encodings.}
					{Please use the [onlymath] option for the sansmathfonts 
						package, or select your font encoding before you 	
						load the sansmathfonts package.}
			\fi \fi
		\fi \fi
		}	
	
	% beamer currently sets 
	% \mathrm to upright serif and
	% \mathit to slanted sans serif.
	% They should be consistent,
	% and the setup should be such that if you aren't paying attention,
	% then you get the font of the rest of the letters,
	% that is, sans serif.
	
	% Code borrowed from fontmath.ltx 
	% (edited; cmr->cmsmf)
	\DeclareSymbolFontAlphabet{\mathrm}    {operators}
	\DeclareSymbolFontAlphabet{\mathnormal}{letters}
	\DeclareSymbolFontAlphabet{\mathcal}   {symbols}
	\DeclareMathAlphabet      {\mathbf}{OT1}{cmsmf}{bx}{n}
	\DeclareMathAlphabet      {\mathit}{OT1}{cmsmf}{m}{it}
	\DeclareMathAlphabet      {\mathtt}{OT1}{cmtt}{m}{n}
	\SetMathAlphabet\mathsf{bold}{OT1}{cmsmf}{bx}{n}
	\SetMathAlphabet\mathit{bold}{OT1}{cmsmf}{bx}{it}
\else
	\ifdefined\sansmho
		\DeclareSymbolFont{sansAMSb}{U}{ssmsb}{m}{n}
		\begingroup \catcode`\"=12
		\let\sansmho\undefined        \DeclareMathSymbol{\sansmho}        {\mathord}{sansAMSb}{"66}
		\let\sanseth\undefined        \DeclareMathSymbol{\sanseth}        {\mathord}{sansAMSb}{"67}
		\let\sanshslash\undefined     \DeclareMathSymbol{\sanshslash}     {\mathord}{sansAMSb}{"7D}
		\let\sanshbar\undefined       \DeclareMathSymbol{\sanshbar}       {\mathord}{sansAMSb}{"7E}
		\let\sansbackepsilon\undefined\DeclareMathSymbol{\sansbackepsilon}{\mathrel}{sansAMSb}{"7F}
		\endgroup
	\fi
	\ifdefined\sansalpha
		\DeclareSymbolFont{sansletters}     {OML}{cmssm} {m}{it}
		\let\sansalpha\undefined      \DeclareMathSymbol{\sansalpha}      {\mathord}{sansletters}{11}
		\let\sansbeta\undefined       \DeclareMathSymbol{\sansbeta}       {\mathord}{sansletters}{12}
		\let\sansgamma\undefined      \DeclareMathSymbol{\sansgamma}      {\mathord}{sansletters}{13}
		\let\sansdelta\undefined      \DeclareMathSymbol{\sansdelta}      {\mathord}{sansletters}{14}
		\let\sansepsilon\undefined    \DeclareMathSymbol{\sansepsilon}    {\mathord}{sansletters}{15}
		\let\sanszeta\undefined       \DeclareMathSymbol{\sanszeta}       {\mathord}{sansletters}{16}
		\let\sanseta\undefined        \DeclareMathSymbol{\sanseta}        {\mathord}{sansletters}{17}
		\let\sanstheta\undefined      \DeclareMathSymbol{\sanstheta}      {\mathord}{sansletters}{18}
		\let\sansiota\undefined       \DeclareMathSymbol{\sansiota}       {\mathord}{sansletters}{19}
		\let\sanskappa\undefined      \DeclareMathSymbol{\sanskappa}      {\mathord}{sansletters}{20}
		\let\sanslambda\undefined     \DeclareMathSymbol{\sanslambda}     {\mathord}{sansletters}{21}
		\let\sansmu\undefined         \DeclareMathSymbol{\sansmu}         {\mathord}{sansletters}{22}
		\let\sansnu\undefined         \DeclareMathSymbol{\sansnu}         {\mathord}{sansletters}{23}
		\let\sansxi\undefined         \DeclareMathSymbol{\sansxi}         {\mathord}{sansletters}{24}
		\let\sanspi\undefined         \DeclareMathSymbol{\sanspi}         {\mathord}{sansletters}{25}
		\let\sansrho\undefined        \DeclareMathSymbol{\sansrho}        {\mathord}{sansletters}{26}
		\let\sanssigma\undefined      \DeclareMathSymbol{\sanssigma}      {\mathord}{sansletters}{27}
		\let\sanstau\undefined        \DeclareMathSymbol{\sanstau}        {\mathord}{sansletters}{28}
		\let\sansupsilon\undefined    \DeclareMathSymbol{\sansupsilon}    {\mathord}{sansletters}{29}
		\let\sansphi\undefined        \DeclareMathSymbol{\sansphi}        {\mathord}{sansletters}{30}
		\let\sanschi\undefined        \DeclareMathSymbol{\sanschi}        {\mathord}{sansletters}{31}
		\let\sanspsi\undefined        \DeclareMathSymbol{\sanspsi}        {\mathord}{sansletters}{32}
		\let\sansomega\undefined      \DeclareMathSymbol{\sansomega}      {\mathord}{sansletters}{33}
		\let\sansvarepsilon\undefined \DeclareMathSymbol{\sansvarepsilon} {\mathord}{sansletters}{34}
		\let\sansvartheta\undefined   \DeclareMathSymbol{\sansvartheta}   {\mathord}{sansletters}{35}
		\let\sansvarpi\undefined      \DeclareMathSymbol{\sansvarpi}      {\mathord}{sansletters}{36}
		\let\sansvarrho\undefined     \DeclareMathSymbol{\sansvarrho}     {\mathord}{sansletters}{37}
		\let\sansvarsigma\undefined   \DeclareMathSymbol{\sansvarsigma}   {\mathord}{sansletters}{38}
		\let\sansvarphi\undefined     \DeclareMathSymbol{\sansvarphi}     {\mathord}{sansletters}{39}
		\let\sansstar\undefined       \DeclareMathSymbol{\sansstar}       {\mathord}{sansletters}{63}
		\let\sanspartial\undefined    \DeclareMathSymbol{\sanspartial}    {\mathord}{sansletters}{64}
		\let\sansflat\undefined       \DeclareMathSymbol{\sansflat}       {\mathord}{sansletters}{91}
		\let\sansnatural\undefined    \DeclareMathSymbol{\sansnatural}    {\mathord}{sansletters}{92}
		\let\sanssharp\undefined      \DeclareMathSymbol{\sanssharp}      {\mathord}{sansletters}{93}
		\let\sanssmile\undefined      \DeclareMathSymbol{\sanssmile}      {\mathord}{sansletters}{94}
		\let\sansfrown\undefined      \DeclareMathSymbol{\sansfrown}      {\mathord}{sansletters}{95}
		\let\sansell\undefined        \DeclareMathSymbol{\sansell}        {\mathord}{sansletters}{96}
		\let\sanswp\undefined         \DeclareMathSymbol{\sanswp}         {\mathord}{sansletters}{125}
	\fi
\fi

\DeclareMathAlphabet      {\mathserif}{OT1}{cmr}{m}{n}
\DeclareMathAlphabet      {\mathsf}{OT1}{cmsmf}{m}{n}

\DeclareFontFamilySubstitution{TS1}{xcmss}{cmss}
\DeclareFontFamilySubstitution{TS1}{cmsmf}{cmss}

% Use the improved sans family
% (provides sans serif small caps fonts)
\let\sfdefault\sfdefault@sansmathfonts