summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltxmisc/sansmath.sty
blob: 8fe92456b3abe8117a468001cfd42df19696c15b (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
% LaTeX package sansmath: typeset sans-serif math using `text' fonts.
%
\ProvidesPackage{sansmath}[2003/12/14 \space ver 0.5  Donald Arseneau]
% 
% Donald Arseneau,  asnd@triumf.ca,  Vancouver, Canada.
%
% This package is released to the public domain by the original
% author, who does not support it, and requests that it be adopted
% and supported by someone who actually knows something about math
% font issues in LaTeX.
%
% The author was persuaded to use the name `sansmath' in hopes of
% working with various text sans fonts (indicated by \sfdefault)
% but the only good results seen were with Computer Modern and cmss.
% (Helvetica with the `pslatex' package was very poor!)
%
% INSTRUCTIONS
% ~~~~~~~~~~~~
% Load this package by inserting `\usepackage{sansmath}' in the
% document preamble.  This will define a new math version `sans'
% and a command `\sansmath', much like `\boldmath'.  Note that
% NO `\unsansmath' is defined, so if math is to be sans-serif for
% just part of a document, one should declare `\sansmath' in a local
% group (perhaps with \begin{sansmath}...\end{sansmath}).  
% Within the scope of the \sansmath declaration, math characters
% will be taken from the text sans-serif family as much as possible.
% The actual sans fonts are OT1 encodings of those indicated by the 
% meaning of \sfdefault WHEN THE PACKAGE WAS LOADED -- not the 
% meaning at each math environment!
% 
% Since the (OT1) text fonts do not provide the lower-case greek 
% letters, there is a package option [eulergreek] to take the 
% lowercase greek from the Euler math fonts.
% Since some (many) sans fonts have no uppercase greek letters either
% (missing characters from the OT1 encoding), there is an option 
% [EULERGREEK] to take ALL greek letters from the euler fonts.
% One should also investigate using Euler for ALL MATH in the document,
% using package `euler' instead of this one!
%
% This package achieves math-italic by reloading the slanted version
% of the text sans-serif font, and changing a fontdimen parameter 
% (spaceskip).  This causes the italic correction to be applied between
% letters (good) but does not break up the `fi' and `fl' ligatures (bad)
% (Why does a sans font have these ligatures anyway?)  At this point,
% nothing is done about this bug.

\DeclareMathAlphabet{\mathsfsl}{OT1}{\sfdefault}{m}{sl}
\DeclareOldFontCommand{\sfsl}{\normalfont\sffamily\slshape}{\mathsfsl}
\DeclareMathAlphabet{\mathsfbf}{OT1}{\sfdefault}{bx}{sl}
\DeclareOldFontCommand{\sfbf}{\normalfont\sffamily\bfseries}{\mathsfbf}

\DeclareMathVersion{sans}
\SetMathAlphabet{\mathrm} {sans}{OT1}{\sfdefault}{m}{n}
\SetMathAlphabet{\mathsfsl}{sans}{OT1}{\sfdefault}{m}{sl}
\SetSymbolFont {operators}{sans}{OT1}{\sfdefault}{m}{n}

% The cmm and cmsy are too light for cmss.  I tried {b} for the next
% two lines, but it did not work well (unbold +, bold greek, bad \neq)
\SetSymbolFont {letters}  {sans}{OML}{cmm} {m}{it}
\SetSymbolFont {symbols}  {sans}{OMS}{cmsy}{m}{n}

\SetMathAlphabet{\mathsfbf}{sans}{OT1}{\sfdefault}{bx}{n}

\DeclareMathSymbol{0}{\mathord}{operators}{`0}
\DeclareMathSymbol{1}{\mathord}{operators}{`1}
\DeclareMathSymbol{2}{\mathord}{operators}{`2}
\DeclareMathSymbol{3}{\mathord}{operators}{`3}
\DeclareMathSymbol{4}{\mathord}{operators}{`4}
\DeclareMathSymbol{5}{\mathord}{operators}{`5}
\DeclareMathSymbol{6}{\mathord}{operators}{`6}
\DeclareMathSymbol{7}{\mathord}{operators}{`7}
\DeclareMathSymbol{8}{\mathord}{operators}{`8}
\DeclareMathSymbol{9}{\mathord}{operators}{`9}
\DeclareMathSymbol{!}{\mathclose}{operators}{"21}
\DeclareMathSymbol{,}{\mathpunct}{operators}{`\,}
\DeclareMathSymbol{.}{\mathord}{operators}{`\.}
\DeclareMathSymbol{:}{\mathrel}{operators}{`\:}
\DeclareMathSymbol{;}{\mathpunct}{operators}{`\;}
\DeclareMathSymbol{?}{\mathclose}{operators}{`\?}
%\DeclareMathSymbol{+}{\mathbin}{operators}{"2B}
%\DeclareMathSymbol{=}{\mathrel}{operators}{`\=}


\let\EulGreek\relax
\let\EuUCGreek\relax
\DeclareOption{EULERGREEK}{
  \ExecuteOptions{eulergreek}
  \def\EuUCGreek{%
    \@euG\Gamma \@euG\Delta \@euG\Theta \@euG\Lambda \@euG\Xi \@euG\Pi
    \@euG\Sigma \@euG\Upsilon \@euG\Phi \@euG\Psi \@euG\Omega
}}
\DeclareOption{eulergreek}{
 \def\EulGreek{%
  \ifnum\alpha<\@eugreekOffset
    \@eug\alpha \@eug\beta \@eug\gamma \@eug\delta \@eug\epsilon
    \@eug\zeta \@eug\eta \@eug\theta \@eug\iota \@eug\kappa \@eug\lambda
    \@eug\mu \@eug\nu \@eug\xi \@eug\pi \@eug\rho \@eug\sigma \@eug\tau
    \@eug\upsilon \@eug\phi \@eug\chi \@eug\psi \@eug\omega
    \@eug\varepsilon \@eug\vartheta \@eug\varpi \@eug\varrho
    \@eug\varsigma \@eug\varphi
    \EuUCGreek
  \fi
}}
\ProcessOptions

\ifx\EulGreek\relax\else
 \DeclareSymbolFont{EulerGreek}{U}{eur}{m}{n}
 \SetSymbolFont{EulerGreek}{sans}{U}{eur}{m}{n}
 \DeclareSymbolFontAlphabet\matheug{EulerGreek}

 \newcount\@eugreekOffset
 \let\@tempa\relax
 \DeclareMathSymbol{\@tempa}{\mathord}{EulerGreek}{11}
 \@eugreekOffset\@tempa
 \advance\@eugreekOffset-\alpha

 \def\@eug#1{\@tempcnta#1\advance\@tempcnta\@eugreekOffset
    \mathchardef#1\@tempcnta}

 \ifx\EuUCGreek\relax\else

  \newcount\@euGREEKOffset
  \let\@tempa\relax
  \DeclareMathSymbol{\@tempa}{\mathord}{EulerGreek}{1}
  \@euGREEKOffset\@tempa
  \advance\@euGREEKOffset-\Delta

  \def\@euG#1{\@tempcnta#1\advance\@tempcnta\@euGREEKOffset
     \mathchardef#1\@tempcnta}
 \fi
\fi

\def\sfMathSwitch{\sfsl
  \make@math@version@font \textfont \fam \tf@size
  \make@math@version@font \scriptfont \fam \sf@size
  \make@math@version@font \scriptscriptfont \fam \ssf@size
}

\def\make@math@version@font #1#2#3{%
  \begingroup
    \escapechar\m@ne
    \xdef\sansm@name{\expandafter\string\the#1#2+}%
  \endgroup
  \@ifundefined{\sansm@name}{%
      \@load@variant@font \sansm@name{#1#2}{#3\p@}}{}%
  #1#2\csname \sansm@name\endcsname
}

\begingroup
\catcode`\A=12 \catcode`\T=12
\lowercase{% necessary because \fontname\font produces "at" in catcode 12.
\endgroup
%
\def\@load@variant@font #1#2#3{\expandafter\@do@load@varfont
     \csname #1\expandafter\endcsname \fontname#2 AT #3 AT \relax }
%
\def\@do@load@varfont #1#2 AT #3 AT #4\relax{%
  \dimen@#3\advance\dimen@ 1sp
  \global\font #1=#2 at \dimen@
  \fontdimen\tw@#1=\z@}
}

\def\sansmath{%
  \mathversion{sans}%
  \let\mathbf\mathsfbf
  \let\sansm@every@math\sfMathSwitch
  \EulGreek
}

\expandafter\def\expandafter\check@mathfonts\expandafter{\check@mathfonts
   \sansm@every@math}

\let\sansm@every@math\relax