summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pst-calculate/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/pst-calculate/latex
Initial commit
Diffstat (limited to 'macros/latex/contrib/pst-calculate/latex')
-rw-r--r--macros/latex/contrib/pst-calculate/latex/pst-calculate.sty57
1 files changed, 57 insertions, 0 deletions
diff --git a/macros/latex/contrib/pst-calculate/latex/pst-calculate.sty b/macros/latex/contrib/pst-calculate/latex/pst-calculate.sty
new file mode 100644
index 0000000000..82d5b0be21
--- /dev/null
+++ b/macros/latex/contrib/pst-calculate/latex/pst-calculate.sty
@@ -0,0 +1,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
+