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
|
% LaTeX package sansmath: typeset sans-serif math using `text' fonts.
%
\ProvidesPackage{sansmath}[2007/02/28 \space ver 1.1 Donald Arseneau]
%
% Donald Arseneau, asnd@triumf.ca, Vancouver, Canada.
%
% This package is released to the public domain by me, Donald Arseneau,
% the original author, who disclaims all rights. I do not support it,
% and request that it be adopted and supported by someone who knows
% more about math font issues in LaTeX.
%
% The point of this package is to allow sans-serif math in the absence
% of proper sans math fonts.
%
% 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'. There is also
% an `\unsansmath' defined, but if math is to be sans-serif for
% a region 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!
%
% OT1 encoding is normally required to get the uppercase greek letters,
% but if you use the [EULERGREEK] option or don't use any uppercase greek
% letters, then you are welcome to define \sansmathencoding *before*
% loading this package. There is also a package option [T1] to perform
% that particuler definition. Note the comment above about only cmms
% being good; even the T1-encoded ec fonts are poor substitutes.
%
% 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.
\providecommand\sansmathencoding{OT1}
\DeclareOption{T1}{
\def\sansmathencoding{T1}
}
\let\EulGreek\relax
\let\EuUCGreek\relax
\let\NonEulGreek\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 % avoid multi-mapping when repeated
\EulGreekList
\EuUCGreek
\let\varrho\rho \let\varsigma\sigma % Euler's missing variants
\fi
}
\def\EulGreekList{\@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\varphi
}
\def\NonEulGreek{% Reverse previous mapping
\ifnum\alpha>\@eugreekOffset % avoid multi-mapping when repeated
\@eugreekOffset=-\@eugreekOffset \@euGREEKOffset=-\@euGREEKOffset
\EulGreekList
\EuUCGreek
\@eugreekOffset=-\@eugreekOffset \@euGREEKOffset=-\@euGREEKOffset
\fi
}}
\ProcessOptions
\DeclareMathAlphabet{\mathsfsl}{\sansmathencoding}{\sfdefault}{m}{sl}
\DeclareOldFontCommand{\sfsl}{\normalfont\sffamily\slshape}{\mathsfsl}
\DeclareMathAlphabet{\mathsfbf}{\sansmathencoding}{\sfdefault}{bx}{sl}
\DeclareOldFontCommand{\sfbf}{\normalfont\sffamily\bfseries}{\mathsfbf}
\DeclareMathVersion{sans}
\SetMathAlphabet{\mathrm} {sans}{\sansmathencoding}{\sfdefault}{m}{n}
\SetMathAlphabet{\mathsfsl}{sans}{\sansmathencoding}{\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}{\sansmathencoding}{\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}{`\=}
\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
%\message{Change \string#1 from \number#1 to \number\@tempcnta}%
\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{%
\ifx\mnorm@mathbf\mathbf\else \let\mnorm@mathbf\mathbf \fi
\mathversion{sans}%
\let\mathbf\mathsfbf
\let\sansm@every@math\sfMathSwitch
\EulGreek
}
\def\unsansmath{%
\mathversion{normal}%
\let\mathbf\mnorm@mathbf
\let\sansm@every@math\relax
\NonEulGreek
}
\expandafter\def\expandafter\check@mathfonts\expandafter{\check@mathfonts
\sansm@every@math}
\let\sansm@every@math\relax
\let\mnorm@mathbf\mathbf
% Repair of a LaTeX bug that has not been fixed in 6 years.
% Latex bug: latex/3357
\def \@fontswitch #1#2{%
\ifmmode
\let \math@bgroup \relax
\def \math@egroup ##1{%
\let \math@bgroup \@@math@bgroup
\let \math@egroup \@@math@egroup
##1}%
#2\relax
\else
#1%
\fi
}
|