diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/numprint/nbaseprt.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/numprint/nbaseprt.sty | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/numprint/nbaseprt.sty b/Master/texmf-dist/tex/latex/numprint/nbaseprt.sty new file mode 100644 index 00000000000..fa6d570a341 --- /dev/null +++ b/Master/texmf-dist/tex/latex/numprint/nbaseprt.sty @@ -0,0 +1,190 @@ +%% +%% This is file `nbaseprt.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% nbaseprt.dtx (with options: `package') +%% +%% numprint package +%% +%% Copyright 2000--2005 Harald Harders +%% +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN +%% archives in directory macros/latex/base/lppl.txt; either +%% version 1 of the License, or any later version. +%% +%% h.harders@tu-bs.de +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{nbaseprt} + [2004/12/14 v0.11 Print numbers with numerical bases (HH)] +\typeout{^^J*************************************************************} +\PackageWarningNoLine{nbaseprt}{This version of nbaseprt.sty is a BETA + VERSION.\MessageBreak + The main command \string\nbaseprint\space will stay stable + but\MessageBreak + all configuration commands and the output of\MessageBreak + \string\nbaseprint\space may change in future.\MessageBreak + Please give me feedback what can be improved and if\MessageBreak + the abbreviations for the different number bases are\MessageBreak + correct} +\typeout{*************************************************************^^J} +\DeclareOption{np}{% + \newcommand*\nbp{\nbaseprint}% + \PassOptionsToPackage{np}{numprint}% +} +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{numprint}} +\ProcessOptions\relax +\RequirePackage{numprint} +\RequirePackage{ifthen} +\newcommand*\nbprt@base{} +\newcommand*\nbprt@number{} +\newcommand*\nbprt@testbase{} +\def\nbprt@testbase#1#2#3\@empty{% + \ifthenelse{\equal{#1#2}{0x}\or\equal{#1#2}{0X}\or\equal{#1}{"}}{% + \gdef\nbprt@base{hex}% + \ifthenelse{\equal{#1}{"}}{% + \edef\nbprt@number{#2#3}% + }{% + \edef\nbprt@number{#3}% + }% + }{% + \ifthenelse{\equal{#1#2}{0o}\or\equal{#1#2}{0O}\or\equal{#1}{'}}{% + \gdef\nbprt@base{oct}% + \ifthenelse{\equal{#1}{'}}{% + \edef\nbprt@number{#2#3}% + }{% + \edef\nbprt@number{#3}% + }% + }{% + \ifthenelse{\equal{#1#2}{0d}\or\equal{#1#2}{0D}}{% + \gdef\nbprt@base{dec}% + \edef\nbprt@number{#3}% + }{% + \ifthenelse{\equal{#1#2}{0b}\or\equal{#1#2}{0B}}{% + \gdef\nbprt@base{bin}% + \edef\nbprt@number{#3}% + }{% + \def\nbprt@base{dec}% + \edef\nbprt@number{#1#2#3}% + \nbprt@ishex#1#2#3h\@empty\@empty + \nbprt@isHex#1#2#3H\@empty\@empty + \nbprt@isoct#1#2#3o\@empty\@empty + \nbprt@isOct#1#2#3O\@empty\@empty + }% + }% + }% + }% + \expandafter\nbprt@testsign\nbprt@number\@empty\@empty\@empty + \def\nbprt@string{}% + \@tempcnta=0 + \@tempcntb=0 + \expandafter\nbprt@parsenum\nbprt@number\@empty + \whiledo{\the\@tempcntb<\nprt@lpaddigits}{% + \ifnum\@tempcnta=\csname nbprt@digitgroup@\nbprt@base\endcsname\relax + \edef\nbprt@string{\nprt@separator@before\nbprt@string}% + \@tempcnta=0 + \fi + \edef\nbprt@string{\nprt@lpadchar\nbprt@string}% + \advance\@tempcntb 1 + \advance\@tempcnta 1 + }% + \ifnbprt@pretext + \csname nbprt@pretext@\nbprt@base\endcsname + \nbprt@presep + \fi + \nprt@printsign{mantissa}\nbprt@sign\@empty + \nbprt@string + \ifnbprt@pretext + \else + \nbprt@postsep + \csname nbprt@posttext@\nbprt@base\endcsname + \fi +} +\def\nbprt@testsign#1#2#3\@empty{% + \nprt@IfCharInString{#1}{\nprt@signlist}{% + \edef\nbprt@number{#2#3}% + \edef\nbprt@sign{#1}% + \ifx\nbprt@sign\nprt@plus@test + \def\nprt@tmp{#2}% + \ifx\nprt@tmp\nprt@minus@test + \edef\nbprt@sign{+-}% + \edef\nbprt@number{#3}% + \fi + \else + \ifx\nbprt@sign\nprt@plusminus@test + \edef\nbprt@sign{+-}% + \fi + \fi + }{% + \edef\nbprt@number{#1#2#3}% + }% +} +\def\nbprt@ishex#1h#2\@empty{% + \ifthenelse{\equal{#2}{h}}{% + \def\nbprt@base{hex}% + \edef\nbprt@number{#1}% + }{}% +} +\def\nbprt@isHex#1H#2\@empty{% + \ifthenelse{\equal{#2}{H}}{% + \def\nbprt@base{hex}% + \edef\nbprt@number{#1}% + }{}% +} +\def\nbprt@isoct#1o#2\@empty{% + \ifthenelse{\equal{#2}{o}}{% + \def\nbprt@base{oct}% + \edef\nbprt@number{#1}% + }{}% +} +\def\nbprt@isOct#1O#2\@empty{% + \ifthenelse{\equal{#2}{O}}{% + \def\nbprt@base{oct}% + \edef\nbprt@number{#1}% + }{}% +} +\def\nbprt@parsenum#1#2\@empty{% + \ifthenelse{\equal{#2}{\@empty}}{}{% + \expandafter\nbprt@parsenum#2\@empty + }% + \ifnum\@tempcnta=\csname nbprt@digitgroup@\nbprt@base\endcsname\relax + \edef\nbprt@string{\nprt@separator@before\nbprt@string}% + \@tempcnta=0 + \fi + \edef\nbprt@string{% + \uppercase{\ifmmode\mathrm{#1}\else#1\fi}% + \nbprt@string}% + \advance\@tempcntb 1 + \advance\@tempcnta 1 +} +\newif\ifnbprt@pretext +\newcommand*\nbasepretext{\nbprt@pretexttrue} +\newcommand*\nbaseposttext{\nbprt@pretextfalse} +\def\nbprt@pretext@hex{0\ifmmode\mathrm{x}\else x\fi}% +\def\nbprt@pretext@oct{0\ifmmode\mathrm{o}\else o\fi}% +\def\nbprt@pretext@dec{0\ifmmode\mathrm{d}\else d\fi}% +\def\nbprt@pretext@bin{0\ifmmode\mathrm{b}\else b\fi}% +\def\nbprt@presep{\,}% +\def\nbprt@posttext@hex{\ifmmode\mathrm{h}\else h\fi}% +\def\nbprt@posttext@oct{\ifmmode\mathrm{o}\else o\fi}% +\def\nbprt@posttext@dec{\ifmmode\mathrm{d}\else d\fi}% +\def\nbprt@posttext@bin{\ifmmode\mathrm{b}\else b\fi}% +\def\nbprt@postsep{\,}% +\nbasepretext +\def\nbprt@digitgroup@hex{2}% +\def\nbprt@digitgroup@oct{3}% +\def\nbprt@digitgroup@dec{3}% +\def\nbprt@digitgroup@bin{4}% +\DeclareRobustCommand*\nbaseprint[1]{% + \edef\nbprt@number{#1}% + \def\nbprt@sign{}% + \expandafter\nbprt@testsign\nbprt@number\@empty\@empty\@empty + \expandafter\nbprt@testbase\nbprt@number\@empty\@empty\@empty +} + +\endinput +%% +%% End of file `nbaseprt.sty'. |