summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex-dev/tools/calc.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex-dev/tools/calc.sty')
-rw-r--r--Master/texmf-dist/tex/latex-dev/tools/calc.sty289
1 files changed, 289 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex-dev/tools/calc.sty b/Master/texmf-dist/tex/latex-dev/tools/calc.sty
new file mode 100644
index 00000000000..175d5a48a7d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex-dev/tools/calc.sty
@@ -0,0 +1,289 @@
+%%
+%% 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.
+%%
+%% The source is maintained by the LaTeX Project team and bug
+%% reports for it can be opened at https://latex-project.org/bugs/
+%% (but please observe conditions on bug reports sent to that address!)
+%%
+%%
+%% Copyright (C) 1993-2019
+%% 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.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/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--2007
+%% 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}
+ [2017/05/25 v4.3 Infix arithmetic (KKT,FJ)]
+\def\calc@assign@generic#1#2#3#4{\let\calc@A#1\let\calc@B#2%
+ \calc@open(#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}}}%
+ \def\stepcounter#1{\@ifundefined {c@#1}%
+ {\@nocounterr {#1}}%
+ {\global\advance\csname c@#1\endcsname \@ne
+ \begingroup
+ \let\@elt\@stpelt \csname cl@#1\endcsname
+ \endgroup}}%
+\@ifpackageloaded{amstext}{%
+ \expandafter\def\expandafter\stepcounter
+ \expandafter#\expandafter1\expandafter{%
+ \expandafter\iffirstchoice@\stepcounter{#1}\fi
+ }
+ \expandafter\def\expandafter\addtocounter
+ \expandafter#\expandafter1\expandafter#\expandafter2\expandafter{%
+ \expandafter\iffirstchoice@\addtocounter{#1}{#2}\fi
+ }
+}{}
+\DeclareRobustCommand\setlength{\calc@assign@skip}
+\DeclareRobustCommand\addtolength[1]{\calc@assign@skip{\advance#1}}
+\def\calc@pre@scan#1{%
+ \expandafter\@calc@pre@scan\romannumeral-`\a#1}
+\def\@calc@pre@scan#1{%
+ \ifx(#1%
+ \expandafter\calc@open
+ \else
+ \ifx\widthof#1%
+ \expandafter\expandafter\expandafter\calc@textsize
+ \else
+ \ifx\maxof#1%
+ \expandafter\expandafter\expandafter\expandafter
+ \expandafter\expandafter\expandafter\calc@maxmin@addsub
+ \else
+ \calc@numeric% no \expandafter needed for this one.
+ \fi
+ \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}
+\@for\reserved@a:=widthof,heightof,depthof,totalheightof,maxof,minof\do
+{\@ifundefined{\reserved@a}{}{%
+ \PackageError{calc}{%
+ The\space calc\space package\space reserves\space the\space
+ command\space name\space `\@backslashchar\reserved@a'\MessageBreak
+ but\space it\space has\space already\space been\space defined\space
+ with\space the\space meaning\MessageBreak
+ `\expandafter\meaning\csname\reserved@a\endcsname'.\MessageBreak
+ This\space original\space definition\space will\space be\space lost}%
+ {If\space you\space need\space a\space command\space with\space
+ this\space definition,\space you\space must\space use\space a\space
+ different\space name.}}%
+}
+\let\widthof\ignorespaces
+\let\heightof\ignorespaces
+\let\depthof\ignorespaces
+\let\totalheightof\ignorespaces
+\def\calc@textsize #1#2{%
+ \begingroup
+ \let\widthof\wd
+ \let\heightof\ht
+ \let\depthof\dp
+ \def\totalheightof{\ht\dp}%
+ \expandafter\@settodim\expandafter{#1}%
+ {\global\calc@A}%
+ {%
+ \let\widthof\ignorespaces
+ \let\heightof\ignorespaces
+ \let\depthof\ignorespaces
+ \let\totalheightof\ignorespaces
+ #2}%
+ \endgroup
+ \calc@post@scan}
+\def\calc@post@scan#1{%
+ \expandafter\@calc@post@scan\romannumeral-`\a#1}
+\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
+ \ifx#1\relax\let\calc@next\calc@post@scan \else
+ \def\calc@next{\calc@error#1}%
+ \fi
+ \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
+ \ifx\maxof#1\let\calc@next\calc@maxmin@multiply \else
+ \let\calc@next\calc@multiply
+ \fi
+ \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
+ \ifx\maxof#1\let\calc@next\calc@maxmin@divide \else
+ \let\calc@next\calc@divide
+ \fi
+ \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}}
+\newcount\calc@Ccount
+\let\calc@numerator=\calc@Bcount
+\let\calc@denominator=\calc@Ccount
+\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}}
+\let\maxof\@@italiccorr
+\let\minof\@@italiccorr
+\newskip\calc@Cskip
+\newif\ifcalc@count@
+\def\calc@maxmin@addsub#1#2#3{\begingroup
+ \ifx\calc@A\calc@Acount%
+ \calc@count@true
+ \else
+ \calc@count@false
+ \fi
+ \calc@maxmin@generic#1{#2}{#3}%
+ \endgroup
+ \calc@post@scan
+}
+\def\calc@maxmin@generic#1#2#3{%
+ \begingroup
+ \ifcalc@count@
+ \calc@assign@count\calc@Ccount{#2}%
+ \calc@assign@count\calc@Bcount{#3}%
+ \def\minof{<}\def\maxof{>}%
+ \global\calc@A\ifnum\calc@Ccount#1\calc@Bcount
+ \calc@Ccount\else\calc@Bcount\fi
+ \else
+ \calc@assign@skip\calc@Cskip{#2}%
+ \calc@assign@skip\calc@Bskip{#3}%
+ \def\minof{<}\def\maxof{>}%
+ \global\calc@A\ifdim\calc@Cskip#1\calc@Bskip
+ \calc@Cskip\else\calc@Bskip\fi
+ \fi
+ \endgroup
+}
+\def\calc@maxmin@divmul#1#2#3#4{%
+ \endgroup\begingroup
+ \calc@count@true
+ \aftergroup#1%
+ \calc@maxmin@generic#2{#3}{#4}%
+ \endgroup\begingroup
+ \calc@post@scan
+}
+\def\calc@maxmin@multiply{\calc@maxmin@divmul\calc@multiplyBbyA}
+\def\calc@maxmin@divide {\calc@maxmin@divmul\calc@divideBbyA}
+\def\calc@error#1{%
+ \PackageError{calc}%
+ {`#1' invalid at this point}%
+ {I expected to see one of: + - * / )}}
+\def\@settodim#1#2#3{%
+ \setbox\@tempboxa\hbox{{#3}}%
+ \dimen@ii=\z@
+ \@tf@r\reserved@a #1\do{%
+ \advance\dimen@ii\reserved@a\@tempboxa}%
+ #2=\dimen@ii
+ \setbox\@tempboxa\box\voidb@x}
+\def\settototalheight{\@settodim{\ht\dp}}
+\endinput
+%%
+%% End of file `calc.sty'.