% sfmath.sty by Olaf Dietrich (odt@dtrx.de)

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sfmath}[2001/11/15 v0.3 sans serif maths]


% This is a simple package for sans serif maths in documents.
%
% Usage: \usepackage{sfmath} or \usepackage[OPTIONS]{sfmath}
%
% OPTIONS are
%
% * slantedGreek: for slanted uppercase Greek letters
% * helvet: use Postscript Helvetica (phv) for maths (explicitly)
% * cm: use Computer Modern (cmss) for maths (explicitly)
% * mathrmOrig: do not change the behavior of the \mathrm command
% * mathbfOrig: do not change the behavior of the \mathbf command
% * mathitOrig: do not change the behavior of the \mathit command
% * mathsfOrig: do not change the behavior of the \mathsf command
%
%
% This package should work with pdflatex and produce documents
% with Postscript Type 1 Fonts. If \sfdefault is changed by a
% package like pslatex.sty or times.sty (obsolete) or manually,
% then include sfmath.sty _after_ having changed \sfdefault.
% Alternatively, select the desired sans serif font with the
% package options helvet or cm.
%
% Functionality is limited by the intention to work without additionally
% defined (virtual) fonts; instead, only standard fonts are used.


% CHANGES:
%
% v0.3:
%
% * Add sans serif shapes for "," and ".", "\ldotp"
%
% * Modified documentation
%
%
% v0.2:
%
% * New option slantedGreek for slanted greek capitals
%
% * Options helvet and cm to select explicitly the sans serif font
%   for maths. Without any of these options, the current \sfdefault
%   is chosen.
%
% * Options mathxxOrig: don't change the alphabet command \mathxx;
%   available for \mathrm, \mathbf, \mathit, and \mathsf
%
% * Provide dotlessi and dotlessj (if available)
%


% BUGS/LIMITATIONS/PROBLEMS:
%
% This package is not working particularly well or typographically satisfying:
%
% * In many constellations with Postscript fonts (helvet.sty,
%   pslatex.sty, ...) the upper-case greek letters are not chosen
%   correctly within \mathrm, \mathbf, \mathit, ... (because
%   they should be part of OT1-encoded fonts but are not included
%   in these standard postscript fonts).
%
% * Bold math symbols are not always available (e. g. with pslatex.sty)
%   or at least not slanted (e. g. with cmss fonts), so better don't
%   use bold maths with this package.
%
% * The font metrics are not adjusted to maths usage.
%
% * The set symbols \mathbb{N} or \mathbbm{N} (from bbm.sty) are not
%   changed. You might like to use \mathbbmss{n} (from bbm.sty).
%
% * Some symbols have serifish shapes (\sum, \prod, probably more) and
%   are not changed.
%
% * Lower-case greek letters are not available in sans serif shape
%   (they don't have real serifs, but cannot be expected to harmonize
%   with the sans serif latin letters).
%
% * Is this the Right Way to do it? Or would it be preferable to define
%   one or two new math _versions_ (sans, sansbold), such that formulas
%   are switched to sans by \mathversion{sans}?
%
% * New virtual fonts for maths would be a more complicated but
%   better solution.
%


% HERE WE GO:

% Declare options and defaults and process options

\DeclareOption{helvet}{\renewcommand{\math@sfdefault}{phv}}
\DeclareOption{cm}{\renewcommand{\math@sfdefault}{cmss}}

\DeclareOption{slantedGreek}{\renewcommand{\greek@shape}{sl}}

\DeclareOption{mathrmOrig}{\renewcommand{\mathrm@lph}{cmr}}
\DeclareOption{mathbfOrig}{\renewcommand{\mathbf@lph}{cmr}}
\DeclareOption{mathitOrig}{\renewcommand{\mathit@lph}{cmr}}
\DeclareOption{mathsfOrig}{\renewcommand{\mathsf@lph}{cmss}}



\newcommand{\math@sfdefault}{\sfdefault}

\newcommand{\greek@shape}{n}

\newcommand{\mathrm@lph}{\math@sfdefault}
\newcommand{\mathbf@lph}{\math@sfdefault}
\newcommand{\mathit@lph}{\math@sfdefault}
\newcommand{\mathsf@lph}{\math@sfdefault}



\ProcessOptions



% Change font for digits and "operators" (\sin, \exp, ...)
% to default sans serif font

\SetSymbolFont{operators}{normal}{OT1}{\math@sfdefault}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{\math@sfdefault}{bx}{n}


% Most special math symbols remain unmodified (and many of those
% don't have serifs); however all letters (A-Z, a-z) are
% explicitely changed to the sans serif version (again
% default sans serif font).
%
% Unfortunately, there is no standard slanted+bold sans serif font
% available (as Postscript Type 1 font), so try an upright
% version (may be better than nothing).

\DeclareSymbolFont{SFMath}{OT1}{\math@sfdefault}{m}{sl}
\SetSymbolFont{SFMath}{normal}{OT1}{\math@sfdefault}{m}{sl}
\SetSymbolFont{SFMath}{bold}{OT1}{\math@sfdefault}{bx}{n}
\DeclareMathSymbol{A}{\mathalpha}{SFMath}{`A}
\DeclareMathSymbol{B}{\mathalpha}{SFMath}{`B}
\DeclareMathSymbol{C}{\mathalpha}{SFMath}{`C}
\DeclareMathSymbol{D}{\mathalpha}{SFMath}{`D}
\DeclareMathSymbol{E}{\mathalpha}{SFMath}{`E}
\DeclareMathSymbol{F}{\mathalpha}{SFMath}{`F}
\DeclareMathSymbol{G}{\mathalpha}{SFMath}{`G}
\DeclareMathSymbol{H}{\mathalpha}{SFMath}{`H}
\DeclareMathSymbol{I}{\mathalpha}{SFMath}{`I}
\DeclareMathSymbol{J}{\mathalpha}{SFMath}{`J}
\DeclareMathSymbol{K}{\mathalpha}{SFMath}{`K}
\DeclareMathSymbol{L}{\mathalpha}{SFMath}{`L}
\DeclareMathSymbol{M}{\mathalpha}{SFMath}{`M}
\DeclareMathSymbol{N}{\mathalpha}{SFMath}{`N}
\DeclareMathSymbol{O}{\mathalpha}{SFMath}{`O}
\DeclareMathSymbol{P}{\mathalpha}{SFMath}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{SFMath}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{SFMath}{`R}
\DeclareMathSymbol{S}{\mathalpha}{SFMath}{`S}
\DeclareMathSymbol{T}{\mathalpha}{SFMath}{`T}
\DeclareMathSymbol{U}{\mathalpha}{SFMath}{`U}
\DeclareMathSymbol{V}{\mathalpha}{SFMath}{`V}
\DeclareMathSymbol{W}{\mathalpha}{SFMath}{`W}
\DeclareMathSymbol{X}{\mathalpha}{SFMath}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{SFMath}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{SFMath}{`Z}
\DeclareMathSymbol{a}{\mathalpha}{SFMath}{`a}
\DeclareMathSymbol{b}{\mathalpha}{SFMath}{`b}
\DeclareMathSymbol{c}{\mathalpha}{SFMath}{`c}
\DeclareMathSymbol{d}{\mathalpha}{SFMath}{`d}
\DeclareMathSymbol{e}{\mathalpha}{SFMath}{`e}
\DeclareMathSymbol{f}{\mathalpha}{SFMath}{`f}
\DeclareMathSymbol{g}{\mathalpha}{SFMath}{`g}
\DeclareMathSymbol{h}{\mathalpha}{SFMath}{`h}
\DeclareMathSymbol{i}{\mathalpha}{SFMath}{`i}
\DeclareMathSymbol{j}{\mathalpha}{SFMath}{`j}
\DeclareMathSymbol{k}{\mathalpha}{SFMath}{`k}
\DeclareMathSymbol{l}{\mathalpha}{SFMath}{`l}
\DeclareMathSymbol{m}{\mathalpha}{SFMath}{`m}
\DeclareMathSymbol{n}{\mathalpha}{SFMath}{`n}
\DeclareMathSymbol{o}{\mathalpha}{SFMath}{`o}
\DeclareMathSymbol{p}{\mathalpha}{SFMath}{`p}
\DeclareMathSymbol{q}{\mathalpha}{SFMath}{`q}
\DeclareMathSymbol{r}{\mathalpha}{SFMath}{`r}
\DeclareMathSymbol{s}{\mathalpha}{SFMath}{`s}
\DeclareMathSymbol{t}{\mathalpha}{SFMath}{`t}
\DeclareMathSymbol{u}{\mathalpha}{SFMath}{`u}
\DeclareMathSymbol{v}{\mathalpha}{SFMath}{`v}
\DeclareMathSymbol{w}{\mathalpha}{SFMath}{`w}
\DeclareMathSymbol{x}{\mathalpha}{SFMath}{`x}
\DeclareMathSymbol{y}{\mathalpha}{SFMath}{`y}
\DeclareMathSymbol{z}{\mathalpha}{SFMath}{`z}

\DeclareMathSymbol{\imath}{\mathalpha}{SFMath}{"10}
\DeclareMathSymbol{\jmath}{\mathalpha}{SFMath}{"11}


% The symbols ",", ".", and "\ldotp" should be sans serif
% but upright.

\DeclareSymbolFont{SFMathUp}{OT1}{\math@sfdefault}{m}{n}
\SetSymbolFont{SFMathUp}{normal}{OT1}{\math@sfdefault}{m}{n}
\SetSymbolFont{SFMathUp}{bold}{OT1}{\math@sfdefault}{bx}{n}
\DeclareMathSymbol{,}{\mathpunct}{SFMathUp}{`,}
\DeclareMathSymbol{.}{\mathord}{SFMathUp}{`.}
\DeclareMathSymbol{\ldotp}{\mathord}{SFMathUp}{`.}


% Take capital greek letters from cmss; other sans serif fonts
% like helvetica don't have capital greeks, so here cmss is
% taken instead of \sfdefault. Unfortunately, this does not work
% within the alphabet commands \mathrm, \mathsf, ...

\DeclareSymbolFont{SFMathGreek}{OT1}{cmss}{m}{\greek@shape}
\SetSymbolFont{SFMathGreek}{normal}{OT1}{cmss}{m}{\greek@shape}
\SetSymbolFont{SFMathGreek}{bold}{OT1}{cmss}{bx}{n}

\DeclareMathSymbol{\Gamma}{\mathalpha}{SFMathGreek}{"00}
\DeclareMathSymbol{\Delta}{\mathalpha}{SFMathGreek}{"01}
\DeclareMathSymbol{\Theta}{\mathalpha}{SFMathGreek}{"02}
\DeclareMathSymbol{\Lambda}{\mathalpha}{SFMathGreek}{"03}
\DeclareMathSymbol{\Xi}{\mathalpha}{SFMathGreek}{"04}
\DeclareMathSymbol{\Pi}{\mathalpha}{SFMathGreek}{"05}
\DeclareMathSymbol{\Sigma}{\mathalpha}{SFMathGreek}{"06}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{SFMathGreek}{"07}
\DeclareMathSymbol{\Phi}{\mathalpha}{SFMathGreek}{"08}
\DeclareMathSymbol{\Psi}{\mathalpha}{SFMathGreek}{"09}
\DeclareMathSymbol{\Omega}{\mathalpha}{SFMathGreek}{"0A}



% Define new behavior for math alphabet commands


\SetMathAlphabet{\mathnormal}{normal}{OT1}{\math@sfdefault}{m}{sl}
\SetMathAlphabet{\mathnormal}{bold}{OT1}{\math@sfdefault}{bx}{n}

\SetMathAlphabet{\mathrm}{normal}{OT1}{\mathrm@lph}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{OT1}{\mathrm@lph}{bx}{n}

\SetMathAlphabet{\mathbf}{normal}{OT1}{\mathbf@lph}{bx}{n}
\SetMathAlphabet{\mathbf}{bold}{OT1}{\mathbf@lph}{bx}{n}

\SetMathAlphabet{\mathit}{normal}{OT1}{\mathit@lph}{m}{sl}
\SetMathAlphabet{\mathit}{bold}{OT1}{\mathit@lph}{m}{sl}

\SetMathAlphabet{\mathsf}{normal}{OT1}{\mathsf@lph}{m}{n}
\SetMathAlphabet{\mathsf}{bold}{OT1}{\mathsf@lph}{bx}{n}



% Define new math alphabet command \mathsl

\DeclareMathAlphabet{\mathsl}{OT1}{\math@sfdefault}{m}{sl}
\SetMathAlphabet{\mathsl}{bold}{OT1}{\math@sfdefault}{m}{sl}


\endinput
