blob: 82d5b0be21aa96e9ae3a787b119e8a2969e22d03 (
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
|
%% $Id: pst-calculate.sty 920 2019-01-24 20:24:45Z herbert $
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory macros/latex/base/lppl.txt.
%% Either version 1.3 or, at your option, any later version.
%%
% Copyright 2018 Herbert Voss hvoss@tug.org
%%
\def\pstcalculate@version{0.02}
\ProvidesPackage{pst-calculate}[%
2019/01/24 v. \pstcalculate@version (Herbert Voss) Support for
caculations with floating point numbers.]
%
\RequirePackage{xkeyval}
\newif\ifcalc@useComma \calc@useCommafalse
\DeclareOptionX{useComma}[true]{\@nameuse{calc@useComma#1}}
%
\let\calc@roundDigit\relax
\DeclareOptionX{roundDigit}{\def\calc@roundDigit{#1}}
\DeclareOptionX*{\PassOptionsToPackage\CurrentOption{siunitx}}
\ProcessOptionsX\relax
\RequirePackage{xparse,siunitx}
\ifx\relax\calc@roundDigit \else
\sisetup{round-mode=places,round-precision=\calc@roundDigit}%
\fi
\ifcalc@useComma
\sisetup{output-decimal-marker={,}}
\fi
\ExplSyntaxOn
\DeclareExpandableDocumentCommand\ps@Calculate{m}{\fp_to_decimal:n{#1}}%
%\DeclareExpandableDocumentCommand\ps@@Calculate{m}{\fp_to_int:n{#1}}%
%\DeclareExpandableDocumentCommand\ps@@@Calculate{m}{\fp_to_scientific:n{#1}}%
\ExplSyntaxOff
\def\pst@calculateType{0}
\def\psCalculate{\@ifnextchar[\psCalculate@i{\psCalculate@i[]}}
\def\psCalculate@i[#1]#2{%
\begingroup
\ifx\relax#1\relax\else\sisetup{#1}\fi
\num{\ps@Calculate{#2}}
\endgroup
\ignorespaces
}
\let\pscalculate\ps@Calculate
%%
\endinput
|