blob: d0b1a78fed974372fb61f0aa8ed6b8bf7884b3b3 (
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
|
%%
%% This is file `calc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% calc.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
%% The LaTeX3 Project and any individual authors listed elsewhere
%% in this file.
%%
%% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'.
%% --------------------------------------------------------------------------
%%
%% It 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 this 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 file may only be distributed together with a copy of the LaTeX
%% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle'
%% without such generated files.
%%
%% The list of all files belonging to the LaTeX `Tools Bundle' is
%% given in the file `manifest.txt'.
%%
%% File `calc.dtx'.
%% Copyright (C) 1992--1995
%% Kresten Krab Thorup and Frank Jensen.
%% Copyright (C) 1997--1998
%% Kresten Krab Thorup, Frank Jensen and the LaTeX3 Project.
%%
%% The original authors (fj@hugin.dk and krab@daimi.aau.dk) have
%% contributed this package to the LaTeX distribution.
%% Problems with this package should now be sent using latexbug.tex to
%% the normal LaTeX bug report address.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{calc}
[1998/07/07 v4.1b Infix arithmetic (KKT,FJ)]
\def\calc@assign@generic#1#2#3#4{\let\calc@A#1\let\calc@B#2%
\expandafter\calc@open\expandafter(#4!%
\global\calc@A\calc@B\endgroup#3\calc@B}
\def\calc@assign@count{\calc@assign@generic\calc@Acount\calc@Bcount}
\def\calc@assign@dimen{\calc@assign@generic\calc@Adimen\calc@Bdimen}
\def\calc@assign@skip{\calc@assign@generic\calc@Askip\calc@Bskip}
\newcount\calc@Acount \newcount\calc@Bcount
\newdimen\calc@Adimen \newdimen\calc@Bdimen
\newskip\calc@Askip \newskip\calc@Bskip
\def\setcounter#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}%
{\calc@assign@count{\global\csname c@#1\endcsname}{#2}}}
\def\addtocounter#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}%
{\calc@assign@count{\global\advance\csname c@#1\endcsname}{#2}}}
\DeclareRobustCommand\setlength{\calc@assign@skip}
\DeclareRobustCommand\addtolength[1]{\calc@assign@skip{\advance#1}}
\def\calc@pre@scan#1{%
\ifx(#1%
\expandafter\calc@open
\else
\ifx\widthof#1%
\expandafter\expandafter\expandafter\calc@textsize
\else
\calc@numeric% no \expandafter needed for this one.
\fi
\fi
#1}
\def\calc@open({\begingroup\aftergroup\calc@initB
\begingroup\aftergroup\calc@initB
\calc@pre@scan}
\def\calc@initB{\calc@B\calc@A}
\def\calc@numeric{\afterassignment\calc@post@scan \global\calc@A}
\newcommand\widthof{}
\let\widthof\ignorespaces
\newcommand\heightof{}
\let\heightof\ignorespaces
\newcommand\depthof{}
\let\depthof\ignorespaces
\def\calc@textsize #1#2{%
\begingroup
\let\widthof\wd
\let\heightof\ht
\let\depthof\dp
\@settodim #1%
{\global\calc@A}%
{%
\let\widthof\ignorespaces
\let\heightof\ignorespaces
\let\depthof\ignorespaces
#2}%
\endgroup
\calc@post@scan}
\def\calc@post@scan#1{%
\ifx#1!\let\calc@next\endgroup \else
\ifx#1+\let\calc@next\calc@add \else
\ifx#1-\let\calc@next\calc@subtract \else
\ifx#1*\let\calc@next\calc@multiplyx \else
\ifx#1/\let\calc@next\calc@dividex \else
\ifx#1)\let\calc@next\calc@close \else \calc@error#1%
\fi
\fi
\fi
\fi
\fi
\fi
\calc@next}
\def\calc@add{\calc@generic@add\calc@addAtoB}
\def\calc@subtract{\calc@generic@add\calc@subtractAfromB}
\def\calc@generic@add#1{\endgroup\global\calc@A\calc@B\endgroup
\begingroup\aftergroup#1\begingroup\aftergroup\calc@initB
\calc@pre@scan}
\def\calc@addAtoB{\advance\calc@B\calc@A}
\def\calc@subtractAfromB{\advance\calc@B-\calc@A}
\ifx\real\@undefined\let\real\relax\fi
\ifx\ratio\@undefined\let\ratio\relax\fi
\def\calc@ratio@x{\ratio}
\def\calc@real@x{\real}
\def\calc@multiplyx#1{\def\calc@tmp{#1}%
\ifx\calc@tmp\calc@ratio@x \let\calc@next\calc@ratio@multiply \else
\ifx\calc@tmp\calc@real@x \let\calc@next\calc@real@multiply \else
\let\calc@next\calc@multiply
\fi
\fi
\calc@next#1}
\def\calc@dividex#1{\def\calc@tmp{#1}%
\ifx\calc@tmp\calc@ratio@x \let\calc@next\calc@ratio@divide \else
\ifx\calc@tmp\calc@real@x \let\calc@next\calc@real@divide \else
\let\calc@next\calc@divide
\fi
\fi
\calc@next#1}
\def\calc@multiply{\calc@generic@multiply\calc@multiplyBbyA}
\def\calc@divide{\calc@generic@multiply\calc@divideBbyA}
\def\calc@generic@multiply#1{\endgroup\begingroup
\let\calc@A\calc@Acount \let\calc@B\calc@Bcount
\aftergroup#1\calc@pre@scan}
\def\calc@multiplyBbyA{\multiply\calc@B\calc@Acount}
\def\calc@divideBbyA{\divide\calc@B\calc@Acount}
\def\calc@close
{\endgroup\global\calc@A\calc@B
\endgroup\global\calc@A\calc@B
\calc@post@scan}
\def\calc@ratio@multiply\ratio{\calc@ratio@evaluate}
\def\calc@ratio@divide\ratio#1#2{\calc@ratio@evaluate{#2}{#1}}
\let\calc@numerator=\calc@Bcount
\newcount\calc@denominator
\def\calc@ratio@evaluate#1#2{%
\endgroup\begingroup
\calc@assign@dimen\calc@numerator{#1}%
\calc@assign@dimen\calc@denominator{#2}%
\gdef\calc@the@ratio{}%
\ifnum\calc@numerator<0 \calc@numerator-\calc@numerator
\gdef\calc@the@ratio{-}%
\fi
\ifnum\calc@denominator<0 \calc@denominator-\calc@denominator
\xdef\calc@the@ratio{\calc@the@ratio-}%
\fi
\calc@Acount\calc@numerator
\divide\calc@Acount\calc@denominator
\xdef\calc@the@ratio{\calc@the@ratio\number\calc@Acount.}%
\calc@next@digit \calc@next@digit \calc@next@digit
\calc@next@digit \calc@next@digit \calc@next@digit
\endgroup
\calc@multiply@by@real\calc@the@ratio
\begingroup
\calc@post@scan}
\def\calc@next@digit{%
\multiply\calc@Acount\calc@denominator
\advance\calc@numerator -\calc@Acount
\multiply\calc@numerator 10
\calc@Acount\calc@numerator
\divide\calc@Acount\calc@denominator
\xdef\calc@the@ratio{\calc@the@ratio\number\calc@Acount}}
\def\calc@multiply@by@real#1{\calc@Bdimen #1\calc@B \calc@B\calc@Bdimen}
\def\calc@real@multiply\real#1{\endgroup
\calc@multiply@by@real{#1}\begingroup
\calc@post@scan}
\def\calc@real@divide\real#1{\calc@ratio@evaluate{1pt}{#1pt}}
\def\calc@error#1{%
\PackageError{calc}%
{`#1' invalid at this point}%
{I expected to see one of: + - * / )}}
\endinput
%%
%% End of file `calc.sty'.
|