summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/smartunits
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-02-05 23:35:16 +0000
committerKarl Berry <karl@freefriends.org>2016-02-05 23:35:16 +0000
commit58496e93da32b893f5958b37a5d1bf630a93dc15 (patch)
treea91b258e2dbd453712f8613574c9550492a5892c /Master/texmf-dist/tex/latex/smartunits
parentb0b816931ede90b5237dcb504755552bd5db7387 (diff)
smartunits (5feb16)
git-svn-id: svn://tug.org/texlive/trunk@39592 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/smartunits')
-rw-r--r--Master/texmf-dist/tex/latex/smartunits/smartunits.sty53
1 files changed, 40 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/latex/smartunits/smartunits.sty b/Master/texmf-dist/tex/latex/smartunits/smartunits.sty
index 5fd01f609ce..29ed4640e23 100644
--- a/Master/texmf-dist/tex/latex/smartunits/smartunits.sty
+++ b/Master/texmf-dist/tex/latex/smartunits/smartunits.sty
@@ -8,8 +8,8 @@
% http://tex.stackexchange.com/questions/241169/is-it-possible-in-latex-to-print-all-numbers-between-imperial-and-metric/241179#241179
\NeedsTeXFormat{LaTeX2e}
-\def\smart@version{Version 1.1}
-\ProvidesPackage{smartunits}[2016/02/03 \smart@version\space- Smart conversion between metric and Imperial units]
+\def\smart@version{Version 1.2 -- 2016/02/05}
+\ProvidesPackage{smartunits}[2016/02/05 \smart@version\space- Smart conversion between metric and Imperial units]
\RequirePackage{siunitx,pgfmath,pgfkeys}
% a global pgfkeyssetvalue from Martin Scharrer's answer to http://tex.stackexchange.com/questions/15204
@@ -40,7 +40,7 @@
system/.initial=usa,% for purely demographic reasons
usa/.style={system=usa},%
uk/.style={system=uk},%
- %%% for local changes to the siunitz precision
+ %%% for local changes to the siunitx precision
figures/.code={\sisetup{round-mode=figures, round-precision=#1}},
places/.code={\sisetup{round-mode=places, round-precision=#1}},
%%%%%%%%%%%%%%%%%%%% conversion routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -74,7 +74,9 @@
weight/imperial/.style={/SmartUnit/conversion={pound}{kg}{0}{2.2046226}{0}{\text{lbs}}},%
%%%% convert=temperature: C <-> F %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
celsius/.style={convert=temperature, unit celsius=#1},%
+ C/.style={convert=temperature, unit celsius=#1},%
fahrenheit/.style={convert=temperature, unit fahrenheit=#1},%
+ F/.style={convert=temperature, unit fahrenheit=#1},%
temperature/metric/.style={/SmartUnit/conversion={celsius}{fahrenheit}{-32}{5/9}{0}{\degreeCelsius}},%
temperature/imperial/.style={/SmartUnit/conversion={fahrenheit}{celsius}{0}{9/5}{32}{\si{\degree}\text{F}}},%
%%%% convert=length: cm <-> feet and inches %%%%%%%%%%%%%%%%%%%%%%%%%
@@ -86,24 +88,24 @@
{\pgfkeysifdefined{/SmartUnit/unit inches}{\pgfmathsetmacro{\smart@tmp}{2.54*\smart@val{unit inches}}}{\def\smart@tmp{0}}%
\pgfkeysifdefined{/SmartUnit/unit feet}{\pgfmathparse{\smart@tmp+30.84*\smart@val{unit feet}}}{\let\pgfmathresult\smart@tmp}%
}%
- \SI{\pgfmathresult}{cm}%
+ \SI{\pgfmathresult}{\cm}%
},
%%%% slightly tricker as we have to convert centimeters to feet and inches
length/imperial/.code={% called via /SmartUnit/printunit -> /SmartUnit/output with convert=length
\pgfkeysifdefined{/SmartUnit/unit inches}{\pgfkeysifdefined{/SmartUnit/unit feet}{\SI{\smart@val{unit feet}}{\arcminute}\enspace\SI{\smart@val{unit inches}}{\arcsecond}}%
- {\enspace\SI{\smart@val{unit inches}}{\arcsecond}}%
+ {\enspace\SI{\smart@val{unit inches}}{\arcsecond}}%
}%
{\pgfkeysifdefined{/SmartUnit/unit feet}{\SI{\smart@val{unit feet}}{\arcminute}}%
{\pgfmathsetmacro{\smart@tmp}{0.39370079*\smart@val{unit cm}}% centimeters -> inches
\pgfmathparse{greater(\smart@tmp,11)}%
\ifnum\pgfmathresult=1%
- \pgfmathparse{int(\smart@tmp/12)}\SI{\pgfmathresult}{\arcminute}%
- \pgfmathparse{int(\smart@tmp-12*\pgfmathresult)}\enspace\SI{\pgfmathresult}{\arcsecond}%
+ \pgfmathparse{int(\smart@tmp/12)}\SI[round-mode=places,round-precision=0]{\pgfmathresult}{\arcminute}%
+ \pgfmathparse{\smart@tmp-12*\pgfmathresult}\enspace\SI{\pgfmathresult}{\arcsecond}%
\else%
- \SI{\smart@tmp}{\arcminute}%
+ \SI{\smart@tmp}{\arcsecond}%
\fi%
}%
- }%
+ }%
},%
%%%% convert=time: 24-hour times versus 12-hour time %%%%%%%%%%%%%%%%%%%%%%%%%
am/.style={convert=time, unit am=1},%
@@ -141,7 +143,25 @@
\newcommand\SmartUnitSettings[1]{\pgfkeys{/SmartUnit,#1}}
\endinput
-%% End of file `printunits.sty'.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% CHANGE LOG
+%%
+%% Version 1.2
+%% - corrections to the documentation and in particular to the incorrect conversion
+%% of 20 C to Fahrenheit as reported by Barbara Beeton
+%% - added shorthands C and F for temperature conversions
+%% - fixed bug that resulted in incorrect unit being printed for inches in length
+%% conversions with no feet and forced feet to always be printed as integers
+%%
+%% Version 1.1
+%% - initial release to ctan
+%%
+%% Version 1.0
+%% - initial version based on tex.stackexchange.com question
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Copyright (C) 2016 by Andrew Mathas <andrew.mathas@gmail.com>
%%
@@ -155,9 +175,16 @@
%% This work is "maintained" (as per LPPL maintenance status) by
%% Andrew Mathas.
%%
-%% This work consists of the files smartunits.sty
-%% smartunits.tex
-%% README.md
+%% This work consists of the files:
+%% smartunits.sty
+%% smartunits.tex
+%% smartunits.pdf
+%% README.md
%%
%% Copyright (c) 2016 Andrew Mathas <andrew.mathas@gmail.com>
%% end of smartunits.sty
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%
+%% End of file `smartunits.sty'.
+%%