blob: 72e9a4d0a0f1879d196a8c0accfc1ffdea238a40 (
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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, 2007, 2008, 2012 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.
%%
%% harald.harders@gmx.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'.
|