summaryrefslogtreecommitdiff
path: root/fonts/sansmathfonts/tex/sansmathfonts.sty
blob: 3c2dfd41b87de4a32bb630d942a4d7242365178f (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
% sansmathfonts.sty
%
% Provides complete sans serif math fonts
%
% author: Ariel Barton
%
% Copyright Ariel Barton, 2013
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 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'.
%

\ProvidesPackage{sansmathfonts}[2021/06/22]

\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}

\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. I will ignore the [I] package option.}
	\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
\iftext@sansmathfonts
	\def\sfdefault@sansmathfonts{xcmss}
	\ifI@sansmathfonts
		\def\sfdefault@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}{\sfdefault@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}
	}{}%
	\@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.}
			{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}

\fi

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

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