summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pst-calculate
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-02-04 21:39:47 +0000
committerKarl Berry <karl@freefriends.org>2018-02-04 21:39:47 +0000
commitbf12dd1f8724f65d1116fbfb6d9a94cfb49c88ac (patch)
tree883e981258ff8dc56a4c57dfdd554ad534f771b0 /Master/texmf-dist/tex/latex/pst-calculate
parent371ddd4c16bf1b16d9bd81caf9525e53128d3087 (diff)
pst-calculate (4feb18)
git-svn-id: svn://tug.org/texlive/trunk@46544 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pst-calculate')
-rw-r--r--Master/texmf-dist/tex/latex/pst-calculate/pst-calculate.sty57
1 files changed, 57 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/pst-calculate/pst-calculate.sty b/Master/texmf-dist/tex/latex/pst-calculate/pst-calculate.sty
new file mode 100644
index 00000000000..de95bfda10b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/pst-calculate/pst-calculate.sty
@@ -0,0 +1,57 @@
+%% $Id: pst-calculate.sty 723 2018-02-04 12:45:52Z 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.01}
+\ProvidesPackage{pst-calculate}[%
+ 2018/02/04 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
+