summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/smartunits/README.md21
-rw-r--r--Master/texmf-dist/doc/latex/smartunits/smartunits.pdfbin331493 -> 336458 bytes
-rw-r--r--Master/texmf-dist/doc/latex/smartunits/smartunits.tex30
-rw-r--r--Master/texmf-dist/tex/latex/smartunits/smartunits.sty53
4 files changed, 76 insertions, 28 deletions
diff --git a/Master/texmf-dist/doc/latex/smartunits/README.md b/Master/texmf-dist/doc/latex/smartunits/README.md
index 1942639f661..e68f705ed0b 100644
--- a/Master/texmf-dist/doc/latex/smartunits/README.md
+++ b/Master/texmf-dist/doc/latex/smartunits/README.md
@@ -2,7 +2,8 @@ smartunits
==========
A [LaTeX](http://en.wikipedia.org/wiki/LaTeX) package that implements
-automatic conversions between (some) metric and Imperial units.
+automatic conversions between (some) metric and Imperial units. All units are
+printed using siuntx
Example
-------
@@ -12,14 +13,22 @@ Example
\usepackage{smartunits}
\begin{document}
\SmartUnitSettings{metric imperial, places=1}
- \SmartUnit{cm=10} % 10 cm (4')
- \SmartUnit{celsius=20} % 20 C (43 F)
- \SmartUnit{miles=5} % 8 km (5 mi)
- \SmartUnit{miles=5, precision=1} % 8.0 km (5 mi)
- \SmartUnit{miles=5, km=7} % 7 km (5 mi)
+ \SmartUnit{km=100.0,figures=1} % 100 km (60 mi)
+ \SmartUnit{miles=62.15,places=1} % 100 km (62.2 mi)
+ \SmartUnit{cm=10} % 10 cm (3.9")
+ \SmartUnit{celsius=20} % 20 C (68.0 F)
+ \SmartUnit{miles=5.0} % 8.0 km (5.0 mi)
+ \SmartUnit{miles=5.0, figures=1} % 8 km (5 mi)
+ \SmartUnit{hours=0, minutes=59} % 0:59 (12:59 AM)
+ \SmartUnit{hours=12, minutes=12} % 12:12 (12:12 PM)
+ \SmartUnit{kg=10.0, places=1} % 10.0kg (22.0 lbs)
+ \SmartUnit{pound=10.0,figures=1} % 5kg (10 lbs)
+ \SmartUnit{l=10.0, places=1} % 10.0l (2.6gal)
+ \SmartUnit{L=10.0, places=1,uk} % 10.0L (2.2gal)
\end{document}
```
+
Units supported
---------------
diff --git a/Master/texmf-dist/doc/latex/smartunits/smartunits.pdf b/Master/texmf-dist/doc/latex/smartunits/smartunits.pdf
index eb81116ba63..e55b6217b28 100644
--- a/Master/texmf-dist/doc/latex/smartunits/smartunits.pdf
+++ b/Master/texmf-dist/doc/latex/smartunits/smartunits.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/smartunits/smartunits.tex b/Master/texmf-dist/doc/latex/smartunits/smartunits.tex
index 78c23ee12a0..fe57502fbd4 100644
--- a/Master/texmf-dist/doc/latex/smartunits/smartunits.tex
+++ b/Master/texmf-dist/doc/latex/smartunits/smartunits.tex
@@ -107,8 +107,9 @@
Imperial units (there is no error checking, however). Depending on
the (global) settings the unit will be printed either as a metric
unit, or as an Imperial unit, or both. If the required unit is not
- given as an argument to \Verb|\SmartUnit| then it is computed. The
- units are printed using \ctan{siunitx}, so the formatting of the
+ given as an argument to \Verb|\SmartUnit| then it is computed.
+
+ The units are printed using \ctan{siunitx}, so the formatting of the
units can be controlled using \Verb|\sisetup| together with
formatting parameters from \ctan{siunitx}. Some aspects of the
formatting can be controlled ``locally'' using \Verb|\SmartUnit| and
@@ -136,6 +137,7 @@
\SmartUnitSettings{places=2} % Some global settings < \SmartUnitSettings{places=2} >
\SmartUnit{metric imperial} % Output format: metric (Imperial) < \SmartUnit{metric imperial} >
\SmartUnit{cm=10} % < \SmartUnit{cm=10} >
+ \SmartUnit{cm=66} % < \SmartUnit{cm=66} >
\SmartUnit{feet=4,inches=3} % < \SmartUnit{feet=4,inches=3} >
\SmartUnit{celsius=20} % < \SmartUnit{celsius=20} >
\SmartUnit{metric} % Output format: metric < \SmartUnit{metric} >
@@ -223,6 +225,8 @@
\end{lstlisting}
\item[Length -- cm, inches, feet]
+ Feet are always printed as integers. Significant figures/places
+ are applied only to the printing of inches.
\begin{lstlisting}[texcl]
\SmartUnit{feet=7, inches=1} % \SmartUnit{feet=7, inches=1}
\SmartUnit{cm=189, feet=7, inches=1} % \SmartUnit{cm=189, feet=7, inches=1}
@@ -230,10 +234,15 @@
\end{lstlisting}
\item[Temperature -- celsius, fahrenheit]
+ Convesions between Celsius and Fehrenheit can be speficied using
+ \textsf{celsius}, \textsf{C}, \textsf{fahrenheit} or \textsf{F}.
+
\begin{lstlisting}[texcl]
\SmartUnit{celsius=32,places=3} % \SmartUnit{celsius=32,places=3}
\SmartUnit{celsius=0} % \SmartUnit{celsius=0}
+ \SmartUnit{C=37} % \SmartUnit{C=37}
\SmartUnit{fahrenheit=0} % \SmartUnit{fahrenheit=0,places=2}
+ \SmartUnit{F=22,figures=4} % \SmartUnit{F=212,figures=4}
\end{lstlisting}
\item[Time -- hours, minutes, seconds, am, pm]
@@ -277,8 +286,8 @@
\Verb|\sisetup| macro from the \ctan{siunitx} package.
\begin{description}
- \item[figures] This is equivalent to \Verb|\sisetup{round-mode=figures, precision=#1}|. All units are printed
- with \#1 significant figures.
+ \item[figures] This is equivalent to \Verb|\sisetup{round-mode=figures, precision=#1}|.
+ Units are printed with \#1 significant figures.
\begin{lstlisting}[texcl]
\SmartUnit{miles=60, metric, figures=0} % \SmartUnit{miles=60, metric, figures=0}
\SmartUnit{miles=60, metric, figures=1} % \SmartUnit{miles=60, metric, figures=1}
@@ -288,8 +297,8 @@
\end{lstlisting}
\item[places]
- This is equivalent to \Verb|\sisetup{round-mode=figures, precision=#1}|. All units are printed
- with \#1 significant figures.
+ This is equivalent to \Verb|\sisetup{round-mode=places, precision=#1}|.
+ Units are printed with \#1 decimal places.
\begin{lstlisting}[texcl]
\SmartUnit{miles=60, metric, places=0} % \SmartUnit{miles=60, metric, places=0}
\SmartUnit{miles=60, metric, places=1} % \SmartUnit{miles=60, metric, places=1}
@@ -404,12 +413,15 @@
The package was written in response to a
\href{http://tex.stackexchange.com/questions/241169/}{TeX.SX question},
partly as a proof-of-concept and partly as an exercise to learn how
- to use \ctan{pgfkeys}. I thank Mark Adams for asking the question.
+ to use \ctan{pgfkeys}. Thanks to Mark Adams for asking the question.
\Section{Author}
- \href{mailto:Andrew.Mathas@gmail.com?smartunits}{Andrew Mathas}, \copyright\space February 2016.
+ \href{mailto:Andrew.Mathas@gmail.com?smartunits}{Andrew Mathas},
+ \copyright\space 2015, 2016.
\Section{Licence}
- Released under the \href{http://www.latex-project.org/lppl.txt}{LaTeX Project Public License}, v1.3c or later.
+ Released under the
+ \href{http://www.latex-project.org/lppl.txt}%
+ {LaTeX Project Public License}, v1.3c or later.
\end{document}
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'.
+%%