diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-12 23:50:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-12 23:50:55 +0000 |
commit | 580196c77cf299077e97bf4c0bae9adfd2018ebb (patch) | |
tree | d4df287c19cd9ce68ac3fc974dba2771b0152bdc /Master | |
parent | 0a30ff5033d3952570ddcb1e64b466c3c9b3508e (diff) |
SIstyle
git-svn-id: svn://tug.org/texlive/trunk@636 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/tex/latex/SIstyle/sistyle.sty | 326 |
1 files changed, 326 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/SIstyle/sistyle.sty b/Master/texmf-dist/tex/latex/SIstyle/sistyle.sty new file mode 100644 index 00000000000..3903be6c4df --- /dev/null +++ b/Master/texmf-dist/tex/latex/SIstyle/sistyle.sty @@ -0,0 +1,326 @@ +%% +%% This is file `sistyle.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% sistyle.dtx (with options: `package') +%% Author: Danie Els (dnjels@sun.ac.za) +%% +%% Copyright 2004 by Danie Els. All rights reserved. +%% +%% 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/12/01 or later. +%% +%% This work has the LPPL maintenance status "author-maintained". +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{sistyle} + [2004/07/09 v2.0 SI units and numbers (DNJ Els)] +\RequirePackage{amstext} +\begingroup + \catcode`\Q=3 + \long\gdef\SI@ifempt#1{\SI@xifempt#1QQ\@secondoftwo\@firstoftwo\@nil} + \long\gdef\SI@xifempt#1#2Q#3#4#5\@nil{#4} +\endgroup + \newcommand{\GetMathFontFams}{% + \sbox{0}{$% + \@ifundefined{mathsf} + {\global\chardef\SI@sffam=99}% + {\mathsf{\global\chardef\SI@sffam=\fam}}% + \@ifundefined{mathtt} + {\global\chardef\SI@ttfam=99}% + {\mathtt{\global\chardef\SI@ttfam=\fam}}% + $}% + } +\AtBeginDocument{\GetMathFontFams} +\newcommand{\IfTbold}[2]{% + \if b\expandafter\@car\f@series\@nil% + #1\else #2\fi} +\newcommand{\IfMbold}[2]{% + \edef\temp@bm{bold}% + \ifx\math@version\temp@bm + #1\else #2\fi} +\newif\ifSIobeybold +\SIobeyboldfalse +\newcommand*{\SI@defaultMfam}{\mathrm} +\newcommand*{\SIdefaultMfam}[1]{\renewcommand*{\SI@defaultMfam}{#1}} +\newcommand*{\SI@defaultNfam}{\mathrm} +\newcommand*{\SIdefaultNfam}[1]{\renewcommand*{\SI@defaultNfam}{#1}} +\newcommand*{\SI@defaultTfam}{\rmfamily} +\newcommand*{\SIdefaultTfam}[1]{\renewcommand*{\SI@defaultTfam}{#1}} +\newif\ifupmath +\upmathfalse +\newcommand*{\SIupmath}[2][\SI@defaultMfam]{% +\begingroup + \upmathtrue + \edef\temp@sf{\sfdefault}% + \edef\temp@tt{\ttdefault}% + \let\SI@bold=\relax + \ifmmode + \ifdim\displaywidth>0pt\relax%--- DISPLAY MATH ------------ + \ifnum\the\fam=\SI@sffam + \let\SI@mfam=\mathsf + \let\SI@tfam=\sffamily + \else \ifnum\the\fam=\SI@ttfam + \let\SI@mfam=\mathtt + \let\SI@tfam=\ttfamily + \else + \let\SI@mfam=#1% + \let\SI@tfam=\SI@defaultTfam + \fi\fi + \IfMbold{\def\SI@bold{\bfseries}}% + {\def\SI@bold{\mdseries}}% + \else%--- INLINE MATH ---------- + \ifx\f@family\temp@sf + \let\SI@mfam=\mathsf + \let\SI@tfam=\sffamily + \else\ifx\f@family\temp@tt + \let\SI@mfam=\mathtt + \let\SI@tfam=\ttfamily + \else + \let\SI@mfam=#1% + \let\SI@tfam=\SI@defaultTfam + \fi\fi + \IfTbold{\def\SI@bold{\boldmath}}% + {\def\SI@bold{\unboldmath}}% + \fi + \else%----- NORMAL TEXT -------------- + \ifx\f@family\temp@sf + \let\SI@mfam=\mathsf + \let\SI@tfam=\sffamily + \else\ifx\f@family\temp@tt + \let\SI@mfam=\mathtt + \let\SI@tfam=\ttfamily + \else + \let\SI@mfam=#1% + \let\SI@tfam=\SI@defaultTfam + \fi\fi + \IfTbold{\def\SI@bold{\boldmath}}% + {\def\SI@bold{\unboldmath}}% + \fi%----- END OF TEST -------------- + \text{% + \ifSIobeybold\SI@bold\else\unboldmath\mdseries\fi + \upshape\SI@tfam + $\SI@mfam{#2}$}% +\endgroup +\check@mathfonts} +\DeclareRobustCommand{\ensureupmath}{% + \ifupmath + \expandafter\@firstofone + \else + \expandafter\SIupmath + \fi} +\newcommand*{\SI@decsign}{{.}} +\newcommand*{\SIdecimalsign}[1]{\renewcommand*{\SI@decsign}{{#1}}} +\newcommand*{\SI@thousandsep}{{\,}} +\newcommand*{\SIthousandsep}[1]{\renewcommand*{\SI@thousandsep}{{#1}}} +\newcommand*{\SI@prod}{\ensuremath{{}\times{}}} +\newcommand*{\SIproductsign}[1]{\renewcommand*{\SI@prod}{\ensuremath{{}#1{}}}} +\newif\ifSIgroupfour +\SIgroupfourtrue +\def\SI@num#1{% + \SI@ifempt{#1}{}{% + \edef\SI@tmpa{\lowercase{\noexpand\SI@@num{\zap@space#1 \@empty}}}% + \SI@tmpa}} +\def\SI@@num#1{\SI@numsplit#1ee\SI@numexp\SI@realp\@empty} +\def\SI@numsplit#1e#2e#3#4#5{#4{#1}{#2}} +\def\SI@p@tst{+} +\def\SI@m@tst{-} +\def\SI@numexp#1#2{% + \SI@ifempt{#1}{}{% + \def\SI@tmpb{#1}% + \ifx\SI@tmpb\SI@p@tst\ensuremath{+}\else + \ifx\SI@tmpb\SI@m@tst\ensuremath{-}\else + \SI@realp{#1}{}\SI@prod% + \fi\fi}% + \ifmmode + 10^{\SI@realp{#2}{}}% + \else + 10\textsuperscript{\SI@realp{#2}{}}% + \fi} +\def\SI@realp#1#2{\SI@realpsplit#1..\SI@realfrc\SI@realc\@empty} +\def\SI@realpsplit#1.#2.#3#4#5{#4{#1}{#2}} +\def\SI@realc#1#2{\SI@realcsplit#1,,\SI@realfrc\SI@signedint\@empty} +\def\SI@realcsplit#1,#2,#3#4#5{#4{#1}{#2}} +\def\SI@realfrc#1#2{% + \SI@ifempt{#1}{\SI@int{0}}% + {\SI@signedint{#1}{}}% + \SI@decsign\SI@dec{#2}} +\def\SI@signedint#1#2{\SI@@signedint#1 } +\def\SI@@signedint#1#2 {% + \if +#1\ensuremath{+}% + \SI@ifempt{#2}{\SI@int{0}}{\SI@int{#2}}% + \else + \if -#1\ensuremath{-}% + \SI@ifempt{#2}{\SI@int{0}}{\SI@int{#2}}% + \else + \SI@int{#1#2}\fi \fi} +\def\SI@not@v#1{\SI@@not@v#1\@empty\@empty\@empty\@empty\@empty\@nil} +\def\SI@@not@v#1#2#3#4#5\@nil{% + \ifx\@empty#5\@empty + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\def\SI@int#1{% + \ifSIgroupfour + \SI@not@v{#1}{#1}{\SI@intfmt{}#1\@empty\@empty\@empty}% + \else + \SI@intfmt{}#1\@empty\@empty\@empty% + \fi} +\def\SI@intfmt#1#2#3#4{% + \ifx\@empty#2\@empty% + \SI@addthousandsep#1\relax + \else + \ifx\@empty#3\@empty% + \SI@addthousandsep\@empty\@empty#1#2\relax + \else + \ifx\@empty#4\@empty% + \SI@addthousandsep\@empty#1#2#3\relax + \else + \SI@intfmtafterfi{#1#2#3#4}% + \fi + \fi + \fi} +\def\SI@intfmtafterfi#1\fi\fi\fi{\fi\fi\fi\SI@intfmt{#1}} +\def\SI@addthousandsep#1#2#3#4{#1#2#3% + \if\relax#4\relax + \else + \SI@thousandsep\expandafter\SI@addthousandsep\expandafter#4% + \fi} +\def\SI@dec#1{% + \ifSIgroupfour + \SI@not@v{#1}{#1}{\SI@decfmt#1\@empty\@empty\@empty\@empty}% + \else + \SI@decfmt#1\@empty\@empty\@empty\@empty% + \fi} +\def\SI@decfmt#1#2#3#4{#1#2#3% + \ifx\@empty#4\@empty% + \else + \SI@thousandsep\expandafter\SI@decfmt\expandafter#4% + \fi} +\newcommand*{\SInum}[1]{{% + \let\SI@unitdot=\pnt% + \SIupmath[\SI@defaultNfam]{\SI@num{#1}}}} +\DeclareRobustCommand*{\num}{\@ifstar{\SI@num}{\SInum}} +\let\SI@degs=\relax +\let\SI@mins=\relax +\let\SI@secs=\relax +\DeclareRobustCommand{\ang}[1]{\SI@ang#1;;;\@nnil} +\def\SI@ang#1;#2;#3;#4\@nnil{% +\bgroup + \SI@ifempt{#3}{}{\def\SI@secs{\SInum{#3}\SIupmath{\arcsec}}% + \def\SI@mins{\SInum{0}\SIupmath{\arcmin}}% + \def\SI@degs{\SInum{0}\SIupmath{\arcdeg}}}% + \SI@ifempt{#2}{}{\def\SI@mins{\SInum{#2}\SIupmath{\arcmin}}% + \def\SI@degs{\SInum{0}\SIupmath{\arcdeg}}}% + \SI@ifempt{#1}{}{\def\SI@degs{\SInum{#1}\SIupmath{\arcdeg}}}% + \SI@degs\SI@mins\SI@secs +\egroup} +\newcommand*{\SI@unitsep}{\,} +\newcommand*{\SIunitsep}[1]{\renewcommand*{\SI@unitsep}{#1}} +\newcommand*{\SI@unitspace}{\,} +\newcommand*{\SIunitspace}[1]{\renewcommand*{\SI@unitspace}{#1}} +\newcommand*{\SI@unitdot}{{\cdot}} +\newcommand*{\SIunitdot}[1]{\renewcommand*{\SI@unitdot}{#1}} +\DeclareMathSymbol{\pnt}{\mathord}{letters}{58} %(\pnt = .) +{\catcode`\.=13 \gdef.{\SI@unitdot}} +\newcommand*{\SIunit}[1]{% +\begingroup% + \mathcode`.="8000% + \def~{\SI@unitspace}% + \SIupmath{#1}% +\endgroup} +\DeclareRobustCommand*{\SI}[2]{% + \SI@ifempt{#1}{}{\SInum{#1}\SI@unitsep}% + \SIunit{#2}} +\AtBeginDocument{% + \@ifpackageloaded{textcomp}{% + \providecommand*{\micro}{\ensureupmath{\mbox{\textmu}}}% + \providecommand*{\ohm}{\ensureupmath{\mbox{\textohm}}}% + \providecommand*{\degC}{\ensureupmath{\mbox{\textcelsius}}}% + \providecommand*{\degF}{\ensureupmath{\mbox{\textdegree F}}}% + \providecommand*{\arcdeg}{\ensureupmath{\mbox{\textdegree}}}% + \providecommand*{\angstrom}{\ensureupmath{\mbox{\capitalring{A}}}}% + }{% + \providecommand*{\micro}{\ensureupmath{\mu}}% + \providecommand*{\ohm}{\ensureupmath{\Omega}}% + \providecommand*{\degC}{% + \ensureupmath{{}^{\circ}\kern-\scriptspace C}}% + \providecommand*{\degF}{% + \ensureupmath{{}^{\circ}\kern-\scriptspace F}}% + \providecommand*{\arcdeg}{\ensureupmath{{}^{\circ}}}% + \providecommand*{\angstrom}{\ensureupmath{\mbox{\AA}}}% + }% + \providecommand*{\arcmin}{\ensureupmath{{}^{\prime}}}% + \providecommand*{\arcsec}{\ensureupmath{{}^{\prime\prime}}}% +} +\newtoks\ttoks@A +\newtoks\ttoks@B +\newcommand{\SIstyle}[1]{% + \@ifundefined{SIstyle#1}% + {\PackageError{SIstyle}{Style `#1' is not defined}% + {See SIstyle package documentation}}% + {\@nameuse{SIstyle#1}}} +\newcommand{\AddToSIstyle}{% + \@ifstar{\SI@s@addto@stl}{\SI@addto@stl}} +\newcommand{\SI@s@addto@stl}[1]{% + \expandafter\let\csname SIstyle#1\endcsname\relax + \SI@addto@stl{#1}} +\newcommand{\SI@addto@stl}[2]{% + \expandafter\SI@addto@list\csname SIstyle#1\endcsname{#2}} +\@onlypreamble\AddToSIstyle +\newcommand*{\SIstyleToLang}[2]{% + \expandafter\SI@addto@list + \csname extras#1\expandafter\endcsname + \csname SIstyle#2\endcsname} +\@onlypreamble\SIstyleToLang +\newcommand{\SI@addto@list}[2]{% + \ttoks@A{#2}% + \ifx#1\@undefined + \edef#1{\the\ttoks@A}% + \else + \ifx#1\relax + \edef#1{\the\ttoks@A}% + \else + \ttoks@B\expandafter{#1}% + \edef#1{\the\ttoks@B\the\ttoks@A}% + \fi + \fi + \ttoks@A{}\ttoks@B\ttoks@A} +\AddToSIstyle{USA}{% + \SIdecimalsign{.}% + \SIthousandsep{\,}% + \SIunitsep{\,}% + \SIunitdot{\cdot}% + \SIunitspace{\;}% + \SIproductsign{\times}% + \SIobeyboldfalse + \SIgroupfourtrue} +\AddToSIstyle{German}{% + \SIdecimalsign{,}% + \SIthousandsep{\,}% + \SIproductsign{\cdot}% + \SIunitsep{\,}% + \SIunitspace{\,}% + \SIunitdot{\cdot}% + \SIobeyboldfalse + \SIgroupfourtrue} +\AddToSIstyle{S-Africa}{% + \SIdecimalsign{,}% + \SIthousandsep{\,}% + \SIproductsign{\times}% + \SIunitsep{\,}% + \SIunitspace{\,}% + \SIunitdot{\cdot}% + \SIobeyboldfalse + \SIgroupfourtrue} +\endinput +%% +%% End of file `sistyle.sty'. |