diff options
author | Karl Berry <karl@freefriends.org> | 2016-09-29 20:34:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-09-29 20:34:14 +0000 |
commit | 9e0420d6944dc5399e597a557bf532aa77cdc7d3 (patch) | |
tree | ededc1f6a1939ac3cafb8d2950d632c426a23cca /Master/texmf-dist | |
parent | e1299094244773357580180a167c2feefb49214c (diff) |
cooking-units (29sep16)
git-svn-id: svn://tug.org/texlive/trunk@42181 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/cooking-units/README.md | 16 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf | bin | 517854 -> 568919 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx | 382 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/cooking-units/cooking-units.ins | 5 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty | 136 |
5 files changed, 374 insertions, 165 deletions
diff --git a/Master/texmf-dist/doc/latex/cooking-units/README.md b/Master/texmf-dist/doc/latex/cooking-units/README.md index bf7bdbafd48..801a5b1c0db 100644 --- a/Master/texmf-dist/doc/latex/cooking-units/README.md +++ b/Master/texmf-dist/doc/latex/cooking-units/README.md @@ -9,14 +9,14 @@ While writing a cookery book, units and their format can be quite troublesome. This contains not only the question of how to print those units, but also the question of the conversion of units. A cookery book doesn't contain only SI units, it contains a much more colorful range -of units (kg, dag, g, oz, ... for example) and this may cause some +of units (kg, dag, g, oz, ... for example) and it may cause some confusion if too many different units are used, but if you just write a -cookery book for fun you don't think about this case ... until someone +cookery book for fun you don't think about this ... until someone (my mother in my case) tells you that it's too confusing. This package solves both problems: It formats your input and -you have the option to convert the units globally or locally using a key-value -system. +you have the option to convert the units globally or locally using an +easy to use key-value system. Please note that this package is not intended to be used to print units (and numbers) physically correct. It should be used for @@ -42,12 +42,7 @@ This file contains Changes ------- - * v1.00a Converting 'Re' to 'eV' should be correct now. - * v1.01 Added units 'ssp', 'csp' and 'dsp' (salt-, coffee-, dessertspoonful) - English: litre (and only litre) now uses curly l - British English: 'pinch' is written in full. - * v1.02 Replaced \cufrac by \cuam - New message: 'obsolete-command'. +See section 'Change History' in the documentation. Supported Languages ------------------- @@ -64,4 +59,3 @@ This material is subject to the LaTeX Project Public License. See for the details of that license. - diff --git a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf Binary files differindex 1c42da2768c..3d1b4bfebab 100644 --- a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf +++ b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx index 27c7c2628ee..826bea4642c 100644 --- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx +++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx @@ -20,14 +20,14 @@ While writing a cookery book, units and their format can be quite troublesome. This contains not only the question of how to print those units, but also the question of the conversion of units. A cookery book doesn't contain only SI units, it contains a much more colorful range -of units (kg, dag, g, oz, ... for example) and this may cause some +of units (kg, dag, g, oz, ... for example) and it may cause some confusion if too many different units are used, but if you just write a -cookery book for fun you don't think about this case ... until someone +cookery book for fun you don't think about this ... until someone (my mother in my case) tells you that it's too confusing. This package solves both problems: It formats your input and -you have the option to convert the units globally or locally using a key-value -system. +you have the option to convert the units globally or locally using an +easy to use key-value system. Please note that this package is not intended to be used to print units (and numbers) physically correct. It should be used for @@ -54,12 +54,7 @@ This file contains Changes ------- - * v1.00a Converting 'Re' to 'eV' should be correct now. - * v1.01 Added units 'ssp', 'csp' and 'dsp' (salt-, coffee-, dessertspoonful) - English: litre (and only litre) now uses curly l - British English: 'pinch' is written in full. - * v1.02 Replaced \cufrac by \cuam - New message: 'obsolete-command'. +See section 'Change History' in the documentation. Supported Languages ------------------- @@ -103,7 +98,7 @@ LaTeX version 2008-05-04 or later. This work has the LPPL maintenance status `maintained'. -This work consists of the files README, cooking-units.dtx and cooking-units.ins +This work consists of the files README.md, cooking-units.dtx and cooking-units.ins and the derived file cooking-units.sty. \endpreamble @@ -161,6 +156,7 @@ and the derived file cooking-units.sty. %\EnableCrossrefs \labelformat{table}{table~#1} +\labelformat{section}{section~#1} \newcommand\mycs[1]{\cs{\textcolor{blue}{#1}}} \newcommand\opt{\texttt} @@ -181,12 +177,12 @@ and the derived file cooking-units.sty. -\NewDocumentCommand \dothewhitespace { O{ All your spaces are belong to us } } +\NewDocumentCommand \dothewhitespace { O{ 42 } } { \textcolor{white} {#1} \\ } -\NewEnviron { cuexamplecode } +\NewEnviron { cuexamplecode }[1][] { \begin{center} \begin{minipage}{0.4\linewidth} @@ -195,6 +191,7 @@ and the derived file cooking-units.sty. \BODY \end{minipage} + #1 \int_zero:N \l_tmpa_int \begin{minipage}{0.5\linewidth} \ttfamily @@ -358,7 +355,21 @@ and the derived file cooking-units.sty. % \changes {2016/09/03} {1.01} {Separated Messerpsitze and pinch} % \changes {2016/09/05} {1.02} {Replaced \cs{cufrac} by \cs{cuam}} % \changes {2016/09/05} {1.02} {New message: 'obsolete-command'} +% \changes {2016/09/09} {1.02a} {Changed name from \cs{@@_parse_fraction_in_input:www} to \cs{@@_parse_mixed_fraction_in_input:www}} +% \changes {2016/09/09} {1.02b} {Changed name from \cs{@@_cunum_parse_range} (and derivatives) to \cs{@@_cutext_parse_range}.} +% \changes {2016/09/09} {1.02c} {In \cs{@@_cutext_default:nnn} it is only +% checked once if a range is inside.} +% \changes {2016/09/09} {1.02d} {\cs{@@_calculate_input_and_store_in:nN} optimiert durch neue property-key: single.} +% \changes {2016/09/09} {1.02d} {Add 'single' to property list of singlekeys.} +% \changes {2016/09/16} {1.02e} {Only use \cs{phantom} if the argument (for \cs{phantom}) is not empty.} +% \changes {2016/09/09} {1.02i} {Delete 'single' from property lists of singlekeys cause it is not as safe as I thought.} +% \changes {2016/09/09} {1.02f} {Corrected mistake: 'ELektronenvolt' (note upperacse L) to 'Elektronenvolt' in german.} +% \changes {2016/09/26} {1.03} {New option (and needed macros): add-temperature-to-check.} +% \changes {2016/09/26} {1.03a} {\cs{cuaddsinglekeys} now tests if the unit exists (it didn't before).} +% \changes {2016/09/26} {1.03b} {Replaced \cs{prop_clear_new:c} by \cs{prop_clear:c}.} +% \changes {2016/09/26} {1.03b} {Recalculated all electron volt values for conversion (as 'kg' was wrong before). Let's hope they are correct this time.} % +% % \GetFileInfo{\jobname.sty} % %\title{The \pkg{\jobname} package^^A @@ -371,6 +382,7 @@ and the derived file cooking-units.sty. % % \begin{documentation} % +% % \begin{abstract} % This package enables user to globally format units and to switch % between them. It should be used for light-hearted things like @@ -380,7 +392,7 @@ and the derived file cooking-units.sty. % % \tableofcontents % -% +% % \section{Introduction} % % @@ -524,7 +536,7 @@ and the derived file cooking-units.sty. % % \lstinline|\cuam| works like a more primitive version \mycs{cunum} % which doesn't need a unit, but doesn't check the input like \mycs{cunum}. -% Like in \lstinline|\cunum| \texttt{\_} and \texttt{/} are used to imply a (mixed) fraction and \texttt{-{}-} +% Like in \lstinline|\cunum| \texttt{\_} and \texttt{/} are used to imply a (mixed) fraction and \texttt{-{}-} is % used to print ranges\footnote{Note that since v1.02 \mycs{myfrac} is obsolete.}: % % \begin{cuexamplecode} @@ -831,7 +843,7 @@ and the derived file cooking-units.sty. % % % \begin{cuexample} -% Suppose you are british (I am sorry, I can't think of another +% Suppose you are British (I am sorry, I can't think of another % reason to use those units) and you want to implement 'stone' (yes, I % was surprised myself that such a unit exists, but it even appears in % a Sherlock-Holmes story). You exactly know that \SI{1}{\st} equals @@ -851,6 +863,7 @@ and the derived file cooking-units.sty. % \cunum[st=g]{1}{st} \\ % \cunum[st=kg]{1}{st} \\ % \cunum[kg=st]{1}{kg} \\ +% \cunum[st=kg]{16}{st} \\ % \end{cuexamplecode} % \end{cuexample} % @@ -1422,9 +1435,52 @@ and the derived file cooking-units.sty. % Checks if the used temperature is below the absolute zero point. % Currently \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re} are supported. % While \lstinline|\cunum{0}{K}| is ok, \lstinline!\cunum{-1}{K}! raises an error, -% same for the others. Is set to \texttt{false} by default. +% same for the others. Is set to \texttt{false} by default. To add new units +% see \opt{add-temperature-to-check}. +% \end{function} +% +% \begin{function}{add-temperature-to-check} +% \begin{syntax} +% add-temperature-to-check = +% \ \ \{ +% \ \ \ \ \meta{unit-key-1} = \meta{minimum-value-1} , +% \ \ \ \ \meta{unit-key-2} = \meta{minimum-value-2} , +% \ \ \ \ \dots +% \ \ \} +% \end{syntax} +% This option adds \meta{unit-key-1} and so on to the list of units to be checked +% if \opt{check-temperature} is active. The argument can be a comma-separated +% list of \meta{unit-key} = \meta{minimum-value}. This sets the allowed minimum +% value of \meta{unit-key} to \meta{minimum-value}. +% % \end{function} % +% For example, this package implements the allowed minimum values for the +% temperatures \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re} to be checked if +% \opt{check-temperature} is active: +% \begin{lstlisting} +% \cusetup +% { +% add-temperature-to-check = +% { +% K = 0, +% C = -273.15 , +% F = -459.67 , +% Re = -218.52 +% } +% } +% \end{lstlisting} +% +% If you want to add a new value, for example degree R{\o}mer +% (which has be defined in another example) you can write: +% \begin{lstlisting} +% \cusetup +% { +% add-temperature-to-check = { Ro = -135.90375 } +% } +% \end{lstlisting} +% +% % ^^A \begin{cuexamplecode} % ^^A \cusetup{check-temperature=true} @ % ^^A \cunum{0}{K} \\ @@ -1442,11 +1498,12 @@ and the derived file cooking-units.sty. % option is: % a) experimental and probably will forever be and b) just a joke, you are not % supposed to use this units in a cookery book (and as you see this package -% doesn't support the arrangement of such huge numbers). +% doesn't support the arrangement of such huge numbers). Also you may +% want to check the values if you really want to use them, just to be sure. % % \end{function} % -% \begin{cuexamplecode} +% \begin{cuexamplecode}[\hfill] % \cusetup{ convert-to-eV=true } @ % \cunum{1}{kg} \\ % \cunum{1}{l} \\ @@ -1533,6 +1590,57 @@ and the derived file cooking-units.sty. %^^A \end{align} % % +%^^A \section{Notes and other stuff} +%^^A \subsection{Some details to electron volts} +%^^A This section explains how I calculated the values for conversion into electron volt +%^^A or the respective derivative. Let's begin with some constants (from Wikipedia), note that +%^^A \begin{equation*} +%^^A \num{1.23456(78)e-9} = \num[separate-uncertainty = true]{1.23456(78)e-9} +%^^A \end{equation*} +%^^A just for info. +%^^A +%^^A \begin{align} +%^^A \SI{1}{\eV} &= \SI{1.6021766208(98)e-19}{\J} \\ +%^^A \hbar &= \SI{1.054571800(13)e-34}{\J\s} \\ +%^^A k_B &= \SI{1.38064852(79)e-23}{\J\per\K} = \SI{8.6173303(50)e-5}{\eV\per\K}\\ +%^^A c &= \SI{299792458}{\m\per\s} +%^^A \end{align} +%^^A +%^^A Note that all those and following values are rounded to the second relevant figure of the +%^^A uncertainty of the value. +%^^A +%^^A Well then, next are temperatures. +%^^A +%^^A Temperatures are fairly easy. Just convert the temperature of your choice to kelvin +%^^A and multiplicate it with $k_B$: +%^^A \begin{align} +%^^A \SI{1}{\K} * k_B &= \SI{8.6173303(50)e-5}{\eV} +%^^A \end{align} +%^^A +%^^A Next is more complicated. To compute the resulting unceartanity I using +%^^A \enquote{Gauß'sches Fehlerfortpflanzungsgesetz} (I don't know if this has +%^^A a translation). Anyway. We know that +%^^A \begin{align*} +%^^A \frac{\SI{1}{\eV}}{c^2} &= \frac{\SI{1.6021766208e-19}{\J}}{(\SI{299792458}{\m\per\s})^2} +%^^A = \frac{\SI{1.6021766208e-19}{\kg\m\squared\per\s\squared}}{\SI{8,98755178736818E16}{\m\squared\per\s\squared}} = \\ +%^^A &\frac{\SI{1.6021766208e-3}{\kg}}{\num{8,98755178736818}} = +%^^A \SI{1782661906,94091624922088}{\kg} +%^^A \end{align*} +%^^A +%^^A Great, now we have to calucalte the unceartinity: +%^^A \begin{align} +%^^A f(\si{\eV},c) &= \frac{\si{\eV}}{c^2} \\ +%^^A df(\si\eV,c) &= \sqrt{ (\frac{\partial f}{\partial \si\eV})^2 * (\Delta \si\eV)^2 + (\frac{\partial f}{\partial c})^2 * (\Delta c)^2 } = \\ +%^^A &= \sqrt{ (\frac{1}{c^2})^2 * (\Delta \si\eV)^2 + (-2\frac{eV}{c^{-3}})^2 * (\Delta c)^2 } +%^^A \end{align} +%^^A +%^^A Now we know that $\Delta c = 0$: +%^^A \begin{align} +%^^A df(\si\eV,c) &= \sqrt{ (\frac{1}{c^2})^2 * (\Delta \si\eV)^2 } = +%^^A \sqrt{ \frac{1}{(\SI{299792458}{\m\per\s} )^2} * (\SI{0.0000000098e-19}{\J})^2 } \\ +%^^A &= +%^^A \end{align} +% % \end{documentation} % % \begin{implementation} @@ -1565,8 +1673,8 @@ and the derived file cooking-units.sty. % \begin{macrocode} \ProvidesExplPackage {cooking-units} - {2016/09/05} - {1.02} + {2016/09/26} + {1.03b} {Ein Paket fuer Kocheinheiten} % \end{macrocode} % Chekcing if \pkg{expl3} is uptodate, otherwise abort the loading of the package. @@ -1630,9 +1738,11 @@ and the derived file cooking-units.sty. \cs_generate_variant:Nn \tl_replace_all:Nnn { NVn } \cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn } \cs_generate_variant:Nn \tl_if_in:nnTF { nVTF } +\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF } \cs_generate_variant:Nn \tl_if_in:NnT { NVT } \cs_generate_variant:Nn \fp_compare:nNnT { cNnT } \cs_generate_variant:Nn \fp_eval:n { c } + % \end{macrocode} % \end{macro} % @@ -1803,6 +1913,15 @@ and the derived file cooking-units.sty. % \end{macrocode} % \end{macro} % +% \begin{macro} { \l_@@_temperatures_to_check_clist } +% \changes {1.02h} {New.} +% Stores units which should be tested if \opt{check-temperature} equals true. +% \begin{macrocode} +\clist_new:N \l_@@_temperatures_to_check_clist +%\clist_set:Nn \l_@@_temperatures_to_check_clist { C , F , K , Re } +% \end{macrocode} +% \end{macro} +% % \begin{macro} % { % \l_@@_error_bool , @@ -1834,6 +1953,7 @@ and the derived file cooking-units.sty. \bool_new:N \l_@@_cutext_uppercase_word_bool \bool_new:N \l_@@_error_for_unknown_value_bool \bool_new:N \l_@@_parse_range_bool +%\bool_new:N \l_@@_unit_is_singlekey_bool % \end{macrocode} % \end{macro} % @@ -2008,6 +2128,19 @@ and the derived file cooking-units.sty. check-temperature .default:n = { true } , % \end{macrocode} % +%\begin{macro}{ add-temperature-to-check } +% Adds a temperature to check for \texttt{check-temperature}. +% \begin{macrocode} + add-temperature-to-check .code:n = + { + \keyval_parse:NNn + \@@_temperature_to_check_print_error:n + \@@_temperatures_to_check_define:nn + {#1} + }, + temperature-to-check .value_required:n = { true } , +% \end{macrocode} +% %\begin{macro}{ convert-to-eV } % Another weird option, converts pretty much any unit defined by this % package to electron volt or the respective derivative. @@ -2226,7 +2359,32 @@ and the derived file cooking-units.sty. Command \ #1 is \ obsolete. \ Please \ use \ #2 instead. } { - Don't \ use \ the \ old \ command \ ... + Don't \ use \ this \ old \ command \ ... + \msg_see_documentation_text:n { cooking-units } + } +% \end{macrocode} +% +% Error message if a new temperature to check is defined and no +% minimal value is given. +% \begin{macrocode} +\msg_new:nnnn { cooking - units } { No-Value-given } + { + Please \ input \ a \ number \ to \ check \ for \ + 'check-temperature'. + } + { + \msg_see_documentation_text:n { cooking-units } + } +% \end{macrocode} +% +% +% \begin{macrocode} +\msg_new:nnnn { cooking - units } { Minimum-already-defined } + { + A \ minimum \ for \ '#1' \ has \ already \ been \ defined. + } + { + You \ cannot \ redefine \ it. \msg_see_documentation_text:n { cooking-units } } % \end{macrocode} @@ -2246,6 +2404,7 @@ and the derived file cooking-units.sty. \cs_new:Npn \@@_error_if_unit_not_defined:n #1 { \clist_if_in:NnF \g_@@_list_of_defined_units_clist {#1} +% \tl_if_exist:cF { l_@@_tmpa_ #1 _tl } { \msg_error:nnn { cooking-units } { unknown-unit } {#1} } } \cs_generate_variant:Nn \@@_error_if_unit_not_defined:n { V } @@ -2267,17 +2426,14 @@ and the derived file cooking-units.sty. { \bool_if:NTF \l_@@_parse_input_bool { -% \cs_set_eq:NN \@@_if_number_and_parse_aux: \prg_return_true: \tl_map_inline:nn {#1} { \tl_if_in:NnF \l_@@_input_digits_tl {##1} { -% \cs_set_eq:NN \@@_if_number_and_parse_aux: \prg_return_false: \tl_map_break:n { \use_iii:nnn } } } \use_i:nn \prg_return_true: \prg_return_false: -% \@@_if_number_and_parse_aux: } { \prg_return_false: } } @@ -2345,6 +2501,29 @@ and the derived file cooking-units.sty. % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_deftranslation:Nnn} +% Commands used in the option \texttt{temperature-to-check}. +% If no value is given (first command) it raises an error. If a value +% is given the unit is added to a check-list and a new +% constant is defined. +% \begin{macrocode} +\cs_new:Npn \@@_temperature_to_check_print_error:n #1 + { + \msg_error:nn { cooking-units } { No-Value-given } + } +\cs_new:Npn \@@_temperatures_to_check_define:nn #1#2 + { + \@@_error_if_unit_not_defined:n {#1} + \fp_if_exist:cTF { c_@@_ #1 _min_fp } + { \msg_error:nnn { cooking-units } { Minimum-already-defined } {#1} } + { + \clist_put_right:Nn \l_@@_temperatures_to_check_clist {#1} + \fp_const:cn { c_@@_ #1 _min_fp } {#2} + } + } +% \end{macrocode} +% \end{macro} +% % \subsection {Parsing and cheking numbers} % % This section contains macros helping an checking the input. @@ -2355,13 +2534,13 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_cunum_parse_input:N #1 { - \tl_if_in:nnTF {#1} { \q_@@_range } + \bool_if:NTF \l_@@_parse_range_bool { \@@_parse_range_in_input:ww #1 \q_stop } { \tl_if_in:nnTF {#1} { / } { \tl_if_in:nnTF {#1} { _ } - { \@@_parse_fraction_in_input:www #1 \q_stop } + { \@@_parse_mixed_fraction_in_input:www #1 \q_stop } { \@@_parse_fraction_in_input:ww #1 \q_stop } } { \@@_parse_number_in_input:n {#1} } @@ -2393,7 +2572,6 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_parse_range_in_input:ww #1 \q_@@_range #2 \q_stop { - \bool_set_true:N \l_@@_parse_range_bool \@@_parse_input_and_safe_in:nN {#1} \l_@@_tmpa_tl \@@_parse_input_and_safe_in:nN {#2} \l_@@_tmpb_tl \@@_calculate_and_print_input:N \l_@@_tmpa_tl @@ -2430,7 +2608,7 @@ and the derived file cooking-units.sty. % \end{macrocode} % \end{macro} % -% \begin{macro}{ \@@_parse_fraction_in_input:www } +% \begin{macro}{ \@@_parse_mixed_fraction_in_input:www } % The same procedure as last function? The same procedure as every % function! % @@ -2443,7 +2621,7 @@ and the derived file cooking-units.sty. % \end{align} % % \begin{macrocode} -\cs_new:Npn \@@_parse_fraction_in_input:www #1_#2/#3 \q_stop +\cs_new:Npn \@@_parse_mixed_fraction_in_input:www #1_#2/#3 \q_stop { \@@_parse_input_and_safe_in:nN {#1} \l_@@_mixed_fraction_tl \@@_parse_input_and_safe_in:nN {#2} \l_@@_tmpa_tl @@ -2604,6 +2782,15 @@ and the derived file cooking-units.sty. \cs_new:Npn \@@_calculate_input_and_store_in:nN #1#2 { \fp_set:Nn \l_tmpa_fp {#1} +% \tl_set:Nf #2 +% { +% \fp_eval:n +% { +% \bool_if:NF \l_@@_unit_is_singlekey_bool +% { \l_tmpa_fp * } +% \tl_use:c { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } +% } +% } \tl_if_in:cnTF { l_@@_tmpa_ \l_@@_tmp_unit_tl _ tl } { \l_tmpa_fp } { \tl_set:Nf #2 @@ -2643,10 +2830,8 @@ and the derived file cooking-units.sty. } \cs_new:Npn \@@_get_number_after_dot_aux:w #1. #2 . { - \quark_if_recursion_tail_stop_do:nn {#2} - { \bool_set_false:N \l_tmpa_bool } - \int_compare:nNnTF { \tl_count:n {#2} } < {\l_@@_significant_figures_plus_one_int } - { \bool_set_false:N \l_tmpa_bool } + \quark_if_recursion_tail_stop:n {#2} + \int_compare:nNnF { \tl_count:n {#2} } < { \l_@@_significant_figures_plus_one_int } { \bool_set_true:N \l_tmpa_bool } \use_none_delimit_by_q_recursion_stop:w } @@ -2661,6 +2846,7 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_round_calculated_input:NN #1#2 { + \bool_set_false:N \l_tmpa_bool \@@_get_number_after_dot:n {#2} \tl_set:Nf #1 { @@ -2691,7 +2877,7 @@ and the derived file cooking-units.sty. \cs_new:Npn \@@_formatiere_fractions:nnn #1#2#3 { \bool_set_true:N \l_@@_fraction_in_input_bool - \tl_if_blank:nF {#1} + \tl_if_empty:nF {#1} { #1 \hbox_to_wd:nn { \l_@@_mixed_frac_dim } { } @@ -2712,7 +2898,7 @@ and the derived file cooking-units.sty. { \bool_if:NT \l_@@_check_temperature_bool { - \clist_if_in:nVT { C , F , K , Re } \l_@@_option_unit_tl + \clist_if_in:NVT \l_@@_temperatures_to_check_clist \l_@@_option_unit_tl { \fp_compare:cNnT { c_@@_ \l_@@_option_unit_tl _min_fp } > {#1} @@ -2841,9 +3027,11 @@ and the derived file cooking-units.sty. } {#1} \tl_if_empty:VF \l_tmpa_tl { -%% besser mit boolean arbeiten als nochmals ueberpruefen lassen? \tl_if_in:NVT \l_tmpa_tl \l_@@_input_range_sign_tl - { \tl_replace_once:NVn \l_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range } } + { + \tl_replace_once:NVn \l_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range } + \bool_set_true:N \l_@@_parse_range_bool + } \@@_cunum_parse_input:V \l_tmpa_tl } \@@_cunum_print_correct_unit:nnn {#2} {#3} {#4} @@ -2861,7 +3049,7 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_cunum_print_correct_unit:nnn #1#2#3 { - \phantom {#1} + \tl_if_empty:nF {#1} { \phantom {#1} } \tl_use:N \l_@@_value_unit_space_tl \bool_if:nTF { @@ -2921,7 +3109,6 @@ and the derived file cooking-units.sty. { \@@_cukeys_parse_and_create_single_key:nn {#1} {#2} }{ -% \fp_set:Nn \l_tmpa_fp { \c_one_fp } \fp_set_eq:NN \l_tmpa_fp \c_one_fp \tl_set:Nn \l_@@_tmp_unit_tl {#1} \@@_cukeys_parse_and_create_keys:nn {#1} @@ -2969,6 +3156,10 @@ and the derived file cooking-units.sty. % \end{macro} % % \begin{macro}{ \@@_cukeys_create_key_prop:n } +% +% \changes {2016/09/22} {1.02f} {Save 'Liste', 'prop' and 'Erstes Ding' to \cs{l_tmpb_prop} and set the unit-prop lists equal to \cs{l_tmpb_prop}.} +% \changes {2016/09/22} {1.02g} {Do not need \cs{tl_clear_new:c} as token list is already defined.} +% % All linked unit-keys are stored within \lstinline|\l_tmpa_clist| and are mapped % one after another. At first a property list is created (or cleared), this property list % stores the units linked to this unit, saves the created property list which contains the @@ -3021,16 +3212,15 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_cukeys_create_key_prop:n #1 { + \prop_clear:N \l_tmpb_prop + \prop_put:NnV \l_tmpb_prop { Liste } \l_tmpa_clist + \prop_put:NnV \l_tmpb_prop { prop } \l_tmpa_prop + \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l_@@_tmp_unit_tl \clist_map_inline:Nn \l_tmpa_clist { - \prop_clear_new:c { l_@@_cukeys_ ##1 _prop } - \tl_clear_new:c { l_@@_tmpa_ ##1 _tl } -% \tl_set:cn { l_@@_tmpa_ ##1 _tl } { 1 } -% \tl_set:cn { l_@@_tmpa_ ##1 _tl } { \c_one_fp } + \prop_clear:c { l_@@_cukeys_ ##1 _prop } + \prop_set_eq:cN { l_@@_cukeys_ ##1 _prop } \l_tmpb_prop \tl_set_eq:cN { l_@@_tmpa_ ##1 _tl } \c_one_fp - \prop_put:cnV { l_@@_cukeys_ ##1 _prop } { Liste } \l_tmpa_clist - \prop_put:cnV { l_@@_cukeys_ ##1 _prop } { prop } \l_tmpa_prop - \prop_put:cnV { l_@@_cukeys_ ##1 _prop } { Erstes Ding } \l_@@_tmp_unit_tl \clist_map_inline:Nn \l_tmpa_clist { \prop_put:cnx { l_@@_cukeys_ ##1 _prop } @@ -3121,6 +3311,7 @@ and the derived file cooking-units.sty. \quark_if_recursion_tail_stop:n {#1} \quark_if_recursion_tail_stop_do:nn {#2} { \msg_error:nn { cooking-units } { missing-argument } } + \@@_error_if_unit_not_defined:n {#1} \clist_put_right:Nn \l_tmpa_clist {#1} \tl_set:Nn \l_tmpa_tl {#2} \tl_replace_all:NVn \l_tmpa_tl \c_@@_str_hash_one_tl { \l_tmpa_fp } @@ -3132,7 +3323,7 @@ and the derived file cooking-units.sty. % \begin{macrocode} \cs_new:Npn \@@_cusinglekeys_create_key_prop:n #1 { - \prop_clear_new:c { l_@@_cukeys_ #1 _prop } + \prop_clear:c { l_@@_cukeys_ #1 _prop } \tl_set_eq:cN { l_@@_tmpa_ #1 _tl } \c_one_fp % \tl_set:cn { l_@@_tmpa_ #1 _tl } { \c_one_fp } \prop_put:cnV { l_@@_cukeys_ #1 _prop } { Liste } \l_tmpa_clist @@ -3259,10 +3450,10 @@ and the derived file cooking-units.sty. \clist_if_in:NnTF \g_@@_list_of_defined_units_clist {#2} { \msg_error:nnn { cooking-units } { unit-already-defined } {#2} } { + \clist_put_right:Nn \g_@@_list_of_defined_units_clist {#2} \tl_new:c { l_@@_tmpa_ #2 _tl } % \tl_set:cn { l_@@_tmpa_ #2 _tl } { \c_one_fp } \tl_set_eq:cN { l_@@_tmpa_ #2 _tl } \c_one_fp - \clist_put_right:Nn \g_@@_list_of_defined_units_clist {#2} \clist_new:c { l_@@_predefined_option_#2_clist } \keys_define:nn { cooking - units } { @@ -3320,10 +3511,14 @@ and the derived file cooking-units.sty. \bool_if:NTF \l_@@_parse_input_bool { \tl_set:Nn \l_tmpb_tl {#2} - \tl_replace_once:Nnn \l_tmpb_tl { -- } { \q_@@_range } - \tl_if_in:NnTF \l_tmpb_tl \q_@@_range - { \@@_cunum_parse_range:Vn \l_tmpb_tl {#3} } - { \@@_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3} } + \tl_if_in:NVTF \l_tmpb_tl \l_@@_input_range_sign_tl + { + \tl_replace_once:NVn \l_tmpb_tl \l_@@_input_range_sign_tl { \q_@@_range } + \@@_cutext_parse_range:Vn \l_tmpb_tl {#3} +% \bool_set_true:N \l_@@_parse_range_bool + }{ + \@@_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3} + } } {#2} } @@ -3331,12 +3526,12 @@ and the derived file cooking-units.sty. % \end{macro} % % \begin{macrocode} -\cs_new:Npn \@@_cunum_parse_range:Nn #1 #2 +\cs_new:Npn \@@_cutext_parse_range:Nn #1 #2 { - \@@_cunum_parse_range_aux:nww {#2} #1 \q_stop + \@@_cutext_parse_range_aux:nww {#2} #1 \q_stop } -\cs_generate_variant:Nn \@@_cunum_parse_range:Nn { V } -\cs_new:Npn \@@_cunum_parse_range_aux:nww #1 #2 \q_@@_range #3 \q_stop +\cs_generate_variant:Nn \@@_cutext_parse_range:Nn { V } +\cs_new:Npn \@@_cutext_parse_range_aux:nww #1 #2 \q_@@_range #3 \q_stop { \tl_set:Nn \l_@@_tmpa_tl {#2} \tl_set:Nn \l_@@_tmpb_tl {#3} @@ -3650,7 +3845,7 @@ and the derived file cooking-units.sty. { \@@_error_if_unit_not_defined:n {#1} } % \deftranslation [ to=\l_@@_language_tl ] { #1 ( cu-unit ) } {#2} \@@_deftranslation:Vnn \l_@@_language_tl { #1 ( cu-unit ) } {#2} -cu-unitgender \@@_cuprint_define_printed_unit:nn + \@@_cuprint_define_printed_unit:nn } % \end{macrocode} % @@ -3768,7 +3963,7 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { kcal } { Kilokalorie } [ Kilokalorien ] < f > { J } { Joule } { kJ } { Kilojoule } - { eV } { ELektronenvolt } < n > + { eV } { Elektronenvolt } < n > % \end{macrocode} % \begin{macrocode} { Msp } [ Msp. ] { Messerspitze } [ Messerspitzen ] < f > @@ -3935,8 +4130,9 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { g } { 1000 } { oz } { 35.27399 } { lb } { 2.204 622 6 } %% 2.204 622 6 + { eVc-2 } { 560958865.0e+27 } %% 560958865.0 +- 3.5 e+27 } -\cuaddtokeys { kg } { eVc-2 } { 1.78266173e-16 } +%\cuaddtokeys { kg } { eVc-2 } { 1.78266173e-16 } % \end{macrocode} % \begin{macrocode} \cudefinekeys { d } @@ -3944,8 +4140,9 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { h } { 24 } { min }{ 1440 } { s } { 86400 } + { hbareV-1 } { 151926746.1e+7 * 86400 } %% 151926746.1 +- 2.1 e+7 } -\cuaddtokeys { s } { hbareV-1 } { 6.582119514e-16 } +%\cuaddtokeys { s } { hbareV-1 } { 6.582119514e-16 } % \end{macrocode} % \begin{macrocode} \cudefinekeys { m } @@ -3954,8 +4151,9 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { cm } { 100 } { mm } { 1000 } { in } { 39.370079 } + { chbareV-1 } { 5067730.759 } %% 5067730.759 +- 0.070 } -\cuaddtokeys { m } { chbareV-1 } { 1.97326972e-7 } +%\cuaddtokeys { m } { chbareV-1 } { 1.97326972e-7 } % \end{macrocode} % \begin{macrocode} \cudefinekeys { l } @@ -3963,7 +4161,7 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { dl } { 10 } { cl } { 100 } { ml }{ 1000 } - { (chbareV-1)3 } { 1.30148943e+17 } + { (chbareV-1)3 } { 130148929.5e+12 * 1e-3 } %% (130148929.5 +- 5.4 e+12)*1e-3 } % \end{macrocode} % \begin{macrocode} @@ -3972,8 +4170,9 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn { kJ }{ 1e-3 } { cal }{ 0.2388459 } { kcal }{ 0.2388459e-3 } + { eV }{ 624150912.6e+10 } %% 624150912.6 +- 3.9 e+10 } -\cuaddtokeys { J } { eV } { 1.6021766208e-19 } +%\cuaddtokeys { J } { eV } { 1.6021766208e-19 } % \end{macrocode} % \begin{macrocode} \fp_const:Nn \c_@@_kb_eV_fp { 8.617 330 3 e-5 } @@ -4009,10 +4208,10 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn % % % \begin{macrocode} -\fp_const:Nn \c_@@_K_min_fp { 0 } -\fp_const:Nn \c_@@_C_min_fp { -273.15 } -\fp_const:Nn \c_@@_F_min_fp { -459.67 } -\fp_const:Nn \c_@@_Re_min_fp { -218.52 } +%\fp_const:Nn \c_@@_K_min_fp { 0 } +%\fp_const:Nn \c_@@_C_min_fp { -273.15 } +%\fp_const:Nn \c_@@_F_min_fp { -459.67 } +%\fp_const:Nn \c_@@_Re_min_fp { -218.52 } % \end{macrocode} % % @@ -4026,6 +4225,13 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn set-option-for-C = { round-to-int = true } , set-option-for-K = { round-to-int = true } , set-option-for-Re = { round-to-int = true } , + add-temperature-to-check = + { + K = 0, + C = -273.15 , + F = -459.67 , + Re = -218.52 + } , } % \end{macrocode} % @@ -4043,42 +4249,4 @@ cu-unitgender \@@_cuprint_define_printed_unit:nn % Local Variables: % mode: doctex % TeX-master: t -% End: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% End:
\ No newline at end of file diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins b/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins index 0084204cbee..ba80ea43655 100644 --- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins +++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.ins @@ -19,7 +19,7 @@ %% %% This work has the LPPL maintenance status `maintained'. %% -%% This work consists of the files README, cooking-units.dtx and cooking-units.ins +%% This work consists of the files README.md, cooking-units.dtx and cooking-units.ins %% and the derived file cooking-units.sty. %% \input l3docstrip.tex @@ -39,7 +39,7 @@ LaTeX version 2008-05-04 or later. This work has the LPPL maintenance status `maintained'. -This work consists of the files README, cooking-units.dtx and cooking-units.ins +This work consists of the files README.md, cooking-units.dtx and cooking-units.ins and the derived file cooking-units.sty. \endpreamble @@ -49,7 +49,6 @@ and the derived file cooking-units.sty. \file{\jobname.sty}{\from{\jobname.dtx}{package}} } \endbatchfile - \endinput %% %% End of file `cooking-units.ins'. diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty index b12965f826b..8fc9a0f6b3c 100644 --- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty +++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty @@ -19,7 +19,7 @@ %% %% This work has the LPPL maintenance status `maintained'. %% -%% This work consists of the files README, cooking-units.dtx and cooking-units.ins +%% This work consists of the files README.md, cooking-units.dtx and cooking-units.ins %% and the derived file cooking-units.sty. %% \@ifpackageloaded {xparse} @@ -30,8 +30,8 @@ { \RequirePackage {expl3} } \ProvidesExplPackage {cooking-units} - {2016/09/05} - {1.02} + {2016/09/26} + {1.03b} {Ein Paket fuer Kocheinheiten} \@ifpackagelater { expl3 } { 2016/05/18 } { } @@ -65,9 +65,11 @@ \cs_generate_variant:Nn \tl_replace_all:Nnn { NVn } \cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn } \cs_generate_variant:Nn \tl_if_in:nnTF { nVTF } +\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF } \cs_generate_variant:Nn \tl_if_in:NnT { NVT } \cs_generate_variant:Nn \fp_compare:nNnT { cNnT } \cs_generate_variant:Nn \fp_eval:n { c } + \cs_new_eq:NN \__cooking_units_frac:nn \sfrac \prop_new:N \l__cooking_units_change_unit_prop \tl_new:N \l__cooking_units_tmpa_tl @@ -128,6 +130,7 @@ \clist_new:N \l__cooking_units_list_of_defined_keys_clist \clist_new:N \g__cooking_units_list_of_defined_units_clist \clist_new:N \g__cooking_units_allowed_unit_phrases_clist +\clist_new:N \l__cooking_units_temperatures_to_check_clist \bool_new:N \l__cooking_units_error_bool \bool_new:N \l__cooking_units_eval_fractions_bool \bool_new:N \l__cooking_units_parse_input_bool @@ -197,6 +200,14 @@ input-range-sign .default:n = { -- } , check-temperature .bool_set:N = \l__cooking_units_check_temperature_bool , check-temperature .default:n = { true } , + add-temperature-to-check .code:n = + { + \keyval_parse:NNn + \__cooking_units_temperature_to_check_print_error:n + \__cooking_units_temperatures_to_check_define:nn + {#1} + }, + temperature-to-check .value_required:n = { true } , convert-to-eV .bool_set:N = \l__cooking_units_convert_to_eV_bool , convert-to-eV .default:n = { true } , use-numerals-below .int_set:N = \l__cooking_units_print_numerals_below_int , @@ -327,7 +338,23 @@ Command \ #1 is \ obsolete. \ Please \ use \ #2 instead. } { - Don't \ use \ the \ old \ command \ ... + Don't \ use \ this \ old \ command \ ... + \msg_see_documentation_text:n { cooking-units } + } +\msg_new:nnnn { cooking - units } { No-Value-given } + { + Please \ input \ a \ number \ to \ check \ for \ + 'check-temperature'. + } + { + \msg_see_documentation_text:n { cooking-units } + } +\msg_new:nnnn { cooking - units } { Minimum-already-defined } + { + A \ minimum \ for \ '#1' \ has \ already \ been \ defined. + } + { + You \ cannot \ redefine \ it. \msg_see_documentation_text:n { cooking-units } } \cs_new:Npn \__cooking_units_error_if_unit_not_defined:n #1 @@ -398,15 +425,29 @@ \deftranslation [ to=#1 ] { #2 } {#3} } \cs_generate_variant:Nn \__cooking_units_deftranslation:Nnn { Vnn } +\cs_new:Npn \__cooking_units_temperature_to_check_print_error:n #1 + { + \msg_error:nn { cooking-units } { No-Value-given } + } +\cs_new:Npn \__cooking_units_temperatures_to_check_define:nn #1#2 + { + \__cooking_units_error_if_unit_not_defined:n {#1} + \fp_if_exist:cTF { c__cooking_units_ #1 _min_fp } + { \msg_error:nnn { cooking-units } { Minimum-already-defined } {#1} } + { + \clist_put_right:Nn \l__cooking_units_temperatures_to_check_clist {#1} + \fp_const:cn { c__cooking_units_ #1 _min_fp } {#2} + } + } \cs_new:Npn \__cooking_units_cunum_parse_input:N #1 { - \tl_if_in:nnTF {#1} { \q__cooking_units_range } + \bool_if:NTF \l__cooking_units_parse_range_bool { \__cooking_units_parse_range_in_input:ww #1 \q_stop } { \tl_if_in:nnTF {#1} { / } { \tl_if_in:nnTF {#1} { _ } - { \__cooking_units_parse_fraction_in_input:www #1 \q_stop } + { \__cooking_units_parse_mixed_fraction_in_input:www #1 \q_stop } { \__cooking_units_parse_fraction_in_input:ww #1 \q_stop } } { \__cooking_units_parse_number_in_input:n {#1} } @@ -420,7 +461,6 @@ } \cs_new:Npn \__cooking_units_parse_range_in_input:ww #1 \q__cooking_units_range #2 \q_stop { - \bool_set_true:N \l__cooking_units_parse_range_bool \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_tmpa_tl \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_tmpb_tl \__cooking_units_calculate_and_print_input:N \l__cooking_units_tmpa_tl @@ -442,7 +482,7 @@ { \l__cooking_units_tmpb_tl } } } -\cs_new:Npn \__cooking_units_parse_fraction_in_input:www #1_#2/#3 \q_stop +\cs_new:Npn \__cooking_units_parse_mixed_fraction_in_input:www #1_#2/#3 \q_stop { \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_mixed_fraction_tl \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_tmpa_tl @@ -568,15 +608,14 @@ } \cs_new:Npn \__cooking_units_get_number_after_dot_aux:w #1. #2 . { - \quark_if_recursion_tail_stop_do:nn {#2} - { \bool_set_false:N \l_tmpa_bool } - \int_compare:nNnTF { \tl_count:n {#2} } < {\l__cooking_units_significant_figures_plus_one_int } - { \bool_set_false:N \l_tmpa_bool } + \quark_if_recursion_tail_stop:n {#2} + \int_compare:nNnF { \tl_count:n {#2} } < { \l__cooking_units_significant_figures_plus_one_int } { \bool_set_true:N \l_tmpa_bool } \use_none_delimit_by_q_recursion_stop:w } \cs_new:Npn \__cooking_units_round_calculated_input:NN #1#2 { + \bool_set_false:N \l_tmpa_bool \__cooking_units_get_number_after_dot:n {#2} \tl_set:Nf #1 { @@ -598,7 +637,7 @@ \cs_new:Npn \__cooking_units_formatiere_fractions:nnn #1#2#3 { \bool_set_true:N \l__cooking_units_fraction_in_input_bool - \tl_if_blank:nF {#1} + \tl_if_empty:nF {#1} { #1 \hbox_to_wd:nn { \l__cooking_units_mixed_frac_dim } { } @@ -609,7 +648,7 @@ { \bool_if:NT \l__cooking_units_check_temperature_bool { - \clist_if_in:nVT { C , F , K , Re } \l__cooking_units_option_unit_tl + \clist_if_in:NVT \l__cooking_units_temperatures_to_check_clist \l__cooking_units_option_unit_tl { \fp_compare:cNnT { c__cooking_units_ \l__cooking_units_option_unit_tl _min_fp } > {#1} @@ -685,9 +724,11 @@ } {#1} \tl_if_empty:VF \l_tmpa_tl { -%% besser mit boolean arbeiten als nochmals ueberpruefen lassen? \tl_if_in:NVT \l_tmpa_tl \l__cooking_units_input_range_sign_tl - { \tl_replace_once:NVn \l_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range } } + { + \tl_replace_once:NVn \l_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range } + \bool_set_true:N \l__cooking_units_parse_range_bool + } \__cooking_units_cunum_parse_input:V \l_tmpa_tl } \__cooking_units_cunum_print_correct_unit:nnn {#2} {#3} {#4} @@ -695,7 +736,7 @@ \cs_generate_variant:Nn \__cooking_units_cunum:nnNN { nnVV } \cs_new:Npn \__cooking_units_cunum_print_correct_unit:nnn #1#2#3 { - \phantom {#1} + \tl_if_empty:nF {#1} { \phantom {#1} } \tl_use:N \l__cooking_units_value_unit_space_tl \bool_if:nTF { @@ -754,14 +795,15 @@ } \cs_new:Npn \__cooking_units_cukeys_create_key_prop:n #1 { + \prop_clear:N \l_tmpb_prop + \prop_put:NnV \l_tmpb_prop { Liste } \l_tmpa_clist + \prop_put:NnV \l_tmpb_prop { prop } \l_tmpa_prop + \prop_put:NnV \l_tmpb_prop { Erstes Ding } \l__cooking_units_tmp_unit_tl \clist_map_inline:Nn \l_tmpa_clist { - \prop_clear_new:c { l__cooking_units_cukeys_ ##1 _prop } - \tl_clear_new:c { l__cooking_units_tmpa_ ##1 _tl } + \prop_clear:c { l__cooking_units_cukeys_ ##1 _prop } + \prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l_tmpb_prop \tl_set_eq:cN { l__cooking_units_tmpa_ ##1 _tl } \c_one_fp - \prop_put:cnV { l__cooking_units_cukeys_ ##1 _prop } { Liste } \l_tmpa_clist - \prop_put:cnV { l__cooking_units_cukeys_ ##1 _prop } { prop } \l_tmpa_prop - \prop_put:cnV { l__cooking_units_cukeys_ ##1 _prop } { Erstes Ding } \l__cooking_units_tmp_unit_tl \clist_map_inline:Nn \l_tmpa_clist { \prop_put:cnx { l__cooking_units_cukeys_ ##1 _prop } @@ -833,6 +875,7 @@ \quark_if_recursion_tail_stop:n {#1} \quark_if_recursion_tail_stop_do:nn {#2} { \msg_error:nn { cooking-units } { missing-argument } } + \__cooking_units_error_if_unit_not_defined:n {#1} \clist_put_right:Nn \l_tmpa_clist {#1} \tl_set:Nn \l_tmpa_tl {#2} \tl_replace_all:NVn \l_tmpa_tl \c__cooking_units_str_hash_one_tl { \l_tmpa_fp } @@ -841,7 +884,7 @@ } \cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1 { - \prop_clear_new:c { l__cooking_units_cukeys_ #1 _prop } + \prop_clear:c { l__cooking_units_cukeys_ #1 _prop } \tl_set_eq:cN { l__cooking_units_tmpa_ #1 _tl } \c_one_fp \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { Liste } \l_tmpa_clist \prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { prop } \l_tmpa_prop @@ -930,9 +973,9 @@ \clist_if_in:NnTF \g__cooking_units_list_of_defined_units_clist {#2} { \msg_error:nnn { cooking-units } { unit-already-defined } {#2} } { + \clist_put_right:Nn \g__cooking_units_list_of_defined_units_clist {#2} \tl_new:c { l__cooking_units_tmpa_ #2 _tl } \tl_set_eq:cN { l__cooking_units_tmpa_ #2 _tl } \c_one_fp - \clist_put_right:Nn \g__cooking_units_list_of_defined_units_clist {#2} \clist_new:c { l__cooking_units_predefined_option_#2_clist } \keys_define:nn { cooking - units } { @@ -973,19 +1016,22 @@ \bool_if:NTF \l__cooking_units_parse_input_bool { \tl_set:Nn \l_tmpb_tl {#2} - \tl_replace_once:Nnn \l_tmpb_tl { -- } { \q__cooking_units_range } - \tl_if_in:NnTF \l_tmpb_tl \q__cooking_units_range - { \__cooking_units_cunum_parse_range:Vn \l_tmpb_tl {#3} } - { \__cooking_units_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3} } + \tl_if_in:NVTF \l_tmpb_tl \l__cooking_units_input_range_sign_tl + { + \tl_replace_once:NVn \l_tmpb_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range } + \__cooking_units_cutext_parse_range:Vn \l_tmpb_tl {#3} + }{ + \__cooking_units_cutext_print_nummerical_output:Nn \l_tmpb_tl {#3} + } } {#2} } -\cs_new:Npn \__cooking_units_cunum_parse_range:Nn #1 #2 +\cs_new:Npn \__cooking_units_cutext_parse_range:Nn #1 #2 { - \__cooking_units_cunum_parse_range_aux:nww {#2} #1 \q_stop + \__cooking_units_cutext_parse_range_aux:nww {#2} #1 \q_stop } -\cs_generate_variant:Nn \__cooking_units_cunum_parse_range:Nn { V } -\cs_new:Npn \__cooking_units_cunum_parse_range_aux:nww #1 #2 \q__cooking_units_range #3 \q_stop +\cs_generate_variant:Nn \__cooking_units_cutext_parse_range:Nn { V } +\cs_new:Npn \__cooking_units_cutext_parse_range_aux:nww #1 #2 \q__cooking_units_range #3 \q_stop { \tl_set:Nn \l__cooking_units_tmpa_tl {#2} \tl_set:Nn \l__cooking_units_tmpb_tl {#3} @@ -1195,7 +1241,7 @@ \clist_if_in:NnF \g__cooking_units_allowed_unit_phrases_clist {#1} { \__cooking_units_error_if_unit_not_defined:n {#1} } \__cooking_units_deftranslation:Vnn \l__cooking_units_language_tl { #1 ( cu-unit ) } {#2} -cu-unitgender \__cooking_units_cuprint_define_printed_unit:nn + \__cooking_units_cuprint_define_printed_unit:nn } \NewDocumentCommand \cusetup { m } { @@ -1267,7 +1313,7 @@ cu-unitgender \__cooking_units_cuprint_define_printed_unit:nn { kcal } { Kilokalorie } [ Kilokalorien ] < f > { J } { Joule } { kJ } { Kilojoule } - { eV } { ELektronenvolt } < n > + { eV } { Elektronenvolt } < n > { Msp } [ Msp. ] { Messerspitze } [ Messerspitzen ] < f > { pn } [ Prise ] { Prise } [ Prisen ] < f > { EL } [ EL ] { Essl{\"o}ffel } @@ -1379,37 +1425,37 @@ cu-unitgender \__cooking_units_cuprint_define_printed_unit:nn { g } { 1000 } { oz } { 35.27399 } { lb } { 2.204 622 6 } %% 2.204 622 6 + { eVc-2 } { 560958865.0e+27 } %% 560958865.0 +- 3.5 e+27 } -\cuaddtokeys { kg } { eVc-2 } { 1.78266173e-16 } \cudefinekeys { d } { { h } { 24 } { min }{ 1440 } { s } { 86400 } + { hbareV-1 } { 151926746.1e+7 * 86400 } %% 151926746.1 +- 2.1 e+7 } -\cuaddtokeys { s } { hbareV-1 } { 6.582119514e-16 } \cudefinekeys { m } { { dm } { 10 } { cm } { 100 } { mm } { 1000 } { in } { 39.370079 } + { chbareV-1 } { 5067730.759 } %% 5067730.759 +- 0.070 } -\cuaddtokeys { m } { chbareV-1 } { 1.97326972e-7 } \cudefinekeys { l } { { dl } { 10 } { cl } { 100 } { ml }{ 1000 } - { (chbareV-1)3 } { 1.30148943e+17 } + { (chbareV-1)3 } { 130148929.5e+12 * 1e-3 } %% (130148929.5 +- 5.4 e+12)*1e-3 } \cudefinekeys { J } { { kJ }{ 1e-3 } { cal }{ 0.2388459 } { kcal }{ 0.2388459e-3 } + { eV }{ 624150912.6e+10 } %% 624150912.6 +- 3.9 e+10 } -\cuaddtokeys { J } { eV } { 1.6021766208e-19 } \fp_const:Nn \c__cooking_units_kb_eV_fp { 8.617 330 3 e-5 } \cudefinesinglekey { C } { @@ -1439,18 +1485,20 @@ cu-unitgender \__cooking_units_cuprint_define_printed_unit:nn { F } { #1 * 2.25 + 32 } { eV } { ( #1 * 1.25 + 273.15 ) * \c__cooking_units_kb_eV_fp } } -\fp_const:Nn \c__cooking_units_K_min_fp { 0 } -\fp_const:Nn \c__cooking_units_C_min_fp { -273.15 } -\fp_const:Nn \c__cooking_units_F_min_fp { -459.67 } -\fp_const:Nn \c__cooking_units_Re_min_fp { -218.52 } \cusetup { set-option-for-F = { round-to-int = true } , set-option-for-C = { round-to-int = true } , set-option-for-K = { round-to-int = true } , set-option-for-Re = { round-to-int = true } , + add-temperature-to-check = + { + K = 0, + C = -273.15 , + F = -459.67 , + Re = -218.52 + } , } - \endinput %% %% End of file `cooking-units.sty'. |