diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty | 136 |
1 files changed, 92 insertions, 44 deletions
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'. |