| 1 |
% \iffalse meta-comment |
| 2 |
% !TEX encoding = UTF-8 Unicode |
| 3 |
% !TEX program = pdfLaTeX |
| 4 |
%^^A PdfLaTeX-dev |
| 5 |
% |
| 6 |
%<*internal> |
| 7 |
\iffalse |
| 8 |
%</internal> |
| 9 |
%<*readme> |
| 10 |
|
| 11 |
cooking-units |
| 12 |
============= |
| 13 |
|
| 14 |
Overview |
| 15 |
-------- |
| 16 |
|
| 17 |
While writing a cookery book, units and their format can be quite |
| 18 |
troublesome. This contains not only the question of how to print those |
| 19 |
units, but also the question of the conversion of units. A cookery |
| 20 |
book doesn't contain only SI units, it contains a much more colorful |
| 21 |
range of units (kg, dag, g, oz, ... for example) and it may cause |
| 22 |
some confusion if too many different units are used, but if you just |
| 23 |
write a cookery book for fun you don't think about this ... until |
| 24 |
someone (my mother in my case) tells you that it's too confusing. |
| 25 |
|
| 26 |
This package solves both problems: It formats your input and you have |
| 27 |
the option to convert the units globally or locally using an easy to |
| 28 |
use key-value system. |
| 29 |
|
| 30 |
Please note that this package is not intended to be used to print |
| 31 |
units (and numbers) physically correct. It should be used for more |
| 32 |
light-hearted stuff (like a cookery book for example). |
| 33 |
|
| 34 |
Requirements |
| 35 |
------------ |
| 36 |
|
| 37 |
* expl3 & xparse |
| 38 |
* translations |
| 39 |
* xfrac |
| 40 |
* l3keys2e |
| 41 |
* fmtcount (optional) |
| 42 |
|
| 43 |
|
| 44 |
This file contains |
| 45 |
------------------ |
| 46 |
|
| 47 |
* README |
| 48 |
* cooking-units.pdf |
| 49 |
* cooking-units.dtx |
| 50 |
* cooking-units.ins |
| 51 |
|
| 52 |
Changes |
| 53 |
------- |
| 54 |
|
| 55 |
See section 'Change History' in the documentation. |
| 56 |
|
| 57 |
Supported Languages |
| 58 |
------------------- |
| 59 |
|
| 60 |
* German |
| 61 |
* English |
| 62 |
* French |
| 63 |
|
| 64 |
License |
| 65 |
------- |
| 66 |
This material is subject to the LaTeX Project Public License 1.3c or later. See |
| 67 |
|
| 68 |
https://www.latex-project.org/lppl/ |
| 69 |
|
| 70 |
for the details of that license. |
| 71 |
|
| 72 |
%</readme> |
| 73 |
%<*internal> |
| 74 |
\fi |
| 75 |
\def\nameofplainTeX{plain} |
| 76 |
\ifx\fmtname\nameofplainTeX\else |
| 77 |
\expandafter\begingroup |
| 78 |
\fi |
| 79 |
%</internal> |
| 80 |
%<*install> |
| 81 |
\input l3docstrip.tex |
| 82 |
%\keepsilent |
| 83 |
\askforoverwritefalse |
| 84 |
\preamble |
| 85 |
Copyright (C) 2016--2022 by Ben Vitecek (current Maintainer) |
| 86 |
|
| 87 |
This file may be distributed and/or modified under the |
| 88 |
conditions of the LaTeX Project Public License, either |
| 89 |
version 1.3c of this license or (at your option) any later |
| 90 |
version. The latest version of this license is in: |
| 91 |
|
| 92 |
https://www.latex-project.org/lppl/ |
| 93 |
|
| 94 |
and version 1.3c or later is part of all distributions of |
| 95 |
LaTeX version 2008-05-04 or later. |
| 96 |
|
| 97 |
This work has the LPPL maintenance status `maintained'. |
| 98 |
|
| 99 |
This work consists of the files README.md, cooking-units.dtx and cooking-units.ins |
| 100 |
and the derived file cooking-units.sty. |
| 101 |
|
| 102 |
\endpreamble |
| 103 |
%\postamble |
| 104 |
|
| 105 |
|
| 106 |
%\endpostamble |
| 107 |
\usedir{tex/latex/cooking-units} |
| 108 |
\generate{ |
| 109 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 110 |
} |
| 111 |
%</install> |
| 112 |
%<install>\endbatchfile |
| 113 |
%<*internal> |
| 114 |
\usedir{source/latex/cooking-units} |
| 115 |
\generate{ |
| 116 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 117 |
} |
| 118 |
\nopreamble\nopostamble |
| 119 |
\usedir{doc/latex/cooking-units} |
| 120 |
\generate{ |
| 121 |
\file{README.md}{\from{\jobname.dtx}{readme}} |
| 122 |
} |
| 123 |
\ifx\fmtname\nameofplainTeX |
| 124 |
\expandafter\endbatchfile |
| 125 |
\else |
| 126 |
\expandafter\endgroup |
| 127 |
\fi |
| 128 |
%</internal> |
| 129 |
%<*driver> |
| 130 |
\documentclass[ |
| 131 |
ngerman, |
| 132 |
french, |
| 133 |
english, %french, naustrian |
| 134 |
onlydoc, |
| 135 |
% check-declarations, |
| 136 |
]{l3doc} |
| 137 |
\usepackage[utf8]{inputenc} |
| 138 |
\usepackage[main=english]{babel} |
| 139 |
\usepackage[use-fmtcount-numerals=true]{cooking-units} |
| 140 |
\usepackage{tikzsymbols} |
| 141 |
\usepackage{listings} |
| 142 |
\usepackage{environ} |
| 143 |
\usepackage{nicefrac} |
| 144 |
\usepackage{cleveref} |
| 145 |
\usepackage{mathtools} |
| 146 |
\usepackage{siunitx}[=v2] |
| 147 |
\usepackage{totalcount} |
| 148 |
%\usepackage{microtype} |
| 149 |
\usepackage{enumitem} |
| 150 |
|
| 151 |
|
| 152 |
\newcounter{CookingUnitsCounter} |
| 153 |
\newcounter{cunumCounter} |
| 154 |
\newcounter{cuamCounter} |
| 155 |
\newcounter{cutextCounter} |
| 156 |
\newcounter{CutextCounter} |
| 157 |
\DeclareTotalCounter{CookingUnitsCounter} |
| 158 |
\DeclareTotalCounter{cunumCounter} |
| 159 |
\DeclareTotalCounter{cuamCounter} |
| 160 |
\DeclareTotalCounter{cutextCounter} |
| 161 |
\DeclareTotalCounter{CutextCounter} |
| 162 |
|
| 163 |
\babeltags{myde = ngerman} |
| 164 |
|
| 165 |
\DeclareSIUnit{\ounce}{oz} |
| 166 |
\DeclareSIUnit{\oz}{\ounce} |
| 167 |
\DeclareSIUnit{\pound}{lb} |
| 168 |
\DeclareSIUnit{\lb}{\pound} |
| 169 |
\DeclareSIUnit{\stone}{st} |
| 170 |
\DeclareSIUnit{\st}{\stone} |
| 171 |
\DeclareSIUnit{\stick}{st} |
| 172 |
\DeclareSIUnit{\inch}{in} |
| 173 |
\cusetup{print-numerals=false} |
| 174 |
|
| 175 |
%\EnableCrossrefs |
| 176 |
|
| 177 |
\newcommand\US{$^{\mathrm{U.S.}}$} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
\ExplSyntaxOn |
| 182 |
|
| 183 |
\NewDocumentCommand \cookingunitsToDo { m } |
| 184 |
{ |
| 185 |
\marginpar { \textcolor{red}{#1} } |
| 186 |
} |
| 187 |
\NewDocumentCommand \cookingunitsTODO { m } { \cookingunitsToDo {#1} } |
| 188 |
\NewDocumentCommand \cookingunitsContinue { } { \cookingunitsToDo {Continue} } |
| 189 |
\NewDocumentCommand \cookingunitsCONTINUE { } { \cookingunitsContinue } |
| 190 |
\NewDocumentCommand \cookingunitsChecked { } |
| 191 |
{ |
| 192 |
\cookingunitsToDo{Checked} |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
\clist_new:N \l_cookingunits_list_of_defined_befehlen_clist |
| 197 |
\clist_set:Nn \l_cookingunits_list_of_defined_befehlen_clist |
| 198 |
{ |
| 199 |
cunum, |
| 200 |
cutext, |
| 201 |
Cutext, |
| 202 |
cuam, |
| 203 |
newcookingunit, |
| 204 |
declarecookingunit, |
| 205 |
providecookingunit, |
| 206 |
cudefinename, |
| 207 |
cudefinesymbol, |
| 208 |
cusetup, |
| 209 |
cudefinekeys, |
| 210 |
cudefinesinglekey, |
| 211 |
cuaddkeys, |
| 212 |
cuaddsinglekeys, |
| 213 |
cuaddtokeys, |
| 214 |
culabel, |
| 215 |
curef, |
| 216 |
cudefinephrase, |
| 217 |
declarecookingderivatives , |
| 218 |
cufrac , |
| 219 |
cusetoptionfor, cuaddoptionfor, cuclearoptionfor, |
| 220 |
cudeclareunitgroup, cuaddtounitgroup, cuclearunitgroup , |
| 221 |
cudefinekeys , |
| 222 |
, cudefinekeychain , cuaddtokeychain |
| 223 |
, cudeclareunitgroup |
| 224 |
, cookingunits_print_fraction:nnn , cookingunits_print_range:nn |
| 225 |
, ExplSyntaxOff, ExplSyntaxOn |
| 226 |
} |
| 227 |
|
| 228 |
\NewDocumentCommand \mycs { m } |
| 229 |
{ |
| 230 |
\tl_set_rescan:Nnn \l_tmpa_tl |
| 231 |
{ |
| 232 |
\char_set_catcode_letter:N \_ % |
| 233 |
\char_set_catcode_letter:N \: % |
| 234 |
} {#1} |
| 235 |
\clist_if_in:NVTF \l_cookingunits_list_of_defined_befehlen_clist \l_tmpa_tl |
| 236 |
{ |
| 237 |
\cs_if_exist:cTF { \l_tmpa_tl } |
| 238 |
{ \cs{\textcolor{blue}{ \l_tmpa_tl }} } |
| 239 |
{ \tl_show:n {#1}\mycsERRORII } |
| 240 |
} |
| 241 |
{ \tl_show:n {#1} \mycsERROR } |
| 242 |
} |
| 243 |
\newcommand\opt{\texttt} |
| 244 |
\newcommand\myunit{\texttt} |
| 245 |
\newcommand\mygroup{\texttt} |
| 246 |
\newcommand\myaarg[1]{\texttt{<}\meta{#1}\texttt{>}} |
| 247 |
\newcommand\true{\opt{true}} |
| 248 |
\newcommand\false{\opt{false}} |
| 249 |
|
| 250 |
%: \PrintUnit |
| 251 |
\NewDocumentCommand \PrintUnit { o m } |
| 252 |
{ |
| 253 |
\__cookingunits_culang_let:nnN { name } {#2} \l_tmpa_tl |
| 254 |
\tl_if_eq:NNF \l_tmpa_tl \c__cookingunits_no_translation_str |
| 255 |
{ \l_tmpa_tl } |
| 256 |
\IfNoValueF {#1} {#1} |
| 257 |
& |
| 258 |
\PrintUnitSymbol {#2} |
| 259 |
} |
| 260 |
\NewDocumentCommand \PrintUnitSymbol { m } |
| 261 |
{ |
| 262 |
\texttt {#1} & |
| 263 |
\tl_use:c { l__cookingunits_default_unit_ #1 _tl } |
| 264 |
} |
| 265 |
\NewDocumentCommand \PrintGroup { m } |
| 266 |
{ |
| 267 |
\mygroup {#1} & |
| 268 |
\texttt{\seq_use:cn { l__cookingunits_group_ #1 _seq } { \textrm{,~} }} |
| 269 |
} |
| 270 |
|
| 271 |
\NewDocumentCommand \DeactivateForbiddenUnitError { } |
| 272 |
{ |
| 273 |
\msg_redirect_name:nnn { cooking-units } { curef-forbidden-unit } { warning } |
| 274 |
} |
| 275 |
|
| 276 |
%% Allyourwhitespacearebelongtous (too long) |
| 277 |
%% 42 |
| 278 |
%% Miep! |
| 279 |
%% Ducks |
| 280 |
\NewDocumentCommand \dothewhitespace { O{ cup~of~tea } } |
| 281 |
{ |
| 282 |
\textcolor{white} {#1} \\ |
| 283 |
} |
| 284 |
\newcommand\eatthewhitespace{} |
| 285 |
\NewEnviron { cuexamplecode }[1][] |
| 286 |
{ |
| 287 |
\begin{center} |
| 288 |
\begin{minipage}{0.4\linewidth} |
| 289 |
\hbadness=10000 |
| 290 |
\tl_replace_all:Nnn \BODY { @ } { \dothewhitespace } |
| 291 |
\tl_replace_all:Nnn \BODY { \% } { \color{red} \% \ignorespaces } |
| 292 |
\tl_replace_all:Nnn \BODY { \\ } { \\ \color{black} } |
| 293 |
\tl_replace_all:Nnn \BODY { & } { \ignorespaces } |
| 294 |
\BODY |
| 295 |
\end{minipage} |
| 296 |
|
| 297 |
#1 |
| 298 |
\int_zero:N \l_tmpa_int |
| 299 |
\begin{minipage}{0.5\linewidth} |
| 300 |
\hbadness=10000 |
| 301 |
\ttfamily |
| 302 |
\tl_set_rescan:Nno \l_tmpa_tl |
| 303 |
{ |
| 304 |
\char_set_catcode_other:N \{ % |
| 305 |
\char_set_catcode_other:N \} % |
| 306 |
\char_set_catcode_other:N \_ % |
| 307 |
\char_set_catcode_other:N \~ % |
| 308 |
% \char_set_catcode_other:N \# % |
| 309 |
} |
| 310 |
{ \BODY } |
| 311 |
\tl_map_inline:Nn \l_tmpa_tl |
| 312 |
{ |
| 313 |
\token_if_cs:NTF ##1 |
| 314 |
{ |
| 315 |
\cs_if_eq:NNTF ##1 \\ |
| 316 |
{ \textbackslash\textbackslash \\ } |
| 317 |
{ \textbackslash \textcolor {blue} { \cs_to_str:N ##1 } } |
| 318 |
}{ |
| 319 |
\token_if_letter:NTF ##1 |
| 320 |
{##1} |
| 321 |
{ |
| 322 |
\str_case:nnF {##1} |
| 323 |
{ |
| 324 |
{ @ } { \\ } |
| 325 |
{ & } { \space } |
| 326 |
}{ |
| 327 |
\token_if_active:NTF ##1 |
| 328 |
{##1} |
| 329 |
{ |
| 330 |
\token_if_parameter:NTF ##1 |
| 331 |
{ |
| 332 |
\int_compare:nNnTF { \l_tmpa_int } = { 0 } |
| 333 |
{ \c_hash_str \int_incr:N \l_tmpa_int } |
| 334 |
{ \int_zero:N \l_tmpa_int } |
| 335 |
} |
| 336 |
{ ##1 {} } |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
} |
| 341 |
} |
| 342 |
\end{minipage} |
| 343 |
\end{center} |
| 344 |
} |
| 345 |
\ProvideDocumentEnvironment{cuexamplecode}{}{}{}{} |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
\NewDocumentEnvironment { cuexample } { } |
| 350 |
{ |
| 351 |
\paragraph{Example:} |
| 352 |
% \par \bigskip \noindent |
| 353 |
% \mbox{} |
| 354 |
% \marginpar{\raggedleft\textbf{Example}}\ |
| 355 |
% \ignorespaces |
| 356 |
} |
| 357 |
{ } |
| 358 |
|
| 359 |
\NewDocumentEnvironment { cunote } { } |
| 360 |
{ |
| 361 |
\paragraph{Note:} |
| 362 |
}{ } |
| 363 |
|
| 364 |
\NewEnviron { cuenumnote } |
| 365 |
{ |
| 366 |
\begin{enumerate}[label={Note \space \arabic*:}] |
| 367 |
\BODY |
| 368 |
\end{enumerate} |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
\NewDocumentEnvironment { cuinterest } { m } |
| 373 |
{ |
| 374 |
\par \bigskip |
| 375 |
\clist_set:Nn \l_tmpa_clist {#1} |
| 376 |
\mbox{}\marginpar{\raggedleft\opt{ \clist_use:Nn \l_tmpa_clist { \\ } }} |
| 377 |
\ignorespaces |
| 378 |
} |
| 379 |
{ } |
| 380 |
|
| 381 |
|
| 382 |
%: table |
| 383 |
\tl_new:N \l_translation_does_not_exist_tl |
| 384 |
\tl_set:Nn \l_translation_does_not_exist_tl { --- } |
| 385 |
\tl_new:N \translationdoesnotexisttl |
| 386 |
\tl_set_eq:NN \translationdoesnotexisttl \l_translation_does_not_exist_tl |
| 387 |
\tl_new:N \mytablecolumns |
| 388 |
\tl_set:Nn \mytablecolumns { l l l l l } |
| 389 |
\clist_new:N \l_list_of_units_clist |
| 390 |
\clist_new:N \l_list_of_textunits_clist |
| 391 |
\clist_set:Nn \l_list_of_textunits_clist |
| 392 |
{ |
| 393 |
decimal-mark , |
| 394 |
one (m) , |
| 395 |
one (f) , |
| 396 |
one (n) , |
| 397 |
} |
| 398 |
\clist_set:Nx \l_list_of_units_clist |
| 399 |
{ |
| 400 |
kg , dag , g , oz , lb , space , |
| 401 |
C , F , Re , K , space , |
| 402 |
d , h , min , s , space , |
| 403 |
m , dm , cm , mm , in , space , |
| 404 |
l , dl , cl , ml , space , |
| 405 |
cal , kcal , J , kJ , eV , space , |
| 406 |
pn , EL , TL , csp , dsp , ssp , Msp , space , |
| 407 |
\clist_use:Nn \l_list_of_textunits_clist { , } , |
| 408 |
THEEND |
| 409 |
} |
| 410 |
|
| 411 |
\cs_new:Npn \__table_midrule: |
| 412 |
{ |
| 413 |
\\ \midrule |
| 414 |
\cs_gset:Npn \__table_midrule: { \\ } |
| 415 |
} |
| 416 |
\cs_new_eq:NN \__table_default_midrule: \__table_midrule: |
| 417 |
|
| 418 |
\cs_new:Npn \__cu_use:n #1 |
| 419 |
{ \cs_if_exist_use:cF { __cookingunits_#1 } {\ERRORcommandNOTexist} } |
| 420 |
|
| 421 |
\NewDocumentCommand \CreateTableForLanguages { s >{\TrimSpaces} m } |
| 422 |
{ |
| 423 |
\IfBooleanTF {#1} |
| 424 |
{ \clist_gset_eq:NN \l_tmpa_clist \l_list_of_textunits_clist } |
| 425 |
{ \clist_gset_eq:NN \l_tmpa_clist \l_list_of_units_clist } |
| 426 |
\cs_gset_eq:NN \__table_midrule: \__table_default_midrule: |
| 427 |
\CreateTableHeader {#2} |
| 428 |
\CreateTableRow {#2} |
| 429 |
} |
| 430 |
|
| 431 |
\NewDocumentCommand \CreateTableHeader { m } |
| 432 |
{ |
| 433 |
\meta{unit-key} & |
| 434 |
printed \ unit & unit name & (plural) & gender |
| 435 |
} |
| 436 |
\NewDocumentCommand \CreateTableRow { m } |
| 437 |
{ |
| 438 |
\clist_map_inline:Nn \l_tmpa_clist |
| 439 |
{ |
| 440 |
\str_case:nnF {##1} |
| 441 |
{ |
| 442 |
{ space } { \\ \addlinespace \cs_set:Npn \__table_midrule: {} } |
| 443 |
{ THEEND } { \\ \bottomrule } |
| 444 |
}{ |
| 445 |
\__table_midrule: |
| 446 |
\__cookingunits_doc_print_table_row:nn {#1} {##1} |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
\cs_new:Npn \__cookingunits_doc_print_table_row:nn #1#2 |
| 452 |
{ |
| 453 |
\texttt{#2} |
| 454 |
& |
| 455 |
\clist_if_in:NnTF \l_list_of_textunits_clist {#2} |
| 456 |
{ \l_translation_does_not_exist_tl } |
| 457 |
{ |
| 458 |
\__cu_use:n { culang_let_for:nnnN } {#1} { unit-symbol } {#2} \l_tmpa_tl |
| 459 |
\tl_if_in:NnTF \l_tmpa_tl \c__cookingunits_no_translation_str |
| 460 |
{ \l_translation_does_not_exist_tl } |
| 461 |
{ \l_tmpa_tl } |
| 462 |
} |
| 463 |
& |
| 464 |
\__cu_use:n { culang_let_for:nnnN } {#1} { name } {#2} \l_tmpa_tl |
| 465 |
\tl_if_eq:NNTF \l_tmpa_tl \c__cookingunits_no_translation_str |
| 466 |
{ \l_translation_does_not_exist_tl } |
| 467 |
{ \l_tmpa_tl } |
| 468 |
& |
| 469 |
\__cu_use:n { culang_let_for:nnnN } {#1} { name } {#2} \l_tmpa_tl |
| 470 |
\__cu_use:n { culang_let_for:nnnN } {#1} { name-pl } {#2} \l_tmpb_tl |
| 471 |
\str_if_eq:NNF \l_tmpa_tl \l_tmpb_tl |
| 472 |
{ |
| 473 |
\tl_if_eq:NNTF \l_tmpb_tl \c__cookingunits_no_translation_str |
| 474 |
{ \l_translation_does_not_exist_tl } |
| 475 |
{ (\l_tmpb_tl) } |
| 476 |
} |
| 477 |
& |
| 478 |
\__cu_use:n { culang_let_for:nnnN } {#1} { gender } {#2} \l_tmpa_tl |
| 479 |
\tl_if_eq:NNTF \l_tmpa_tl \c__cookingunits_no_translation_str |
| 480 |
{ \l_translation_does_not_exist_tl } |
| 481 |
{ \l_tmpa_tl } |
| 482 |
} |
| 483 |
|
| 484 |
\NewDocumentCommand \CreateTableForPhrases { >{\TrimSpaces} m } |
| 485 |
{ |
| 486 |
\seq_clear:N \l_tmpa_seq |
| 487 |
\__cu_use:n { culang_get_phrase_prop_for:nN } {#1} \l_tmpa_prop |
| 488 |
\prop_if_exist:NTF \l_tmpa_prop |
| 489 |
{ |
| 490 |
\tl_if_eq:NNTF \c__cookingunits_no_translation_str \l_tmpa_prop |
| 491 |
{ \ERRORCreateTablePhraseII } |
| 492 |
{ \prop_get:NnN \l_tmpa_prop { seq } \l_tmpa_seq } |
| 493 |
} |
| 494 |
{ \ERRORCreateTablePhraseI } |
| 495 |
\seq_gput_right:Nn \l_tmpa_seq { THEEND } |
| 496 |
\cs_gset_eq:NN \__table_midrule: \__table_default_midrule: |
| 497 |
\begin{tabular}{ l l l l l } |
| 498 |
\toprule |
| 499 |
\meta{Phrase-key} & phrase & (plural) & gender |
| 500 |
\CreatePhraseTableRow {#1} |
| 501 |
\end{tabular} |
| 502 |
} |
| 503 |
|
| 504 |
\NewDocumentCommand \CreatePhraseTableRow { m } |
| 505 |
{ |
| 506 |
\seq_map_inline:Nn \l_tmpa_seq |
| 507 |
{ |
| 508 |
\str_case:nnF {##1} |
| 509 |
{ |
| 510 |
{ space } { \addlinespace \cs_set:Npn \__table_midrule: {} } |
| 511 |
{ THEEND } { \\ \bottomrule } |
| 512 |
}{ |
| 513 |
\__table_midrule: |
| 514 |
##1 |
| 515 |
& |
| 516 |
\prop_get:NnN \l_tmpa_prop {##1} \l_tmpa_tl |
| 517 |
\tl_gset:NV \l_tmpa_tl \l_tmpa_tl %% Damit global |
| 518 |
\l_tmpa_tl |
| 519 |
& |
| 520 |
\prop_get:NnN \l_tmpa_prop {##1-pl} \l_tmpb_tl |
| 521 |
\tl_if_eq:NNF \l_tmpa_tl \l_tmpb_tl { \l_tmpb_tl } |
| 522 |
& |
| 523 |
\prop_get:NnN \l_tmpa_prop {##1-gender} \l_tmpa_tl |
| 524 |
\l_tmpa_tl |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
\newcommand\txtupde{\textsuperscript{de}} |
| 534 |
\newcommand\txtupsic{\textsuperscript{sicilian}} |
| 535 |
\newcommand\txtupen{\textsuperscript{en}} |
| 536 |
\NewDocumentCommand\unititem { m d** O{} O{} } |
| 537 |
{ |
| 538 |
\item |
| 539 |
[{ |
| 540 |
#1 |
| 541 |
\IfNoValueF {#2} { \use:c { txtup #2 } } |
| 542 |
\tl_if_empty:nF {#3} {\ (#3) } |
| 543 |
\tl_if_empty:nF {#4} {\ [#4] } |
| 544 |
}] |
| 545 |
} |
| 546 |
|
| 547 |
\NewDocumentEnvironment { myquote } { o o } |
| 548 |
{ |
| 549 |
\list{}{% |
| 550 |
\topsep 0pt |
| 551 |
\leftmargin 0pt |
| 552 |
} |
| 553 |
\item\relax |
| 554 |
\itshape |
| 555 |
}{ |
| 556 |
\normalfont |
| 557 |
\IfNoValueF{#1}{(see\ \cite{#1} \IfNoValueF{#2}{\ page \ #2} )} |
| 558 |
\endlist |
| 559 |
} |
| 560 |
\makeatletter |
| 561 |
%\newenvironment{mydescription} |
| 562 |
% {\list{}{\labelwidth\z@ \itemindent-\leftmargin |
| 563 |
% \let\makelabel\descriptionlabel}} |
| 564 |
% {\endlist} |
| 565 |
\renewcommand*\descriptionlabel[1]{\hspace\labelsep |
| 566 |
\normalfont\bfseries #1} |
| 567 |
\makeatother |
| 568 |
\ExplSyntaxOff |
| 569 |
|
| 570 |
\newcommand\cCutext{\mycs{cutext} and \mycs{Cutext}} |
| 571 |
|
| 572 |
\lstset |
| 573 |
{ |
| 574 |
basicstyle = \ttfamily, |
| 575 |
basewidth = 0.51em, |
| 576 |
gobble = 3, |
| 577 |
keywordstyle = \color{blue}, |
| 578 |
language = [LaTeX]{TeX}, |
| 579 |
commentstyle=\color{red!80!black}, |
| 580 |
moretexcs = |
| 581 |
{ |
| 582 |
cunum, |
| 583 |
cutext, |
| 584 |
Cutext, |
| 585 |
cuam, |
| 586 |
newcookingunit, |
| 587 |
declarecookingunit, |
| 588 |
providecookingunit, |
| 589 |
cudefinename, |
| 590 |
cudefinesymbol, |
| 591 |
cusetup, |
| 592 |
cudefinekeys, |
| 593 |
cudefinesinglekey, |
| 594 |
cuaddkeys, |
| 595 |
cuaddsinglekeys, |
| 596 |
cuaddtokeys, |
| 597 |
culabel, |
| 598 |
curef, |
| 599 |
cudefinephrase, |
| 600 |
declarecookingderivatives, |
| 601 |
, cudefinekeychain |
| 602 |
, cuaddtokeychain |
| 603 |
, cudeclareunitgroup |
| 604 |
, cusetoptionfor |
| 605 |
, usepackage |
| 606 |
} |
| 607 |
} |
| 608 |
|
| 609 |
\newcookingunit {st} |
| 610 |
\newcookingunit [\ensuremath{ {} ^ { \circ } }\kern-\scriptspace R{\text{\o}}] {Ro} |
| 611 |
\newcookingunit {ft} |
| 612 |
\newcookingunit {km} |
| 613 |
|
| 614 |
%\cuaddkeys {lb} |
| 615 |
% { |
| 616 |
% {st} { 1/14 } %% 1 lb are 1/14 st |
| 617 |
% } |
| 618 |
\cuaddtokeychain |
| 619 |
{ |
| 620 |
{lb} { 14 } |
| 621 |
{st} { 1 } |
| 622 |
} |
| 623 |
\cuaddtokeys {m} {ft} {0.3048} |
| 624 |
\cuaddtokeys {m} {km} {1000} |
| 625 |
\cuaddsinglekeys {C} |
| 626 |
{ |
| 627 |
{Ro} { #1*21/40 + 7.5 } |
| 628 |
} |
| 629 |
|
| 630 |
\newcommand\eneunit[3]{\sfrac{#1\,#2${}^2$}{#3${}^2$}} |
| 631 |
%% Can overflow and takes too long, hard code it |
| 632 |
\declarecookingderivatives{kg,m,s}{#1*#2:#3}{ (#1)*(#2)^2/(#3)^2 } {\eneunit{#1}{#2}{#3}} |
| 633 |
\declarecookingderivatives{m,s}{#1:#2}{ (#1)/(#2) } {\sfrac{#1}{#2}} |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
\cusetup |
| 638 |
{ |
| 639 |
commands-add-hook = {\stepcounter{CookingUnitsCounter}} , |
| 640 |
cunum-add-hook = {\stepcounter{cunumCounter}} , |
| 641 |
cutext-add-hook = {\stepcounter{cutextCounter}} , |
| 642 |
Cutext-add-hook = {\stepcounter{CutextCounter}} , |
| 643 |
cuam-add-hook = {\stepcounter{cuamCounter}} , |
| 644 |
set-option-for-Ro = { round-precision= 0 } , |
| 645 |
% add-unit-to-group = { weight = {st} , temperature = {Ro} } |
| 646 |
} |
| 647 |
|
| 648 |
%: \cusetup |
| 649 |
\cusetup |
| 650 |
{ |
| 651 |
% weight=stick, |
| 652 |
% 42 = true , |
| 653 |
% convert-to-eV=true , |
| 654 |
% cutext-range-sign = {as}, |
| 655 |
% erase-all-options, |
| 656 |
% set-option-for-K= {}, |
| 657 |
% set-unknown-message = error , |
| 658 |
% check-temperature = true, |
| 659 |
% round-precision = 30 , |
| 660 |
} |
| 661 |
|
| 662 |
|
| 663 |
\EnableCrossrefs |
| 664 |
\CodelineIndex |
| 665 |
\RecordChanges |
| 666 |
\AtEndDocument { \PrintChanges \PrintIndex } |
| 667 |
|
| 668 |
|
| 669 |
\begin{document} |
| 670 |
\DocInput{\jobname.dtx} |
| 671 |
\end{document} |
| 672 |
%</driver> |
| 673 |
% \fi |
| 674 |
% |
| 675 |
% |
| 676 |
% |
| 677 |
% |
| 678 |
% \CharacterTable |
| 679 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 680 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 681 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 682 |
% Exclamation \! Double quote \" Hash (number) \# |
| 683 |
% Dollar \$ Percent \% Ampersand \& |
| 684 |
% Acute accent \' Left paren \( Right paren \) |
| 685 |
% Asterisk \* Plus \+ Comma \, |
| 686 |
% Minus \- Point \. Solidus \/ |
| 687 |
% Colon \: Semicolon \; Less than \< |
| 688 |
% Equals \= Greater than \> Question mark \? |
| 689 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 690 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 691 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 692 |
% Right brace \} Tilde \~} |
| 693 |
% |
| 694 |
% |
| 695 |
% \iffalse |
| 696 |
%: changes |
| 697 |
% \fi |
| 698 |
% |
| 699 |
% \changes {2016/06/11} {0.99} {Added the package option to load 'fmtcount'.} |
| 700 |
% \changes {2016/08/31} {1.00} {Initial version} |
| 701 |
% \changes {2016/08/31} {1.00a} {Fixed calculation: degree Reamur to eV} |
| 702 |
% \changes {2016/09/03} {1.01} {Added units 'ssp', 'csp', 'dsp'} |
| 703 |
% \changes {2016/09/03} {1.01} {English unit: litre (and only litre) uses the curly l \protect\ensuremath{\protect\ell} now } |
| 704 |
% \changes {2016/09/03} {1.01} {British English: 'pinch' is written in full} |
| 705 |
% \changes {2016/09/03} {1.01} {Separated Messerspitze and pinch} |
| 706 |
% \changes {2016/09/05} {1.02} {Replaced \cs{cufrac} by \cs{cuam}} |
| 707 |
% \changes {2016/09/05} {1.02} {New message: 'obsolete-command'} |
| 708 |
% \changes {2016/09/09} {1.02a} {Changed name from \cs{@@_parse_fraction_in_input:www} to \cs{@@_parse_mixed_fraction_in_input:www}} |
| 709 |
% \changes {2016/09/09} {1.02b} {Changed name from \cs{@@_cunum_parse_range} (and derivatives) to \cs{@@_cutext_parse_range}.} |
| 710 |
% \changes {2016/09/09} {1.02c} {In \cs{@@_cutext_default:nnn} it is only |
| 711 |
% checked once if a range is inside.} |
| 712 |
% \changes {2016/09/09} {1.02d} {\cs{@@_calculate_input_and_store_in:nN} optimiert durch neue property-key: single.} |
| 713 |
% \changes {2016/09/09} {1.02d} {Add 'single' to property list of singlekeys.} |
| 714 |
% \changes {2016/09/16} {1.02e} {Only use \cs{phantom} if the argument (for \cs{phantom}) is not empty.} |
| 715 |
% \changes {2016/09/09} {1.02i} {Delete 'single' from property lists of singlekeys cause it is not as safe as I thought.} |
| 716 |
% \changes {2016/09/09} {1.02f} {Corrected mistake: 'ELektronenvolt' (note uppercase L) to 'Elektronenvolt' in german.} |
| 717 |
% \changes {2016/09/26} {1.03} {New option (and needed macros): add-temperature-to-check.} |
| 718 |
% \changes {2016/09/26} {1.03a} {\cs{cuaddsinglekeys} now tests if the unit exists (it didn't before).} |
| 719 |
% \changes {2016/09/26} {1.03b} {Replaced \cs{prop_clear_new:c} by \cs{prop_clear:c}.} |
| 720 |
% \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.} |
| 721 |
% \changes {2016/09/26} {1.04} {New option: 'round-half'.} |
| 722 |
% \changes {2016/10/19} {1.04} {Use \cs{keys_set:nn} only if second argument is not empty.} |
| 723 |
% \changes {2016/10/19} {1.04} {'convert-to-eV' now also as optional argument available.} |
| 724 |
% \changes {2016/10/19} {1.04} {Option 'load-time-option' now spells 'available' correct.} |
| 725 |
% \changes {2016/10/19} {1.04} {Update of documentation.} |
| 726 |
% \changes {2016/10/28} {1.10alpha} {Start implementation of \enquote{Change recipe from $n$ to $m$ persons.}.} |
| 727 |
% \changes {2016/10/28} {1.10alpha} {\cs{cutext} (and \cs{Cutext}) and \cs{cuam} now parse their input like \cs{cunum}. This is needed as they also need to be changed.} |
| 728 |
% \changes {2016/10/29} {1.10alpha} {Tiding code: Now every command is separated into a \enquote{calc} function, a \enquote{print numeric value} and a \enquote{print unit} (if there) function. At least, that's the plan.} |
| 729 |
% \changes {2016/10/30} {1.10} {Fractions should now deal correctly with minus signs.} |
| 730 |
% \changes {2016/11/07} {1.10} {Finished writing v1.10.} |
| 731 |
% \changes {2016/11/13} {1.10} {Change amounts for specific number of persons.} |
| 732 |
% \changes {2016/11/13} {1.10} {\cs{cutext}, \cs{Cutext} and \cs{cuam} check their input, allows conversion of units.} |
| 733 |
% \changes {2016/11/13} {1.10} {New commands: \cs{culabel} and \cs{curef}.} |
| 734 |
% \changes {2016/11/13} {1.10} {New commands: \cs{declarecookingunit} and \cs{providecookingunit}.} |
| 735 |
% \changes {2016/11/13} {1.10} {New options: \opt{cutext-to-cunum}, \opt{cutext-change-unit} and \opt{cutext-space}.} |
| 736 |
% \changes {2016/11/13} {1.10} {New options: \opt{cuam-version} and \opt{cutext-version}} |
| 737 |
% \changes {2016/11/13} {1.10} {New options: \opt{recalculate-amount} and \opt{set-number-of-persons}, \opt{label}, \opt{get-label}, \opt{ref}.} |
| 738 |
% \changes {2017/03/10} {1.10a} {\cs{curef} is now defined by \cs{NewExpandableDocumentCommand} instead of the Declare variant.} |
| 739 |
% \changes {2017/03/10} {1.11} {Removed \cs{translate} and others from code |
| 740 |
% and replaced them with wrapper-macros.} |
| 741 |
% \changes {2017/03/10} {1.11} {Removed things like 'cu-unit' from translate input |
| 742 |
% and placed them into separate tl's.} |
| 743 |
% |
| 744 |
% \changes {2017/10/23} {1.20} {Replaced \pkg{translator} by \pkg{translations}.} |
| 745 |
% \changes {2017/10/23} {1.20} {Added \enquote{phrases}.} |
| 746 |
% \changes {2017/10/23} {1.20} {Added unit \enquote{stick} (of butter).} |
| 747 |
% \changes {2017/10/23} {1.20} {|<| is not allowed as a special sign anymore.} |
| 748 |
% \changes {2017/10/23} {1.20} {New option: \opt{set-cutext-translation-message}.} |
| 749 |
% \changes {2017/10/23} {1.20} {New option: \opt{print-numerals}.} |
| 750 |
% \changes {2017/10/23} {1.20} {New option: \opt{use-phrases}.} |
| 751 |
% \changes {2017/10/23} {1.20} {New option: \opt{phrase-space}.} |
| 752 |
% \changes {2017/10/23} {1.20} {New option: \opt{amount-unit-space}.} |
| 753 |
% \changes {2017/10/23} {1.20} {Now checks for ranges if both values can be printed as numerals (if activated) (bug fix).} |
| 754 |
% \changes {2017/10/23} {1.20} {Reworked quite a lot of code.} |
| 755 |
% |
| 756 |
% \changes {2018/04/20} {1.30} {Allow round precision to be negative.} |
| 757 |
% \changes {2018/04/20} {1.30} {Fix argument specifiers.} |
| 758 |
% \changes {2018/04/20} {1.30} {Change large portions of code.} |
| 759 |
% \changes {2018/04/20} {1.30} {Introduce key-groups (weight, volume, etc.).} |
| 760 |
% \changes {2018/04/20} {1.30} {Option: \opt{add-natural-unit}.} |
| 761 |
% \changes {2018/04/20} {1.30} {New Option: \opt{42}.} |
| 762 |
% \changes {2018/04/20} {1.30} {New options: \opt{expand-both}, \opt{expand-amount}, \opt{expand-unit}.} |
| 763 |
% \changes {2018/04/20} {1.30} {New options: \opt{set-option-for} \& \opt{add-option-for}.} |
| 764 |
% \changes {2018/04/20} {1.30} {New option: \opt{erase-all-options-for}} |
| 765 |
% \changes {2018/04/20} {1.30} {New option: \opt{add-unit-to-group}} |
| 766 |
% \changes {2018/04/20} {1.30} {New feature: Hooks} |
| 767 |
% \changes {2018/04/20} {1.30} {New parsing algorithm. Hopefully better |
| 768 |
% error recovery (if signs for fractions are in wrong order e.g.)} |
| 769 |
% \changes {2018/04/20} {1.30} {Add \enquote{Division-by-zero} error.} |
| 770 |
% \changes {2018/04/20} {1.30} {Cooking Units-keys are not allowed to contain |
| 771 |
% either \enquote{,} or \enquote{/}.} |
| 772 |
% |
| 773 |
% \changes {2018/06/05} {1.40} {This version introduces mayor internal changes. |
| 774 |
% For users not many things change.} |
| 775 |
% \changes {2018/06/05} {1.40} {Rework parsing code (again). As this is |
| 776 |
% basically an improved version of the old parsing algorithm, there is |
| 777 |
% no huge version change.} |
| 778 |
% \changes {2018/06/05} {1.40} {Improve error-recovery by a lot!} |
| 779 |
% \changes {2018/06/05} {1.40} {Bugfix: A range in \mycs{Cutext} (and numerals=true) |
| 780 |
% will print the second word small.} |
| 781 |
% \changes {2018/06/05} {1.40} {Add \enquote{range-sign} for translations (not usable yet).} |
| 782 |
% \changes {2018/06/05} {1.40} {Convert \texttt{clist} to \texttt{seq} if possible.} |
| 783 |
% \changes {2018/06/05} {1.40} {Remove unnecessary variants.} |
| 784 |
% \changes {2018/06/05} {1.40} {Fix some more argument specifiers.} |
| 785 |
% \changes {2018/06/05} {1.40} {Renaming of some internal commands.} |
| 786 |
% \changes {2018/06/05} {1.40} {\opt{set-unknown-message}: Fix default value.} |
| 787 |
% \changes {2018/06/05} {1.40} {Change (\texttt{amount-not-known}): Change message a bit.} |
| 788 |
% \changes {2018/06/05} {1.40} {Bugfix (\texttt{label-not-defined}): Add |'#1'|.} |
| 789 |
% \changes {2018/06/05} {1.40} {Bugfix (\texttt{unit-change}): \opt{convert-to-eV} |
| 790 |
% can be again used as a local argument.} |
| 791 |
% \changes {2018/06/05} {1.40} {Change order of boolean testing for |\@@_calc_references_and_store_in:N|.} |
| 792 |
% \changes {2018/06/05} {1.40} {Bugfix (\texttt{phrases}): Use the phrase from the first amount to check |
| 793 |
% the second (and don't parse through the second amount).} |
| 794 |
% |
| 795 |
% \changes {2018/09/24} {1.45} {Changes prefix from \texttt{cooking\_units} to \texttt{cookingunits}.} |
| 796 |
% \changes {2018/09/24} {1.45} {New language symbols: \opt{cutext-range-sign}} |
| 797 |
% \changes {2018/09/24} {1.45} {Improved french (not in general, only for this package)} |
| 798 |
% \changes {2018/09/24} {1.45} {New section in documentation.} |
| 799 |
% \changes {2018/09/24} {1.45} {Remove exhaustive expansion from internals (shouldn't change anything for users).} |
| 800 |
% |
| 801 |
% \changes {2021/03/21} {2.00} {Overall reworking of internal code.} |
| 802 |
% \changes {2021/03/21} {2.00} {Much better error handling.} |
| 803 |
% \changes {2021/03/21} {2.00} {Remove exhaustive expansion from translations. Shouldn't really change anything.} |
| 804 |
% \changes {2021/03/21} {2.00} {New options: \opt{definition/symbol}, \opt{definition/gender}, \opt{definition/set-option}, \opt{definition/add-to-group}. } |
| 805 |
% \changes {2021/03/21} {2.00} {Adding keys to unit definition.} |
| 806 |
% \changes {2021/03/21} {2.00} {Updatet |\declarecookingderivatives|.} |
| 807 |
% \changes {2021/03/21} {2.00} {New commands: |\cudefinekeychain|, |\cuaddtokeychain|} |
| 808 |
% \changes {2021/03/21} {2.00} {New joke options: \opt{nothing-special}, \opt{going-bonkers}, \opt{fully-bonkers} and \opt{xD-lol}.} |
| 809 |
% \changes {2021/03/21} {2.00} {New commands to define keys: \mycs{cudefinekeychain} and \mycs{cuaddtokeychain}.} |
| 810 |
% \changes {2021/03/21} {2.00} {Using commands as unit-keys now works.} |
| 811 |
% |
| 812 |
% \changes {2022/03/26} {2.00a} {Bugfix: Fixing property list retrival error (storing property lists via translations did not work too well).} |
| 813 |
% \changes {2022/03/26} {2.00a} {Bugfix: |\cuam| prints a unit in case of an error. This also happens with \opt{parse-number=false}.} |
| 814 |
% \changes {2022/03/26} {2.00a} {Bugfix: Remove \cs{peek_meaning_ignore_spaces:NTF}.} |
| 815 |
% |
| 816 |
% \changes {2022/06/06} {2.01} {Correction of french language. Thanks to Alexis Jeandeau} |
| 817 |
% \changes {2022/06/06} {2.01} {Implement a way to define the plural-finding algorithm.} |
| 818 |
% \changes {2022/06/06} {2.01} {Add two public commands \cs{cookingunits_print_fraction:nnn} and \cs{cookingunits_print_range:nn}.} |
| 819 |
% |
| 820 |
% \changes {2022/11/27} {3.00} {Allow ranges and fractions to be combined!} |
| 821 |
% \changes {2022/11/27} {3.00} {New input type: products!} |
| 822 |
% \changes {2022/11/27} {3.00} {Change |cutext-range-unit| to |cutext-range-phrase|.} |
| 823 |
% |
| 824 |
% |
| 825 |
% |
| 826 |
% \GetFileInfo{\jobname.sty} |
| 827 |
% |
| 828 |
%\title{The \pkg{\jobname} package^^A |
| 829 |
%\thanks{This document corresponds to \textsf{Benedikt Vitecek}~\fileversion, dated~\filedate.}} |
| 830 |
%\author{Ben Vitecek \\ [email protected]}% |
| 831 |
%\date{\filedate}% |
| 832 |
% |
| 833 |
% |
| 834 |
% \maketitle |
| 835 |
%^^A \TODO{Test für Phrases schreiben!} |
| 836 |
% |
| 837 |
% \begin{documentation} |
| 838 |
% \begin{abstract} |
| 839 |
% This package enables user to globally format units, to switch |
| 840 |
% between them and change your recipes to a given |
| 841 |
% number of persons. |
| 842 |
% |
| 843 |
% For not implemented units or differences between Imperial and U.S.\ unit |
| 844 |
% you may have a look at \cref{sec:other-units}. |
| 845 |
% |
| 846 |
% It should be used for light-hearted things like |
| 847 |
% cookery books (and not e.g. scientific texts; use e.g.\ \pkg{siunitx} for those). |
| 848 |
% |
| 849 |
% ^^A Please read through the section \enquote{Important Changes} |
| 850 |
% \end{abstract} |
| 851 |
% |
| 852 |
% \tableofcontents |
| 853 |
% |
| 854 |
% \section{Introduction} |
| 855 |
% |
| 856 |
% While writing on a cookery book I used -- for some reasons whatsoever -- |
| 857 |
% three different units for weight: kilogram (kg), gram (g) and |
| 858 |
% decagram (dag, or older: dkg). Later my mother told me that she |
| 859 |
% doesn't like it if a cookery book uses more than two different units |
| 860 |
% (for weight in this case). Happily I hardly used Decagram and |
| 861 |
% therefore didn't have many problems changing the units. But, well |
| 862 |
% \dots\ I am using \LaTeX\ and changing those units by hand seemed |
| 863 |
% not very \LaTeX-like, so I started writing some code to convert |
| 864 |
% units. I expanded the code, rewrote it in \LaTeX3 (which is much |
| 865 |
% more pleasant than \LaTeXe) and here it is. |
| 866 |
% |
| 867 |
% |
| 868 |
% |
| 869 |
% |
| 870 |
% |
| 871 |
% \subsection{Supported languages} |
| 872 |
% \begin{itemize} |
| 873 |
% \item German |
| 874 |
% \item English |
| 875 |
% \item French |
| 876 |
% \end{itemize} |
| 877 |
% Want to contribute a new language or make a correction to an existing one? |
| 878 |
% See \cref{sec:bug-feed} for more details. Wanna just check the |
| 879 |
% existing translations? See \cref{sec:Translations}. |
| 880 |
% |
| 881 |
% \subsection{What's new?} |
| 882 |
% Since v3.00 fraction and ranges can now be combined! |
| 883 |
% Furthermore, products are introduced! Check the next section for more info. |
| 884 |
% |
| 885 |
% \section {The Commands} |
| 886 |
% \label{sec:commands} |
| 887 |
% |
| 888 |
% |
| 889 |
% This package offers the following commands for number/unit printing (and |
| 890 |
% converting): |
| 891 |
% |
| 892 |
% \begin{itemize} |
| 893 |
% \item \mycs{cunum}\myaarg{label}\oarg{options}\marg{amount}\oarg{space}\marg{unit-key} |
| 894 |
% \item \mycs{cutext}\myaarg{label}\oarg{options}\marg{amount}\marg{unit-key} |
| 895 |
% \item \mycs{Cutext}\myaarg{label}\oarg{options}\marg{amount}\marg{unit-key} |
| 896 |
% \item \mycs{cuam}\myaarg{label}\oarg{options} \marg{amount} |
| 897 |
% \item \mycs{cusetup}\marg{options} |
| 898 |
% \end{itemize} |
| 899 |
% |
| 900 |
% Numbers and units are printed using \mycs{cunum}. The numerical part |
| 901 |
% can interpret \verb|_| and \texttt{/} as (mixed) fractions, |
| 902 |
% \verb|--| as a separator for ranges and |x| or |\times| for products; |
| 903 |
% to convert units use the option |
| 904 |
% \texttt{\meta{old-unit}=\meta{new-unit}}\footnote{New keys can be |
| 905 |
% added and defined, see \cref{sec:pred-units} and |
| 906 |
% \cref{sec:def-units} for further information.}. It furthermore |
| 907 |
% allows the sign \texttt{?} to be used as a placeholder for not known |
| 908 |
% amounts and raises a warning to remind you that this amount needs a |
| 909 |
% check-up\footnote{You can customize this behavior, see |
| 910 |
% \cref{sec:options}}. \oarg{space} adds a space between the number |
| 911 |
% and the unit using \lstinline|\phantom|. |
| 912 |
% |
| 913 |
% For a list of predefined units have a look at \cref{tab:def-units}. |
| 914 |
% |
| 915 |
% \meta{label} is explained in \cref{sec:labeletref}. |
| 916 |
% |
| 917 |
% |
| 918 |
% \begin{cuexamplecode} |
| 919 |
% \cunum{1}{kg} \\ |
| 920 |
% \cunum{2.3}{kg} \\ |
| 921 |
% \cunum{2,3}{kg} \\ |
| 922 |
% \cunum{2--3}{kg} \\ |
| 923 |
% \cunum{2.5--3.5}{kg} \\ |
| 924 |
% \cunum{2.5 x 3.5}{kg} \\ |
| 925 |
% \cunum{2.5 \times 3.5}{kg} \\ |
| 926 |
% \cunum{2.5 x 3 \times 4,5}{kg} \\ |
| 927 |
% \cunum[kg=g]{2.5--3,5}{kg} \\ |
| 928 |
% \cunum[kg=g]{2.5 x 3,5}{kg} \\ |
| 929 |
% \cunum[C=F]{200}{C} \\ |
| 930 |
% \cunum[C=F]{180--200}{C} \\ |
| 931 |
% \cunum{1/2}{m} \\ |
| 932 |
% \cunum{1_1/2}{m} \\ |
| 933 |
% \cunum[m=cm]{1_1/2}{m} \\ |
| 934 |
% \cunum{1_1/2--2}{m} \\ |
| 935 |
% \cunum[m=cm]{1--1_1/2}{m} \\ |
| 936 |
% \cunum[m=cm]{1 x 1_1/2 x 2}{m} \\ |
| 937 |
% \cunum{?}{l} \\ |
| 938 |
% \cunum{50}{dag} \\ |
| 939 |
% \cunum{5}[0]{dag} \\ |
| 940 |
% \cunum{1.1234}{m} |
| 941 |
% \end{cuexamplecode} |
| 942 |
% |
| 943 |
% Decimal numbers are automatically rounded to 2 digits after the |
| 944 |
% colon, temperatures (\myunit{C}, \myunit{F}, \myunit{K} and |
| 945 |
% \myunit{Re}) are automatically rounded to integers.\footnote{You can |
| 946 |
% -- of course -- change this behavior, see \cref{sec:options}.} |
| 947 |
% |
| 948 |
% |
| 949 |
% \cCutext\ print the number and the written name of the unit. Since |
| 950 |
% v1.10 it works similar\footnote{One could also say \enquote{exactly |
| 951 |
% like}.} to \mycs{cunum}: it allows the conversion between units and |
| 952 |
% interprets the numerical part (again |_| and |/| are used for |
| 953 |
% (mixed) fractions, |--| for ranges and |x| or |\times| for products). |
| 954 |
% Furthermore, \cCutext\ allow |
| 955 |
% the usages of numerals (see \cref{sec:load-time-options} for more information). |
| 956 |
%^^A if the package |
| 957 |
%^^A option \opt{use-fmtcount-numerals} (see \cref{sec:load-time-options}) |
| 958 |
%^^A is used, integers below a specific integer |
| 959 |
%^^A (by default 13; see \opt{use-numerals-below}) are written out with |
| 960 |
%^^A \lstinline|\Cutext| capitalizing the first letter (using package |
| 961 |
%^^A \pkg{fmtcount}). |
| 962 |
% |
| 963 |
% \begin{cuexamplecode} |
| 964 |
% \cutext{1}{l} \\ |
| 965 |
% \Cutext{1}{l} \\ |
| 966 |
% \Cutext{1--2}{l} \\ |
| 967 |
% \Cutext{1 x 2}{l} \\ |
| 968 |
% \cutext{12}{l} \\ |
| 969 |
% \Cutext{13}{l} |
| 970 |
% \end{cuexamplecode} |
| 971 |
% and using (e.g.)\ package option \opt{use-fmtcount-numerals=true} |
| 972 |
% \cusetup{print-numerals=true} |
| 973 |
% \begin{cuexamplecode} |
| 974 |
% \cutext{1}{l} \\ |
| 975 |
% \Cutext{1}{l} \\ |
| 976 |
% \cutext{1--2}{l} \\ |
| 977 |
% \Cutext{1--2}{l} \\ |
| 978 |
% \Cutext{1 x 2}{l} \\ |
| 979 |
% \cutext{12}{l} \\ |
| 980 |
% \Cutext{13}{l} |
| 981 |
% \end{cuexamplecode} |
| 982 |
% \cusetup{print-numerals=false} |
| 983 |
% You can customize the numeral functions used with \opt{numeral-function} and |
| 984 |
% \opt{Numeral-function}. |
| 985 |
% |
| 986 |
% Furthermore, |
| 987 |
% since v1.10 \cCutext\ also allow their units to be changed (this behavior |
| 988 |
% can be altered using \opt{cutext-change-unit}): |
| 989 |
% \begin{cuexamplecode} |
| 990 |
% \cusetup{ l=ml } @ |
| 991 |
% \cutext{1}{l} \\ |
| 992 |
% \Cutext{1}{l} \\ |
| 993 |
% \cutext{1--2}{l} \\ |
| 994 |
% \cutext{1 x 2}{l} \\ |
| 995 |
% \cutext{12}{l} \\ |
| 996 |
% \Cutext{13}{l} \\ |
| 997 |
% \Cutext{?}{l} \\ |
| 998 |
% \Cutext{1/2}{l} \\ |
| 999 |
% \end{cuexamplecode} |
| 1000 |
% |
| 1001 |
% |
| 1002 |
% \lstinline|\cuam| works like \mycs{cunum}, but without a unit, so |
| 1003 |
% changing units doesn't affect it. It has the same syntax as \mycs{cunum}. |
| 1004 |
% |
| 1005 |
% \begin{cuexamplecode} |
| 1006 |
% \cuam{3} \\ |
| 1007 |
% \cuam{2--3} \\ |
| 1008 |
% \cuam{2 x 3 x 4} \\ |
| 1009 |
% \cuam{2/3} \\ |
| 1010 |
% \cuam{1_2/3} \\ |
| 1011 |
% \cuam{2/3--1_2/3} \\ |
| 1012 |
% \cuam{2/3 x 1 x 1_2/3} |
| 1013 |
% \end{cuexamplecode} |
| 1014 |
% |
| 1015 |
% Furthermore it allows the concept of \enquote{phrases} (replacing a positive integer |
| 1016 |
% by a word; such as \enquote{12} becoming \enquote{dozen}\footnote{At least I think}) |
| 1017 |
% which can be activated by the option \opt{use-phrases} |
| 1018 |
% (as I don't know any english phrases, I switched the language to german for the following examples) |
| 1019 |
%^^A \begin{myde} |
| 1020 |
% \begin{cuexamplecode} |
| 1021 |
% \selectlanguage{ngerman} @ |
| 1022 |
% \cusetup{use-phrases=true} @ |
| 1023 |
% \cuam{11} \\ |
| 1024 |
% \cuam{12} \\ |
| 1025 |
% \cuam{13} \\ |
| 1026 |
% \cuam{24} \\ |
| 1027 |
% \cuam{12--24} \\ |
| 1028 |
% \cuam{12--13}\\ |
| 1029 |
% \cuam{12x24x36} \\ |
| 1030 |
% \cuam{18} \\ |
| 1031 |
% \cuam{60} |
| 1032 |
% \end{cuexamplecode} |
| 1033 |
%^^A \end{myde} |
| 1034 |
% |
| 1035 |
% |
| 1036 |
% \section{Label \& refs: Changing the amount of the recipe} |
| 1037 |
% \label{sec:labeletref} |
| 1038 |
% |
| 1039 |
% |
| 1040 |
% What if you don't want to change units, but the amounts of the recipe because |
| 1041 |
% you cook not for 4 persons, but for 2 and don't like to do the math? |
| 1042 |
% Simple, use the following commands: |
| 1043 |
% |
| 1044 |
% \begin{itemize} |
| 1045 |
% \item \mycs{culabel}\marg{label}\marg{number of persons} |
| 1046 |
% \item \mycs{curef}\marg{label} |
| 1047 |
% \end{itemize} |
| 1048 |
% |
| 1049 |
% |
| 1050 |
% The first one is the important one: It defines a \meta{label} for a recipe |
| 1051 |
% which is initially for \meta{number of persons}. Afterwards \meta{label} |
| 1052 |
% can be used to tell the commands from \cref{sec:commands} that the given |
| 1053 |
% amounts are for \meta{number of persons}. |
| 1054 |
% Each \meta{label} must be unique and an error is raised if a \meta{label} |
| 1055 |
% is already defined. |
| 1056 |
% |
| 1057 |
% If you would like to print the number of persons this recipe is for, use |
| 1058 |
% \mycs{curef}, which is fully expandable. |
| 1059 |
% |
| 1060 |
% The following example uses \mycs{culabel} to specify that the recipe is |
| 1061 |
% initially intended for 2 persons: |
| 1062 |
% \begin{cuexamplecode} |
| 1063 |
% \culabel{recipe}{2} @ |
| 1064 |
% recipe & for & \curef{recipe} & persons: \\ |
| 1065 |
% \cunum<recipe>{10--20}{dag} & flour, \\ |
| 1066 |
% \cunum<recipe>{1/2}{l} & water, \\ |
| 1067 |
% \cutext[ref=recipe]{10}{g} & nuts, \\ |
| 1068 |
% \cuam<recipe>{2--3} & eggs, \\ |
| 1069 |
% \cunum{180}{C} & (\cunum[C=F]{180}{C}) & open & fire |
| 1070 |
% \end{cuexamplecode} |
| 1071 |
% |
| 1072 |
% In combination with the option \opt{set-number-of-persons} |
| 1073 |
% and \opt{recalculate-amount} you can have this recipe |
| 1074 |
% changed to four persons: |
| 1075 |
% \begin{lstlisting} |
| 1076 |
% \culabel{recipe}{2} |
| 1077 |
% %% adding options: |
| 1078 |
% \cusetup{set-number-of-persons=4,recalculate-amount=true} |
| 1079 |
% \end{lstlisting} |
| 1080 |
% \cusetup{set-number-of-persons=4,recalculate-amount=true} |
| 1081 |
% |
| 1082 |
% \begin{cuexamplecode} |
| 1083 |
% recipe & for & \curef{recipe} & persons: \\ |
| 1084 |
% \cunum<recipe>{10--20}{dag} & flour, \\ |
| 1085 |
% \cunum<recipe>{1/2}{l} & water, \\ |
| 1086 |
% \cutext[ref=recipe]{10}{g} & nuts, \\ |
| 1087 |
% \cuam<recipe>{2--3} & eggs, \\ |
| 1088 |
% \cunum{180}{C} & & (\cunum[C=F]{180}{C}) & open & fire |
| 1089 |
% \end{cuexamplecode} |
| 1090 |
% \cusetup{recalculate-amount=false} |
| 1091 |
% |
| 1092 |
% Note that fractions are automatically evaluated and that only values |
| 1093 |
% with a \meta{label} are changed (\lstinline|\cunum{180}{C}| for example |
| 1094 |
% stays the same which also makes sense as the heat should be the same). |
| 1095 |
% |
| 1096 |
% |
| 1097 |
% |
| 1098 |
% |
| 1099 |
% |
| 1100 |
% |
| 1101 |
% \section{Good to know stuff} |
| 1102 |
% |
| 1103 |
% \subsection{Rounding temperatures} |
| 1104 |
% |
| 1105 |
% |
| 1106 |
% By default temperatures are rounded to integers (using \opt{round-precision=0}). |
| 1107 |
% Since v1.30 it is possible to round amounts to a negative precision. |
| 1108 |
% If you want to round temperatures to the tens see the following |
| 1109 |
% example (\mycs{cusetoptionfor} is described in \cref{sec:opt:unit-spec}). |
| 1110 |
% |
| 1111 |
% \begin{cuexamplecode} |
| 1112 |
% \cunum{182}{C} \\ |
| 1113 |
% \cunum[C=F]{180}{C} \\ |
| 1114 |
% \cunum[C=Re]{180}{C} \\ |
| 1115 |
% \cunum[C=K]{180}{C} \\ |
| 1116 |
% \cusetoptionfor{C,F,K,Re}{ round-precision = -1 } @ |
| 1117 |
% \cunum{182}{C} \\ |
| 1118 |
% \cunum[C=F]{180}{C} \\ |
| 1119 |
% \cunum[C=Re]{180}{C} \\ |
| 1120 |
% \cunum[C=K]{180}{C} \\ |
| 1121 |
% \end{cuexamplecode} |
| 1122 |
% |
| 1123 |
% |
| 1124 |
% \subsection{At which point is the plural used?} |
| 1125 |
% While using \cCutext\ one may wonder which rules are used in order to determine |
| 1126 |
% if the printed unit is singular or plural. If rules for a specific language are not found |
| 1127 |
% the default ruleset is used. There are currently two rule sets: One default |
| 1128 |
% and one for the french language. |
| 1129 |
% |
| 1130 |
% Each set has three separate rules: one for \enquote{normal} numbers, one for |
| 1131 |
% ranges and one for fractions. |
| 1132 |
% |
| 1133 |
% \subsubsection*{French} |
| 1134 |
% |
| 1135 |
% Use singular if: |
| 1136 |
% \begin{description} |
| 1137 |
% \item[number] The absolute value of the number is smaller $2$ |
| 1138 |
% \item[fraction] The absolute value of the evaluated fraction is smaller $2$. |
| 1139 |
% (e.g.\ $1\,\sfrac{1}{2} = 1.5$ uses singular, $2\,\sfrac{3}{4} = 2.75$ uses plural). |
| 1140 |
% \item[range/product] Take the last item and use one of the rules above. |
| 1141 |
% \end{description} |
| 1142 |
% |
| 1143 |
% For sources see \cite{Plural-French-Academia}, \cite{Plural-French-absolute-1} \& |
| 1144 |
% \cite{Plural-French-absolute-2}\footnote{Thanks a lot to Alexis Jeandeau! I never would |
| 1145 |
% have imagined that the french language uses the sinfular for everything smaller $2$.}. |
| 1146 |
% |
| 1147 |
% \subsubsection*{Default (all other languages)} |
| 1148 |
% |
| 1149 |
% Use singular if: |
| 1150 |
% \begin{description} |
| 1151 |
% \item[number] The number is equal to $1$. |
| 1152 |
% \item[fraction] There is no mixed fraction part and the numerator is equal to $1$. |
| 1153 |
% \item[range/product] Take the last item and use one of the rules above. |
| 1154 |
% \end{description} |
| 1155 |
% |
| 1156 |
% \section{Predefined units \& some notes} |
| 1157 |
% \label{sec:pred-units} |
| 1158 |
% |
| 1159 |
% |
| 1160 |
% |
| 1161 |
% In \cref{tab:def-units} and you can find all predefined units which can be |
| 1162 |
% transformed into each other (sorted by group). Other predefined units |
| 1163 |
% (which cannot be used for transformations) are shown in \cref{tab:some-more-units}. |
| 1164 |
% \Cref{tab:strange-units} pretty much exists just for fun. |
| 1165 |
% |
| 1166 |
% |
| 1167 |
% \begin{table}[htb] |
| 1168 |
% \centering |
| 1169 |
% \caption{^^A |
| 1170 |
% This table shows all units which can be transformed into each other, sorted |
| 1171 |
% by group. The columns \enquote{default} show the abbreviations used if |
| 1172 |
% no translation is defined for the given language. The translations used for \cCutext\ |
| 1173 |
% are shown in \cref{sec:Translations}. |
| 1174 |
% Note that \enquote{electron volt} exists just for fun. |
| 1175 |
% } |
| 1176 |
% \smallskip |
| 1177 |
% \begin{tabular}{ lll @{\hspace{1cm}} lll } |
| 1178 |
% \toprule |
| 1179 |
% description & key & default & description & key & default \\ \midrule |
| 1180 |
% \PrintUnit {kg} & \PrintUnit{m} \\ |
| 1181 |
% \PrintUnit {dag} & \PrintUnit{dm} \\ |
| 1182 |
% \PrintUnit {g} & \PrintUnit{cm} \\ |
| 1183 |
% \PrintUnit {oz} & \PrintUnit{mm} \\ |
| 1184 |
% \PrintUnit {lb} & \PrintUnit{in} \\ |
| 1185 |
% \PrintUnit [ (of butter)] {stick} \\ \addlinespace |
| 1186 |
% |
| 1187 |
% \PrintUnit {d} & \PrintUnit {l} \\ |
| 1188 |
% \PrintUnit {h} & \PrintUnit {dl} \\ |
| 1189 |
% \PrintUnit {min} & \PrintUnit {cl} \\ |
| 1190 |
% \PrintUnit {s} & \PrintUnit{ml} \\ \addlinespace |
| 1191 |
% |
| 1192 |
% \PrintUnit{cal} & \PrintUnit{C} \\ |
| 1193 |
% \PrintUnit{kcal} & \PrintUnit{F} \\ |
| 1194 |
% \PrintUnit{J} & \PrintUnit{Re} \\ |
| 1195 |
% \PrintUnit{kJ} & \PrintUnit{K} \\ |
| 1196 |
% \PrintUnit{eV} |
| 1197 |
% |
| 1198 |
% \\ \bottomrule |
| 1199 |
% \end{tabular} |
| 1200 |
% \label{tab:def-units} |
| 1201 |
% \end{table} |
| 1202 |
% |
| 1203 |
% \begin{table}[htb] |
| 1204 |
% \centering |
| 1205 |
% \caption{A (not only) spoonful of (more or less) country and |
| 1206 |
% language dependent units. Please note that sometimes a |
| 1207 |
% translation is nearly impossible as a unit |
| 1208 |
% (e.g. \enquote{saltspoonful}) may not exist in another language |
| 1209 |
% (like german; at least I never heard of it). So please only use |
| 1210 |
% units known to you. For \enquote{tablespoon} and \enquote{teaspoon} |
| 1211 |
% I used the german abbreviations \enquote{EL} and \enquote{TL} (because I forgot to |
| 1212 |
% change them initially).} |
| 1213 |
% \smallskip |
| 1214 |
% \begin{tabular}{ lll } |
| 1215 |
% \toprule |
| 1216 |
% description & key & symbol \\ \midrule |
| 1217 |
% \PrintUnit {pn} \\ \addlinespace |
| 1218 |
% \PrintUnit {EL} \\ |
| 1219 |
% \PrintUnit {TL} \\ |
| 1220 |
% \PrintUnit {dsp} \\ |
| 1221 |
% \PrintUnit {csp} \\ |
| 1222 |
% \PrintUnit {ssp} \\ \addlinespace |
| 1223 |
% \PrintUnit [Messerspitze (point of a knife)] {Msp} \\ |
| 1224 |
% \bottomrule |
| 1225 |
% \end{tabular} |
| 1226 |
% \label{tab:some-more-units} |
| 1227 |
% \end{table} |
| 1228 |
% |
| 1229 |
% \begin{table}[htb] |
| 1230 |
% \centering |
| 1231 |
% \caption{List of (not really) nonsense units (exist just for fun, there will be |
| 1232 |
% no support for those units; unless -- of course -- you really want it).} |
| 1233 |
% \smallskip |
| 1234 |
% \begin{tabular}{ ll } |
| 1235 |
% \toprule |
| 1236 |
% unit-key & symbol \\ \midrule |
| 1237 |
% \PrintUnitSymbol {eVc-2} \\ |
| 1238 |
% \PrintUnitSymbol {hbareV-1} \\ |
| 1239 |
% \PrintUnitSymbol {chbareV-1} \\ |
| 1240 |
% \PrintUnitSymbol {(chbareV-1)3} \\ |
| 1241 |
% \bottomrule |
| 1242 |
% \end{tabular} |
| 1243 |
% \label{tab:strange-units} |
| 1244 |
% \end{table} |
| 1245 |
% |
| 1246 |
% |
| 1247 |
% |
| 1248 |
% \section{Defining units} |
| 1249 |
% \label{sec:def-units} |
| 1250 |
% |
| 1251 |
% |
| 1252 |
% New units can be defined using |
| 1253 |
% \begin{itemize} |
| 1254 |
% \item \mycs{declarecookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1255 |
% \item \mycs{newcookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1256 |
% \item \mycs{providecookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1257 |
% \end{itemize} |
| 1258 |
% |
| 1259 |
% \begin{function}{\declarecookingunit,\newcookingunit,\providecookingunit} |
| 1260 |
% \begin{syntax} |
| 1261 |
% \mycs{declarecookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1262 |
% \mycs{newcookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1263 |
% \mycs{providecookingunit}\oarg{symbol/key-val-list}\marg{unit-key} |
| 1264 |
% \end{syntax} |
| 1265 |
% |
| 1266 |
% These commands define the unit \meta{unit-key}. Note that \meta{unit-key} |
| 1267 |
% can neither contain |/| nor |,|; but it is allowed to be a command since v2.00 |
| 1268 |
% (see examples below). |
| 1269 |
% |
| 1270 |
% If the key is not the same as the printed symbol use the optional argument. |
| 1271 |
% It can either contain the symbol you want printed or a key-value list (see below) |
| 1272 |
% for more advanced adjustments. |
| 1273 |
% |
| 1274 |
% \mycs{newcookingunit} raises an error if the unit is already defined, |
| 1275 |
% \mycs{declarecookingunit} creates or (if given) overwrites \meta{symbol} |
| 1276 |
% and \mycs{providecookingunit} does nothing if the unit is already |
| 1277 |
% defined. |
| 1278 |
% |
| 1279 |
% All units have male gender |m| by default (unless you change it using a key below). |
| 1280 |
% |
| 1281 |
% Some examples: |
| 1282 |
% \begin{lstlisting}[commentstyle=\color{black}] |
| 1283 |
% \declarecookingunit{kg} |
| 1284 |
% \declarecookingunit{g} |
| 1285 |
% \declarecookingunit[Msp.] {Msp} |
| 1286 |
% \declarecookingunit[\ensuremath{{}^{\circ}}\kern-\scriptspace C] {C} |
| 1287 |
% \declarecookingunit{\%} % can use commands now |
| 1288 |
% \end{lstlisting} |
| 1289 |
% |
| 1290 |
% \end{function} |
| 1291 |
% |
| 1292 |
% \begin{cunote} |
| 1293 |
% The definition of the printed degree Celsius is |
| 1294 |
% copied and pasted from (a maybe older version of) \pkg{siunitx}. |
| 1295 |
% \end{cunote} |
| 1296 |
% |
| 1297 |
% \begin{function}{symbol, gender, set-option, add-to-group, natural-unit} |
| 1298 |
% |
| 1299 |
% \begin{syntax} |
| 1300 |
% symbol = \marg{symbol} |
| 1301 |
% gender = \marg{m/f/n} |
| 1302 |
% set-option = \marg{key-val-list} |
| 1303 |
% add-to-group = \marg{group} |
| 1304 |
% natural-unit = \marg{true/false} |
| 1305 |
% \end{syntax} |
| 1306 |
% |
| 1307 |
% Those keys can only be used in the optional argument of |
| 1308 |
% \mycs{declarecookingunit}, \mycs{newcookingunit} or \mycs{providecookingunit}. |
| 1309 |
% They can be used to define some properties of the unit during its initialization. |
| 1310 |
% |
| 1311 |
% \opt{symbol} allows you to set the printed symbol of the unit. A similar effect can be |
| 1312 |
% achieved by just using the optional argument. Use this option if you want to |
| 1313 |
% use other keys during the definition. This symbol is used as a fallback for all |
| 1314 |
% langauges, if no explicit symbol is found for said langauge. |
| 1315 |
% |
| 1316 |
% \opt{gender} sets the gender of the unit (default ist |m|). Allowed is |m|, |f| or |n|. |
| 1317 |
% Note that this sets the default gender for all languages. |
| 1318 |
% |
| 1319 |
% \opt{set-option} allows to add some key-vals to the specific unit which are |
| 1320 |
% activated once the unit is used. See \cpageref{code:set-option}. |
| 1321 |
% |
| 1322 |
% \opt{add-to-group} adds the unit defined to \meta{group}. See \cref{sec:opt:unit-spec} |
| 1323 |
% for more information. |
| 1324 |
% |
| 1325 |
% \opt{natural-unit} is a simple true/false switch. If |true| the unit will be specified to be |
| 1326 |
% a \enquote{natural-unit}. This is more or less a joke option. |
| 1327 |
% \end{function} |
| 1328 |
% |
| 1329 |
% |
| 1330 |
% |
| 1331 |
% \begin{function}{\declarecookingderivatives} |
| 1332 |
% \begin{syntax} |
| 1333 |
% \mycs{declarecookingderivatives} \marg{unit-list} \marg{unit-key} |
| 1334 |
% \ \ \marg{mathematical-relation} \marg{unit-symbol} |
| 1335 |
% \end{syntax} |
| 1336 |
% |
| 1337 |
% \emph{This function is experimental}. Defines new units which are a combination |
| 1338 |
% of the units given in \meta{unit-list} \emph{and} their key-chain. |
| 1339 |
% \meta{unit-key}, \meta{mathematical-relation} and \meta{unit-symbol} |
| 1340 |
% accept |#1| to |#n| as arguments with $n$ being the number of units |
| 1341 |
% given in \meta{unit-list}. $n$ \emph{cannot} be greater than $8$ (and it will |
| 1342 |
% probably compile for quite a while). Also note that this command doesn't work/isn't |
| 1343 |
% tested for single keys. |
| 1344 |
% |
| 1345 |
% Also note that it is quite possible that an \enquote{overflow-error} will |
| 1346 |
% occur if there are too many units. |
| 1347 |
% |
| 1348 |
% \end{function} |
| 1349 |
% |
| 1350 |
% \begin{cuexample} |
| 1351 |
% Your homework is to change the unit of energy \si{\kg\m\squared\per\s\squared} |
| 1352 |
% into \si{\ounce\inch\squared\per\minute\squared}. To check if you are correct |
| 1353 |
% you use \mycs{declarecookingderivatives}: |
| 1354 |
% \begin{lstlisting} |
| 1355 |
% \declarecookingderivatives{kg,m,s}{#1*#2:#3} |
| 1356 |
% { (#1)*(#2)^2/(#3)^2 } {\sfrac{#1\,#2${}^2$}{#3${}^2$}} |
| 1357 |
% \end{lstlisting} |
| 1358 |
% |
| 1359 |
% Using |\cunum[kg*m:s=oz*in:min]{1}{kg*m:s}| shows that |
| 1360 |
% \cunum{1}{kg*m:s} is equal to \cunum[kg*m:s=oz*in:min]{1}{kg*m:s}. |
| 1361 |
%^^A\cunum{196829101.34}{oz*in:min} |
| 1362 |
% |
| 1363 |
%^^A \cunum[m:s=km:h]{1}{m:s} |
| 1364 |
% |
| 1365 |
% \end{cuexample} |
| 1366 |
% |
| 1367 |
% \begin{cunote} |
| 1368 |
% As this is a bit more experimental and can easily lead to overflow-errors, |
| 1369 |
% no actual \LaTeX\ keys are created with \mycs{declarecookingderivatives}. |
| 1370 |
% Internally the keys and possible values are stored in a \emph{huge} property list. |
| 1371 |
% If an unknown key is encountered, it checks if said key can be found in the |
| 1372 |
% property list. |
| 1373 |
% \end{cunote} |
| 1374 |
% |
| 1375 |
% |
| 1376 |
% |
| 1377 |
% |
| 1378 |
% |
| 1379 |
% \section{Defining options to change units} |
| 1380 |
% \label{sec:defining-opt} |
| 1381 |
% |
| 1382 |
% |
| 1383 |
% |
| 1384 |
% Options (to change units) can be newly defined or added to already existing ones |
| 1385 |
% using |
| 1386 |
% \begin{itemize} |
| 1387 |
% \item \mycs{cudefinekeychain} |
| 1388 |
%^^A \item \mycs{cudefinekeys} |
| 1389 |
% \item \mycs{cudefinesinglekey} |
| 1390 |
% \item \mycs{cuaddtokeychain} |
| 1391 |
%^^A \item \mycs{cuaddkeys} |
| 1392 |
% \item \mycs{cuaddsinglekeys} |
| 1393 |
%^^A \item \mycs{cuaddtokeys} |
| 1394 |
% \end{itemize} |
| 1395 |
% |
| 1396 |
% |
| 1397 |
% |
| 1398 |
% \begin{function}{\cudefinekeychain, \cudefinesinglekey } |
| 1399 |
% \begin{syntax} |
| 1400 |
% \mycs{cudefinekeychain} |
| 1401 |
% \ \ \{ |
| 1402 |
% \ \ \ \ \marg{unit-key-1} \marg{value} |
| 1403 |
% \ \ \ \ \marg{unit-key-2} \marg{... unit-key-2 are \meta{value} unit-key-1} |
| 1404 |
% \ \ \ \ \marg{unit-key-3} \marg{... unit-key-3 are \meta{value} unit-key-1} |
| 1405 |
% \ \ \ \ \dots |
| 1406 |
% \ \ \} |
| 1407 |
% |
| 1408 |
% \mycs{cudefinesinglekey}\marg{unit-key-1} |
| 1409 |
% \ \ \{ |
| 1410 |
% \ \ \ \ \marg{unit-key-2} \marg{$1$ unit-key-2 are \dots\ unit-key-1} |
| 1411 |
% \ \ \ \ \marg{unit-key-3} \marg{$1$ unit-key-3 are \dots\ unit-key-1} |
| 1412 |
% \ \ \ \ \dots |
| 1413 |
% \ \ \} |
| 1414 |
% \end{syntax} |
| 1415 |
% If you define new units (see \cref{sec:def-units}) and cannot add |
| 1416 |
% them to already existing keys you may use |
| 1417 |
% \mycs{cudefinekeychain} or \mycs{cudefinesinglekey} respectively to |
| 1418 |
% define new key-chains or single keys. |
| 1419 |
% |
| 1420 |
% \mycs{cudefinekeychain} collects the unit-key's given and defines a key-chain. |
| 1421 |
% This allows you to change every unit into every other unit given in the list. |
| 1422 |
% So \meta{unit-key-1} can take \meta{unit-key-1}, \meta{unit-key-2}, \meta{unit-key-3}, |
| 1423 |
% \dots\ as values; \meta{unit-key-2} can take \meta{unit-key-1}, \meta{unit-key-2}, |
| 1424 |
% \meta{unit-key-3}, \dots\ as values, etc. Please note that \meta{\dots} has to |
| 1425 |
% be a number. |
| 1426 |
% |
| 1427 |
% Sometimes it is not that easy and the conversion of one unit into |
| 1428 |
% another needs are more complicated formula (see for example |
| 1429 |
% temperatures). If that is the case use |
| 1430 |
% \mycs{cudefinesinglekey}. As the name says it defines |
| 1431 |
% \emph{only} a single key \meta{unit-key-1} with the values |
| 1432 |
% \meta{unit-key-1}, \meta{unit-key-2}, etc. The advantage of this |
| 1433 |
% command is that now \meta{\dots} can be a formula and the |
| 1434 |
% numerical input of \mycs{cunum}, etc.\ can be placed explicitly using \texttt{\#1}. |
| 1435 |
% \end{function} |
| 1436 |
% |
| 1437 |
% |
| 1438 |
% |
| 1439 |
% |
| 1440 |
% \begin{cuexample} |
| 1441 |
% This example defines following keys with their respective value: |
| 1442 |
% \begin{itemize} |
| 1443 |
% \item the key \myunit{kg} with the values \myunit{kg}, \myunit{dag}, |
| 1444 |
% \myunit{g} and \myunit{oz} |
| 1445 |
% \item the key \myunit{dag} with the values \myunit{kg}, |
| 1446 |
% \myunit{dag}, \myunit{g} and \myunit{oz} |
| 1447 |
% \item the key \myunit{g} with the values \myunit{kg}, \myunit{dag}, |
| 1448 |
% \myunit{g} and \myunit{oz} |
| 1449 |
% \item the key \myunit{oz} with the values \myunit{kg}, \myunit{dag}, |
| 1450 |
% \myunit{g} and \myunit{oz} |
| 1451 |
% \item \dots |
| 1452 |
% \end{itemize} |
| 1453 |
% \begin{align*} |
| 1454 |
% \SI{1}{\kg}&= \SI{1}{\kg} & |
| 1455 |
% \SI{1}{\kg}&= \SI{100}{\deka\g} & |
| 1456 |
% \SI{1}{\kg}&= \SI{1000}{\g} \\ |
| 1457 |
% \SI{1}{\kg}&= \SI{35.27399}{\ounce} & |
| 1458 |
% \SI{1}{\kg}&= \SI{2.204 622 6}{\pound} |
| 1459 |
% \end{align*} |
| 1460 |
% \begin{lstlisting} |
| 1461 |
% \cudefinekeychain |
| 1462 |
% { |
| 1463 |
% {kg} { 1 } |
| 1464 |
% {dag}{ 100 } %% 1 kg are 100 dag |
| 1465 |
% {g} { 1000 } %% 1 kg are 1000 g |
| 1466 |
% {oz} { 35.27399 } %% 1 kg are 35.27399 oz |
| 1467 |
% {lb} { 2.204 622 6 } %% 1 kg are 2.204 622 6 lb |
| 1468 |
% } |
| 1469 |
% |
| 1470 |
% \cudefinekeychain |
| 1471 |
% { |
| 1472 |
% {d} { 1 } |
| 1473 |
% {h} { 24 } %% 1 day are 24 hours |
| 1474 |
% {min}{ 1440 } %% 1 day are 1440 minutes |
| 1475 |
% {s} { 86400 } %% 1 day are 86400 seconds |
| 1476 |
% } |
| 1477 |
% \end{lstlisting} |
| 1478 |
% \end{cuexample} |
| 1479 |
% |
| 1480 |
% \begin{cunote} |
| 1481 |
% The value of the first item can be something different from $1$. |
| 1482 |
% So something like this is also possible: |
| 1483 |
% \begin{lstlisting} |
| 1484 |
% \cudefinekeychain |
| 1485 |
% { |
| 1486 |
% {kg} { 0.4535924 } |
| 1487 |
% {dag}{ 45.35924 } |
| 1488 |
% {g} { 453,5924 } |
| 1489 |
% {oz} { 16 } |
| 1490 |
% {lb} { 1 } |
| 1491 |
% } |
| 1492 |
% \end{lstlisting} |
| 1493 |
% \end{cunote} |
| 1494 |
% |
| 1495 |
% \begin{cuexample} |
| 1496 |
% To convert degree Fahrenheit to degree Celsius, kelvin and degree R\'eamur one |
| 1497 |
% needs the formulas\footnote{See Wikipedia.} |
| 1498 |
% \begin{align*} |
| 1499 |
% T_C &= ( T_F - 32 ) \cdot \frac{5}{9} \\ |
| 1500 |
% T_K &= ( T_F - 459.67 ) \cdot \frac{5}{9} \\ |
| 1501 |
% T_{Re} &= ( T_F - 32 ) \cdot \frac{4}{9} |
| 1502 |
% \end{align*} |
| 1503 |
% with $T_F$ being the input temperature in degree Fahrenheit and |
| 1504 |
% $T_C$ being the same temperature in degree Celsius, etc. Using |
| 1505 |
% \lstinline|\cudefinesinglekey| the key \myunit{F} with values |
| 1506 |
% \myunit{C}, \myunit{K} and \myunit{Re} is defined by: |
| 1507 |
% |
| 1508 |
% \begin{lstlisting} |
| 1509 |
% \cudefinesinglekey {F} |
| 1510 |
% { |
| 1511 |
% {C} { ( #1 - 32 ) * 5/9 } %% see formulas above |
| 1512 |
% {K} { ( #1 + 459.67 ) * 5/9 } |
| 1513 |
% {Re} { ( #1 - 32 ) * 4/9 } |
| 1514 |
% } |
| 1515 |
% \end{lstlisting} |
| 1516 |
% |
| 1517 |
% This defines the key \myunit{F} with the values \myunit{F}, \myunit{C}, |
| 1518 |
% \myunit{K} and \myunit{Re}. |
| 1519 |
% |
| 1520 |
% \end{cuexample} |
| 1521 |
% |
| 1522 |
% |
| 1523 |
% |
| 1524 |
% \begin{function}{\cuaddtokeychain,\cuaddsinglekeys} |
| 1525 |
% \begin{syntax} |
| 1526 |
% \mycs{cuaddtokeychain} |
| 1527 |
% \ \ \{ |
| 1528 |
% \ \ \ \ \marg{unit-key-1} \marg{value} |
| 1529 |
% \ \ \ \ \marg{unit-key-2} \marg{... unit-key-2 are \meta{value} unit-key-1} |
| 1530 |
% \ \ \ \ \marg{unit-key-3} \marg{... unit-key-3 are \meta{value} unit-key-1} |
| 1531 |
% \ \ \ \ \dots |
| 1532 |
% \ \ \} |
| 1533 |
% |
| 1534 |
% \mycs{cuaddsinglekeys}\marg{unit-key-1} |
| 1535 |
% \ \ \{ |
| 1536 |
% \ \ \ \ \marg{unit-key-2} \marg{$1$ unit-key-2 are \dots\ unit-key-1} |
| 1537 |
% \ \ \ \ \marg{unit-key-3} \marg{$1$ unit-key-3 are \dots\ unit-key-1} |
| 1538 |
% \ \ \ \ \dots |
| 1539 |
% \ \ \} |
| 1540 |
% \end{syntax} |
| 1541 |
% |
| 1542 |
% \mycs{cuaddtokeychain} first parses through its unit-list and searches for |
| 1543 |
% a base unit key which is already in a key-chain |
| 1544 |
% (aka.\ was defined by \mycs{cudefinekeychain}). The other units, not yet |
| 1545 |
% part of a key-chain, are added to the same key-chain as the base unit. |
| 1546 |
% So the newly added units are available as a key and a value for the other |
| 1547 |
% units in the same key-chain. Note that \meta{...} must be a number. |
| 1548 |
% |
| 1549 |
% |
| 1550 |
% If the conversion is more complicated use |
| 1551 |
% \lstinline|\cuaddsinglekeys|. It adds \meta{unit-key-2}, etc.\ as |
| 1552 |
% values to \meta{unit-key-1}. The numerical input can be placed |
| 1553 |
% using \myunit{\#1} (see \mycs{cudefinesinglekey}). This |
| 1554 |
% command neither defines new keys nor does it add values to |
| 1555 |
% keys other than \meta{unit-key-1}. |
| 1556 |
% |
| 1557 |
% |
| 1558 |
% \end{function} |
| 1559 |
% |
| 1560 |
% |
| 1561 |
% |
| 1562 |
% |
| 1563 |
% \begin{cuexample} |
| 1564 |
% Suppose you are British (I am sorry, I can't think of another |
| 1565 |
% reason to use those units) and you want to implement 'stone' (yes, |
| 1566 |
% I was surprised myself that such a unit exists, but it even |
| 1567 |
% appears in a Sherlock Holmes story). You exactly know that |
| 1568 |
% \SI{1}{\st} equals \SI{14}{\lb}, well \dots\ now you have two |
| 1569 |
% choices. \lstinline|\cuaddkeys| or \lstinline|\cuaddtokeys| (use |
| 1570 |
% the one best fitting). This example uses the first, the next the |
| 1571 |
% latter one. |
| 1572 |
% \begin{lstlisting} |
| 1573 |
% \newcookingunit{st} %% defining new unit 'stone' |
| 1574 |
% \cuaddtokeychain |
| 1575 |
% { |
| 1576 |
% {lb} { 14 } %% unit already in a key-chain. |
| 1577 |
% {st} { 1 } %% new unit. 1st = 14lb |
| 1578 |
% } |
| 1579 |
% \end{lstlisting} |
| 1580 |
% \begin{cuexamplecode} |
| 1581 |
% \cunum[lb=st]{1}{lb} \\ |
| 1582 |
% \cunum[st=lb]{1}{st} \\ |
| 1583 |
% \cunum[st=g]{1}{st} \\ |
| 1584 |
% \cunum[st=kg]{1}{st} \\ |
| 1585 |
% \cunum[kg=st]{1}{kg} \\ |
| 1586 |
% \cunum[st=kg]{16}{st} |
| 1587 |
% \end{cuexamplecode} |
| 1588 |
% \end{cuexample} |
| 1589 |
% |
| 1590 |
% \begin{cunote} |
| 1591 |
% Of course using |
| 1592 |
% \begin{lstlisting} |
| 1593 |
% \cuaddtokeychain |
| 1594 |
% { |
| 1595 |
% {st} { 1/14 } %% 1lb = 1/14st |
| 1596 |
% {lb} { 1 } %% unit already in a key-chain. |
| 1597 |
% } |
| 1598 |
% \end{lstlisting} |
| 1599 |
% is also possible |
| 1600 |
% \end{cunote} |
| 1601 |
% |
| 1602 |
% \begin{cuexample} |
| 1603 |
% Now you want to add degree R{\o}mer and convert Celsius to degree |
| 1604 |
% R{\o}mer: |
| 1605 |
% \begin{equation*} |
| 1606 |
% T_{R\text\o} = T_C * \frac{21}{40} + 7.5 |
| 1607 |
% \end{equation*} |
| 1608 |
% |
| 1609 |
% \begin{lstlisting} |
| 1610 |
% %% defining new unit 'degree R{\o}mer' |
| 1611 |
% \newcookingunit [\ensuremath{ {} ^ { \circ } }\kern-\scriptspace R{\o}] {Ro} |
| 1612 |
% \cuaddsinglekeys {C} %% adds value 'Ro' to key 'C'. |
| 1613 |
% { |
| 1614 |
% {Ro} { #1 * 21/40 + 7.5 } |
| 1615 |
% } |
| 1616 |
% \cusetoptionfor{Ro}{ round-precision = 0 } %% round to integer automatically |
| 1617 |
% \end{lstlisting} |
| 1618 |
% \begin{cuexamplecode} |
| 1619 |
% \cunum{10}{C} \\ |
| 1620 |
% \cunum[C=Ro]{10}{C} |
| 1621 |
% \end{cuexamplecode} |
| 1622 |
% \end{cuexample} |
| 1623 |
% |
| 1624 |
% |
| 1625 |
% |
| 1626 |
% |
| 1627 |
% |
| 1628 |
% |
| 1629 |
% |
| 1630 |
% |
| 1631 |
% |
| 1632 |
% |
| 1633 |
% |
| 1634 |
% |
| 1635 |
% |
| 1636 |
% |
| 1637 |
% |
| 1638 |
% \subsection{Obsolete Commands} |
| 1639 |
% |
| 1640 |
% \begin{function}{cudefinekeys} |
| 1641 |
% \begin{syntax} |
| 1642 |
% \mycs{cudefinekeys}\marg{unit-key-1} |
| 1643 |
% \ \ \{ |
| 1644 |
% \ \ \ \ \marg{unit-key-2} \marg{$1$ unit-key-1 are \dots\ unit-key-2} |
| 1645 |
% \ \ \ \ \marg{unit-key-3} \marg{$1$ unit-key-1 are \dots\ unit-key-3} |
| 1646 |
% \ \ \ \ \marg{unit-key-4} \marg{$1$ unit-key-1 are \dots\ unit-key-4} |
| 1647 |
% \ \ \ \ \dots |
| 1648 |
% \ \ \} |
| 1649 |
% \end{syntax} |
| 1650 |
% |
| 1651 |
% \emph{This command is going to be obsolete at one point. It is advised to use |
| 1652 |
% \mycs{cudefinekeychain} instead.} |
| 1653 |
% |
| 1654 |
% \mycs{cudefinekeys} takes \marg{unit-key-1} as a |
| 1655 |
% \enquote{basis}, defines a key with the name \meta{unit-key-1} and |
| 1656 |
% adds the values \meta{unit-key-1}, \meta{unit-key-2}, |
| 1657 |
% \meta{unit-key-3}, etc. Furthermore this command also defines the |
| 1658 |
% keys \meta{unit-key-2}, \meta{unit-key-3}, etc. with the same |
| 1659 |
% values as \meta{unit-key-1}. Please note that \meta{\dots} has to |
| 1660 |
% be a number. |
| 1661 |
% \end{function} |
| 1662 |
% |
| 1663 |
% |
| 1664 |
% |
| 1665 |
% \begin{function}{\cuaddkeys,\cuaddtokeys} |
| 1666 |
% \begin{syntax} |
| 1667 |
% \mycs{cuaddkeys}\marg{unit-key-1} |
| 1668 |
% \ \ \{ |
| 1669 |
% \ \ \ \ \marg{unit-key-2} \marg{$1$ unit-key-1 are \dots\ unit-key-2} |
| 1670 |
% \ \ \ \ \marg{unit-key-3} \marg{$1$ unit-key-1 are \dots\ unit-key-3} |
| 1671 |
% \ \ \ \ \marg{unit-key-4} \marg{$1$ unit-key-1 are \dots\ unit-key-4} |
| 1672 |
% \ \ \ \ \dots |
| 1673 |
% \ \ \} |
| 1674 |
% |
| 1675 |
% \mycs{cuaddtokeys} \marg{unit-key-1} \marg{unit-key-2} \marg{$1$ unit-key-2 are \dots\ unit-key-1} |
| 1676 |
% \end{syntax} |
| 1677 |
% |
| 1678 |
% \emph{Those commands are going to be obsolete at one point. It is advised to use |
| 1679 |
% \mycs{cuaddtokeychain} instead.} |
| 1680 |
% |
| 1681 |
% |
| 1682 |
% \lstinline|\cuaddkeys| takes the already defined key |
| 1683 |
% \marg{unit-key-1} as a \enquote{basis}, and adds |
| 1684 |
% \meta{unit-key-2}, \meta{unit-key-3}, etc. to its |
| 1685 |
% values. Furthermore it adds those new values to other keys linked |
| 1686 |
% to \meta{unit-key-1} and defines the new keys \meta{unit-key-2}, |
| 1687 |
% etc.\ with the same values as \meta{unit-key-1}. |
| 1688 |
% |
| 1689 |
% Works similar to \mycs{cuaddkeys} regarding the definition of keys. |
| 1690 |
% \end{function} |
| 1691 |
% |
| 1692 |
% |
| 1693 |
% |
| 1694 |
% |
| 1695 |
% |
| 1696 |
% |
| 1697 |
% |
| 1698 |
% \section{Language support} |
| 1699 |
% \label{sec:language} |
| 1700 |
% |
| 1701 |
% |
| 1702 |
% Unit names and symbols depend on the language. To change the |
| 1703 |
% name and symbol for given language you can use \lstinline|\cudefinename|; |
| 1704 |
% to only change symbols use \lstinline|\cudefinesymbol|. |
| 1705 |
% |
| 1706 |
% \begin{function}{decimal-mark,cutext-range-phrase, one(m),one(f),one(n)} |
| 1707 |
% Those are special keys (as they cannot be used as units). Not only |
| 1708 |
% are printed units language depending, but as is the decimal mark |
| 1709 |
% (|.| or |,|) and the text which substitutes the range-sign. |
| 1710 |
% To set the decimal mark use |
| 1711 |
% \opt{decimal-mark} (see examples below), to set the range-sign for \cCutext\ |
| 1712 |
% use \opt{cutext-range-phrase}. |
| 1713 |
% |
| 1714 |
% Note that \opt{cutext-range-phrase} is \enquote{overwritten} by the \emph{option} |
| 1715 |
% \opt{cutext-range-sign}. If the \emph{option} is set, then the language symbol |
| 1716 |
% will be ignored. |
| 1717 |
% |
| 1718 |
% Furthermore if you are using numerals |
| 1719 |
% you may also use the keys \opt{one(m)}, \opt{one(f)} and |
| 1720 |
% \opt{one(n)}. Integers below a certain |
| 1721 |
% value (see option \opt{use-numerals-below}) are written-out. The |
| 1722 |
% problem is that the written-out \enquote{1} depends on the |
| 1723 |
% gender of the word following (e.g. \enquote{ein Baum} (m), |
| 1724 |
% \enquote{eine Pflanze} (f) and \enquote{ein Auto} (n)). Use those keys |
| 1725 |
% to set the specific gender of \enquote{1} (see also examples below). |
| 1726 |
% \end{function} |
| 1727 |
% |
| 1728 |
% \begin{function}{\cudefinename} |
| 1729 |
% \begin{syntax} |
| 1730 |
% \mycs{cudefinename}\marg{Language} |
| 1731 |
% \ \ \{ |
| 1732 |
% \ \ \ \ \marg{unit-key-1} \oarg{symbol-1} \marg{singular-1} \oarg{plural-1} \myaarg{gender} |
| 1733 |
% \ \ \ \ \marg{unit-key-2} \oarg{symbol-2} \marg{singular-2} \oarg{plural-2} \myaarg{gender} |
| 1734 |
% \ \ \ \ \dots |
| 1735 |
% \ \ \} |
| 1736 |
% \end{syntax} |
| 1737 |
% |
| 1738 |
% This command defines the names (and optionally the symbol) of the |
| 1739 |
% units printed in \lstinline|\cutext| and \lstinline|\Cutext| |
| 1740 |
% (and \lstinline|\cunum| regarding the symbol) for the specific |
| 1741 |
% \meta{Language}. For details regarding \meta{language} see the |
| 1742 |
% \pkg{translations} documentation. |
| 1743 |
% |
| 1744 |
% If the plural form of the name differs from the singular form use |
| 1745 |
% \oarg{plural} to specify the plural form, else it will be equal to its singular |
| 1746 |
% form. The singular form |
| 1747 |
% is only used if the number in \lstinline|\cutext| and |
| 1748 |
% \lstinline|\Cutext| is equal to $1$. |
| 1749 |
% |
| 1750 |
% \meta{gender} can be \texttt{m} (maskulin), \texttt{f} (feminin) or |
| 1751 |
% \texttt{n} (neutrum). If not given, \texttt{m} is used as default. |
| 1752 |
% \end{function} |
| 1753 |
% |
| 1754 |
% \begin{lstlisting} |
| 1755 |
% \cudefinename {English} |
| 1756 |
% { |
| 1757 |
% {kg} {kilogramme} |
| 1758 |
% {oz} {ounce} |
| 1759 |
% {h} {hour} [hours] |
| 1760 |
% {C} {degree\space Celsius} [degrees\space Celsius] |
| 1761 |
% {decimal-marker} {.} |
| 1762 |
% {cutext-range-phrase} {~to~} |
| 1763 |
% {one(m)} {one} |
| 1764 |
% {one(f)} {one} |
| 1765 |
% {one(n)} {one} |
| 1766 |
% } |
| 1767 |
% \end{lstlisting} |
| 1768 |
% \begin{lstlisting} |
| 1769 |
% \cudefinename {German} |
| 1770 |
% { |
| 1771 |
% {kg} {Kilogramm} <n> |
| 1772 |
% {oz} {Unze} <f> |
| 1773 |
% {d} {Tag} [Tage] |
| 1774 |
% {h} {Stunde} [Stunden] <f> |
| 1775 |
% {C} {Grad\space Celsius} |
| 1776 |
% {decimal-marker} {,} |
| 1777 |
% {cutext-range-phrase} {~bis~} |
| 1778 |
% {one(m)} {ein} |
| 1779 |
% {one(f)} {eine} |
| 1780 |
% {one(n)} {ein} |
| 1781 |
% } |
| 1782 |
% \end{lstlisting} |
| 1783 |
% |
| 1784 |
% |
| 1785 |
% \begin{function}{\cudefinesymbol} |
| 1786 |
% |
| 1787 |
% \begin{syntax} |
| 1788 |
% \mycs{cudefinesymbol}\marg{Language} |
| 1789 |
% \ \ \{ |
| 1790 |
% \ \ \ \ \marg{unit-key-1} \marg{symbol-1} |
| 1791 |
% \ \ \ \ \marg{unit-key-2} \marg{symbol-2} |
| 1792 |
% \ \ \ \ \dots |
| 1793 |
% \ \ \} |
| 1794 |
% \end{syntax} |
| 1795 |
% |
| 1796 |
% This command defines the symbols of the units printed in |
| 1797 |
% \lstinline|\cunum| for the specific \meta{Language}. It works |
| 1798 |
% similar as \lstinline|\cudefinename|, but only the symbols (and no |
| 1799 |
% names) can be set. For details regarding \meta{Language} see |
| 1800 |
% the \pkg{translations} documentation. |
| 1801 |
% |
| 1802 |
% \end{function} |
| 1803 |
% |
| 1804 |
% |
| 1805 |
% \begin{lstlisting} |
| 1806 |
% \cudefinesymbol {English} |
| 1807 |
% { |
| 1808 |
% {decimal-mark} {.} |
| 1809 |
% {cutext-range-phrase} {~to~} |
| 1810 |
% {one(m)} {one} |
| 1811 |
% {one(f)} {one} |
| 1812 |
% {one(n)} {one} |
| 1813 |
% } |
| 1814 |
% \cudefinesymbol {German} |
| 1815 |
% { |
| 1816 |
% {decimal-mark} {,} |
| 1817 |
% {cutext-range-phrase} {~bis~} |
| 1818 |
% {one(m)} {ein} |
| 1819 |
% {one(f)} {eine} |
| 1820 |
% {one(n)} {ein} |
| 1821 |
% } |
| 1822 |
% \cudefinesymbol {French} |
| 1823 |
% { |
| 1824 |
% {l} {L} |
| 1825 |
% {dl} {dL} |
| 1826 |
% {cl} {cL} |
| 1827 |
% {ml} {mL} |
| 1828 |
% {cutext-range-phrase} {~\`{a}~} |
| 1829 |
% {decimal-mark} {,} |
| 1830 |
% {one(m)} {un} |
| 1831 |
% {one(f)} {une} |
| 1832 |
% {one(n)} {un} |
| 1833 |
% } |
| 1834 |
% \end{lstlisting} |
| 1835 |
% |
| 1836 |
% \begin{cuexample} |
| 1837 |
% Imagine that instead of the abbreviation \enquote{dag} for \enquote{decagramme} |
| 1838 |
% you want to use \enquote{ducks} (because \dots\ I don't know). You can easily |
| 1839 |
% do this via |
| 1840 |
% \begin{lstlisting} |
| 1841 |
% \cudefinesymbol {English} |
| 1842 |
% { |
| 1843 |
% {dag} {ducks} |
| 1844 |
% } |
| 1845 |
% \end{lstlisting} |
| 1846 |
% \cudefinesymbol {English} |
| 1847 |
% { |
| 1848 |
% {dag} {ducks} |
| 1849 |
% } |
| 1850 |
% As you can see it may be a bit suboptimal as there is no plural version allowed. |
| 1851 |
% You do it anyway and end up with: |
| 1852 |
% \begin{cuexamplecode} |
| 1853 |
% \cunum{12}{dag} & weed\\ |
| 1854 |
% \cunum{3}[0]{dag} & nuts\\ |
| 1855 |
% \cunum{10}{dag} & duckmeat |
| 1856 |
% \end{cuexamplecode} |
| 1857 |
% |
| 1858 |
% |
| 1859 |
% \end{cuexample} |
| 1860 |
% |
| 1861 |
% |
| 1862 |
% |
| 1863 |
% |
| 1864 |
% |
| 1865 |
% |
| 1866 |
% \subsection{Phrases} |
| 1867 |
% \label{sec:phrases} |
| 1868 |
% |
| 1869 |
% Each language has synonyms for certain (integer) numbers. This package |
| 1870 |
% supports those phrases and they can be implemented with the following |
| 1871 |
% command to be used by \mycs{cuam}: |
| 1872 |
% |
| 1873 |
% \begin{function}{\cudefinephrase} |
| 1874 |
% \begin{syntax} |
| 1875 |
% \mycs{cudefinephrase}\marg{Language} |
| 1876 |
% \ \ \{ |
| 1877 |
% \ \marg{integer-1} \marg{phrase-1} \oarg{phrase-1-plural} \myaarg{gender-1} |
| 1878 |
% \ \marg{integer-2} * \marg{phrase-2} \oarg{phrase-2-plural} \myaarg{gender-2} |
| 1879 |
% \ \dots |
| 1880 |
% \ \ \} |
| 1881 |
% \end{syntax} |
| 1882 |
% |
| 1883 |
% This command pairs for a given \marg{Language} (see package \pkg{translations}) |
| 1884 |
% the number \marg{integer-1} |
| 1885 |
% with \marg{phrase-1} (\& \meta{phrase-1-plural} and \meta{gender-1}). |
| 1886 |
% Afterwards the package can check if an amount |
| 1887 |
% given in \mycs{cuam} is either this number or a \emph{multiple} of it. |
| 1888 |
% |
| 1889 |
% If the behavior of checking for a multiple is not wanted, you can use the optional |
| 1890 |
% star \texttt{*}. |
| 1891 |
% |
| 1892 |
% \meta{gender} can be \opt{m}, \opt{f} or \opt{n}. It is \opt{m} by default. |
| 1893 |
% |
| 1894 |
% Afterwards the numbers are ordered from highest to lowest so that |
| 1895 |
% the phrase with the highest number is used (if used at all). |
| 1896 |
% |
| 1897 |
% Furthermore, it chooses star (|*|) phrases over non-star phrases. |
| 1898 |
% \end{function} |
| 1899 |
% \begin{cuexample} |
| 1900 |
% The following example creates some phrases for the language |
| 1901 |
% \enquote{German}: |
| 1902 |
% |
| 1903 |
% \cudefinephrase {German} |
| 1904 |
% { |
| 1905 |
% { 60 } {Schock} <n> |
| 1906 |
% { 6 }* {halbes\ Dutzend} <n> |
| 1907 |
% } |
| 1908 |
% |
| 1909 |
% |
| 1910 |
% \begin{lstlisting} |
| 1911 |
% \cudefinephrase {German} |
| 1912 |
% { |
| 1913 |
% { 12 } {Dutzend} <n> %% implemented by default |
| 1914 |
% { 60 } {Schock} <n> |
| 1915 |
% { 6 }* {halbes\ Dutzend} <n> |
| 1916 |
% } |
| 1917 |
% \end{lstlisting} |
| 1918 |
% Let's just use them (german language activated!): |
| 1919 |
%^^A \begin{myde} |
| 1920 |
% \begin{cuexamplecode} |
| 1921 |
% \selectlanguage{ngerman} @ |
| 1922 |
% \cusetup{use-phrases=true} @ |
| 1923 |
% \cuam{12} \\ |
| 1924 |
% \cuam{24} \\ |
| 1925 |
% \cuam{25} \\ |
| 1926 |
% \cuam{60} \\ |
| 1927 |
% \cuam{120} \\ |
| 1928 |
% \cuam{121} \\ |
| 1929 |
% \cuam{6} \\ |
| 1930 |
% \cuam{18} |
| 1931 |
% \end{cuexamplecode} |
| 1932 |
%^^A \end{myde} |
| 1933 |
% |
| 1934 |
% As you can see, \enquote{Schock} ($60$) is preferred over \enquote{Dutzend} ($12$) |
| 1935 |
% as it linked to the higher number. Furthermore, for $6$ the phrase \enquote{halbes |
| 1936 |
% Dutzend} (half a dozen) is used, but because it is a star version it is \emph{not} |
| 1937 |
% used for $18$. |
| 1938 |
% |
| 1939 |
% \end{cuexample} |
| 1940 |
% |
| 1941 |
% |
| 1942 |
% \section{Options} |
| 1943 |
% \label{sec:options} |
| 1944 |
% |
| 1945 |
% |
| 1946 |
% Options in \pkg{cooking-units} can mostly be set globally using |
| 1947 |
% \lstinline|\cusetup| or locally using the optional argument of the |
| 1948 |
% respective command (but \emph{not} as a package option). The only |
| 1949 |
% exception is the option given in \cref{sec:load-time-options} which |
| 1950 |
% needs to be used as a package option. |
| 1951 |
% |
| 1952 |
% \begin{function}{\cusetup} |
| 1953 |
% \begin{syntax} |
| 1954 |
% \mycs{cusetup}\marg{options} |
| 1955 |
% \end{syntax} |
| 1956 |
% Options can be set using \mycs{cusetup}\Arg{options}. |
| 1957 |
% \end{function} |
| 1958 |
% |
| 1959 |
% |
| 1960 |
% \begin{function}{\cusetoptionfor,\cuaddoptionfor,\cuclearoptionfor} |
| 1961 |
% \label{code:set-option} |
| 1962 |
% \begin{syntax} |
| 1963 |
% \mycs{cusetoptionfor}\marg{unit-list}\marg{options} |
| 1964 |
% \mycs{cuaddoptionfor}\marg{unit-list}\marg{options} |
| 1965 |
% \mycs{cuclearoptionfor}\marg{unit-list} |
| 1966 |
% \end{syntax} |
| 1967 |
% \pkg{cooking-units} allows you to attach options to units. |
| 1968 |
% Those |
| 1969 |
% options are activated if (and only if) the specific unit is used \emph{or} |
| 1970 |
% if another unit is converted |
| 1971 |
% into it. Those options allow you to e.g.\ round temperatures to |
| 1972 |
% integers automatically. Furthermore, those added options are |
| 1973 |
% overwritten by local options. |
| 1974 |
% |
| 1975 |
% \mycs{cusetoptionfor} \emph{sets} \meta{options} to each unit in \meta{unit-list} |
| 1976 |
% overwriting the old ones. |
| 1977 |
% |
| 1978 |
% \mycs{cuaddoptionfor} \emph{add}s \meta{options} to each unit in \meta{unit-list}. |
| 1979 |
% |
| 1980 |
% \mycs{cuclearoptionfor} clears all options given to each unit in \meta{unit-list}. |
| 1981 |
% \end{function} |
| 1982 |
% \begin{cuexample} |
| 1983 |
% Temperatures \myunit{C}, \myunit{F}, \myunit{K} and \myunit{Re} are |
| 1984 |
% by default rounded to integers. |
| 1985 |
% \begin{cuexamplecode} |
| 1986 |
% \cunum{75.23}{C} \\ |
| 1987 |
% \cunum{75.23}{F} \\ |
| 1988 |
% \cunum{75.23}{K} \\ |
| 1989 |
% \cunum{75.23}{Re} \\ |
| 1990 |
% \cusetoptionfor{C,F,K,Re}{round-precision=-1} @ |
| 1991 |
% \cunum{75.23}{C} \\ |
| 1992 |
% \cunum{75.23}{F} \\ |
| 1993 |
% \cunum{75.23}{K} \\ |
| 1994 |
% \cunum{75.23}{Re} \\ |
| 1995 |
% \cuclearoptionfor{C,F,K,Re} @ |
| 1996 |
% \cunum{75.23}{C} \\ |
| 1997 |
% \cunum{75.23}{F} \\ |
| 1998 |
% \cunum{75.23}{K} \\ |
| 1999 |
% \cunum{75.23}{Re} |
| 2000 |
% \end{cuexamplecode} |
| 2001 |
% \end{cuexample} |
| 2002 |
% |
| 2003 |
% \subsection{Load time options} |
| 2004 |
% \label{sec:load-time-options} |
| 2005 |
% \begin{function}{use-fmtcount-numerals} |
| 2006 |
% \begin{syntax} |
| 2007 |
% \cs{usepackage}[use-fmtcount-numerals=\meta{true/false}]\{cooking-units\} |
| 2008 |
% \end{syntax} |
| 2009 |
% If set to \true\ loads package \pkg{fmtcount} and uses |
| 2010 |
% \cs{numberstringnum} for \mycs{cutext} |
| 2011 |
% and \cs{Numberstringnum} for \mycs{Cutext} to write-out numbers below |
| 2012 |
% \opt{use-numerals-below} ($13$ by default), integers above are |
| 2013 |
% printed as numbers. |
| 2014 |
% You can decide to not print any numerals by setting \opt{print-numerals} |
| 2015 |
% to \false. |
| 2016 |
% |
| 2017 |
% Note: You don't need to use this function to use numerals. Using |
| 2018 |
% \opt{print-numerals} and setting \opt{numeral-function} and \opt{Numeral-function} |
| 2019 |
% also works. |
| 2020 |
% \end{function} |
| 2021 |
% |
| 2022 |
% \cusetup{print-numerals=true} |
| 2023 |
% \begin{cuexamplecode} |
| 2024 |
% \cutext{1}{kg} \\ |
| 2025 |
% \Cutext{1}{kg} \\ |
| 2026 |
% \cutext{2}{kg} \\ |
| 2027 |
% \Cutext{2}{kg} \\ |
| 2028 |
% \cutext{12}{kg} \\ |
| 2029 |
% \Cutext{12}{kg} \\ |
| 2030 |
% \cutext{13}{kg} \\ |
| 2031 |
% \cutext{13}{kg} \\ |
| 2032 |
% \Cutext{14}{kg} |
| 2033 |
% \end{cuexamplecode} |
| 2034 |
% \cusetup{print-numerals=false} |
| 2035 |
% |
| 2036 |
% \begin{cunote} |
| 2037 |
% \opt{use-fmtcount-numerals} is a package option as it needs to load |
| 2038 |
% \pkg{fmtcount} which is not loaded by default. |
| 2039 |
% \end{cunote} |
| 2040 |
% |
| 2041 |
% \begin{cunote} |
| 2042 |
% Please note the keys \opt{one(m)}, \opt{one(f)} |
| 2043 |
% and \opt{one(n)} to change the printed \enquote{one} (as |
| 2044 |
% \enquote{one} is in many languages dependent on the gender of the |
| 2045 |
% following word. E.g in German: Masculine: ein Baum, |
| 2046 |
% Feminin: eine Pflanze, Neutrum: ein Auto). |
| 2047 |
% \end{cunote} |
| 2048 |
% |
| 2049 |
% \begin{cunote} |
| 2050 |
% You can always change the functions used to print numerals with |
| 2051 |
% \opt{numeral-function} and \opt{Numeral-function}. |
| 2052 |
% \end{cunote} |
| 2053 |
% |
| 2054 |
% \subsection{Normal options} |
| 2055 |
% |
| 2056 |
% Options in this subsection can only be set as local options or using |
| 2057 |
% \lstinline|\cusetup|, but \emph{not} as load time options. |
| 2058 |
% |
| 2059 |
% |
| 2060 |
% \subsubsection{Unit Specific options} |
| 2061 |
% \label{sec:opt:unit-spec} |
| 2062 |
% |
| 2063 |
% \begin{function}{<unit>} |
| 2064 |
% \begin{syntax} |
| 2065 |
% \meta{unit-key-1} = \meta{unit-key-2} |
| 2066 |
% \end{syntax} |
| 2067 |
% Change \meta{unit-key-1} to \meta{unit-key-2} (see |
| 2068 |
% \cref{sec:defining-opt} to define new options). |
| 2069 |
% \end{function} |
| 2070 |
% |
| 2071 |
% \begin{function}{<group>} |
| 2072 |
% \begin{syntax} |
| 2073 |
% \meta{group} = \meta{unit-key} |
| 2074 |
% \end{syntax} |
| 2075 |
% Changes each unit contained in \meta{group} to \meta{unit-key} (\meta{unit-key} |
| 2076 |
% must be part of \meta{group}). |
| 2077 |
% |
| 2078 |
% \begin{center} |
| 2079 |
% \begin{tabular}{ll} |
| 2080 |
% \toprule |
| 2081 |
% \meta{group} & default \meta{unit-key}s \\ \midrule |
| 2082 |
% \PrintGroup{weight} \\ |
| 2083 |
% \PrintGroup{length} \\ |
| 2084 |
% \PrintGroup{volume} \\ |
| 2085 |
% \PrintGroup{temperature} \\ |
| 2086 |
% \PrintGroup{energy} \\ |
| 2087 |
% \PrintGroup{time} \\ \bottomrule |
| 2088 |
% \end{tabular} |
| 2089 |
% \end{center} |
| 2090 |
% \end{function} |
| 2091 |
% |
| 2092 |
% \begin{cuexamplecode} |
| 2093 |
% \cusetup{weight=g} @ |
| 2094 |
% \cunum{1}{kg} \\ |
| 2095 |
% \cunum{1}{dag} \\ |
| 2096 |
% \cunum{1}{g} \\ |
| 2097 |
% \cunum{1}{oz} \\ |
| 2098 |
% \cunum{1}{lb} \\ |
| 2099 |
% \cunum{1}{stick} \\ |
| 2100 |
% \end{cuexamplecode} |
| 2101 |
% |
| 2102 |
% You can define new groups using \mycs{cudeclareunitgroup}: |
| 2103 |
% \begin{function} {\cudeclareunitgroup} |
| 2104 |
% \begin{syntax} |
| 2105 |
% \mycs{cudeclareunitgroup} \marg{group-name} \marg{unit-list} |
| 2106 |
% \end{syntax} |
| 2107 |
% Defines the group \meta{group-name} containing the list \meta{unit-list}. |
| 2108 |
% This allows the usage of \texttt{\meta{group-name}=\meta{unit-key}} to |
| 2109 |
% change all units in the group \meta{group-name} to \meta{unit-key} |
| 2110 |
% (which has to be part of \meta{unit-list}). |
| 2111 |
% \end{function} |
| 2112 |
% |
| 2113 |
% \begin{cuexample} |
| 2114 |
% Define the group \enquote{weight}: |
| 2115 |
% \begin{lstlisting} |
| 2116 |
% \cudeclareunitgroup {weight} { kg , dag, g, oz, lb, stick } |
| 2117 |
% \end{lstlisting} |
| 2118 |
% Now \lstinline|\cusetup{weight=dag}| can be used to change all units |
| 2119 |
% contained in |weight| to |dag|. |
| 2120 |
% \end{cuexample} |
| 2121 |
% |
| 2122 |
% |
| 2123 |
% \begin{function}{\cuaddtounitgroup} |
| 2124 |
% \begin{syntax} |
| 2125 |
% \mycs{cuaddtounitgroup}\marg{group}\marg{unit-list} |
| 2126 |
% \end{syntax} |
| 2127 |
% Adds \meta{unit-list} to an already existing \meta{group} (both need to exist). |
| 2128 |
% \end{function} |
| 2129 |
% \begin{cuexample} |
| 2130 |
% Adding \myunit{st} to the group \mygroup{weight} |
| 2131 |
% \begin{cuexamplecode} |
| 2132 |
% \cuaddtounitgroup {weight} {st} @ |
| 2133 |
% \cusetup{weight = g } @ |
| 2134 |
% \cunum{1}{kg} \\ |
| 2135 |
% \cunum{1}{dag} \\ |
| 2136 |
% \cunum{1}{g} \\ |
| 2137 |
% \cunum{1}{oz} \\ |
| 2138 |
% \cunum{1}{lb} \\ |
| 2139 |
% \cunum{1}{stick} \\ |
| 2140 |
% \cunum{1}{st} |
| 2141 |
% \end{cuexamplecode} |
| 2142 |
% \end{cuexample} |
| 2143 |
% |
| 2144 |
% |
| 2145 |
% \begin{function}{add-unit-to-group} |
| 2146 |
% \begin{syntax} |
| 2147 |
% add-unit-to-group = |
| 2148 |
% \ \{ |
| 2149 |
% \ \meta{group1} = \marg{unit-key-list}, |
| 2150 |
% \ \meta{group2} = \marg{unit-key-list}, |
| 2151 |
% \ \dots |
| 2152 |
% \ \} |
| 2153 |
% \end{syntax} |
| 2154 |
% \emph{This option is going to be obsolete at one point.} |
| 2155 |
% Adds each \meta{unit-key} in \meta{unit-keys-list} to \meta{group}. |
| 2156 |
% The key-val equivalent of \mycs{cuaddtounitgroup}. |
| 2157 |
% \end{function} |
| 2158 |
%^^A \begin{cuexample} |
| 2159 |
%^^A The same as above: |
| 2160 |
%^^A This example adds the unit \myunit{st} to the group \mygroup{weight} |
| 2161 |
%^^A and \myunit{Ro} to \mygroup{temperature}. |
| 2162 |
%^^A \begin{lstlisting} |
| 2163 |
%^^A \cusetup |
| 2164 |
%^^A { |
| 2165 |
%^^A add-unit-to-group = { weight = {st} , temperature = {Ro} } |
| 2166 |
%^^A } |
| 2167 |
% ^^A\end{lstlisting} |
| 2168 |
%^^A |
| 2169 |
%^^A \cusetup{ add-unit-to-group = { weight = {st} } } |
| 2170 |
%^^A |
| 2171 |
%^^A \begin{cuexamplecode} |
| 2172 |
%^^A \cusetup{weight=g} @ |
| 2173 |
%^^A \cunum{1}{kg} \\ |
| 2174 |
%^^A \cunum{1}{dag} \\ |
| 2175 |
%^^A \cunum{1}{g} \\ |
| 2176 |
%^^A \cunum{1}{oz} \\ |
| 2177 |
%^^A \cunum{1}{lb} \\ |
| 2178 |
%^^A \cunum{1}{stick} \\ |
| 2179 |
%^^A \cunum{1}{st} |
| 2180 |
%^^A \end{cuexamplecode} |
| 2181 |
%^^A \end{cuexample} |
| 2182 |
% |
| 2183 |
% |
| 2184 |
% |
| 2185 |
% \begin{function}{set-option-for-<unit-key>,add-option-for-<unit-key>} |
| 2186 |
% \begin{syntax} |
| 2187 |
% set-option-for-\meta{unit-key} = \marg{ key1 = value1, \dots\ } |
| 2188 |
% add-option-for-\meta{unit-key} = \marg{ key1 = value1, \dots\ } |
| 2189 |
% \end{syntax} |
| 2190 |
% \emph{This option is going to be obsolete at one point.} |
| 2191 |
% Sets and adds \meta{key1=value1,\dots} to a specific |
| 2192 |
% \meta{unit-key}, |
| 2193 |
% \opt{erase-all-options} (see below) is used to erase all options for all |
| 2194 |
% \meta{unit-key}s. |
| 2195 |
% |
| 2196 |
% The less flexible key-value version of \mycs{cusetoptionfor} and |
| 2197 |
% \mycs{cuaddoptionfor}. |
| 2198 |
% |
| 2199 |
% |
| 2200 |
%^^A You may want to attach some options to a special |
| 2201 |
%^^A \meta{unit-key}. Those options are automatically activated if (and |
| 2202 |
%^^A only if) the specific \meta{unit-key} is used (or changed into this |
| 2203 |
%^^A unit). Setting options overwrites old options. Adding options, well |
| 2204 |
%^^A \dots\ adds the options to the old ones. |
| 2205 |
% |
| 2206 |
%^^A You can \enquote{delete} the options by setting |
| 2207 |
%^^A an empty value for a specific \meta{unit-key} (or use |
| 2208 |
%^^A \opt{erase-all-options} (or \opt{erase-all-options-for} ) |
| 2209 |
%^^A (see below) to erase all options for all \meta{unit-key}s) |
| 2210 |
% |
| 2211 |
% \end{function} |
| 2212 |
% |
| 2213 |
%^^A \begin{cuexample} |
| 2214 |
%^^A The following rounds the values to integers for \myunit{F}, \myunit{C}, |
| 2215 |
%^^A \myunit{K} and \myunit{Re}: |
| 2216 |
%^^A \begin{lstlisting} |
| 2217 |
%^^A \cusetup |
| 2218 |
%^^A { |
| 2219 |
%^^A set-option-for-F = { round-precision = 0 } , |
| 2220 |
%^^A set-option-for-C = { round-precision = 0 } , |
| 2221 |
%^^A set-option-for-K = { round-precision = 0 } , |
| 2222 |
%^^A set-option-for-Re = { round-precision = 0 } |
| 2223 |
%^^A } |
| 2224 |
%^^A \end{lstlisting} |
| 2225 |
%^^A although note that it would be easier to simply write |
| 2226 |
%^^A \begin{lstlisting} |
| 2227 |
%^^A \cusetoptionfor {F,C,K,Re} { round-precision = 0 } |
| 2228 |
%^^A \end{lstlisting} |
| 2229 |
%^^A \end{cuexample} |
| 2230 |
% |
| 2231 |
% |
| 2232 |
% \begin{function}{set-option-for, add-option-for} |
| 2233 |
% \begin{syntax} |
| 2234 |
% set-option-for = |
| 2235 |
% \ \{ |
| 2236 |
% \ \meta{unit-key1} = \marg{keys=vals}, |
| 2237 |
% \ \meta{unit-key2} = \marg{keys=vals}, |
| 2238 |
% \ \dots |
| 2239 |
% \ \} |
| 2240 |
% add-option-for = |
| 2241 |
% \ \{ |
| 2242 |
% \ \meta{unit-key1} = \marg{keys=vals}, |
| 2243 |
% \ \meta{unit-key2} = \marg{keys=vals}, |
| 2244 |
% \ \dots |
| 2245 |
% \ \} |
| 2246 |
% \end{syntax} |
| 2247 |
% \emph{This option is going to be obsolete at one point.} |
| 2248 |
% Sets/adds each \meta{keys=vals} to the specific \meta{unit-key}. Works pretty much |
| 2249 |
% the same way their \opt{set-option-for-\meta{unit-key}} and |
| 2250 |
% \opt{add-option-for-\meta{unit-key}} counterparts. |
| 2251 |
% |
| 2252 |
% The less flexible versions of the commands \mycs{cusetoptionfor} and |
| 2253 |
% \mycs{cuaddoptionfor}. |
| 2254 |
% \end{function} |
| 2255 |
% |
| 2256 |
%^^A \begin{cuexample} |
| 2257 |
%^^A The following example does the same as the example above: |
| 2258 |
%^^A \begin{lstlisting} |
| 2259 |
%^^A \cusetup |
| 2260 |
%^^A { |
| 2261 |
%^^A set-option-for = |
| 2262 |
%^^A { |
| 2263 |
%^^A F = { round-precision = 0 } , |
| 2264 |
%^^A C = { round-precision = 0 } , |
| 2265 |
%^^A K = { round-precision = 0 } , |
| 2266 |
%^^A Re = { round-precision = 0 } |
| 2267 |
%^^A } |
| 2268 |
%^^A } |
| 2269 |
%^^A \end{lstlisting} |
| 2270 |
%^^A \end{cuexample} |
| 2271 |
% |
| 2272 |
% \begin{function}{erase-all-options, erase-all-options-for} |
| 2273 |
% \begin{syntax} |
| 2274 |
% erase-all-options |
| 2275 |
% erase-all-options-for = \marg{unit-key1, unit-key2, \dots} |
| 2276 |
% \end{syntax} |
| 2277 |
% \emph{This option is going to be obsolete at one point.} |
| 2278 |
% Erase options added to units. \opt{erase-all-options} erases all options |
| 2279 |
% for \emph{all} \meta{unit-key}s. |
| 2280 |
% |
| 2281 |
%^^A If you only want to erase options for specific \meta{unit-key}s, you may |
| 2282 |
%^^A use \opt{erase-all-options-for}. |
| 2283 |
% |
| 2284 |
% \opt{erase-all-options-for} is used to remove added options from |
| 2285 |
% the specified \meta{unit-key}s (key-value version of \mycs{cuclearoptionfor}). |
| 2286 |
% |
| 2287 |
% \end{function} |
| 2288 |
% |
| 2289 |
%^^A \begin{cuexample} |
| 2290 |
%^^A The following code erases all attached options from \myunit{C}, \myunit{F}, |
| 2291 |
%^^A \myunit{K} and \myunit{Re}: |
| 2292 |
%^^A |
| 2293 |
%^^A \begin{lstlisting} |
| 2294 |
%^^A \cusetup{ erase-all-options-for = {C, F, K, Re} } |
| 2295 |
%^^A \end{lstlisting} |
| 2296 |
%^^A It's the same as |
| 2297 |
%^^A \begin{lstlisting} |
| 2298 |
%^^A \cuclearoptionfor {C, F, K, Re} |
| 2299 |
%^^A \end{lstlisting} |
| 2300 |
%^^A \end{cuexample} |
| 2301 |
% |
| 2302 |
% |
| 2303 |
% |
| 2304 |
% \subsubsection{Command behavior} |
| 2305 |
% |
| 2306 |
% \begin{function}{cutext-to-cunum} |
| 2307 |
% \begin{syntax} |
| 2308 |
% cutext-to-cunum = \meta{true/false} |
| 2309 |
% \end{syntax} |
| 2310 |
% Want to get rid of all \cCutext? Set this option to \opt{true} and all |
| 2311 |
% \cCutext\ are changed into \mycs{cunum}. |
| 2312 |
% \end{function} |
| 2313 |
% \begin{cuexamplecode} |
| 2314 |
% \cutext{1}{kg} \\ |
| 2315 |
% \Cutext{2}{kg} \\ |
| 2316 |
% \cutext{1/2}{kg} \\ |
| 2317 |
% \cutext{?}{kg} \\ |
| 2318 |
% \cutext[kg=g]{1--2}{kg} \\ |
| 2319 |
% \cusetup{cutext-to-cunum = true } @ |
| 2320 |
% \cutext{1}{kg} \\ |
| 2321 |
% \Cutext{2}{kg} \\ |
| 2322 |
% \cutext{1/2}{kg} \\ |
| 2323 |
% \cutext{?}{kg} \\ |
| 2324 |
% \cutext[kg=g]{1--2}{kg} |
| 2325 |
% \end{cuexamplecode} |
| 2326 |
% |
| 2327 |
% |
| 2328 |
% \begin{function}{cutext-change-unit} |
| 2329 |
% \begin{syntax} |
| 2330 |
% cutext-change-unit = \meta{true/false} |
| 2331 |
% \end{syntax} |
| 2332 |
% Set this option to \opt{false} if you do \emph{not} want the units of \cCutext\ |
| 2333 |
% to be changed. Set to \true\ by default |
| 2334 |
% \end{function} |
| 2335 |
% \begin{cuexamplecode} |
| 2336 |
% \cutext[kg=g]{1}{kg} \\ |
| 2337 |
% \cutext[kg=g]{1/2}{kg} \\ |
| 2338 |
% \cutext[kg=g]{1--2}{kg} \\ |
| 2339 |
% \cusetup{cutext-change-unit = false } @ |
| 2340 |
% \cutext[kg=g]{1}{kg} \\ |
| 2341 |
% \cutext[kg=g]{1/2}{kg} \\ |
| 2342 |
% \cutext[kg=g]{1--2}{kg} |
| 2343 |
% \end{cuexamplecode} |
| 2344 |
% |
| 2345 |
% \begin{function}{cuam-version,cutext-version} |
| 2346 |
% \begin{syntax} |
| 2347 |
% cuam-version = \meta{old/new} |
| 2348 |
% cutext-version = \meta{old/new} |
| 2349 |
% \end{syntax} |
| 2350 |
% Since v1.10 this package also parses and checks the input of |
| 2351 |
% \cCutext\ and \mycs{cuam}. If you want to restore the old |
| 2352 |
% behavior, set this option to \opt{old}, but note that then you can |
| 2353 |
% neither change the amounts for a given number of persons nor |
| 2354 |
% change the unit of \cCutext. Both of them are set to \opt{new} by |
| 2355 |
% default. |
| 2356 |
% \end{function} |
| 2357 |
% |
| 2358 |
% |
| 2359 |
% |
| 2360 |
% |
| 2361 |
% \subsubsection{Hooks} |
| 2362 |
% |
| 2363 |
% \begin{function}{commands-add-hook,cunum-add-hook,cutext-add-hook,Cutext-add-hook,cuam-add-hook} |
| 2364 |
% \begin{syntax} |
| 2365 |
% commands-add-hook = \marg{code} |
| 2366 |
% cunum-add-hook = \marg{code} |
| 2367 |
% cutext-add-hook = \marg{code} |
| 2368 |
% Cutext-add-hook = \marg{code} |
| 2369 |
% cuam-add-hook = \marg{code} |
| 2370 |
% \end{syntax} |
| 2371 |
% Adds \meta{code} to the respective command (or in case of the first key: |
| 2372 |
% to \emph{all} commands). The hook is executed |
| 2373 |
% \emph{after} setting the keys, but \emph{before} parsing and processing the input. |
| 2374 |
% |
| 2375 |
% Please be carful with spaces, they will be printed. |
| 2376 |
% \end{function} |
| 2377 |
% |
| 2378 |
% \begin{cuexample} |
| 2379 |
% You would like to count how often all commands of this package are used. |
| 2380 |
% Simply add: |
| 2381 |
% \begin{lstlisting} |
| 2382 |
% \newcounter{CookingUnitsCounter} %% or however you like it |
| 2383 |
% \cusetup{commands-add-hook={\stepcounter{CookingUnitsCounter}}} |
| 2384 |
% %% beware of spaces inside the add-hook keys. |
| 2385 |
% \end{lstlisting} |
| 2386 |
% to your preamble. The following table lists how often each command |
| 2387 |
% is used in this documentation (with help of \pkg{totalcount}): |
| 2388 |
% |
| 2389 |
% \begin{center} |
| 2390 |
% \begin{tabular}{lr} |
| 2391 |
% \toprule |
| 2392 |
% command & times \\ \midrule |
| 2393 |
% \mycs{cunum} & \totalcunumCounters \\ |
| 2394 |
% \mycs{cutext} & \totalcutextCounters \\ |
| 2395 |
% \mycs{Cutext} & \totalCutextCounters \\ |
| 2396 |
% \mycs{cuam} & \totalcuamCounters \\ |
| 2397 |
% \cmidrule{2-2} |
| 2398 |
% total & \totalCookingUnitsCounters \\ |
| 2399 |
% \bottomrule |
| 2400 |
% \end{tabular} |
| 2401 |
% \end{center} |
| 2402 |
% \end{cuexample} |
| 2403 |
% |
| 2404 |
% \subsubsection{Input and Outputs} |
| 2405 |
% |
| 2406 |
% |
| 2407 |
% \begin{function}{expand-both , expand-amount, expand-unit} |
| 2408 |
% \begin{syntax} |
| 2409 |
% expand-both = \meta{n/o/f/x} |
| 2410 |
% expand-amount = \meta{n/o/f/x} |
| 2411 |
% expand-unit = \meta{n/o/f/x} |
| 2412 |
% \end{syntax} |
| 2413 |
% By default the commands \mycs{cunum}, \cCutext{} and \mycs{cunum} |
| 2414 |
% do \emph{not} expand their input. You can change the expansion behavior of |
| 2415 |
% \meta{amount} and/or \meta{unit-key} using the options specified |
| 2416 |
% above. The meaning of the available values are the same as specified |
| 2417 |
% in the \LaTeX3\ document \enquote{interface3}. |
| 2418 |
% |
| 2419 |
% It is set to \texttt{n} (no expansion) by default. |
| 2420 |
% |
| 2421 |
% \end{function} |
| 2422 |
% |
| 2423 |
% |
| 2424 |
% |
| 2425 |
% |
| 2426 |
% \begin{function}{set-special-sign,add-special-sign} |
| 2427 |
% \begin{syntax} |
| 2428 |
% set-special-sign = \marg{character(s)} |
| 2429 |
% add-special-sign = \marg{character(s)} |
| 2430 |
% \end{syntax} |
| 2431 |
% Allows \meta{character(s)} to be used in the first mandatory argument of |
| 2432 |
% \mycs{cunum}, \mycs{cuam}, \cCutext{} without raising an error (you can customize this |
| 2433 |
% behavior, see \opt{set-unknown-message}). By default it is set to |?|. |
| 2434 |
% Please note that the sign |<| is not allowed as a special sign. |
| 2435 |
% \end{function} |
| 2436 |
% |
| 2437 |
% \begin{cuexamplecode} |
| 2438 |
% \cunum{?}{kg} \\ |
| 2439 |
% \cunum[g=kg]{10?--20?}{kg} \\ |
| 2440 |
% \cusetup{add-special-sign={xX} } @ |
| 2441 |
% \cunum{x}{kg} \\ |
| 2442 |
% \cunum{X--?}{kg} \\ |
| 2443 |
% \cusetup{set-special-sign={} } @ |
| 2444 |
% \cunum{1}{kg} \\ |
| 2445 |
% \cunum{1--2}{kg} |
| 2446 |
% \end{cuexamplecode} |
| 2447 |
% |
| 2448 |
% \begin{function}{set-unknown-message} |
| 2449 |
% \begin{syntax} |
| 2450 |
% set-unknown-message = \meta{error/warning/none} |
| 2451 |
% \end{syntax} |
| 2452 |
% Using a special sign (\texttt{?} by default) causes a warning to |
| 2453 |
% be raised. Set this option to \opt{error} if you want an error (as |
| 2454 |
% an extra emphasis), \opt{warning} if you want a warning (default) |
| 2455 |
% and \opt{none} if you don't want to know anything about it. |
| 2456 |
% \end{function} |
| 2457 |
% |
| 2458 |
% \begin{function}{set-cutext-translation-message} |
| 2459 |
% \begin{syntax} |
| 2460 |
% set-cutext-translation-message = \meta{error/warning/none} |
| 2461 |
% \end{syntax} |
| 2462 |
% If a translation for \cCutext\ is not available for the language, |
| 2463 |
% the commands are replaced |
| 2464 |
% by \mycs{cunum}. Currently -- if this is happening -- a warning is shown, |
| 2465 |
% you may change the behavior of the message (error, warning or not showing at all) |
| 2466 |
% using this option. |
| 2467 |
% \end{function} |
| 2468 |
% |
| 2469 |
% \begin{function}{print-numerals} |
| 2470 |
% \begin{syntax} |
| 2471 |
% print-numerals = \meta{true/false} |
| 2472 |
% \end{syntax} |
| 2473 |
% |
| 2474 |
% Prints numerals for integers smaller than \opt{use-numerals-below} if |
| 2475 |
% set to \true. If set to \false\ no numerals are printed. |
| 2476 |
% |
| 2477 |
% If you use the package option \opt{use-fmtcount-numerals} this option |
| 2478 |
% is automatically set to \true. |
| 2479 |
% |
| 2480 |
% If you want to use another package, just set this option to \true\ and |
| 2481 |
% use \opt{numeral-function} and \opt{Numeral-function}). |
| 2482 |
% |
| 2483 |
%^^A If the package option \opt{use-fmtcount-numerals} is set to \true\ you can |
| 2484 |
%^^A deactivate the printing of numerals by setting \opt{print-numerals} to |
| 2485 |
%^^A \false\ and activate them by setting it to \true. |
| 2486 |
% |
| 2487 |
% \end{function} |
| 2488 |
% \begin{cuexample} |
| 2489 |
% (Using the package option \opt{use-fmtcount-numerals}: |
| 2490 |
% \cusetup{ print-numerals=true } |
| 2491 |
% \begin{cuexamplecode} |
| 2492 |
% \cutext{1}{kg} \\ |
| 2493 |
% \cutext{2}{kg} \\ |
| 2494 |
% \cutext{12}{kg} \\ |
| 2495 |
% \cutext{13}{kg} \\ |
| 2496 |
% \cusetup{ print-numerals=false } @ |
| 2497 |
% \cutext{1}{kg} \\ |
| 2498 |
% \cutext{2}{kg} \\ |
| 2499 |
% \cutext{12}{kg} \\ |
| 2500 |
% \cutext{13}{kg} \\ |
| 2501 |
% \end{cuexamplecode} |
| 2502 |
% \cusetup{ print-numerals=false } |
| 2503 |
% \end{cuexample} |
| 2504 |
% |
| 2505 |
% \begin{function}{use-numerals-below} |
| 2506 |
% \begin{syntax} |
| 2507 |
% use-numerals-below = \meta{integer} |
| 2508 |
% \end{syntax} |
| 2509 |
% If \opt{print-numerals} is \true, prints the numerals in |
| 2510 |
% \mycs{cutext} and \mycs{Cutext} for integers smaller than |
| 2511 |
% \meta{integer}. \meta{integer} is by default 13. |
| 2512 |
% You can deactivate the printing of numerals by \opt{print-numerals=false}. |
| 2513 |
% \end{function} |
| 2514 |
% \cusetup{ print-numerals=true } |
| 2515 |
% \begin{cuexamplecode} |
| 2516 |
% \cutext{1}{kg} \\ |
| 2517 |
% \cutext{2}{kg} \\ |
| 2518 |
% \cutext{12}{kg} \\ |
| 2519 |
% \cutext{13}{kg} \\ |
| 2520 |
% \cusetup{ use-numerals-below=10 } @ |
| 2521 |
% \cutext{1}{kg} \\ |
| 2522 |
% \cutext{2}{kg} \\ |
| 2523 |
% \cutext{12}{kg} \\ |
| 2524 |
% \cutext{13}{kg} \\ |
| 2525 |
% \cusetup{ use-numerals-below=0 } @ |
| 2526 |
% \cutext{1}{kg} \\ |
| 2527 |
% \cutext{2}{kg} \\ |
| 2528 |
% \cutext{12}{kg} \\ |
| 2529 |
% \cutext{13}{kg} \\ |
| 2530 |
% \cusetup{ use-numerals-below=12001 } @ |
| 2531 |
% \cutext[kg=g]{1}{kg} \\ |
| 2532 |
% \cutext[kg=g]{2}{kg} \\ |
| 2533 |
% \cutext[kg=g]{12}{kg} \\ |
| 2534 |
% \cutext[kg=g]{13}{kg} \\ |
| 2535 |
% \end{cuexamplecode} |
| 2536 |
% \cusetup{ print-numerals=false } |
| 2537 |
% |
| 2538 |
% \begin{function}{numeral-function, Numeral-function } |
| 2539 |
% \begin{syntax} |
| 2540 |
% numeral-function = \meta{function} |
| 2541 |
% Numeral-function = \meta{function} |
| 2542 |
% \end{syntax} |
| 2543 |
% Sets the functions used for printing numerals. |
| 2544 |
% \opt{numeral-function} is used for lowercase, \opt{Numeral-function} |
| 2545 |
% for capitalized cases. |
| 2546 |
% \end{function} |
| 2547 |
% \begin{cuexample} |
| 2548 |
% Using the commands from \pkg{fmtcount} you can set the |
| 2549 |
% numeral function equal to |
| 2550 |
% \begin{lstlisting} |
| 2551 |
% \cusetup{ |
| 2552 |
% numeral-function = \numberstringnum , |
| 2553 |
% Numeral-function = \Numberstringnum |
| 2554 |
% } |
| 2555 |
% \end{lstlisting} |
| 2556 |
% (this happens if you use the package option \opt{use-fmtcount-numerals}) |
| 2557 |
% \end{cuexample} |
| 2558 |
% |
| 2559 |
% |
| 2560 |
% |
| 2561 |
% \begin{function}{parse-number} |
| 2562 |
% \begin{syntax} |
| 2563 |
% parse-number = \meta{true/false} |
| 2564 |
% \end{syntax} |
| 2565 |
% If set to \false\ prints the number of \lstinline!\cunum!, |
| 2566 |
% \lstinline!\cutext!, \lstinline!\Cutext! and \mycs{cuam} as they |
| 2567 |
% are (after some \dots\ well \dots\ parsing due to |
| 2568 |
% \enquote{\lstinline|_|}). Is set to \true\ by default. |
| 2569 |
% \end{function} |
| 2570 |
% |
| 2571 |
% \begin{cuexamplecode} |
| 2572 |
% \cusetup{ parse-number=false } @ |
| 2573 |
% \cunum[kg=g]{1}{kg} \\ |
| 2574 |
% \cunum{1--2}{kg} \\ |
| 2575 |
% \cunum{1----------2}{kg} \\ |
| 2576 |
% \cunum{1.2}{kg} \\ |
| 2577 |
% \cunum[kg=g]{1,2}{kg} \\ |
| 2578 |
% \cunum{1/2}{kg} \\ |
| 2579 |
% \cunum{1_2/3}{kg} \\ |
| 2580 |
% \cunum{1/2_3}{kg} \\ |
| 2581 |
% \cunum{some weird stuff}{kg} \\ |
| 2582 |
% \cutext{1}{kg} \\ |
| 2583 |
% \cutext{100}{kg} \\ |
| 2584 |
% \cutext{gjfak}{kg} \\ |
| 2585 |
% \cutext[kg=g]{12}{kg} \\ |
| 2586 |
% \cuam{1----------2} \\ |
| 2587 |
% \cuam{1,2} \\ |
| 2588 |
% \cuam{1_1/2} \\ |
| 2589 |
% \cuam{kwflk} \\ |
| 2590 |
% \end{cuexamplecode} |
| 2591 |
% |
| 2592 |
% |
| 2593 |
% |
| 2594 |
% \begin{function}{range-sign, cunum-range-sign, cutext-range-sign} |
| 2595 |
% \begin{syntax} |
| 2596 |
% range-sign = \marg{string} |
| 2597 |
% cunum-range-sign = \marg{string} |
| 2598 |
% cutext-range-sign = \marg{string} |
| 2599 |
% \end{syntax} |
| 2600 |
% \opt{cunum-range-sign} sets the \emph{printed} range sign used in \mycs{cunum} |
| 2601 |
% (and \mycs{cuam}) to \meta{string}, \opt{cutext-range-sign} sets the printed |
| 2602 |
% range sign used in \cCutext{} to \meta{string}. |
| 2603 |
% Using \opt{range-sign} sets the |
| 2604 |
% range signs for both \mycs{cunum} (and \mycs{cuam}) and |
| 2605 |
% \mycs{cutext}/\mycs{Cutext} to \meta{string}. |
| 2606 |
% |
| 2607 |
% The default for \meta{string} is \texttt{-{}-} (for both). |
| 2608 |
% \end{function} |
| 2609 |
% |
| 2610 |
% Since version 1.45 there also exists the language symbol \opt{cutext-range-sign} |
| 2611 |
% (see \cref{sec:language}). If the \emph{option} \opt{cutext-range-sign} is set |
| 2612 |
% the language symbol will be ignored. |
| 2613 |
% |
| 2614 |
% \begin{cuexamplecode} |
| 2615 |
% \cunum{1--2}{kg} \\ |
| 2616 |
% \cuam{1--2} \\ |
| 2617 |
% \cutext{1--2}{kg} \\ |
| 2618 |
% \Cutext{1--2}{kg} |
| 2619 |
% \end{cuexamplecode} |
| 2620 |
% \begin{cuexamplecode} |
| 2621 |
% \cusetup{cunum-range-sign={~to~}} @ |
| 2622 |
% \cunum{1--2}{kg} \\ |
| 2623 |
% \cuam{1--2} \\ |
| 2624 |
% \cutext{1--2}{kg} \\ |
| 2625 |
% \Cutext{1--2}{kg} |
| 2626 |
% \end{cuexamplecode} |
| 2627 |
% \begin{cuexamplecode} |
| 2628 |
% \cusetup{cutext-range-sign={--}} @ |
| 2629 |
% \cunum{1--2}{kg} \\ |
| 2630 |
% \cuam{1--2} \\ |
| 2631 |
% \cutext{1--2}{kg} \\ |
| 2632 |
% \Cutext{1--2}{kg} |
| 2633 |
% \end{cuexamplecode} |
| 2634 |
% \begin{cuexamplecode} |
| 2635 |
% \cusetup{range-sign={-to-}} @ |
| 2636 |
% \cunum{1--2}{kg} \\ |
| 2637 |
% \cuam{1--2} \\ |
| 2638 |
% \cutext{1--2}{kg} \\ |
| 2639 |
% \Cutext{1--2}{kg} |
| 2640 |
% \end{cuexamplecode} |
| 2641 |
% |
| 2642 |
% \begin{function} {use-phrases} |
| 2643 |
% \begin{syntax} |
| 2644 |
% use-phrases = \meta{true/false} |
| 2645 |
% \end{syntax} |
| 2646 |
% Setting this option to \true\ replaces certain integers (see \cref{sec:phrases} for |
| 2647 |
% more information) with their phrase counterpart. This option is set to \false\ by default. |
| 2648 |
% \end{function} |
| 2649 |
% |
| 2650 |
% \begin{cuexample} |
| 2651 |
%^^A \begin{myde} |
| 2652 |
% For the German language: |
| 2653 |
% \begin{cuexamplecode} |
| 2654 |
% \selectlanguage{ngerman} @ |
| 2655 |
% \cuam{12} \\ |
| 2656 |
% \cuam{12--24} \\ |
| 2657 |
% \cuam{36} \\ |
| 2658 |
% \cusetup{use-phrases=true} @ |
| 2659 |
% \cuam{12} \\ |
| 2660 |
% \cuam{12--24} \\ |
| 2661 |
% \cuam{36} \\ |
| 2662 |
% \cusetup{use-phrases=true, print-numerals=true} @ |
| 2663 |
% \cuam{12} \\ |
| 2664 |
% \cuam{12--24} \\ |
| 2665 |
% \cuam{36} \\ |
| 2666 |
% \end{cuexamplecode} |
| 2667 |
%^^A \end{myde} |
| 2668 |
% \end{cuexample} |
| 2669 |
% |
| 2670 |
% |
| 2671 |
% \subsubsection{Rounding options} |
| 2672 |
% |
| 2673 |
% \begin{function}{round-precision} |
| 2674 |
% \begin{syntax} |
| 2675 |
% round-precision = \meta{integer} |
| 2676 |
% \end{syntax} |
| 2677 |
% Rounds the amount automatically to \meta{integer} digits after the |
| 2678 |
% colon. Note that units like \myunit{C}, \myunit{F}, \myunit{K} and |
| 2679 |
% \myunit{Re} are still rounded to integers due to \mycs{cusetoptionfor}. |
| 2680 |
% \end{function} |
| 2681 |
% |
| 2682 |
% |
| 2683 |
% \begin{cuexamplecode} |
| 2684 |
% \cusetup{round-precision= 5} @ |
| 2685 |
% \cunum{1.23456789}{kg} \\ |
| 2686 |
% \cunum[g=kg]{12.587}{g} \\ |
| 2687 |
% \cunum{194}{kg} \\ |
| 2688 |
% \cunum[C=F]{200--210}{C} \\ |
| 2689 |
% \cunum[K=C]{0.0012}{K} \\ |
| 2690 |
% \cusetup{round-precision= 1} @ |
| 2691 |
% \cunum{1.23456789}{kg} \\ |
| 2692 |
% \cunum{12.58}{kg} \\ |
| 2693 |
% \cunum[g=kg]{194}{g} \\ |
| 2694 |
% \cunum[C=F]{200--210}{C} \\ |
| 2695 |
% \cunum[K=C]{0.0012}{K} |
| 2696 |
% \end{cuexamplecode} |
| 2697 |
% |
| 2698 |
% \begin{cunote} |
| 2699 |
% Negative numbers are also allowed. |
| 2700 |
% \begin{cuexamplecode} |
| 2701 |
% \cusetoptionfor{C,F}{round-precision=-1} @ |
| 2702 |
% \cunum{-271,2}{C} \\ |
| 2703 |
% \cunum[K=C]{0.0012}{K} \\ |
| 2704 |
% \cunum{185}{C} \\ |
| 2705 |
% \cunum[C=F]{180--200}{C} \\ |
| 2706 |
% \end{cuexamplecode} |
| 2707 |
% \end{cunote} |
| 2708 |
% |
| 2709 |
% \begin{function}{round-to-int} |
| 2710 |
% \begin{syntax} |
| 2711 |
% round-to-int = \meta{true/false} |
| 2712 |
% \end{syntax} |
| 2713 |
% \emph{This option is deprecated.} Rounds the amount to an integer if set \true. |
| 2714 |
% Use \opt{round-precision=0} instead. |
| 2715 |
% \end{function} |
| 2716 |
% |
| 2717 |
% |
| 2718 |
%^^A \begin{cuexamplecode} |
| 2719 |
%^^A \cusetup{round-to-int=true} @ |
| 2720 |
%^^A \cunum{1.23456789}{kg} \\ |
| 2721 |
%^^A \cunum{12.58}{kg} \\ |
| 2722 |
%^^A \cunum[g=kg]{194--294}{g} \\ |
| 2723 |
%^^A \cunum[kg=g]{1.23456789}{kg} |
| 2724 |
%^^A \end{cuexamplecode} |
| 2725 |
% |
| 2726 |
% \begin{function}{round-half} |
| 2727 |
% \begin{syntax} |
| 2728 |
% round-half = \meta{default/commercial} |
| 2729 |
% \end{syntax} |
| 2730 |
% This option is only important for half-way numbers |
| 2731 |
% (e.g. $0.005$). By setting it to \opt{default} the value will be |
| 2732 |
% rounded to the nearest even number. Setting it to |
| 2733 |
% \opt{commercial} rounds the value away from zero. |
| 2734 |
% |
| 2735 |
% It is set to \opt{default} by \dots\ default. |
| 2736 |
% |
| 2737 |
% \begin{cunote} |
| 2738 |
% \opt{default} actually refers to the fact that it is the default |
| 2739 |
% rounding algorithm used by \cs{fp\_eval:n \{ round( ) \}} |
| 2740 |
% without a third argument. |
| 2741 |
% \end{cunote} |
| 2742 |
% |
| 2743 |
% \end{function} |
| 2744 |
% |
| 2745 |
% |
| 2746 |
% \begin{cuexamplecode} |
| 2747 |
% \cusetup{round-half=default} @ |
| 2748 |
% \cunum{0.005}{kg} \\ |
| 2749 |
% \cunum{-0.005}{kg} \\ |
| 2750 |
% \cunum{1.245}{kg} \\ |
| 2751 |
% \cusetup{round-half=commercial} @ |
| 2752 |
% \cunum{0.005}{kg} \\ |
| 2753 |
% \cunum{-0.005}{kg} \\ |
| 2754 |
% \cunum{1.245}{kg} @ |
| 2755 |
% \end{cuexamplecode} |
| 2756 |
% |
| 2757 |
% |
| 2758 |
% |
| 2759 |
% \subsubsection{Fractions} |
| 2760 |
% |
| 2761 |
% \begin{function}{eval-fraction} |
| 2762 |
% \begin{syntax} |
| 2763 |
% eval-fraction = \meta{true/false} |
| 2764 |
% \end{syntax} |
| 2765 |
% This option takes \true\ or \false\ as values. |
| 2766 |
% If set to \true\ all fractions are evaluated. Please note that divisions |
| 2767 |
% through zero are not allowed. |
| 2768 |
% \end{function} |
| 2769 |
% |
| 2770 |
% \begin{cuexamplecode} |
| 2771 |
% \cusetup{eval-fraction=true} @ |
| 2772 |
% \cunum{1/3}{kg} \\ |
| 2773 |
% \cunum{1/2}{kg} \\ |
| 2774 |
% \cunum[kg=g]{1/2}{kg} \\ |
| 2775 |
% \cunum{1_1/2}{kg} \\ |
| 2776 |
% \cunum[kg=g]{1_1/2}{kg} \\ |
| 2777 |
% \cunum[kg=g]{-1_1/2}{kg} \\ |
| 2778 |
% \cunum[kg=g]{1_2/?}{kg} \\ |
| 2779 |
% \end{cuexamplecode} |
| 2780 |
% |
| 2781 |
% |
| 2782 |
% |
| 2783 |
% \begin{function}{convert-fraction} |
| 2784 |
% \begin{syntax} |
| 2785 |
% convert-fraction = \meta{true/false} |
| 2786 |
% \end{syntax} |
| 2787 |
% By default units of fractions are not converted into another unit. |
| 2788 |
% Setting this option to \true\ |
| 2789 |
% allows fractions to be evaluated when a change of units is requested |
| 2790 |
% (and \emph{only} if a change of unit is requested). |
| 2791 |
% \end{function} |
| 2792 |
% |
| 2793 |
% \begin{cuexamplecode} |
| 2794 |
% \cusetup{convert-fraction=true} @ |
| 2795 |
% \cunum{1/3}{kg} \\ |
| 2796 |
% \cunum[kg=g]{1/3}{kg} \\ |
| 2797 |
% \cunum{1_1/2}{kg} \\ |
| 2798 |
% \cunum[kg=g]{1_1/2}{kg} \\ |
| 2799 |
% \cunum[kg=g]{1_?/3}{kg} \\ |
| 2800 |
% \end{cuexamplecode} |
| 2801 |
% |
| 2802 |
% |
| 2803 |
% |
| 2804 |
% |
| 2805 |
% \begin{function}{fraction-command} |
| 2806 |
% \begin{syntax} |
| 2807 |
% fraction-command = \cs{command} |
| 2808 |
% \end{syntax} |
| 2809 |
% Sets the command used for printing fractions equal to \cs{command}. |
| 2810 |
% \cs{command} has to take two arguments. By default |
| 2811 |
% it is equal to |\sfrac| from \pkg{xfrac}. |
| 2812 |
% |
| 2813 |
% Please note that the amount is \emph{not} printed inside a math |
| 2814 |
% environment by default. |
| 2815 |
% \end{function} |
| 2816 |
% |
| 2817 |
% \begin{cuexamplecode} |
| 2818 |
% \newcommand\myfrac[2]{#1/#2} @ |
| 2819 |
% \cusetup{fraction-command=\myfrac} @ |
| 2820 |
% \cuam{1/8} \\ |
| 2821 |
% \cunum{1/2}{kg} \\ |
| 2822 |
% \cunum{4/5}{C} \\ |
| 2823 |
% \cunum{1_2/3}{kg} \\ |
| 2824 |
% \cusetup{fraction-command=\nicefrac} @ |
| 2825 |
% \cuam{1/8} \\ |
| 2826 |
% \cunum{1/2}{kg} \\ |
| 2827 |
% \cunum{4/5}{C} \\ |
| 2828 |
% \cunum{1_2/3}{kg} |
| 2829 |
% \end{cuexamplecode} |
| 2830 |
% |
| 2831 |
% \begin{function}{fraction-inline} |
| 2832 |
% \begin{syntax} |
| 2833 |
% fraction-inline = \marg{input containing \#1 and \#2} |
| 2834 |
% \end{syntax} |
| 2835 |
% Similar to \opt{fraction-command} only that you don't have to |
| 2836 |
% define a command to alter the output of the fraction. |
| 2837 |
% \end{function} |
| 2838 |
% |
| 2839 |
% \begin{cuexamplecode} |
| 2840 |
% \cusetup{fraction-inline={#1/#2} } @ |
| 2841 |
% \cuam{1/8} \\ |
| 2842 |
% \cunum{1/2}{kg} \\ |
| 2843 |
% \cunum{4/5}{C} \\ |
| 2844 |
% \cunum{1_2/3}{kg} \\ |
| 2845 |
% \cusetup{fraction-inline={\nicefrac{#2}{#1}} } @ |
| 2846 |
% \cuam{1/8} \\ |
| 2847 |
% \cunum{1/2}{kg} \\ |
| 2848 |
% \cunum{4/5}{C} \\ |
| 2849 |
% \cunum{1_2/3}{kg} |
| 2850 |
% \end{cuexamplecode} |
| 2851 |
% |
| 2852 |
% \subsubsection{Spaces} |
| 2853 |
% |
| 2854 |
% \begin{function}{mixed-fraction-space} |
| 2855 |
% \begin{syntax} |
| 2856 |
% mixed-fraction-space = \meta{length} |
| 2857 |
% \end{syntax} |
| 2858 |
% Sets the length between the fraction and the number in a mixed-fraction, |
| 2859 |
% default is \texttt{0.1em} (because I said so; if someone has some literature |
| 2860 |
% or sources to look up the space, please let me know). |
| 2861 |
% \end{function} |
| 2862 |
% \begin{cuexamplecode} |
| 2863 |
% \cuam{1_2/3} \\ |
| 2864 |
% \cunum{1_2/3}{kg} \\ |
| 2865 |
% \cunum{10_2/3}{kg} \\ |
| 2866 |
% \cusetup{mixed-fraction-space=1em } @ |
| 2867 |
% \cuam{1_2/3} \\ |
| 2868 |
% \cunum{1_2/3}{kg} \\ |
| 2869 |
% \cunum{10_2/3}{kg} \\ |
| 2870 |
% \cusetup{mixed-fraction-space=0em } @ |
| 2871 |
% \cuam{1_2/3} \\ |
| 2872 |
% \cunum{1_2/3}{kg} \\ |
| 2873 |
% \cunum{10_2/3}{kg} |
| 2874 |
% \end{cuexamplecode} |
| 2875 |
% |
| 2876 |
% \begin{function}{cutext-space} |
| 2877 |
% \begin{syntax} |
| 2878 |
% cutext-space = \marg{string} |
| 2879 |
% \end{syntax} |
| 2880 |
% \meta{string} is inserted between the numeral part and the unit part |
| 2881 |
% when using \cCutext. By default it is set an unbreakable space |~|. |
| 2882 |
% \end{function} |
| 2883 |
% \begin{cuexamplecode} |
| 2884 |
% \cutext{1}{kg}\\ |
| 2885 |
% \Cutext{10}{kg}\\ |
| 2886 |
% \cusetup { cutext-space = \space } @ |
| 2887 |
% \cutext{1}{kg}\\ |
| 2888 |
% \Cutext{10}{kg}\\ |
| 2889 |
% \cusetup { cutext-space = {} } @ |
| 2890 |
% \cutext{1}{kg}\\ |
| 2891 |
% \Cutext{10}{kg}\\ |
| 2892 |
% \cusetup { cutext-space = {qwe} } @ |
| 2893 |
% \cutext{1}{kg}\\ |
| 2894 |
% \Cutext{10}{kg}\\ |
| 2895 |
% \end{cuexamplecode} |
| 2896 |
% |
| 2897 |
% |
| 2898 |
% \begin{function}{phrase-space} |
| 2899 |
% \begin{syntax} |
| 2900 |
% phrase-space = \marg{string} |
| 2901 |
% \end{syntax} |
| 2902 |
% \meta{string} is inserted between the numeral part and the phrase part |
| 2903 |
% while using \mycs{cuam}. By default it is set to the unbreakable space |~|. Use this option |
| 2904 |
% if you want to e.g.\ insert a normal space. |
| 2905 |
% \end{function} |
| 2906 |
%^^A \begin{myde} |
| 2907 |
% \cusetup{use-phrases=true} |
| 2908 |
% (Switching to german) |
| 2909 |
% \begin{cuexamplecode} |
| 2910 |
% \selectlanguage{ngerman} @ |
| 2911 |
% \cuam{12}\\ |
| 2912 |
% \cuam{144}\\ |
| 2913 |
% \cusetup { phrase-space = \space } @ |
| 2914 |
% \cuam{12}\\ |
| 2915 |
% \cuam{144}\\ |
| 2916 |
% \cusetup { phrase-space = {} } @ |
| 2917 |
% \cuam{12}\\ |
| 2918 |
% \cuam{144}\\ |
| 2919 |
% \cusetup { phrase-space = {qwe} } @ |
| 2920 |
% \cuam{12}\\ |
| 2921 |
% \cuam{144}\\ |
| 2922 |
% \end{cuexamplecode} |
| 2923 |
% \cusetup{use-phrases=false} |
| 2924 |
%^^A \end{myde} |
| 2925 |
% |
| 2926 |
% \begin{function}{amount-unit-space} |
| 2927 |
% \begin{syntax} |
| 2928 |
% amount-unit-space = \marg{string} |
| 2929 |
% \end{syntax} |
| 2930 |
% Change the spacing for \mycs{cunum} between the printed amount(s) and |
| 2931 |
% the unit. The default value is |\thinspace|. |
| 2932 |
% \end{function} |
| 2933 |
% |
| 2934 |
% \begin{cuexamplecode} |
| 2935 |
% \cunum{1}{kg}\\ |
| 2936 |
% \cunum{1/2}{kg}\\ |
| 2937 |
% \cunum{1--2}{kg}\\ |
| 2938 |
% \cusetup { amount-unit-space = {\hspace{1em}} } @ |
| 2939 |
% \cunum{1}{kg}\\ |
| 2940 |
% \cunum{1/2}{kg}\\ |
| 2941 |
% \cunum{1--2}{kg}\\ |
| 2942 |
% \cusetup { amount-unit-space = {} } @ |
| 2943 |
% \cunum{1}{kg}\\ |
| 2944 |
% \cunum{1/2}{kg}\\ |
| 2945 |
% \cunum{1--2}{kg}\\ |
| 2946 |
% \cusetup { amount-unit-space = {qwe} } @ |
| 2947 |
% \cunum{1}{kg}\\ |
| 2948 |
% \cunum{1/2}{kg}\\ |
| 2949 |
% \cunum{1--2}{kg}\\ |
| 2950 |
% \end{cuexamplecode} |
| 2951 |
% |
| 2952 |
% \subsubsection{label \& refs} |
| 2953 |
% |
| 2954 |
% \begin{function}{recalculate-amount} |
| 2955 |
% \begin{syntax} |
| 2956 |
% recalculate-amount = \meta{true/false} |
| 2957 |
% \end{syntax} |
| 2958 |
% Set this option to \opt{true} if you want to change your recipes to the given |
| 2959 |
% number of people set by \opt{set-number-of-persons}. Note that only those |
| 2960 |
% values who have a label are changed. |
| 2961 |
% \end{function} |
| 2962 |
% |
| 2963 |
% \begin{function}{set-number-of-persons} |
| 2964 |
% \begin{syntax} |
| 2965 |
% set-number-of-persons = \meta{integer} |
| 2966 |
% \end{syntax} |
| 2967 |
% With this option you can determine the number of people your recipes |
| 2968 |
% are for. Note that this option only has an effect on those who have a \meta{label} |
| 2969 |
% given. It is set to \opt{4} by default. Please also note the use of |
| 2970 |
% \opt{recalculate-amount}. |
| 2971 |
% \end{function} |
| 2972 |
% \begin{cuexamplecode} |
| 2973 |
% \culabel{anotherrecipe}{2} @ |
| 2974 |
% \curef{anotherrecipe}~persons \\ |
| 2975 |
% \cunum<anotherrecipe>{1}{kg}\\ |
| 2976 |
% \cuam<anotherrecipe>{1}\\ |
| 2977 |
% \Cutext[ref=anotherrecipe]{10}{kg}\\ |
| 2978 |
% & |
| 2979 |
% \cusetup{ recalculate-amount = true } @ |
| 2980 |
% \curef{anotherrecipe}~persons \\ |
| 2981 |
% \cunum<anotherrecipe>{1}{kg}\\ |
| 2982 |
% \cuam<anotherrecipe>{1}\\ |
| 2983 |
% \Cutext[ref=anotherrecipe]{10}{kg}\\ |
| 2984 |
% & |
| 2985 |
% \cusetup { set-number-of-persons = 3 } @ |
| 2986 |
% \curef{anotherrecipe}~persons \\ |
| 2987 |
% \cunum<anotherrecipe>{1}{kg} \\ |
| 2988 |
% \cuam<anotherrecipe>{1} \\ |
| 2989 |
% \Cutext[ref=anotherrecipe]{10}{kg}\\ |
| 2990 |
% & |
| 2991 |
% \cusetup { set-number-of-persons = 2 } @ |
| 2992 |
% \curef{anotherrecipe}~persons \\ |
| 2993 |
% \cunum<anotherrecipe>{1}{kg}\\ |
| 2994 |
% \cuam<anotherrecipe>{1}\\ |
| 2995 |
% \cutext<anotherrecipe>{10}{kg}\\ |
| 2996 |
% & |
| 2997 |
% \cusetup { set-number-of-persons = 1 } @ |
| 2998 |
% \curef{anotherrecipe}~persons \\ |
| 2999 |
% \cunum<anotherrecipe>{1}{kg}\\ |
| 3000 |
% \cuam<anotherrecipe>{1}\\ |
| 3001 |
% \Cutext[ref=anotherrecipe]{10}{kg}\\ |
| 3002 |
% \end{cuexamplecode} |
| 3003 |
% |
| 3004 |
% |
| 3005 |
% \begin{function}{label} |
| 3006 |
% \begin{syntax} |
| 3007 |
% label = \{\meta{string}*\meta{integer}\} |
| 3008 |
% \end{syntax} |
| 3009 |
% The key-value version of \mycs{culabel}. It defines the label \meta{string} |
| 3010 |
% which is originally for \meta{integer} people. Please note that the \texttt{*} |
| 3011 |
% is mandatory as it separates the string from the integer. Each |
| 3012 |
% label is defined globally and must be unique. |
| 3013 |
% \end{function} |
| 3014 |
% \begin{cuexamplecode} |
| 3015 |
% \cusetup{label=Toast*1} @ |
| 3016 |
% \curef{Toast}~person \\ |
| 3017 |
% \cuam<Toast>{2} \\ |
| 3018 |
% \cunum<Toast>{2}{dag} \\ |
| 3019 |
% \cusetup { recalculate-amount = true } @ |
| 3020 |
% \curef{Toast}~persons \\ |
| 3021 |
% \cuam<Toast>{2} \\ |
| 3022 |
% \cunum<Toast>{2}{dag} |
| 3023 |
% \end{cuexamplecode} |
| 3024 |
% |
| 3025 |
% |
| 3026 |
% \begin{function}{get-label} |
| 3027 |
% \begin{syntax} |
| 3028 |
% get-label = \marg{label} |
| 3029 |
% \end{syntax} |
| 3030 |
% The key-value version of \mycs{curef}. Note that this key doesn't save the value |
| 3031 |
% inside a macro but rather prints it directly into the document. |
| 3032 |
% \end{function} |
| 3033 |
% \begin{cuexamplecode} |
| 3034 |
% \culabel{Schinken}{3} @ |
| 3035 |
% \cusetup{get-label=Schinken} \\ |
| 3036 |
% \curef{Schinken} \\ |
| 3037 |
% \cusetup { recalculate-amount = true } @ |
| 3038 |
% \cusetup{get-label=Schinken} \\ |
| 3039 |
% \curef{Schinken} |
| 3040 |
% \end{cuexamplecode} |
| 3041 |
% |
| 3042 |
% \begin{cunote} |
| 3043 |
% \mycs{curef} \emph{is} expendable. |
| 3044 |
% \end{cunote} |
| 3045 |
% |
| 3046 |
% |
| 3047 |
% \begin{function}{ref} |
| 3048 |
% \begin{syntax} |
| 3049 |
% ref = \marg{label} |
| 3050 |
% \end{syntax} |
| 3051 |
% Instead of using the first optional arguments of the commands in \cref{sec:commands} |
| 3052 |
% you may use this option. It requires a valid value and throws an error if \meta{label} |
| 3053 |
% is not defined. |
| 3054 |
% \end{function} |
| 3055 |
% \begin{cuexamplecode} |
| 3056 |
% \culabel{Kaese}{3} @ |
| 3057 |
% \cunum<Kaese> [m=dm]{1}{m} \\ |
| 3058 |
% \cunum[ref=Kaese,m=dm]{1}{m} \\ |
| 3059 |
% \cusetup { recalculate-amount = true } @ |
| 3060 |
% \cunum<Kaese>[m=dm]{1}{m} \\ |
| 3061 |
% \cunum[ref=Kaese,m=dm]{1}{m} |
| 3062 |
% \end{cuexamplecode} |
| 3063 |
% |
| 3064 |
% |
| 3065 |
% |
| 3066 |
% \begin{function}{curef-add-forbidden-unit, curef-remove-forbidden-unit,curef-clear-forbidden-units} |
| 3067 |
% \begin{syntax} |
| 3068 |
% curef-add-forbidden-unit = \marg{unit list} |
| 3069 |
% curef-remove-forbidden-unit = \marg{unit list} |
| 3070 |
% curef-clear-forbidden-units = \meta{true/false} |
| 3071 |
% \end{syntax} |
| 3072 |
%^^A How much of a specify ingredient is used generally depends on the number of folks the meal |
| 3073 |
%^^A is for. Change the number of folks and the needed weight of an ingredient will most probably |
| 3074 |
%^^A change, \emph{but} there are units which do not change automatically if you have $2$ instead |
| 3075 |
%^^A of $4$ guests. Units which measure the temperature are for example one of them. So changing |
| 3076 |
%^^A them using the label \& ref system would be accidental and should in the best case create an error. |
| 3077 |
%^^A Use the given options to define units which will throw an error if they are about to be changed |
| 3078 |
%^^A by the label \& ref system. Of course, you can also remove units or clear the whole list. |
| 3079 |
% |
| 3080 |
% There are units which do not depend on the number of folks you are cooking for, units measuring |
| 3081 |
% the temperature are an example. Changing those units with the label \& ref |
| 3082 |
% system would be accidental and in the best case throw an error. With the following options |
| 3083 |
% you can add units to the \enquote{forbidden unit list}, remove them and clear the whole list |
| 3084 |
% entirely. |
| 3085 |
% |
| 3086 |
% By default the list contains \texttt{C}, \texttt{F}, \texttt{K} and \texttt{Re}. |
| 3087 |
% \end{function} |
| 3088 |
% \begingroup |
| 3089 |
% \DeactivateForbiddenUnitError |
| 3090 |
% \begin{cuexamplecode} |
| 3091 |
% \culabel{check}{2} @ |
| 3092 |
% \cusetup{ recalculate-amount=true } @ |
| 3093 |
% \cunum<check>{1}{m} \\ |
| 3094 |
% \cunum<check>{1}{kg} \\ |
| 3095 |
% \cunum[ref=check]{1}{C} \\ |
| 3096 |
% \cusetup { curef-add-forbidden-unit = { m, kg } } @ |
| 3097 |
% \cunum<check>[m]{1}{m} \\ |
| 3098 |
% \cunum<check>[m]{1}{kg} \\ |
| 3099 |
% \cunum[ref=check]{1}{C} \\ |
| 3100 |
% \cusetup { curef-remove-forbidden-unit = { C } } @ |
| 3101 |
% \cunum<check>[m]{1}{m} \\ |
| 3102 |
% \cunum<check>[m]{1}{kg} \\ |
| 3103 |
% \cunum[ref=check]{1}{C} \\ |
| 3104 |
% \cusetup { curef-clear-forbidden-units = true } @ |
| 3105 |
% \cunum<check>[m]{1}{m} \\ |
| 3106 |
% \cunum<check>[m]{1}{kg} \\ |
| 3107 |
% \cunum[ref=check]{1}{C} |
| 3108 |
% \end{cuexamplecode} |
| 3109 |
% \endgroup |
| 3110 |
% |
| 3111 |
% |
| 3112 |
% |
| 3113 |
% |
| 3114 |
% |
| 3115 |
% |
| 3116 |
% |
| 3117 |
% |
| 3118 |
% |
| 3119 |
% |
| 3120 |
% |
| 3121 |
% |
| 3122 |
% |
| 3123 |
% |
| 3124 |
% |
| 3125 |
% \subsection{Weird options} |
| 3126 |
% |
| 3127 |
% \begin{function}{check-temperature} |
| 3128 |
% \begin{syntax} |
| 3129 |
% check-temperature = \meta{true/false} |
| 3130 |
% \end{syntax} |
| 3131 |
% Checks if the used temperature is below absolute zero. |
| 3132 |
% Currently \myunit{C}, \myunit{F}, \myunit{K} and \myunit{Re} are supported. |
| 3133 |
% While \lstinline|\cunum{0}{K}| is ok, \lstinline!\cunum{-1}{K}! raises an error, |
| 3134 |
% same for the others. Is set to \false\ by default. To add new units |
| 3135 |
% see \opt{add-temperature-to-check}. |
| 3136 |
% \end{function} |
| 3137 |
% |
| 3138 |
% \begin{function}{add-temperature-to-check} |
| 3139 |
% \begin{syntax} |
| 3140 |
% add-temperature-to-check = |
| 3141 |
% \ \ \{ |
| 3142 |
% \ \ \ \ \meta{unit-key-1} = \meta{minimum-value-1} , |
| 3143 |
% \ \ \ \ \meta{unit-key-2} = \meta{minimum-value-2} , |
| 3144 |
% \ \ \ \ \dots |
| 3145 |
% \ \ \} |
| 3146 |
% \end{syntax} |
| 3147 |
% This option adds \meta{unit-key-1} and so on to the list of units to be checked |
| 3148 |
% if \opt{check-temperature} is active. The argument can be a comma-separated |
| 3149 |
% list of \meta{unit-key} = \meta{minimum-value}. This sets the allowed minimum |
| 3150 |
% value of \meta{unit-key} to \meta{minimum-value}. |
| 3151 |
% |
| 3152 |
% \end{function} |
| 3153 |
% |
| 3154 |
% \begin{cuexample} |
| 3155 |
% This package implements the allowed minimum values for the |
| 3156 |
% temperatures \myunit{C}, \myunit{F}, \myunit{K} and \myunit{Re} to be checked if |
| 3157 |
% \opt{check-temperature} is active using: |
| 3158 |
% \begin{lstlisting} |
| 3159 |
% \cusetup |
| 3160 |
% { |
| 3161 |
% add-temperature-to-check = |
| 3162 |
% { |
| 3163 |
% K = 0, |
| 3164 |
% C = -273.15 , |
| 3165 |
% F = -459.67 , |
| 3166 |
% Re = -218.52 |
| 3167 |
% } |
| 3168 |
% } |
| 3169 |
% \end{lstlisting} |
| 3170 |
% |
| 3171 |
% If you want to add a new value, for example degree R{\o}mer |
| 3172 |
% (which has be defined in another example) you can write: |
| 3173 |
% \begin{lstlisting} |
| 3174 |
% \cusetup |
| 3175 |
% { |
| 3176 |
% add-temperature-to-check = { Ro = -135.90375 } |
| 3177 |
% } |
| 3178 |
% \end{lstlisting} |
| 3179 |
% \end{cuexample} |
| 3180 |
% |
| 3181 |
% |
| 3182 |
% |
| 3183 |
% |
| 3184 |
% \begin{function}{convert-to-eV} |
| 3185 |
% \begin{syntax} |
| 3186 |
% convert-to-eV = \meta{true/false} |
| 3187 |
% \end{syntax} |
| 3188 |
% Converts (nearly) every unit in \cref{tab:def-units} |
| 3189 |
% to electron volt or the respective derivative (if possible). Note that this |
| 3190 |
% option is: |
| 3191 |
% a) experimental and probably will forever be and (b) just a joke, you are not |
| 3192 |
% supposed to use this units in a cookery book (and as you see this package |
| 3193 |
% doesn't support the arrangement of such huge numbers). Also you may |
| 3194 |
% want to check the values if you really want to use them, just to be sure |
| 3195 |
% (I've checked them several times and hope they are finally correct, but mistakes |
| 3196 |
% happen). |
| 3197 |
% |
| 3198 |
% \end{function} |
| 3199 |
% |
| 3200 |
% \begin{cuexamplecode}[\hfill] |
| 3201 |
% \cusetup{ convert-to-eV=true } @ |
| 3202 |
% \cunum{1}{kg} \\ |
| 3203 |
% \cunum{1}{l} \\ |
| 3204 |
% \cunum{1}{J} \\ |
| 3205 |
% \cunum{1}{m} \\ |
| 3206 |
% \cunum{1}{C} \\ |
| 3207 |
% \cunum{1}{s} |
| 3208 |
% \end{cuexamplecode} |
| 3209 |
% |
| 3210 |
% |
| 3211 |
% \begin{function}{add-natural-unit} |
| 3212 |
% \begin{syntax} |
| 3213 |
% add-natural-unit = \meta{unit-key} |
| 3214 |
% \end{syntax} |
| 3215 |
% This option adds \meta{unit-key} to the list of units \opt{convert-to-eV} |
| 3216 |
% uses to determine how a unit is transformed if set to \true. |
| 3217 |
% \end{function} |
| 3218 |
% |
| 3219 |
% |
| 3220 |
% |
| 3221 |
% \begin{function}{42} |
| 3222 |
% \begin{syntax} |
| 3223 |
% 42 = \meta{true/false} |
| 3224 |
% \end{syntax} |
| 3225 |
% Take a good guess. |
| 3226 |
% \end{function} |
| 3227 |
% |
| 3228 |
% \begin{cuexamplecode}[\hfill] |
| 3229 |
% \cusetup{ 42=true } @ |
| 3230 |
% \cunum{1}{kg} \\ |
| 3231 |
% \cunum[kg=g]{1}{kg} \\ |
| 3232 |
% \cunum{1.5}{J} \\ |
| 3233 |
% \cunum{180}{C} \\ |
| 3234 |
% \cunum{15/4}{s} \\ |
| 3235 |
% \cunum{1--2}{min} \\ |
| 3236 |
% \cunum{1x2x3}{min} \\ |
| 3237 |
% \cunum{?}{l} |
| 3238 |
% \end{cuexamplecode} |
| 3239 |
% |
| 3240 |
% |
| 3241 |
% \begin{function}{nothing-special, going-bonkers, fully-bonkers, xD-lol} |
| 3242 |
% \begin{syntax} |
| 3243 |
% nothing-special = \meta{true/false} |
| 3244 |
% going-bonkers = \meta{true/false} |
| 3245 |
% fully-bonkers = \meta{true/false} |
| 3246 |
% xD-lol = \meta{true/false} |
| 3247 |
% \end{syntax} |
| 3248 |
% Options that do \dots\ stuff. The four stages of madness in option for. |
| 3249 |
% |
| 3250 |
% \begin{description} |
| 3251 |
% \item[nothing-special] is your default. The package behaves as intended. |
| 3252 |
% |
| 3253 |
% \item[going-bonkers] is a bit more strange. It converts an unit into another random unit |
| 3254 |
% (if it can) and does so throughout the document. So if |unit-A| is converted |
| 3255 |
% into |unit-B|, it is going to be converted this way the entire document through. |
| 3256 |
% For an unit to be converted it must have a key, see \cref{sec:defining-opt}. |
| 3257 |
% |
| 3258 |
% |
| 3259 |
% \item[fully-bonkers] converts one unit into another random unit (if it can) and does so for |
| 3260 |
% each unit it encounters. So |unit-A| might be converted into |unit-B| the first time, |
| 3261 |
% but |unit-C| the second. Each conversion picks a random unit for the conversion |
| 3262 |
% (but the conversion itself makes sense, e.g.\ |kg| into |g|, but not into |cm|). |
| 3263 |
% |
| 3264 |
% \item[xD-lol] is pure insanity. A unit is transformed into another, if it makes sense |
| 3265 |
% or not, and its value is replaced by a random number. |
| 3266 |
% \end{description} |
| 3267 |
% \end{function} |
| 3268 |
% |
| 3269 |
% |
| 3270 |
% |
| 3271 |
% |
| 3272 |
% |
| 3273 |
% |
| 3274 |
% \section{Public Commands} |
| 3275 |
% |
| 3276 |
% This section describes some public functions, Their main usage is the printing of |
| 3277 |
% stuff. They are primtivies used between an \mycs{ExplSyntaxOn} and |
| 3278 |
% \mycs{ExplSyntaxOff}; for usage in a document you may do the following: |
| 3279 |
% \begin{lstlisting} |
| 3280 |
% \ExplSyntaxOn |
| 3281 |
% \NewDocumentCommand \cuprintfrac { O{} m m } |
| 3282 |
% { |
| 3283 |
% \cookingunits_print_fraction:nnn {#1} {#2} {#3} |
| 3284 |
% } |
| 3285 |
% \NewDocumentCommand \cuprintrange { m m } |
| 3286 |
% { |
| 3287 |
% \cookingunits_print_range:nn {#1} {#2} |
| 3288 |
% } |
| 3289 |
% \ExplSyntaxOff |
| 3290 |
% \end{lstlisting} |
| 3291 |
% |
| 3292 |
% |
| 3293 |
% \begin{function}{\cookingunits_print_fraction:nnn} |
| 3294 |
% \begin{syntax} |
| 3295 |
% \mycs{cookingunits_print_fraction:nnn} \marg{mixed-part}\marg{numerator}\marg{denominator} |
| 3296 |
% \end{syntax} |
| 3297 |
% \emph{Note:} There is no parsing and processing done in this command, it just |
| 3298 |
% prints the input. |
| 3299 |
% |
| 3300 |
% Uses the internal fraction printing command to print a fraction. \Arg{mixed-part} |
| 3301 |
% can be empty if no mixed part is needed. |
| 3302 |
% \end{function} |
| 3303 |
% |
| 3304 |
% |
| 3305 |
% \begin{function}{\cookingunits_print_range:nn} |
| 3306 |
% \begin{syntax} |
| 3307 |
% \mycs{cookingunits_print_range:nn} \marg{left-part}\marg{right-part} |
| 3308 |
% \end{syntax} |
| 3309 |
% \emph{Note:} There is no parsing and processing done in this command, ist just |
| 3310 |
% prints the input. |
| 3311 |
% |
| 3312 |
% Uses the internal range printing command to print a range (using the same range sign as |
| 3313 |
% \mycs{cunum} would use) |
| 3314 |
% \end{function} |
| 3315 |
% |
| 3316 |
% |
| 3317 |
%^^A \section{Notes} |
| 3318 |
% |
| 3319 |
%^^A There is a unit called \enquote{Batman}. |
| 3320 |
% |
| 3321 |
% |
| 3322 |
% |
| 3323 |
% |
| 3324 |
% |
| 3325 |
% |
| 3326 |
% |
| 3327 |
% |
| 3328 |
% |
| 3329 |
% |
| 3330 |
% |
| 3331 |
% |
| 3332 |
% |
| 3333 |
% \section{Bugs \& Feedback} |
| 3334 |
% \label{sec:bug-feed} |
| 3335 |
% |
| 3336 |
% Bug reports are always welcome. If you are sending a bug report |
| 3337 |
% please include a minimal working example showing the bug and a short |
| 3338 |
% description. If you use mail please add \pkg{cooking-units} |
| 3339 |
% to the e-mail header. GMX has the habit of putting e-mails into the |
| 3340 |
% spam account and adding \pkg{cooking-units} to the header makes |
| 3341 |
% it easier to recognize those e-mails. It can also take longer of GitHub, |
| 3342 |
% but I hope I figured out how to get a mail if a new issue is created (by not me). |
| 3343 |
% |
| 3344 |
% Feedback and requests (commands, units, etc.) are also welcome. Please |
| 3345 |
% also add (if possible) an example of the desired output into the |
| 3346 |
% minimal example (and -- if by mail -- add \pkg{cooking-units} to the |
| 3347 |
% header). |
| 3348 |
% |
| 3349 |
% Furthermore, as you can see I am not able to speak too many |
| 3350 |
% languages (german and english to be precise) so if you are |
| 3351 |
% able to speak a language not yet implemented and would like to help |
| 3352 |
% you can send me the translations known to you. A list of all units |
| 3353 |
% (and their current translations) is given in \cref{sec:Translations}. |
| 3354 |
% |
| 3355 |
% |
| 3356 |
% |
| 3357 |
% |
| 3358 |
% |
| 3359 |
%\clearpage |
| 3360 |
% |
| 3361 |
% \section{Bens Einheitensammelsurium (Bens unit Almanac)} |
| 3362 |
% \label{sec:unit-almanac} |
| 3363 |
% |
| 3364 |
% Units are a fascinating mess. There are so many different ones which are different and |
| 3365 |
% the few ones which are the same (in name at least) are \emph{also} different, depending on |
| 3366 |
% geographical position, time period and probably pure spite. We can be glad that SI-units exist. |
| 3367 |
% |
| 3368 |
% |
| 3369 |
%^^A Units are a fascinating mess. There are so many different ones that one can be glad |
| 3370 |
%^^A that SI-units exist in this world. This section offers some units which didn't manage |
| 3371 |
%^^A to appear in \cref{tab:def-units} and \cref{tab:some-more-units}.^^A\footnote{This somehow |
| 3372 |
%^^A ^^A reminds me of the story of \enquote{Tower of Babel} in the bible. This tower is -- according to the |
| 3373 |
%^^A ^^A story -- the reason (or the symptom) of why people speak different languages. |
| 3374 |
%^^A ^^A I suppose what didn't make it into the story was that as even more severe punishment, |
| 3375 |
%^^A ^^A different units were created. Just my take at lest.}. |
| 3376 |
% |
| 3377 |
% So for those units which didn't make it into \cref{tab:def-units} and \cref{tab:some-more-units}, |
| 3378 |
% this section exists. Please note that this list is intended to be a just-for-fun list and not a |
| 3379 |
% compilation of every unit in existence with its exact value ordered by geographical and chronological |
| 3380 |
% position. I am sadly neither a historian nor very good in regards to languages. It would sound like |
| 3381 |
% fun, but ultimately, I wouldn't have the time. |
| 3382 |
% Therefore I am only taking units into account which I either found in literature (stone, canna, etc.), |
| 3383 |
% are well known (foot) or have some other experience with them (ell) (exception: Batman). The reason I |
| 3384 |
% am not including units which I found in the internet is that I would like to |
| 3385 |
% see those units in their \enquote{natural environment}. |
| 3386 |
% |
| 3387 |
% |
| 3388 |
% \begin{description} |
| 3389 |
% |
| 3390 |
% \unititem{unit}*in given language*[translation][abbreviation] Description, containing a |
| 3391 |
% quote or not. \emph{Please note that most of the units are country dependent! |
| 3392 |
% So the translation may not have the same amount as the word it is translated to.} |
| 3393 |
% |
| 3394 |
% \unititem{Batman} |
| 3395 |
% So \dots\ You wanna be Batman? Be like Bruce Wayne? Having a secret identity? |
| 3396 |
% Then congratulations! You \emph{are} Batman! How much Batman depends on the location, |
| 3397 |
% but Wikipedia is your friend in this matter. |
| 3398 |
% |
| 3399 |
% |
| 3400 |
% \unititem{Rotolo}*sic*[Rottel\txtupde] Around \SI{0.850}{\kg} |
| 3401 |
% \begin{myquote}[Gattopardo][51] |
| 3402 |
% Auf den Fußboden lagen vier ungereifte Käse zu je \emph{zwölf Rottel}, |
| 3403 |
% jeder ungefähr zehn Kilo schwer. |
| 3404 |
% \end{myquote} |
| 3405 |
% |
| 3406 |
% \unititem{Canna}*sic*[Rute\txtupde, rod\txtupen] About \SI{2}{\m} bzw.\ about $6$ foot. |
| 3407 |
% \begin{myquote}[Gattopardo][25] |
| 3408 |
% \enquote{Unsinn, Stella, Unsinn; was soll mir zustoßen? Sie kennen mich alle: |
| 3409 |
% Männer, die \emph{eine Rute} lange sind, gibt es wenige in Palermo.} |
| 3410 |
% \end{myquote} |
| 3411 |
% |
| 3412 |
% \unititem{Stone}[][st] \cunum[st=kg]{1}{st}. According to a fellow student |
| 3413 |
% this unit is still used in |
| 3414 |
% Great Britain. I've also recently found it in a video game; in the german translation |
| 3415 |
% of said video game to be precise. Why is the german translation using stone |
| 3416 |
% and not kilogram (at least in braces)? |
| 3417 |
% |
| 3418 |
% \begin{myquote}[Sh:3][988] |
| 3419 |
% As we had expected, the telegramm was soon followed by its sender, and the card of Mr.\ Cyril Overton, Trinity College, Cambridge, announced the arrival of an enormous young man, \emph{sixteen stone} \emph{[\cunum[st=kg]{16}{st}]} of solid bone and muscle, who spanned the doorway with his broad shoulders \emph{[\dots\!]} |
| 3420 |
% \end{myquote} (Story \enquote{The missing Three Quarters}) |
| 3421 |
% |
| 3422 |
% \unititem{Foot}[][ft] Equals exactly \cunum[ft=m,round-precision=10]{1}{ft} |
| 3423 |
% or \cunum[ft=in]{1}{ft}. |
| 3424 |
% |
| 3425 |
% A bit of a strange unit (for me at least). Where I am from, people |
| 3426 |
% tend to have different feet sizes. Also present in the german translation of the |
| 3427 |
% video game that uses \enquote{Stone}. |
| 3428 |
% |
| 3429 |
% \unititem{degree Rèamur}[][\ensuremath{{}^{\circ}}\kern-\scriptspace R\'{e}] Like degree Celsius, but instead of having the |
| 3430 |
% water boiling at \SI{100}{\degree} (Celsius), water boils at \SI{80}{\degree}. |
| 3431 |
% Water thankfully still freezes at \SI{0}{\degree}. Don't think that this unit |
| 3432 |
% is used anymore. I think I learned about in physics. |
| 3433 |
% |
| 3434 |
% \unititem{Ell} Just read the Wikipedia article. |
| 3435 |
% |
| 3436 |
% Fun Fact: At the Stephansdom |
| 3437 |
% in Vienna left of the main entrance are two metal bars. One is the |
| 3438 |
% \enquote{Tuchelle} (drapery ell, circa \SI{78}{\cm}), the other the |
| 3439 |
% \enquote{Leinenelle} (linen ell, around \SI{89.6}{\cm}). |
| 3440 |
% |
| 3441 |
% \unititem{cup} I think the idea of having a \enquote{cup} and it not being |
| 3442 |
% equal to \cunum{250}{ml} is a bit strange, for me at least. What other sizes can a |
| 3443 |
% cup have? I can imagine \cunum{500}{ml}, but are there other sizes? |
| 3444 |
% ^^A Any person who writes \enquote{cup} and |
| 3445 |
% ^^A \emph{doesn't} mean |
| 3446 |
% ^^A a cup equal to \SI{250}{\ml} should be |
| 3447 |
%^^A^^A -- in my humble opinion\footnote{Which, now that I admitted |
| 3448 |
%^^A^^A my humbleness, is automatically |
| 3449 |
%^^A^^A more important than yours.} -- |
| 3450 |
%^^A excommunicated by default (or incommunicated, |
| 3451 |
%^^A if you are an atheist). |
| 3452 |
% |
| 3453 |
% \unititem{stick} A unit I've made fun of because it is quite regional and doesn't make |
| 3454 |
% any sense for foreigners. Then I realized that I am using the unit \enquote{Packerl} |
| 3455 |
% in my cookery book which is also quite locally\footnote{And maybe doesn't even exist |
| 3456 |
% outside my family} and -- even worse -- the weight changes depending |
| 3457 |
% the content (See \emph{Packerl}). |
| 3458 |
% |
| 3459 |
% \unititem{Packerl}*de*[small bag] I'm a bit split on this unit as I don't actually |
| 3460 |
% know if it exists. The reason I have the unit \emph{Packerl} for my cookery |
| 3461 |
% book is that in Austria you can buy baking powder, (dry) Germ, Natrium, etc. |
| 3462 |
% in small bags (similar to \emph{stick}). The problem: Depending on the content, |
| 3463 |
% the weight of \emph{Packerl} differs. Not only that, but it can also differ |
| 3464 |
% between different producers (but not more than \SI{2}{\g} bzw.\ \cunum[g=oz]{2}{g}). |
| 3465 |
% Here is a table: |
| 3466 |
% |
| 3467 |
% \begin{tabular}{l @{\space} l @{\space} l r l} |
| 3468 |
% |
| 3469 |
% 1 Packerl & Backpulver & (baking powder) & \cunum{16}{g} & (\cunum[g=oz]{16}{g}) \\ |
| 3470 |
% & Natrium & & \cunum{14}{g} & (\cunum[g=oz]{14}{g}) \\ |
| 3471 |
% & Vanillin(-zucker) & (vanillin(-sugar)) & \cunum{8}{g} & (\cunum[g=oz]{8}{g}) \\ |
| 3472 |
% & Germ* & & \cunum{7}{g} & (\cunum[g=oz]{7}{g}) \\ |
| 3473 |
% \end{tabular} |
| 3474 |
% |
| 3475 |
% {\footnotesize *Tockengerm (dry Germ) to be precise} |
| 3476 |
% |
| 3477 |
% For what kind of thing do I need \emph{Natrium} for? |
| 3478 |
% \end{description} |
| 3479 |
% |
| 3480 |
% |
| 3481 |
% |
| 3482 |
% |
| 3483 |
% |
| 3484 |
% |
| 3485 |
% |
| 3486 |
% \appendix |
| 3487 |
% |
| 3488 |
% \section{Translations} |
| 3489 |
% \label{sec:Translations} |
| 3490 |
% This section contains the list of available translations. Each table |
| 3491 |
% shows the available translations regarding the unit symbol, the unit name |
| 3492 |
% (printed if \mycs{cutext} or \mycs{Cutext} is used) and |
| 3493 |
% the plural form (if different from the singular form). A second table |
| 3494 |
% shows the translations used for phrases (if given). |
| 3495 |
% |
| 3496 |
% If a translation is not available a \enquote{\translationdoesnotexisttl} is |
| 3497 |
% shown. |
| 3498 |
% |
| 3499 |
% \small |
| 3500 |
% |
| 3501 |
% |
| 3502 |
%\clearpage |
| 3503 |
% \subsection{English} |
| 3504 |
% \begin{tabular}{ l l l l l } |
| 3505 |
% \toprule |
| 3506 |
% \CreateTableForLanguages{ English } |
| 3507 |
% \end{tabular} |
| 3508 |
% |
| 3509 |
% |
| 3510 |
%\clearpage |
| 3511 |
% \subsection{american} |
| 3512 |
% |
| 3513 |
% \begin{tabular}{ l l l l l } |
| 3514 |
% \toprule |
| 3515 |
% \CreateTableForLanguages{ american } |
| 3516 |
% \end{tabular} |
| 3517 |
% |
| 3518 |
%\clearpage |
| 3519 |
% \subsection{German} |
| 3520 |
% \begin{tabular}{ l l l l l } |
| 3521 |
% \toprule |
| 3522 |
% \CreateTableForLanguages{ German } |
| 3523 |
% \end{tabular} |
| 3524 |
% |
| 3525 |
% \bigskip |
| 3526 |
% |
| 3527 |
% \CreateTableForPhrases { German } |
| 3528 |
% |
| 3529 |
% \bigskip |
| 3530 |
% \begin{minipage}{\textwidth} |
| 3531 |
% Some further phrases, just to write them down (they are not implemented, |
| 3532 |
% as they are barely used). |
| 3533 |
% |
| 3534 |
% \begin{tabular} { l l @{\space} l l l l } |
| 3535 |
% \toprule |
| 3536 |
% \meta{number} & name & \multicolumn{2}{c}{Note} & (plural) & gender \\ \midrule |
| 3537 |
% 60 & Schock & (5 Dutzend, & $12*5$) & & n \\ |
| 3538 |
% 144 & Gros & (12 Dutzend, & $12*12$) && n \\ |
| 3539 |
% 1728 & Gro{\ss}gros &(12 Gro{\ss}, & $12*144$) && n \\ |
| 3540 |
% \bottomrule |
| 3541 |
% \end{tabular} |
| 3542 |
% \end{minipage} |
| 3543 |
% |
| 3544 |
% Note that Gro{\ss}gros has other (probably more common) synonyms. |
| 3545 |
% |
| 3546 |
%\clearpage |
| 3547 |
% \subsection{French} |
| 3548 |
% \begin{tabular}{ l l l l l } |
| 3549 |
% \toprule |
| 3550 |
% \CreateTableForLanguages{ French } |
| 3551 |
% \end{tabular} |
| 3552 |
% |
| 3553 |
% If the spoons should be extra full: |
| 3554 |
% \begin{itemize} |
| 3555 |
% \item cuill\`{e}re \`{a} soupe rase |
| 3556 |
% \item cuill\`{e}re \`{a} caf\'{e} rase |
| 3557 |
% \end{itemize} |
| 3558 |
% |
| 3559 |
%\clearpage |
| 3560 |
% |
| 3561 |
% |
| 3562 |
% |
| 3563 |
% |
| 3564 |
% |
| 3565 |
% \normalsize |
| 3566 |
% |
| 3567 |
% |
| 3568 |
% \section{US, Imperial and Other units} |
| 3569 |
% \label{sec:other-units} |
| 3570 |
% |
| 3571 |
% As source \cite{WM1985} has been used for imperial units, while \cite{Nist2006} |
| 3572 |
% and \cite{Nist2008} were used for U.S.\ units. I hope someone will find this |
| 3573 |
% bringing together useful. |
| 3574 |
% |
| 3575 |
%\begin{center} |
| 3576 |
%\begin{tabular}{ l @{ } l } |
| 3577 |
%\toprule |
| 3578 |
% 1 yard &= \SI{0.9144}{\m} (exact) \\ |
| 3579 |
% 1 yard &= 3 foot \\ |
| 3580 |
% 1 yard &= 36 Inch \\ \midrule |
| 3581 |
% 1 Inch &= \SI{0.0254}{\m} (also exact) \\ |
| 3582 |
% \bottomrule |
| 3583 |
%\end{tabular} |
| 3584 |
%\end{center} |
| 3585 |
% |
| 3586 |
%\begin{center} |
| 3587 |
%\begin{tabular}{r@{ }l r@{ }l} |
| 3588 |
%\toprule |
| 3589 |
% \multicolumn{4}{c}{ 1 liter = \SI{1}{\cubic\deci\meter} } \\ \midrule |
| 3590 |
% 1 gallon &= \SI{4.54609}{liter} (exact) & 1 U.S.\ gallon &= 231\,Inch$^3$ $=$ |
| 3591 |
% $231\times \num{0,016387064}$ liter \\ |
| 3592 |
% 1 gallon &= 4 Quart & 1 U.S.\ gallon &= 4 Quart\US\\ |
| 3593 |
% 1 gallon &= 8 Pint & 1 U.S.\ gallon &= 8 Pint\US\\ |
| 3594 |
% 1 gallon &= 32 Gill & 1 U.S.\ gallon &= 32 Gill\US\\ |
| 3595 |
% 1 gallon &= 160\,fl.\,oz & 1 U.S.\ gallon &= 128\,fl.\,oz\US \\\midrule |
| 3596 |
% 1 \,fl.\,oz&= \num{0.0284130625} liter & 1\,fl.\,oz\US & = \num{0.0295735295625} liter |
| 3597 |
% \\ \bottomrule |
| 3598 |
%\end{tabular}\\ \footnotesize\raggedright |
| 3599 |
%\begin{cuenumnote} |
| 3600 |
% \item I think the American fl.\,oz\US\ is more common. Maybe. Most bottles |
| 3601 |
% have something like 10\,fl.\,oz, which they say is equal to \SI{30}{\ml}. This would |
| 3602 |
% work really well with fl.\,oz\US. |
| 3603 |
% \item Sometimes \enquote{fl.\,oz} is written without the dot. I am also not sure what |
| 3604 |
% kind of spacing has to be between \enquote{fl.} and \enquote{oz} (currently |
| 3605 |
% using \cs{thinspace}). |
| 3606 |
% \item This maybe sounds stupid, but could we introduce something like |
| 3607 |
% \enquote{flouz}, \enquote{floiz} and \enquote{floez}? \enquote{flouz} would be |
| 3608 |
% \enquote{fl.\,oz\US}, \enquote{floiz} would be \enquote{Imperial fl.\,oz} and |
| 3609 |
% \enquote{floez} would simply be equal to \SI{30}{\ml}? |
| 3610 |
%\end{cuenumnote} |
| 3611 |
%\end{center} |
| 3612 |
% |
| 3613 |
% |
| 3614 |
% For \enquote{stick} see \cite{StickSource}. |
| 3615 |
%\begin{center} |
| 3616 |
%\begin{tabular} { l @{ } l } |
| 3617 |
% \toprule |
| 3618 |
% 1\,lb &= \SI{0.453 592 37}{\kg} (exact) \\ |
| 3619 |
% 1\,lb &= 16\,oz \\ |
| 3620 |
% 1\,lb &= \sfrac{1}{14}\,st \\ |
| 3621 |
% 1\,lb &= \sfrac{175}{12}\,ounce~troy \\ |
| 3622 |
% 1\,lb &= 4 stick \\ |
| 3623 |
% \bottomrule |
| 3624 |
%\end{tabular} |
| 3625 |
%\end{center} |
| 3626 |
% |
| 3627 |
% |
| 3628 |
% |
| 3629 |
%\begin{center} |
| 3630 |
%\begin{tabular} { r @{ } l @{ }l r @{ } l } |
| 3631 |
% \toprule |
| 3632 |
% 1 cup &$\approx$ \num{0.25} litre &= \SI{250}{\ml} &1 cup\US &= 8\, fl.\,oz\US \\ |
| 3633 |
% 1 tablespoon &$\approx$ \num{0.015} litre&= \SI{15}{\ml} & 1 tablespoon\US &= \sfrac{1}{2}\, fl.\,oz\US \\ |
| 3634 |
% 1 teaspoon &$\approx$ \num{0.005} litre &= \SI{5}{\ml} & 1 teaspoon\US&= \sfrac{1}{6}\, fl.\,oz\US \\ |
| 3635 |
% \bottomrule |
| 3636 |
%\end{tabular} \footnotesize \\ \raggedright |
| 3637 |
%\begin{cuenumnote} |
| 3638 |
% \item I tested the approximation for tablespoon with water |
| 3639 |
% ($\SI{1}{\mg} \approx \SI{1}{\mg}$) and the approximation looks good enough. |
| 3640 |
% It of course depends on how full you fill your spoon. |
| 3641 |
%\end{cuenumnote} |
| 3642 |
%\end{center} |
| 3643 |
% |
| 3644 |
% |
| 3645 |
% If you ever encounter in a german cookery book the word \enquote{Packerl}, |
| 3646 |
% check out its entry in \cref{sec:unit-almanac}. |
| 3647 |
% |
| 3648 |
% |
| 3649 |
% |
| 3650 |
% |
| 3651 |
% |
| 3652 |
% |
| 3653 |
% |
| 3654 |
% |
| 3655 |
% |
| 3656 |
% |
| 3657 |
% |
| 3658 |
% |
| 3659 |
% |
| 3660 |
% |
| 3661 |
% |
| 3662 |
% |
| 3663 |
% |
| 3664 |
% |
| 3665 |
% |
| 3666 |
% |
| 3667 |
% |
| 3668 |
% |
| 3669 |
% |
| 3670 |
% |
| 3671 |
% |
| 3672 |
% |
| 3673 |
% |
| 3674 |
% |
| 3675 |
%\end{documentation} |
| 3676 |
% |
| 3677 |
% |
| 3678 |
% |
| 3679 |
% |
| 3680 |
% |
| 3681 |
% |
| 3682 |
% |
| 3683 |
% |
| 3684 |
% |
| 3685 |
% |
| 3686 |
% \begin{implementation} |
| 3687 |
% |
| 3688 |
% \section{Implementation} |
| 3689 |
% |
| 3690 |
% \subsection{Beginning} |
| 3691 |
% |
| 3692 |
% \begin{macrocode} |
| 3693 |
%<@@=cookingunits> |
| 3694 |
% \end{macrocode} |
| 3695 |
% |
| 3696 |
% \begin{macrocode} |
| 3697 |
%<*package> |
| 3698 |
% \end{macrocode} |
| 3699 |
% |
| 3700 |
% |
| 3701 |
% |
| 3702 |
% Na dann, auf gehts! |
| 3703 |
% |
| 3704 |
% \begin{macrocode} |
| 3705 |
\@ifpackageloaded {xparse} |
| 3706 |
{ } |
| 3707 |
{ \RequirePackage {xparse} } |
| 3708 |
\@ifpackageloaded {expl3} |
| 3709 |
{ } |
| 3710 |
{ \RequirePackage {expl3} } |
| 3711 |
% \end{macrocode} |
| 3712 |
% |
| 3713 |
%: Package |
| 3714 |
% \begin{macrocode} |
| 3715 |
\ProvidesExplPackage |
| 3716 |
{cooking-units} |
| 3717 |
{2022/12/10} |
| 3718 |
{3.00} |
| 3719 |
{Ein Paket fuer Kocheinheiten} |
| 3720 |
% \end{macrocode} |
| 3721 |
% |
| 3722 |
% Checking if \pkg{expl3} is up-to-date, otherwise abort the loading of the package. |
| 3723 |
% \begin{macrocode} |
| 3724 |
\@ifpackagelater { expl3 } { 2022-09-28 } |
| 3725 |
{ } |
| 3726 |
{ |
| 3727 |
\PackageError { cooking-units } { Support~package~expl3~too~old } |
| 3728 |
{ |
| 3729 |
You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~ |
| 3730 |
'l3packages'.\MessageBreak |
| 3731 |
Loading~cooking-units~will~abort! |
| 3732 |
} |
| 3733 |
\tex_endinput:D |
| 3734 |
} |
| 3735 |
% \end{macrocode} |
| 3736 |
% Loading some needed packages. |
| 3737 |
% \begin{macrocode} |
| 3738 |
\@ifpackageloaded { translations } { } { \RequirePackage { translations } } |
| 3739 |
\@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } } |
| 3740 |
\@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } } |
| 3741 |
% \end{macrocode} |
| 3742 |
% |
| 3743 |
% Checking if \pkg{translations} is up-to-date, otherwise abort the loading of the package. |
| 3744 |
% \begin{macrocode} |
| 3745 |
\@ifpackagelater { translations } { 2022/02/05 } |
| 3746 |
{ } |
| 3747 |
{ |
| 3748 |
\PackageError { cooking-units } { Support~package~translations~too~old } |
| 3749 |
{ |
| 3750 |
You~need~to~update~your~installation~of~the~package~'translations'.\MessageBreak |
| 3751 |
Loading~cooking-units~will~abort! |
| 3752 |
} |
| 3753 |
\tex_endinput:D |
| 3754 |
} |
| 3755 |
% \end{macrocode} |
| 3756 |
% |
| 3757 |
% \begin{macrocode} |
| 3758 |
\msg_new:nnnn { cooking-units } { Option-deprecated } |
| 3759 |
{ |
| 3760 |
The \ option \ '#1' \ is \ deprecated \ and \ should \ be \ |
| 3761 |
replaced \ by \ '#2'. |
| 3762 |
}{ |
| 3763 |
Please \ replace \ the \ option. |
| 3764 |
\msg_see_documentation_text:n { cooking-units } |
| 3765 |
} |
| 3766 |
\msg_new:nnnn { cooking-units } { key-unknown } |
| 3767 |
{ The~key~'#1'~is~unknown~and~is~being~ignored. } |
| 3768 |
{ |
| 3769 |
The~module~'#2'~does~not~have~a~key~called~'#1'.\\ |
| 3770 |
Check~that~you~have~spelled~the~key~name~correctly. |
| 3771 |
} |
| 3772 |
% \end{macrocode} |
| 3773 |
% \begin{macrocode} |
| 3774 |
\bool_new:N \g_@@_opt_numeral_bool |
| 3775 |
%\bool_new:N \g_@@_opt_debug_bool |
| 3776 |
\keys_define:nn { cooking-units } |
| 3777 |
{ |
| 3778 |
use-numerals .code:n = |
| 3779 |
{ |
| 3780 |
\msg_warning:nnnn { cooking-units } { Option-deprecated } { use-numerals } { use-fmtcount-numerals } |
| 3781 |
\keys_set:nn { cooking-units } { use-fmtcount-numerals = #1 } |
| 3782 |
} , |
| 3783 |
use-numerals .default:n = { false }, |
| 3784 |
use-fmtcount-numerals .bool_gset:N = \g_@@_opt_numeral_bool , |
| 3785 |
use-fmtcount-numerals .default:n = { false }, |
| 3786 |
% debug .bool_set:N = \g_@@_opt_debug_bool , |
| 3787 |
% debug .default:n = { true } , |
| 3788 |
unknown .code:n = { \msg_error:nnxx { cooking-units } { key-unknown } |
| 3789 |
{ \l_keys_path_str } { cooking-units } |
| 3790 |
} |
| 3791 |
} |
| 3792 |
% \end{macrocode} |
| 3793 |
% Now process the package options \dots |
| 3794 |
% \begin{macrocode} |
| 3795 |
\ProcessKeysOptions { cooking-units } |
| 3796 |
\bool_if:NT \g_@@_opt_numeral_bool |
| 3797 |
{ |
| 3798 |
\@ifpackageloaded { fmtcount } { } { \RequirePackage { fmtcount } } |
| 3799 |
} |
| 3800 |
% \end{macrocode} |
| 3801 |
% \dots\ and redefine the package option such that it cannot be used elsewhere. |
| 3802 |
% \begin{macrocode} |
| 3803 |
\keys_define:nn { cooking-units } |
| 3804 |
{ |
| 3805 |
use-numerals .code:n = |
| 3806 |
{ |
| 3807 |
\msg_warning:nnnn { cooking-units } { Option-deprecated } { use-numerals } { use-fmtcount-numerals } |
| 3808 |
\msg_error:nnn { cooking-units } { load-time-option } { use-fmtcount-numerals } |
| 3809 |
} , |
| 3810 |
use-fmtcount-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { use-fmtcount-numerals } } , |
| 3811 |
} |
| 3812 |
% \end{macrocode} |
| 3813 |
% |
| 3814 |
% |
| 3815 |
% |
| 3816 |
% \subsection {Defining Variables} |
| 3817 |
% |
| 3818 |
% \begin{macro} { cs variants } |
| 3819 |
% Some variations of commands we will need later. |
| 3820 |
% \begin{macrocode} |
| 3821 |
\cs_generate_variant:Nn \msg_redirect_name:nnn { nnV } |
| 3822 |
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn } |
| 3823 |
\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn } |
| 3824 |
\cs_generate_variant:Nn \tl_if_in:nnTF { nV } |
| 3825 |
\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF } |
| 3826 |
\cs_generate_variant:Nn \tl_if_in:NnT { NVT } |
| 3827 |
\cs_generate_variant:Nn \fp_compare:nNnT { vNnT } |
| 3828 |
\cs_generate_variant:Nn \prop_get:NnN { cVc, Nnc } |
| 3829 |
\cs_generate_variant:Nn \prop_get:NnNF { Nnc } |
| 3830 |
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } |
| 3831 |
\cs_generate_variant:Nn \msg_error:nnnn { nnnV } |
| 3832 |
\cs_generate_variant:Nn \msg_error:nnn { nnV } |
| 3833 |
\cs_generate_variant:Nn \msg_warning:nnn { nnV } |
| 3834 |
\cs_generate_variant:Nn \prop_put:Nnn { cnx } |
| 3835 |
\cs_generate_variant:Nn \seq_remove_all:Nn { NV } |
| 3836 |
\cs_generate_variant:Nn \prop_gput:Nnn { Nnv, Nxv } |
| 3837 |
\cs_generate_variant:Nn \prop_get:NnN { cnc } |
| 3838 |
\cs_generate_variant:Nn \prg_new_conditional:Npnn { c } |
| 3839 |
\cs_generate_variant:Nn \text_uppercase:n { x } |
| 3840 |
% \end{macrocode} |
| 3841 |
% \end{macro} |
| 3842 |
% |
| 3843 |
% |
| 3844 |
% |
| 3845 |
% \begin{macro}{\@@_frac:nn} |
| 3846 |
% This command is used to print fractions and can be changed |
| 3847 |
% accordingly. |
| 3848 |
% \begin{macrocode} |
| 3849 |
\cs_new_eq:NN \@@_frac:nn \sfrac |
| 3850 |
% \end{macrocode} |
| 3851 |
% \end{macro} |
| 3852 |
% |
| 3853 |
% \begin{macro}{\l_@@_unit_argument_spec_tl , \l_@@_unit_argument_spec_tl } |
| 3854 |
% Allows for potential parsing of amount and or unit. |
| 3855 |
% \begin{macrocode} |
| 3856 |
\tl_new:N \l_@@_unit_argument_spec_tl |
| 3857 |
\tl_new:N \l_@@_expand_amount_tl |
| 3858 |
\tl_set:Nn \l_@@_unit_argument_spec_tl { n } |
| 3859 |
\tl_set:Nn \l_@@_expand_amount_tl { n } |
| 3860 |
% \end{macrocode} |
| 3861 |
% \end{macro} |
| 3862 |
% \begin{macro}{\@@_set_amount:Nn , \@@_set_unit:Nn , \@@_to_unit:n } |
| 3863 |
% Definitions to set the amount and the unit. Made so that it can be changed globally. |
| 3864 |
% By default, the amount is just taken as is while the unit is changed into a string. |
| 3865 |
% \begin{macrocode} |
| 3866 |
\cs_new_eq:NN \@@_set_amount:Nn \tl_set:Nn |
| 3867 |
\cs_new_eq:NN \@@_set_unit:Nn \str_set:Nn |
| 3868 |
\cs_new_eq:NN \@@_to_unit:n \tl_to_str:n |
| 3869 |
% \end{macrocode} |
| 3870 |
% \end{macro} |
| 3871 |
% |
| 3872 |
% |
| 3873 |
% \begin{macro}{\@@_print_numeral:n , \@@_print_Numeral:n} |
| 3874 |
% Commands to print numerals. Either use default or set yourself. |
| 3875 |
% \begin{macrocode} |
| 3876 |
\cs_new:Npn \@@_print_numeral:n #1 |
| 3877 |
{ \msg_error:nn {cooking-units} { define-numeral-function } #1 } |
| 3878 |
\cs_new:Npn \@@_print_Numeral:n #1 |
| 3879 |
{ \msg_error:nn {cooking-units} { define-Numeral-function } #1 } |
| 3880 |
\bool_if:NT \g_@@_opt_numeral_bool |
| 3881 |
{ |
| 3882 |
\cs_set_eq:NN \@@_print_numeral:n \numberstringnum |
| 3883 |
\cs_set_eq:NN \@@_print_Numeral:n \Numberstringnum |
| 3884 |
} |
| 3885 |
\cs_generate_variant:Nn \@@_print_numeral:n { V } |
| 3886 |
\cs_generate_variant:Nn \@@_print_Numeral:n { V } |
| 3887 |
% \end{macrocode} |
| 3888 |
% \end{macro} |
| 3889 |
% |
| 3890 |
% |
| 3891 |
% \begin{macro}{ \l_@@_change_unit_prop } |
| 3892 |
% Conversions of units are stored within this property list. |
| 3893 |
% If someone requests that \myunit{kg} should be changed into \myunit{g}, |
| 3894 |
% \myunit{kg} is stored as a key with the value \myunit{g}. If someone |
| 3895 |
% then uses the unit \myunit{kg} the value \myunit{g} is restored and the unit |
| 3896 |
% is changed accordingly. |
| 3897 |
% \begin{macrocode} |
| 3898 |
\prop_new:N \l_@@_change_unit_prop |
| 3899 |
% \end{macrocode} |
| 3900 |
% \end{macro} |
| 3901 |
% |
| 3902 |
% |
| 3903 |
% |
| 3904 |
% \begin{macro} { \g_@@_master_changer_prop } |
| 3905 |
% Similar to |\l_@@_change_unit_prop|, but doesn't store the requested |
| 3906 |
% unit change, but the values needed for conversion. Either a numerical |
| 3907 |
% value is stored or a formula (using |#1| to insert the original value). |
| 3908 |
% |
| 3909 |
% Put and get values via \cs{\@@_prop_gput_master:nnn} |
| 3910 |
% and \cs{@@_prop_get_master:nnNTF}. |
| 3911 |
% \begin{macrocode} |
| 3912 |
\prop_new:N \g_@@_master_changer_prop |
| 3913 |
% \end{macrocode} |
| 3914 |
% \end{macro} |
| 3915 |
% |
| 3916 |
% \begin{macro} { \g_@@_convert_bonkers_remember_prop , \g_@@_convert_to_eV_remember_prop } |
| 3917 |
% If the unit is changed in a \enquote{not normal} way, store |
| 3918 |
% some things in one of the two lists. They are just used as shortcuts |
| 3919 |
% to remember which unit is changed into which. They are one level above |
| 3920 |
% |\g_@@_master_changer_prop|. |
| 3921 |
% \begin{macrocode} |
| 3922 |
\prop_new:N \g_@@_convert_to_eV_remember_prop |
| 3923 |
\prop_new:N \g_@@_convert_bonkers_remember_prop |
| 3924 |
% \end{macrocode} |
| 3925 |
% \end{macro} |
| 3926 |
% |
| 3927 |
% \begin{macro} |
| 3928 |
% { |
| 3929 |
% , \l_@@_number_tmpa_tl |
| 3930 |
% , \l_@@_number_tmpb_tl |
| 3931 |
% , \l_@@_mixed_fraction_tl |
| 3932 |
% , \l_@@_original_amount_tl |
| 3933 |
% , \l_@@_original_unit_tl |
| 3934 |
% , \l_@@_option_unit_tl |
| 3935 |
% , \l_@@_language_tl |
| 3936 |
% , \l_@@_cunum_range_sign_tl |
| 3937 |
% , \l_@@_cutext_range_sign_tl |
| 3938 |
% , \l_@@_value_unit_space_tl |
| 3939 |
% , \l_@@_input_digits_tl |
| 3940 |
% , \l_@@_input_decimal_mark_tl |
| 3941 |
% , \l_@@_input_value_signs_tl |
| 3942 |
% , \l_@@_input_allowed_special_signs_tl |
| 3943 |
% , \g_@@_input_str_hash_one_tl |
| 3944 |
% , \l_@@_input_range_sign_tl |
| 3945 |
% , \l_@@_input_times_sign_tl |
| 3946 |
% , \l_@@_cutext_space_tl |
| 3947 |
% , \l_@@_cutext_numeral_space_tl |
| 3948 |
% , \l_@@_cuphrase_space_tl |
| 3949 |
% , \l_@@_translation_tmpa_tl |
| 3950 |
% , \l_@@_cutext_last_value_tl |
| 3951 |
% , \l_@@_phantom_tl |
| 3952 |
% , \l_@@_phrase_text_tl |
| 3953 |
% , \l_@@_unit_letter_not_allowed_tl |
| 3954 |
% , \l_@@_input_fraction_sign_tl |
| 3955 |
% , \l_@@_input_mixed_fraction_sign_tl |
| 3956 |
% , \l_@@_list_of_units_tl |
| 3957 |
% , \l_@@_list_of_values_tl |
| 3958 |
% , \l_@@_allwed_integer_math_operators_tl |
| 3959 |
% , \l_@@_curr_group_tl |
| 3960 |
% , \l_@@_curr_unit_tl |
| 3961 |
% , \l_@@_cmd_hook_tl |
| 3962 |
% , \l_@@_cunum_hook_tl |
| 3963 |
% , \l_@@_cutext_hook_tl |
| 3964 |
% , \l_@@_Cutext_hook_tl |
| 3965 |
% , \l_@@_cuam_hook_tl |
| 3966 |
% , \l_@@_new_key_base_tl |
| 3967 |
% , \l_@@_decided_unit_tl |
| 3968 |
% , \l_@@_stored_units_tl |
| 3969 |
% , \l_@@_stored_formula_tl |
| 3970 |
% , \l_@@_base_tl |
| 3971 |
% } |
| 3972 |
% Quite a lot of tl's. |
| 3973 |
% \begin{macrocode} |
| 3974 |
\tl_new:N \l_@@_number_tmpa_tl |
| 3975 |
\tl_new:N \l_@@_number_tmpb_tl |
| 3976 |
\tl_new:N \l_@@_mixed_fraction_tl |
| 3977 |
\tl_new:N \l_@@_original_amount_tl |
| 3978 |
\tl_new:N \l_@@_original_unit_tl |
| 3979 |
\tl_new:N \l_@@_option_unit_tl |
| 3980 |
\tl_new:N \l_@@_language_tl |
| 3981 |
\tl_new:N \l_@@_cunum_range_sign_tl |
| 3982 |
\tl_new:N \l_@@_cutext_range_sign_tl |
| 3983 |
\tl_new:N \l_@@_value_unit_space_tl |
| 3984 |
\tl_new:N \l_@@_input_digits_tl |
| 3985 |
\tl_new:N \l_@@_input_decimal_mark_tl |
| 3986 |
\tl_new:N \l_@@_input_value_signs_tl |
| 3987 |
\tl_new:N \l_@@_input_allowed_special_signs_tl |
| 3988 |
\tl_new:N \g_@@_input_str_hash_one_tl |
| 3989 |
\tl_new:N \l_@@_input_range_sign_tl |
| 3990 |
\tl_new:N \l_@@_input_times_sign_tl |
| 3991 |
\tl_new:N \l_@@_cutext_space_tl |
| 3992 |
\tl_new:N \l_@@_cutext_numeral_space_tl |
| 3993 |
\tl_new:N \l_@@_cuphrase_space_tl |
| 3994 |
\tl_new:N \l_@@_translation_tmpa_tl |
| 3995 |
\tl_new:N \l_@@_cutext_last_value_tl |
| 3996 |
\tl_new:N \l_@@_phantom_tl |
| 3997 |
\tl_new:N \l_@@_phrase_text_tl |
| 3998 |
\tl_new:N \l_@@_unit_letter_not_allowed_tl |
| 3999 |
\tl_new:N \l_@@_input_fraction_sign_tl |
| 4000 |
\tl_new:N \l_@@_input_mixed_fraction_sign_tl |
| 4001 |
\tl_new:N \l_@@_list_of_units_tl |
| 4002 |
\tl_new:N \l_@@_list_of_values_tl |
| 4003 |
\tl_new:N \l_@@_allwed_integer_math_operators_tl |
| 4004 |
\tl_new:N \l_@@_curr_group_tl |
| 4005 |
\tl_new:N \l_@@_curr_unit_tl |
| 4006 |
\tl_new:N \l_@@_new_key_base_tl |
| 4007 |
\tl_new:N \l_@@_decided_unit_tl |
| 4008 |
\tl_new:N \l_@@_stored_units_tl |
| 4009 |
\tl_new:N \l_@@_stored_formula_tl |
| 4010 |
\tl_new:N \l_@@_base_tl |
| 4011 |
\tl_new:N \l_@@_times_space_tl |
| 4012 |
\tl_new:N \l_@@_times_sign_tl |
| 4013 |
% \end{macrocode} |
| 4014 |
% \begin{macrocode} |
| 4015 |
\tl_new:N \l_@@_cmd_hook_tl |
| 4016 |
\tl_new:N \l_@@_cunum_hook_tl |
| 4017 |
\tl_new:N \l_@@_cutext_hook_tl |
| 4018 |
\tl_new:N \l_@@_Cutext_hook_tl |
| 4019 |
\tl_new:N \l_@@_cuam_hook_tl |
| 4020 |
% \end{macrocode} |
| 4021 |
% \end{macro} |
| 4022 |
% |
| 4023 |
% |
| 4024 |
% Setting some token lists to their default value. |
| 4025 |
% \cs{c_@@_input_str_hash_one_tl} is used for defining single keys. |
| 4026 |
% (As you will see, I didn't have a better idea) |
| 4027 |
% \begin{macrocode} |
| 4028 |
\tl_set:Nn \l_@@_input_digits_tl { 0123456789 } |
| 4029 |
\tl_set:Nn \l_@@_input_range_sign_tl { -- } |
| 4030 |
\tl_set:Nn \l_@@_input_times_sign_tl { \times x X } |
| 4031 |
\tl_set:Nn \l_@@_input_fraction_sign_tl { / } |
| 4032 |
\tl_set:Nn \l_@@_input_mixed_fraction_sign_tl { _ } |
| 4033 |
\tl_set:Nn \l_@@_input_decimal_mark_tl { . , } |
| 4034 |
\tl_set:Nn \l_@@_input_value_signs_tl { + - } |
| 4035 |
\tl_set:Nn \l_@@_input_allowed_special_signs_tl { ? } |
| 4036 |
\tl_gset_rescan:Nnn \g_@@_input_str_hash_one_tl |
| 4037 |
{ \char_set_catcode_letter:N \# } {#1} |
| 4038 |
\tl_set:Nn \l_@@_allwed_integer_math_operators_tl { +-()*/ } |
| 4039 |
\tl_set:Nn \l_@@_times_sign_tl { \ensuremath { \times } } |
| 4040 |
% \end{macrocode} |
| 4041 |
% \begin{macrocode} |
| 4042 |
\tl_set:Nn \l_@@_cunum_range_sign_tl { -- } |
| 4043 |
\tl_set:Nn \l_@@_cutext_range_sign_tl { } |
| 4044 |
\tl_set:Nn \l_@@_value_unit_space_tl { \thinspace } |
| 4045 |
\tl_set:Nn \l_@@_times_space_tl { \, } % \: |
| 4046 |
\tl_set:Nn \l_@@_cutext_space_tl { ~ } |
| 4047 |
\tl_set:Nn \l_@@_cutext_numeral_space_tl { \space } |
| 4048 |
\tl_set:Nn \l_@@_cuphrase_space_tl { \space } |
| 4049 |
\tl_set:Nn \l_@@_unit_letter_not_allowed_tl { , / } |
| 4050 |
% \end{macrocode} |
| 4051 |
% |
| 4052 |
% \begin{macro}{\c_@@_minus_tl} |
| 4053 |
% Flat out stolen from \pkg{siunitx}. |
| 4054 |
% \begin{macrocode} |
| 4055 |
\AtBeginDocument { |
| 4056 |
\cs_if_free:cT { T@TS1 } |
| 4057 |
{ |
| 4058 |
\DeclareFontEncoding { TS1 } { } { } |
| 4059 |
\DeclareFontSubstitution { TS1 } { cmr } { m } { n } |
| 4060 |
} |
| 4061 |
} |
| 4062 |
% \end{macrocode} |
| 4063 |
% \begin{macrocode} |
| 4064 |
\DeclareTextSymbolDefault \c_@@_minus_tl { TS1 } |
| 4065 |
\DeclareTextSymbol \c_@@_minus_tl { TS1 } { 61 } |
| 4066 |
\AtBeginDocument { |
| 4067 |
\@ifpackageloaded { fontspec } |
| 4068 |
{ |
| 4069 |
\@ifpackageloaded { eulervm } |
| 4070 |
{ } |
| 4071 |
{ |
| 4072 |
\int_const:Nn \c_@@_minus_int { 8722 } |
| 4073 |
\tl_set:Nn \c_@@_minus_tl |
| 4074 |
{ \tex_char:D \c_@@_minus_int } |
| 4075 |
} |
| 4076 |
} |
| 4077 |
{ } |
| 4078 |
} |
| 4079 |
% \end{macrocode} |
| 4080 |
% \end{macro} |
| 4081 |
% |
| 4082 |
% \begin{macro}{ \l_@@_mixed_frac_dim } |
| 4083 |
% The dimension between the fraction and the mixed fraction part is |
| 4084 |
% stored within this macro. There is no real reason why I have |
| 4085 |
% chosen this distance to be 0.1em, I just thought that it looks |
| 4086 |
% best. But if someone has some ideas of how large this distancee |
| 4087 |
% should be I am happy to listen. |
| 4088 |
% \begin{macrocode} |
| 4089 |
\dim_new:N \l_@@_mixed_frac_dim |
| 4090 |
\dim_set:Nn \l_@@_mixed_frac_dim { 0.1 em } |
| 4091 |
% \end{macrocode} |
| 4092 |
% \end{macro} |
| 4093 |
% |
| 4094 |
% |
| 4095 |
% \begin{macro}{ \l_@@_round_precision_int } |
| 4096 |
% Stores the round-precision inside. Can also take negative values. |
| 4097 |
% \begin{macrocode} |
| 4098 |
\int_new:N \l_@@_round_precision_int |
| 4099 |
\int_set:Nn \l_@@_round_precision_int { 2 } |
| 4100 |
% \end{macrocode} |
| 4101 |
% \end{macro} |
| 4102 |
% |
| 4103 |
% \begin{macro}{ \l_@@_print_numerals_below_int } |
| 4104 |
% Used if option \opt{use-numerals} is active. Uses numerals for |
| 4105 |
% integers smaller than this number. I learned this number |
| 4106 |
% at school. |
| 4107 |
% \begin{macrocode} |
| 4108 |
\int_new:N \l_@@_print_numerals_below_int |
| 4109 |
\int_set:Nn \l_@@_print_numerals_below_int { 13 } |
| 4110 |
% \end{macrocode} |
| 4111 |
% \end{macro} |
| 4112 |
% |
| 4113 |
% |
| 4114 |
% \begin{macro}{ \l_@@_local_number_of_persons_int } |
| 4115 |
% Each recipe defined by \cs{culabel} defines a counter to |
| 4116 |
% store the number of persons the recipe is for. For calculation |
| 4117 |
% the value is retrieved and stored inside this temporal integer variable. |
| 4118 |
% \begin{macrocode} |
| 4119 |
\int_new:N \l_@@_local_number_of_persons_int |
| 4120 |
% \end{macrocode} |
| 4121 |
% \end{macro} |
| 4122 |
% |
| 4123 |
% \begin{macro}{ \l_@@_wanted_number_of_persons_int } |
| 4124 |
% Not only the number of persons are recipe is for is needed |
| 4125 |
% for calculation, but also the number of persons you want |
| 4126 |
% the recipe to be. This information is stored here. |
| 4127 |
% \begin{macrocode} |
| 4128 |
\int_new:N \l_@@_wanted_number_of_persons_int |
| 4129 |
\int_set:Nn \l_@@_wanted_number_of_persons_int { 4 } |
| 4130 |
% \end{macrocode} |
| 4131 |
% \end{macro} |
| 4132 |
% |
| 4133 |
% |
| 4134 |
% \begin{macro}{ \l_@@_phrase_number_tl , \l_@@_phrase_gender_tl } |
| 4135 |
% Stores the current \enquote{phrase number} (and gender). |
| 4136 |
% For \enquote{Dutzend} this would |
| 4137 |
% be \enquote{12}, etc. The second stores the gender (m, f or n) |
| 4138 |
% \begin{macrocode} |
| 4139 |
\int_new:N \l_@@_phrase_number_tl |
| 4140 |
\int_new:N \l_@@_phrase_gender_tl |
| 4141 |
% \end{macrocode} |
| 4142 |
% \end{macro} |
| 4143 |
% |
| 4144 |
% \begin{macro}{ \l_@@_list_of_defined_keys_clist , \g_@@_list_of_defined_units_clist } |
| 4145 |
% Sequence of defined units and keys. Units are defined |
| 4146 |
% globally as they create new commands, keys do not do that |
| 4147 |
% (I think). Could be my mistake. |
| 4148 |
% \begin{macrocode} |
| 4149 |
\seq_new:N \l_@@_list_of_defined_keys_seq |
| 4150 |
\seq_new:N \g_@@_list_of_defined_units_seq |
| 4151 |
% \end{macrocode} |
| 4152 |
%\end{macro} |
| 4153 |
% |
| 4154 |
% |
| 4155 |
% \begin{macro} { \g_@@_allowed_special_keys_seq } |
| 4156 |
% \changes {2016/06/12} {New: \cs{g_@@_allowed_unit_phrases_tl}} |
| 4157 |
% Used for the keys 'one(m)', 'one(f)', etc. Those are special keys |
| 4158 |
% which cannot be used as units, but are processed by the commands in |
| 4159 |
% the language section as such. |
| 4160 |
% \begin{macrocode} |
| 4161 |
\seq_new:N \g_@@_allowed_special_keys_seq |
| 4162 |
% \end{macrocode} |
| 4163 |
% \end{macro} |
| 4164 |
% |
| 4165 |
% \begin{macro} { \l_@@_phrase_numbers_seq } |
| 4166 |
% Inside this list the numbers for which a phrase is defined |
| 4167 |
% is stored in. As this is language specific, the list is stored |
| 4168 |
% inside a language-sensitive command and retrieved when needed. |
| 4169 |
% \begin{macrocode} |
| 4170 |
\seq_new:N \l_@@_phrase_numbers_seq |
| 4171 |
% \end{macrocode} |
| 4172 |
% \end{macro} |
| 4173 |
% |
| 4174 |
% |
| 4175 |
% \begin{macro}{ |
| 4176 |
% , \g_@@_stored_derived_unit_symbol_seq |
| 4177 |
% , \g_@@_stored_derived_formula_seq |
| 4178 |
% , \g_@@_stored_derived_unit_print_seq |
| 4179 |
% } |
| 4180 |
% Variables used in \mycs{declarecookingderivatives}. |
| 4181 |
% \begin{macrocode} |
| 4182 |
\seq_new:N \g_@@_stored_derived_unit_symbol_seq |
| 4183 |
\seq_new:N \g_@@_stored_derived_formula_seq |
| 4184 |
\seq_new:N \g_@@_stored_derived_unit_print_seq |
| 4185 |
% \end{macrocode} |
| 4186 |
% \end{macro} |
| 4187 |
% |
| 4188 |
% |
| 4189 |
% \begin{macro}{\l_@@_nr_of_units_int, \l_@@_depth_int} |
| 4190 |
% Also some variables used in \mycs{declarecookingderivatives}. (And for one check during |
| 4191 |
% definitions of keys). |
| 4192 |
% \begin{macrocode} |
| 4193 |
\int_new:N \l_@@_nr_of_units_int |
| 4194 |
\int_new:N \l_@@_depth_int |
| 4195 |
% \end{macrocode} |
| 4196 |
% \end{macro} |
| 4197 |
% |
| 4198 |
% \begin{macro}{\g_@@_natural_units_seq } |
| 4199 |
% Remembers which unit foes to which natural unit. |
| 4200 |
% \begin{macrocode} |
| 4201 |
\seq_new:N \g_@@_natural_units_seq |
| 4202 |
% \end{macrocode} |
| 4203 |
% \end{macro} |
| 4204 |
% |
| 4205 |
% \begin{macro} { \l_@@_temperatures_to_check_seq } |
| 4206 |
% \changes {1.02h} {New.} |
| 4207 |
% Stores units which should be tested if \opt{check-temperature} equals true. |
| 4208 |
% \begin{macrocode} |
| 4209 |
\seq_new:N \l_@@_temperatures_to_check_seq |
| 4210 |
% \end{macrocode} |
| 4211 |
% \end{macro} |
| 4212 |
% |
| 4213 |
% \begin{macro} { \l_@@_curef_do_not_change_seq } |
| 4214 |
% This contains the units which shouldn't be changed. |
| 4215 |
% \begin{macrocode} |
| 4216 |
\seq_new:N \l_@@_curef_do_not_change_seq |
| 4217 |
% \end{macrocode} |
| 4218 |
% \end{macro} |
| 4219 |
% |
| 4220 |
% \begin{macro} { \l_@@_phrase_prop } |
| 4221 |
% Stores the number and he respective phrase. For example |
| 4222 |
% if \enquote{12} has the phrase \enquote{Dutzend}, this |
| 4223 |
% key-value pair is stored inside. |
| 4224 |
% \begin{macrocode} |
| 4225 |
\prop_new:N \l_@@_phrase_prop |
| 4226 |
% \end{macrocode} |
| 4227 |
% \end{macro} |
| 4228 |
% |
| 4229 |
% \begin{macro} { \l_@@_derived_units_prop } |
| 4230 |
% Stores \emph{via} key-value all defined derived units as keys |
| 4231 |
% and the formula to calculate the derived unit as value.. |
| 4232 |
% \begin{macrocode} |
| 4233 |
\prop_new:N \l_@@_derived_units_prop |
| 4234 |
% \end{macrocode} |
| 4235 |
% \end{macro} |
| 4236 |
% |
| 4237 |
% |
| 4238 |
% |
| 4239 |
% \begin{macro} |
| 4240 |
% { |
| 4241 |
% , \l_@@_pckopt_eval_fractions_bool |
| 4242 |
% , \l_@@_pckopt_convert_fractions_bool |
| 4243 |
% , \l_@@_pckopt_draft_bool |
| 4244 |
% , \l_@@_pckopt_round_to_int_bool |
| 4245 |
% , \l_@@_pckopt_check_temperature_bool |
| 4246 |
% , \l_@@_pckopt_convert_to_eV_bool |
| 4247 |
% , \l_@@_pckopt_cuam_old_bool |
| 4248 |
% , \l_@@_pckopt_recalculate_amount_bool |
| 4249 |
% , \l_@@_pckopt_cutext_to_cunum_bool |
| 4250 |
% , \l_@@_pckopt_cutext_old_bool |
| 4251 |
% , \l_@@_pckopt_cutext_keep_unit_bool |
| 4252 |
% , \l_@@_pckopt_round_commercial_bool |
| 4253 |
% , \l_@@_pckopt_use_phrases_bool |
| 4254 |
% , \l_@@_pckopt_round_precision_negative_bool |
| 4255 |
% , \l_@@_pckopt_fourty_two_bool |
| 4256 |
% , \l_@@_pckopt_bonkers_bool |
| 4257 |
% , \l_@@_minus_bool |
| 4258 |
% , \l_@@_round_number_bool |
| 4259 |
% , \l_@@_single_key_bool |
| 4260 |
% , \l_@@_cutext_uppercase_word_bool |
| 4261 |
% , \l_@@_reference_given_bool |
| 4262 |
% , \l_@@_lokal_recalc_for_people_bool |
| 4263 |
% , \l_@@_lokal_phrase_bool |
| 4264 |
% , \l_@@_lokal_change_unit_bool |
| 4265 |
% , \l_@@_pckopt_print_numeral_bool |
| 4266 |
% , \l_@@_lokal_numeral_bool |
| 4267 |
% , \l_@@_phrase_negative_bool |
| 4268 |
% , \l_@@_cutext_use_single_bool |
| 4269 |
% , \l_@@_symbol_was_set_by_key_bool |
| 4270 |
% , \l_@@_contains_valid_key_bool |
| 4271 |
% , \l_@@_check_decimal_bool |
| 4272 |
% , \l_@@_unit_error_bool |
| 4273 |
% } |
| 4274 |
% Some booleans we need later. |
| 4275 |
% \begin{macrocode} |
| 4276 |
\bool_new:N \l_@@_pckopt_eval_fractions_bool |
| 4277 |
\bool_new:N \l_@@_pckopt_convert_fractions_bool |
| 4278 |
\bool_new:N \l_@@_pckopt_draft_bool |
| 4279 |
\bool_new:N \l_@@_pckopt_round_to_int_bool |
| 4280 |
\bool_new:N \l_@@_pckopt_check_temperature_bool |
| 4281 |
\bool_new:N \l_@@_pckopt_convert_to_eV_bool |
| 4282 |
\bool_new:N \l_@@_pckopt_cuam_old_bool |
| 4283 |
\bool_new:N \l_@@_pckopt_recalculate_amount_bool |
| 4284 |
\bool_new:N \l_@@_pckopt_cutext_to_cunum_bool |
| 4285 |
\bool_new:N \l_@@_pckopt_cutext_old_bool |
| 4286 |
\bool_new:N \l_@@_pckopt_cutext_keep_unit_bool |
| 4287 |
\bool_new:N \l_@@_pckopt_round_commercial_bool |
| 4288 |
\bool_new:N \l_@@_pckopt_use_phrases_bool |
| 4289 |
\bool_new:N \l_@@_pckopt_round_precision_negative_bool |
| 4290 |
\bool_new:N \l_@@_pckopt_fourty_two_bool |
| 4291 |
\bool_new:N \l_@@_pckopt_bonkers_bool |
| 4292 |
\bool_new:N \l_@@_minus_bool |
| 4293 |
\bool_new:N \l_@@_round_number_bool |
| 4294 |
\bool_new:N \l_@@_single_key_bool |
| 4295 |
\bool_new:N \l_@@_cutext_uppercase_word_bool |
| 4296 |
\bool_new:N \l_@@_reference_given_bool |
| 4297 |
\bool_new:N \l_@@_lokal_recalc_for_people_bool |
| 4298 |
\bool_new:N \l_@@_lokal_phrase_bool |
| 4299 |
\bool_new:N \l_@@_lokal_change_unit_bool |
| 4300 |
\bool_new:N \l_@@_pckopt_print_numeral_bool |
| 4301 |
\bool_new:N \l_@@_lokal_numeral_bool |
| 4302 |
\bool_new:N \l_@@_phrase_negative_bool |
| 4303 |
\bool_new:N \l_@@_cutext_use_single_bool |
| 4304 |
\bool_new:N \l_@@_symbol_was_set_by_key_bool |
| 4305 |
\bool_new:N \l_@@_contains_valid_key_bool |
| 4306 |
\bool_new:N \l_@@_check_decimal_bool |
| 4307 |
\bool_new:N \l_@@_unit_error_bool |
| 4308 |
\bool_new:N \l_@@_rf_contains_fraction_bool |
| 4309 |
\bool_new:N \l_@@_rf_contains_range_bool |
| 4310 |
\bool_new:N \l_@@_rf_contains_times_bool |
| 4311 |
\bool_new:N \l_@@_rf_check_fraction_bool |
| 4312 |
\bool_new:N \l_@@_lokal_eval_fractions_bool |
| 4313 |
\seq_new:N \l_@@_split_input_seq |
| 4314 |
\seq_new:N \l_@@_parsed_seq |
| 4315 |
\seq_new:N \l_@@_numbers_to_check_seq |
| 4316 |
\int_new:N \l_@@_largest_common_divisor_int |
| 4317 |
\seq_new:N \l_@@_reduced_numbers_seq |
| 4318 |
\bool_new:N \l_@@_seperator_after_fraction_bool |
| 4319 |
\seq_new:N \l_@@_prepared_printing_seq |
| 4320 |
\int_new:N \l_@@_nr_of_items |
| 4321 |
\seq_new:N \l_@@_processed_seq |
| 4322 |
\tl_new:N \l_@@_precompiled_options_tl |
| 4323 |
% \end{macrocode} |
| 4324 |
% \end{macro} |
| 4325 |
% |
| 4326 |
% |
| 4327 |
% |
| 4328 |
% Setting some of them to \true\ or another boolean respectively. |
| 4329 |
% \begin{macrocode} |
| 4330 |
\bool_set_false:N \l_@@_pckopt_cutext_keep_unit_bool |
| 4331 |
\bool_set_eq:NN \l_@@_pckopt_print_numeral_bool \g_@@_opt_numeral_bool |
| 4332 |
% \end{macrocode} |
| 4333 |
% |
| 4334 |
% |
| 4335 |
% \begin{macro}{ \q_@@_range } |
| 4336 |
% Replacing the sign \enquote{-{}-} with \lstinline|\q_@@_range| for testing. |
| 4337 |
% \begin{macrocode} |
| 4338 |
\quark_new:N \q_@@_range |
| 4339 |
% \end{macrocode} |
| 4340 |
%\end{macro} |
| 4341 |
% |
| 4342 |
% \begin{macro}{ \q_@@_no_translation_str } |
| 4343 |
% Checking value if a translation is avaiable. |
| 4344 |
% \begin{macrocode} |
| 4345 |
\quark_new:N \q_@@_no_translation_str |
| 4346 |
\str_const:Nn \c_@@_no_translation_str { no-translation-sady-found-@@ } |
| 4347 |
%\cs_new:Npn \q_@@_no_translation_str { asdasd\ewhkerhjkwejhk } |
| 4348 |
% \end{macrocode} |
| 4349 |
%\end{macro} |
| 4350 |
% |
| 4351 |
% |
| 4352 |
% \begin{macro}{ |
| 4353 |
% , \l_@@_scrap_tl |
| 4354 |
% , \l_@@_tmpa_tl |
| 4355 |
% , \l_@@_tmpb_tl |
| 4356 |
% , \l_@@_tmp_unit_tl |
| 4357 |
% , \l_@@_tmpa_fp |
| 4358 |
% , \l_@@_tmpa_clist |
| 4359 |
% , \l_@@_tmpa_prop |
| 4360 |
% , \l_@@_tmpb_prop |
| 4361 |
% , \l_@@_tmpa_seq |
| 4362 |
% , \l_@@_tmpb_seq |
| 4363 |
% , \l_@@_tmpa_int |
| 4364 |
% , \l_@@_tmpb_int |
| 4365 |
% , \l_@@_tmpa_bool |
| 4366 |
% , \l_@@_tmpb_bool |
| 4367 |
% } |
| 4368 |
% Some temporal stores which are used throughout the code. |
| 4369 |
% \begin{macrocode} |
| 4370 |
\tl_new:N \l_@@_scrap_tl |
| 4371 |
\tl_new:N \l_@@_tmpa_tl |
| 4372 |
\tl_new:N \l_@@_tmpb_tl |
| 4373 |
\tl_new:N \l_@@_tmp_unit_tl |
| 4374 |
\fp_new:N \l_@@_tmpa_fp |
| 4375 |
\clist_new:N \l_@@_tmpa_clist |
| 4376 |
\prop_new:N \l_@@_tmpa_prop |
| 4377 |
\prop_new:N \l_@@_tmpb_prop |
| 4378 |
\seq_new:N \l_@@_tmpa_seq |
| 4379 |
\seq_new:N \l_@@_tmpb_seq |
| 4380 |
\int_new:N \l_@@_tmpa_int |
| 4381 |
\int_new:N \l_@@_tmpb_int |
| 4382 |
\bool_new:N \l_@@_tmpa_bool |
| 4383 |
\bool_new:N \l_@@_tmpb_bool |
| 4384 |
% \end{macrocode} |
| 4385 |
%\end{macro} |
| 4386 |
% |
| 4387 |
% |
| 4388 |
% |
| 4389 |
% \subsection {Keys} |
| 4390 |
% |
| 4391 |
% |
| 4392 |
% Let's define some keys. |
| 4393 |
% \begin{macrocode} |
| 4394 |
\keys_define:nn { cooking-units } |
| 4395 |
{ |
| 4396 |
% \end{macrocode} |
| 4397 |
% |
| 4398 |
% |
| 4399 |
% \begin{macro}{ add-unit-to-group } |
| 4400 |
% \begin{macrocode} |
| 4401 |
add-unit-to-group .code:n = |
| 4402 |
{ |
| 4403 |
\keyval_parse:NNn |
| 4404 |
\@@_add_to_unit_group_error:n |
| 4405 |
\@@_add_to_unit_group:nn |
| 4406 |
{#1} |
| 4407 |
} , |
| 4408 |
add-unit-to-group .default:n = {} , |
| 4409 |
% \end{macrocode} |
| 4410 |
% \end{macro} |
| 4411 |
% |
| 4412 |
%\begin{macro}{ set-option-for } |
| 4413 |
% Setting options. |
| 4414 |
% \begin{macrocode} |
| 4415 |
set-option-for .code:n = |
| 4416 |
{ |
| 4417 |
\keyval_parse:NNn |
| 4418 |
\@@_set_options_for_error:n |
| 4419 |
\@@_set_options_for:nn |
| 4420 |
{#1} |
| 4421 |
}, |
| 4422 |
% \end{macrocode} |
| 4423 |
% \end{macro} |
| 4424 |
% |
| 4425 |
%\begin{macro}{ add-option-for } |
| 4426 |
% Setting options. |
| 4427 |
% \begin{macrocode} |
| 4428 |
add-option-for .code:n = |
| 4429 |
{ |
| 4430 |
\keyval_parse:NNn |
| 4431 |
\@@_add_options_for_error:n |
| 4432 |
\@@_add_options_for:nn |
| 4433 |
{#1} |
| 4434 |
}, |
| 4435 |
% \end{macrocode} |
| 4436 |
% \end{macro} |
| 4437 |
% |
| 4438 |
% \begin{macro}{ erase-all-options } |
| 4439 |
% Erasing all preset options. Again not the best approach \dots\ maybe I need a lower |
| 4440 |
% level \enquote{clear} option. |
| 4441 |
% \begin{macrocode} |
| 4442 |
erase-all-options .code:n = |
| 4443 |
{ |
| 4444 |
\clist_set_from_seq:NN \l_@@_tmpa_clist \g_@@_list_of_defined_units_seq |
| 4445 |
\@@_clear_options_for:V \l_@@_tmpa_clist |
| 4446 |
}, |
| 4447 |
erase-all-options .value_forbidden:n = { true } , |
| 4448 |
% \end{macrocode} |
| 4449 |
% \end{macro} |
| 4450 |
% |
| 4451 |
%\begin{macro}{ erase-all-options-for } |
| 4452 |
% Erasing options. As this simply clears the unit options the argument |#1| |
| 4453 |
% is simply a clist, as such no keyval parsing is needed. |
| 4454 |
% \begin{macrocode} |
| 4455 |
erase-all-options-for .code:n = |
| 4456 |
{ |
| 4457 |
\@@_clear_options_for:n {#1} |
| 4458 |
}, |
| 4459 |
erase-all-options-for .value_required:n = { true } , |
| 4460 |
% \end{macrocode} |
| 4461 |
% \end{macro} |
| 4462 |
% |
| 4463 |
% |
| 4464 |
% |
| 4465 |
% |
| 4466 |
% |
| 4467 |
% |
| 4468 |
% \begin{macro}{ cutext-to-cunum } |
| 4469 |
% Don't want any \mycs{cutext} (or \mycs{Cutext}) in your |
| 4470 |
% document? Use this option! |
| 4471 |
% \begin{macrocode} |
| 4472 |
cutext-to-cunum .bool_set:N = \l_@@_pckopt_cutext_to_cunum_bool , |
| 4473 |
cutext-to-cunum .default:n = { false } , |
| 4474 |
cutext-to-cunum .groups:n = { change-command } , |
| 4475 |
% \end{macrocode} |
| 4476 |
% \end{macro} |
| 4477 |
% |
| 4478 |
% \begin{macro}{ cutext-change-unit } |
| 4479 |
% Do not wanna change units in \mycs{cutext}? Use this option. |
| 4480 |
% \begin{macrocode} |
| 4481 |
cutext-change-unit .bool_set_inverse:N = \l_@@_pckopt_cutext_keep_unit_bool , |
| 4482 |
cutext-change-unit .default:n = { true } , |
| 4483 |
cutext-change-unit .groups:n = { change-unit } , |
| 4484 |
% \end{macrocode} |
| 4485 |
% \end{macro} |
| 4486 |
% |
| 4487 |
% \begin{macro}{ cuam-version , cutext-version} |
| 4488 |
% Some keys with horrible option names. Reverts |
| 4489 |
% the respective command back to its older state (pre v1.10). |
| 4490 |
% \begin{macrocode} |
| 4491 |
cuam-version .choices:nn = |
| 4492 |
{ new , old } |
| 4493 |
{ |
| 4494 |
\int_case:nn { \l_keys_choice_int } |
| 4495 |
{ |
| 4496 |
{ 1 } { \bool_set_false:N \l_@@_pckopt_cuam_old_bool } |
| 4497 |
{ 2 } { \bool_set_true:N \l_@@_pckopt_cuam_old_bool } |
| 4498 |
} |
| 4499 |
} , |
| 4500 |
cuam-version .default:n = { new } , |
| 4501 |
cuam-version .groups:n = { parse } , |
| 4502 |
cutext-version .choices:nn = |
| 4503 |
{ new , old } |
| 4504 |
{ |
| 4505 |
\int_case:nn { \l_keys_choice_int } |
| 4506 |
{ |
| 4507 |
{ 1 } { \bool_set_false:N \l_@@_pckopt_cutext_old_bool } |
| 4508 |
{ 2 } { \bool_set_true:N \l_@@_pckopt_cutext_old_bool } |
| 4509 |
} |
| 4510 |
} , |
| 4511 |
cutext-version .default:n = { new } , |
| 4512 |
cutext-version .groups:n = { parse } , |
| 4513 |
% \end{macrocode} |
| 4514 |
% \end{macro} |
| 4515 |
% |
| 4516 |
% \begin{macro}{ expand-both , expand-amount, expand-unit } |
| 4517 |
% \begin{macrocode} |
| 4518 |
expand-both .choices:nn = |
| 4519 |
{ n , o , f , x } |
| 4520 |
{ |
| 4521 |
\tl_set_eq:NN \l_@@_unit_argument_spec_tl \l_keys_choice_tl |
| 4522 |
\tl_set_eq:NN \l_@@_expand_amount_tl \l_keys_choice_tl |
| 4523 |
} , |
| 4524 |
expand-both .default:n = { n } , |
| 4525 |
expand-both .groups:n = { parse } , |
| 4526 |
% \end{macrocode} |
| 4527 |
% \begin{macrocode} |
| 4528 |
expand-amount .choices:nn = |
| 4529 |
{ n , o , f , x } |
| 4530 |
{ |
| 4531 |
\tl_set_eq:NN \l_@@_expand_amount_tl \l_keys_choice_tl |
| 4532 |
} , |
| 4533 |
expand-amount .default:n = { n } , |
| 4534 |
expand-amount .groups:n = { parse } , |
| 4535 |
% \end{macrocode} |
| 4536 |
% \begin{macrocode} |
| 4537 |
expand-unit .choices:nn = |
| 4538 |
{ n , o , f , x } |
| 4539 |
{ |
| 4540 |
\tl_set_eq:NN \l_@@_unit_argument_spec_tl \l_keys_choice_tl |
| 4541 |
} , |
| 4542 |
expand-unit .default:n = { n } , |
| 4543 |
expand-unit .groups:n = { parse } , |
| 4544 |
% \end{macrocode} |
| 4545 |
% \end{macro} |
| 4546 |
% |
| 4547 |
% |
| 4548 |
% |
| 4549 |
% |
| 4550 |
% |
| 4551 |
%\begin{macro}{ set-special-sign } |
| 4552 |
% Setting allowd special signs. Note that |<| is not allowed. |
| 4553 |
% \begin{macrocode} |
| 4554 |
set-special-sign .code:n = |
| 4555 |
{ |
| 4556 |
\tl_map_inline:nn {#1} |
| 4557 |
{ |
| 4558 |
\str_if_eq:nnTF {##1} { < } |
| 4559 |
{ |
| 4560 |
\msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } |
| 4561 |
\tl_map_break:n { \use_none:nn } |
| 4562 |
} |
| 4563 |
} |
| 4564 |
\use:n |
| 4565 |
{ |
| 4566 |
\str_if_in:nnTF {#1} { x } |
| 4567 |
{ |
| 4568 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { x } |
| 4569 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { X } |
| 4570 |
}{ |
| 4571 |
\str_if_in:nnT {#1} { X } |
| 4572 |
{ |
| 4573 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { x } |
| 4574 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { X } |
| 4575 |
} |
| 4576 |
} |
| 4577 |
\tl_set:Nn \l_@@_input_allowed_special_signs_tl {#1} |
| 4578 |
} |
| 4579 |
} , |
| 4580 |
set-special-sign .groups:n = { parse } , |
| 4581 |
% \end{macrocode} |
| 4582 |
%\end{macro} |
| 4583 |
%\begin{macro}{ add-special-sign } |
| 4584 |
% Adding a (some) special sign(s) which is (are) allowed in the input. |
| 4585 |
% \begin{macrocode} |
| 4586 |
add-special-sign .code:n = |
| 4587 |
{ |
| 4588 |
\tl_map_inline:nn {#1} |
| 4589 |
{ |
| 4590 |
\str_if_eq:nnTF {##1} { < } |
| 4591 |
{ |
| 4592 |
\msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } |
| 4593 |
}{ |
| 4594 |
\bool_lazy_or:nnT |
| 4595 |
{ \str_if_eq_p:nn {##1} { x } } |
| 4596 |
{ \str_if_eq_p:nn {##1} { X } } |
| 4597 |
{ |
| 4598 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { x } |
| 4599 |
\tl_remove_all:Nn \l_@@_input_times_sign_tl { X } |
| 4600 |
} |
| 4601 |
\tl_put_right:Nn \l_@@_input_allowed_special_signs_tl {##1} |
| 4602 |
} |
| 4603 |
} |
| 4604 |
} , |
| 4605 |
add-special-sign .default:n = { } , |
| 4606 |
add-special-sign .groups:n = { parse } , |
| 4607 |
% \end{macrocode} |
| 4608 |
%\end{macro} |
| 4609 |
% |
| 4610 |
% |
| 4611 |
% \begin{macro}{ set-unknown-message } |
| 4612 |
% Sets the message for a special-sign to error, warning or none. |
| 4613 |
% \begin{macrocode} |
| 4614 |
set-unknown-message .choices:nn = |
| 4615 |
{ error , warning , none } |
| 4616 |
{ |
| 4617 |
\msg_redirect_name:nnV { cooking-units } { amount-not-known } |
| 4618 |
\l_keys_choice_tl |
| 4619 |
} , |
| 4620 |
set-unknown-message .default:n = { warning } , |
| 4621 |
% \end{macrocode} |
| 4622 |
%\end{macro} |
| 4623 |
% |
| 4624 |
% \begin{macro}{ set-cutext-translation-message } |
| 4625 |
% Sets the message for a special-sign to error, warning or none. |
| 4626 |
% \begin{macrocode} |
| 4627 |
set-cutext-translation-message .choices:nn = |
| 4628 |
{ error , warning , none } |
| 4629 |
{ |
| 4630 |
\msg_redirect_name:nnV { cooking-units } { cutext-no-translation-available } |
| 4631 |
\l_keys_choice_tl |
| 4632 |
} , |
| 4633 |
set-cutext-translation-message .default:n = { warning } , |
| 4634 |
% \end{macrocode} |
| 4635 |
%\end{macro} |
| 4636 |
% |
| 4637 |
% |
| 4638 |
% \begin{macro}{ print-numerals } |
| 4639 |
% A not very good name, but I couldn't think of a better name. |
| 4640 |
% \begin{macrocode} |
| 4641 |
print-numerals .bool_set:N = \l_@@_pckopt_print_numeral_bool , |
| 4642 |
print-numerals .default:n = { true } , |
| 4643 |
print-numerals .groups:n = { unit-hook } , |
| 4644 |
% \end{macrocode} |
| 4645 |
% \end{macro} |
| 4646 |
% |
| 4647 |
% \begin{macro}{ use-numerals-below } |
| 4648 |
% Use numerals if the integer is below the integer set by this option. |
| 4649 |
% \begin{macrocode} |
| 4650 |
use-numerals-below .int_set:N = \l_@@_print_numerals_below_int , |
| 4651 |
use-numerals-below .default:n = { 13 } , |
| 4652 |
use-numerals-below .groups:n = { unit-hook } , |
| 4653 |
% \end{macrocode} |
| 4654 |
%\end{macro} |
| 4655 |
% |
| 4656 |
%\begin{macro}{ parse-number } |
| 4657 |
% Parse the input? If no the input is printed as is (after some safety parsing). |
| 4658 |
% \begin{macrocode} |
| 4659 |
parse-number .bool_set_inverse:N = \l_@@_pckopt_draft_bool , |
| 4660 |
parse-number .default:n= { true } , |
| 4661 |
parse-number .groups:n = { parse } , |
| 4662 |
% \end{macrocode} |
| 4663 |
%\end{macro} |
| 4664 |
% |
| 4665 |
%\begin{macro}{ range-sign } |
| 4666 |
% Setting the printed range sign and make a difference between cunum |
| 4667 |
% and c(C)utext. |
| 4668 |
% \begin{macrocode} |
| 4669 |
range-sign .meta:n = |
| 4670 |
{ |
| 4671 |
cunum-range-sign = {#1} , |
| 4672 |
cutext-range-sign = {#1} |
| 4673 |
} , |
| 4674 |
range-sign .default:n = { -- } , |
| 4675 |
cunum-range-sign .tl_set:N = \l_@@_cunum_range_sign_tl , |
| 4676 |
cunum-range-sign .default:n = { -- } , |
| 4677 |
cutext-range-sign .tl_set:N = \l_@@_cutext_range_sign_tl , |
| 4678 |
cutext-range-sign .default:n = { -- } , |
| 4679 |
range-sign .groups:n = { unit-hook } , |
| 4680 |
cunum-range-sign .groups:n = { unit-hook } , |
| 4681 |
cutext-range-sign .groups:n = { unit-hook } , |
| 4682 |
% \end{macrocode} |
| 4683 |
%\end{macro} |
| 4684 |
% |
| 4685 |
% \begin{macro}{ use-phrases } |
| 4686 |
% Do not wanna use phrases in \mycs{cuam}? Use this option! |
| 4687 |
% \begin{macrocode} |
| 4688 |
use-phrases .bool_set:N = \l_@@_pckopt_use_phrases_bool , |
| 4689 |
use-phrases .default:n = { true } , |
| 4690 |
use-phrases .groups:n = { unit-hook } , |
| 4691 |
% \end{macrocode} |
| 4692 |
% \end{macro} |
| 4693 |
% |
| 4694 |
% |
| 4695 |
% |
| 4696 |
% |
| 4697 |
% |
| 4698 |
% |
| 4699 |
%\begin{macro}{ round-precision } |
| 4700 |
% Setting the round-precision. Setting those two at once to |
| 4701 |
% not calculate it every time. |
| 4702 |
% \begin{macrocode} |
| 4703 |
round-precision .code:n = |
| 4704 |
{ |
| 4705 |
\int_set:Nn \l_@@_round_precision_int {#1} |
| 4706 |
\int_compare:nNnTF {#1} < { 0 } |
| 4707 |
{ \bool_set_true:N } |
| 4708 |
{ \bool_set_false:N } |
| 4709 |
\l_@@_pckopt_round_precision_negative_bool |
| 4710 |
} , |
| 4711 |
round-precision .default:n = { 2 } , |
| 4712 |
round-precision .groups:n = { unit-hook } , |
| 4713 |
% \end{macrocode} |
| 4714 |
%\end{macro} |
| 4715 |
% |
| 4716 |
%\begin{macro}{ round-to-int } |
| 4717 |
% Rounding the results to an integer. |
| 4718 |
% \begin{macrocode} |
| 4719 |
round-to-int .bool_set:N = \l_@@_pckopt_round_to_int_bool , |
| 4720 |
round-to-int .choices:nn = |
| 4721 |
{ true , false } |
| 4722 |
{ |
| 4723 |
\msg_error:nnnn { cooking-units } |
| 4724 |
{ Option-deprecated } { round-to-int } { round-precision = 0 } |
| 4725 |
\int_compare:nNnT { \l_keys_choice_int } = { 1 } |
| 4726 |
{ |
| 4727 |
\int_set:Nn \l_@@_round_precision_int { 0 } |
| 4728 |
} |
| 4729 |
\use:c { bool_set_ \l_keys_choice_tl :N } \l_@@_pckopt_round_to_int_bool |
| 4730 |
} , |
| 4731 |
round-to-int .default:n = { false } , |
| 4732 |
round-to-int .groups:n = { unit-hook } , |
| 4733 |
% \end{macrocode} |
| 4734 |
%\end{macro} |
| 4735 |
% |
| 4736 |
% \begin{macro}{ round-half } |
| 4737 |
% Choosing between \enquote{normal} rounding to even |
| 4738 |
% and commercial rounding and sets the boolean accordingly. |
| 4739 |
% \begin{macrocode} |
| 4740 |
% TODO: uodate doch und so |
| 4741 |
round-half .choices:nn = |
| 4742 |
{ default , commercial , up } |
| 4743 |
{ |
| 4744 |
\int_case:nn { \l_keys_choice_int } |
| 4745 |
{ |
| 4746 |
{ 1 } { \bool_set_false:N \l_@@_pckopt_round_commercial_bool } |
| 4747 |
{ 2 } { \bool_set_true:N \l_@@_pckopt_round_commercial_bool } |
| 4748 |
{ 3 } { \bool_set_true:N \l_@@_pckopt_round_commercial_bool } |
| 4749 |
} |
| 4750 |
}, |
| 4751 |
round-half .default:n = { default }, |
| 4752 |
round-half .groups:n = { unit-hook } , |
| 4753 |
% \end{macrocode} |
| 4754 |
% \end{macro} |
| 4755 |
% |
| 4756 |
%\begin{macro}{ eval-fraction } |
| 4757 |
% If set to true the fractions are evaluated. |
| 4758 |
% \begin{macrocode} |
| 4759 |
eval-fraction .bool_set:N = \l_@@_pckopt_eval_fractions_bool , |
| 4760 |
eval-fraction .default:n = { false } , |
| 4761 |
% \end{macrocode} |
| 4762 |
%\end{macro} |
| 4763 |
% |
| 4764 |
%\begin{macro}{ convert-fraction } |
| 4765 |
% If set to true the fractions are evaluated \emph{if} the unit is transformed! |
| 4766 |
% \begin{macrocode} |
| 4767 |
convert-fraction .bool_set:N = \l_@@_pckopt_convert_fractions_bool , |
| 4768 |
convert-fraction .default:n = { true } , |
| 4769 |
% \end{macrocode} |
| 4770 |
%\end{macro} |
| 4771 |
% |
| 4772 |
% |
| 4773 |
%\begin{macro}{ fraction-command } |
| 4774 |
% Setting the fraction command |
| 4775 |
% \begin{macrocode} |
| 4776 |
fraction-command .code:n = { \cs_set_eq:NN \@@_frac:nn #1 } , |
| 4777 |
fraction-command .default:n = { \sfrac } , |
| 4778 |
% \end{macrocode} |
| 4779 |
%\end{macro} |
| 4780 |
% |
| 4781 |
%\begin{macro}{ fraction-inline } |
| 4782 |
% Setting the code inline. |
| 4783 |
% \begin{macrocode} |
| 4784 |
fraction-inline .code:n = { \cs_set:Npn \@@_frac:nn ##1##2 {#1} } , |
| 4785 |
fraction-inline .default:n = { \sfrac {#1} {#2} } , |
| 4786 |
% \end{macrocode} |
| 4787 |
%\end{macro} |
| 4788 |
% |
| 4789 |
% |
| 4790 |
% |
| 4791 |
% |
| 4792 |
% |
| 4793 |
% |
| 4794 |
%\begin{macro}{ mixed-fraction-space } |
| 4795 |
% Setting the space between the mixed fraction part and the fraction. |
| 4796 |
% \begin{macrocode} |
| 4797 |
mixed-fraction-space .dim_set:N = \l_@@_mixed_frac_dim , |
| 4798 |
mixed-fraction-space .default:n = { 0.1 em } , |
| 4799 |
mixed-fraction-space .groups:n = { unit-hook } , |
| 4800 |
% \end{macrocode} |
| 4801 |
%\end{macro} |
| 4802 |
% |
| 4803 |
% \begin{macro}{ cutext-space } |
| 4804 |
% The space used in \mycs{cutext} between the \emph{number} |
| 4805 |
% and unit. |
| 4806 |
% \begin{macrocode} |
| 4807 |
cutext-space .tl_set:N = \l_@@_cutext_space_tl , |
| 4808 |
cutext-space .default:n = { ~ } , |
| 4809 |
cutext-space .groups:n = { unit-hook } , |
| 4810 |
% \end{macrocode} |
| 4811 |
% \end{macro} |
| 4812 |
% |
| 4813 |
% \begin{macro}{ cutext-space } |
| 4814 |
% The space used in \mycs{cutext} between the \emph{numeral} |
| 4815 |
% and unit. |
| 4816 |
% \begin{macrocode} |
| 4817 |
cutext-numeral-space .tl_set:N = \l_@@_cutext_numeral_space_tl , |
| 4818 |
cutext-numeral-space .default:n = { \space } , |
| 4819 |
cutext-numeral-space .groups:n = { unit-hook } , |
| 4820 |
% \end{macrocode} |
| 4821 |
% \end{macro} |
| 4822 |
% |
| 4823 |
% \begin{macro}{ phrase-space } |
| 4824 |
% Same as before, but for phrases |
| 4825 |
% \begin{macrocode} |
| 4826 |
phrase-space .tl_set:N = \l_@@_cuphrase_space_tl , |
| 4827 |
phrase-space .default:n = { ~ } , |
| 4828 |
phrase-space .groups:n = { unit-hook } , |
| 4829 |
% \end{macrocode} |
| 4830 |
% \end{macro} |
| 4831 |
% |
| 4832 |
%\begin{macro}{ amount-unit-space } |
| 4833 |
% Setting the space between the value and the printed unit. |
| 4834 |
% \begin{macrocode} |
| 4835 |
amount-unit-space .tl_set:N = \l_@@_value_unit_space_tl , |
| 4836 |
amount-unit-space .default:n = { \thinspace } , |
| 4837 |
amount-unit-space .groups:n = { unit-hook } , |
| 4838 |
% \end{macrocode} |
| 4839 |
%\end{macro} |
| 4840 |
% |
| 4841 |
%\begin{macro}{ amount-unit-space } |
| 4842 |
% Setting the space between the value and the printed unit. |
| 4843 |
% \begin{macrocode} |
| 4844 |
times-space .tl_set:N = \l_@@_times_space_tl , |
| 4845 |
times-space .default:n = { \: } , |
| 4846 |
times-space .groups:n = { unit-hook } , |
| 4847 |
% \end{macrocode} |
| 4848 |
%\end{macro} |
| 4849 |
% |
| 4850 |
% |
| 4851 |
% |
| 4852 |
% |
| 4853 |
% |
| 4854 |
% \begin{macro}{ recalculate-amount } |
| 4855 |
% Setting the number of persons your recipes should be for |
| 4856 |
% is not enough; it is also needed to tell the package to |
| 4857 |
% recalculate the amounts. |
| 4858 |
% \begin{macrocode} |
| 4859 |
recalculate-amount .bool_set:N = \l_@@_pckopt_recalculate_amount_bool , |
| 4860 |
recalculate-amount .default:n = { false } , |
| 4861 |
% \end{macrocode} |
| 4862 |
% \end{macro} |
| 4863 |
% |
| 4864 |
% \begin{macro}{ set-number-of-persons } |
| 4865 |
% Setting the number of persons the recipe should be for. |
| 4866 |
% \begin{macrocode} |
| 4867 |
set-number-of-persons .int_set:N = \l_@@_wanted_number_of_persons_int , |
| 4868 |
set-number-of-persons .default:n = { 4 } , |
| 4869 |
% \end{macrocode} |
| 4870 |
% \end{macro} |
| 4871 |
% |
| 4872 |
% \begin{macro}{ label } |
| 4873 |
% Defines a label. Is \mycs{culabel} in key form. |
| 4874 |
% \begin{macrocode} |
| 4875 |
label .code:n = \@@_label_and_persons:n {#1} , |
| 4876 |
label .value_required:n = { true } , |
| 4877 |
% \end{macrocode} |
| 4878 |
% \end{macro} |
| 4879 |
% |
| 4880 |
% \begin{macro}{ get-label } |
| 4881 |
% \mycs{curef} as a key. |
| 4882 |
% \begin{macrocode} |
| 4883 |
get-label .code:n = \@@_curef:n {#1} , |
| 4884 |
get-label .value_required:n = { true } , |
| 4885 |
% \end{macrocode} |
| 4886 |
% \end{macro} |
| 4887 |
% |
| 4888 |
% \begin{macro}{ ref } |
| 4889 |
% The |<>| option for keys. |
| 4890 |
% \begin{macrocode} |
| 4891 |
ref .code:n = \@@_reference_label_and_persons:n {#1} , |
| 4892 |
ref .value_required:n = { true } , |
| 4893 |
% \end{macrocode} |
| 4894 |
% \end{macro} |
| 4895 |
% |
| 4896 |
% |
| 4897 |
% |
| 4898 |
% |
| 4899 |
% |
| 4900 |
% |
| 4901 |
%\begin{macro}{ check-temperature } |
| 4902 |
% Weird option. Checking the temperature, if the temperature is below the absolute zero temperature |
| 4903 |
% it raises an error. |
| 4904 |
% \begin{macrocode} |
| 4905 |
check-temperature .bool_set:N = \l_@@_pckopt_check_temperature_bool , |
| 4906 |
check-temperature .default:n = { true } , |
| 4907 |
% \end{macrocode} |
| 4908 |
% |
| 4909 |
%\begin{macro}{ add-temperature-to-check } |
| 4910 |
% Adds a temperature to check for \texttt{check-temperature}. |
| 4911 |
% It uses the \cs{keyval\_parse:NNn} command as this |
| 4912 |
% macro is used to parse keys (which is what I need). |
| 4913 |
% \begin{macrocode} |
| 4914 |
add-temperature-to-check .code:n = |
| 4915 |
{ |
| 4916 |
\keyval_parse:NNn |
| 4917 |
\@@_temperature_to_check_print_error:n |
| 4918 |
\@@_temperatures_to_check_define:nn |
| 4919 |
{#1} |
| 4920 |
} , |
| 4921 |
temperature-to-check .value_required:n = { true } , |
| 4922 |
% \end{macrocode} |
| 4923 |
% \end{macro} |
| 4924 |
% |
| 4925 |
%\begin{macro}{ convert-to-eV } |
| 4926 |
% Another weird option, converts pretty much any unit defined by this |
| 4927 |
% package to electron volt or the respective derivative. |
| 4928 |
% As this is a unit transformation, it needs to be inside the |
| 4929 |
% group. |
| 4930 |
% \begin{macrocode} |
| 4931 |
convert-to-eV .bool_set:N = \l_@@_pckopt_convert_to_eV_bool , |
| 4932 |
convert-to-eV .default:n = { true } , |
| 4933 |
% convert-to-eV .groups:n = { change-unit } , |
| 4934 |
% \end{macrocode} |
| 4935 |
%\end{macro} |
| 4936 |
% |
| 4937 |
% \begin{macro}{ add-natural-unit } |
| 4938 |
% \begin{macrocode} |
| 4939 |
add-natural-unit .code:n = |
| 4940 |
{ |
| 4941 |
\seq_set_from_clist:Nn \l_@@_tmpa_seq {#1} |
| 4942 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 4943 |
{ |
| 4944 |
\@@_error_if_unit_not_defined:nNF {##1} \l_@@_curr_unit_tl |
| 4945 |
{ |
| 4946 |
\seq_if_in:NVF \g_@@_natural_units_seq \l_@@_curr_unit_tl |
| 4947 |
{ \seq_gput_right:NV \g_@@_natural_units_seq \l_@@_curr_unit_tl } |
| 4948 |
} |
| 4949 |
} |
| 4950 |
} , |
| 4951 |
add-natural-unit .value_required:n = { true } , |
| 4952 |
% \end{macrocode} |
| 4953 |
% \end{macro} |
| 4954 |
% |
| 4955 |
% \begin{macro}{ 42 } |
| 4956 |
% \begin{macrocode} |
| 4957 |
42 .choice: , |
| 4958 |
42 / true .code:n = { \bool_set_true:N \l_@@_pckopt_fourty_two_bool } , |
| 4959 |
42 / false .code:n = { \msg_fatal:nnn { cooking-units } { 42-is-...-wrong? } } , |
| 4960 |
42 .default:n = { true } , |
| 4961 |
42 .groups:n = { parse } , |
| 4962 |
% \end{macrocode} |
| 4963 |
% \end{macro} |
| 4964 |
% |
| 4965 |
% |
| 4966 |
% |
| 4967 |
% |
| 4968 |
% |
| 4969 |
% |
| 4970 |
% |
| 4971 |
% |
| 4972 |
% |
| 4973 |
% |
| 4974 |
% |
| 4975 |
% |
| 4976 |
% |
| 4977 |
% |
| 4978 |
% |
| 4979 |
% |
| 4980 |
% |
| 4981 |
% |
| 4982 |
% |
| 4983 |
% \begin{macro}{ input-range-sign } |
| 4984 |
% Don't wanna use \verb|--| as a range sperator in \mycs{cunum}? |
| 4985 |
% Use this option. |
| 4986 |
% \begin{macrocode} |
| 4987 |
input-range-sign .tl_set:N = \l_@@_input_range_sign_tl , |
| 4988 |
input-range-sign .default:n = { -- } , |
| 4989 |
input-range-sign .groups:n = { parse } , |
| 4990 |
% \end{macrocode} |
| 4991 |
%\end{macro} |
| 4992 |
% |
| 4993 |
% \begin{macro}{ numeral-function , Numeral-function } |
| 4994 |
% \begin{macrocode} |
| 4995 |
numeral-function .code:n = { \cs_set_eq:NN \@@_print_numeral:n #1 } , |
| 4996 |
Numeral-function .code:n = { \cs_set_eq:NN \@@_print_Numeral:n #1 } , |
| 4997 |
% \end{macrocode} |
| 4998 |
% \end{macro} |
| 4999 |
% |
| 5000 |
% |
| 5001 |
% |
| 5002 |
% |
| 5003 |
% \begin{macro}{ |
| 5004 |
% commands-add-hook , |
| 5005 |
% cunum-add-hook , |
| 5006 |
% cutext-add-hook , Cutext-add-hook , |
| 5007 |
% cuam-add-hook , |
| 5008 |
% } |
| 5009 |
% \begin{macrocode} |
| 5010 |
commands-add-hook .meta:n = |
| 5011 |
{ |
| 5012 |
cunum-add-hook = {#1} , |
| 5013 |
cutext-add-hook = {#1} , |
| 5014 |
Cutext-add-hook = {#1} , |
| 5015 |
cuam-add-hook = {#1} , |
| 5016 |
} , |
| 5017 |
cunum-add-hook .code:n = { \tl_put_right:Nn \l_@@_cunum_hook_tl {#1} } , |
| 5018 |
cutext-add-hook .code:n = { \tl_put_right:Nn \l_@@_cutext_hook_tl {#1} } , |
| 5019 |
Cutext-add-hook .code:n = { \tl_put_right:Nn \l_@@_Cutext_hook_tl {#1} } , |
| 5020 |
cuam-add-hook .code:n = { \tl_put_right:Nn \l_@@_cuam_hook_tl {#1} } , |
| 5021 |
cunum-add-hook .groups:n = { parse } , |
| 5022 |
cutext-add-hook .groups:n = { parse } , |
| 5023 |
Cutext-add-hook .groups:n = { parse } , |
| 5024 |
cuam-add-hook .groups:n = { parse } , |
| 5025 |
commands-add-hook .groups:n = { parse } , |
| 5026 |
% \end{macrocode} |
| 5027 |
% \end{macro} |
| 5028 |
% |
| 5029 |
% |
| 5030 |
% |
| 5031 |
% |
| 5032 |
% |
| 5033 |
% |
| 5034 |
% |
| 5035 |
% |
| 5036 |
% |
| 5037 |
% |
| 5038 |
% |
| 5039 |
% |
| 5040 |
% |
| 5041 |
% |
| 5042 |
% |
| 5043 |
% |
| 5044 |
% |
| 5045 |
% \begin{macro}{ |
| 5046 |
% curef-add-forbidden-unit, |
| 5047 |
% curef-remove-forbidden-unit, |
| 5048 |
% curef-clear-forbidden-units |
| 5049 |
% } |
| 5050 |
% \begin{macrocode} |
| 5051 |
curef-add-forbidden-unit .code:n = { \@@_add_forbidden_unit:n {#1} } , |
| 5052 |
curef-add-forbidden-unit .default:n = { } , |
| 5053 |
curef-remove-forbidden-unit .code:n = { \@@_remove_forbidden_unit:n {#1} } , |
| 5054 |
curef-remove-forbidden-unit .default:n = { } , |
| 5055 |
% |
| 5056 |
curef-clear-forbidden-units .choice: , |
| 5057 |
curef-clear-forbidden-units/true .code:n = { \@@_clear_forbidden_unit: } , |
| 5058 |
curef-clear-forbidden-units/false .code:n = { } , |
| 5059 |
curef-clear-forbidden-units .value_required:n = true, |
| 5060 |
% \end{macrocode} |
| 5061 |
% \end{macro} |
| 5062 |
% |
| 5063 |
% |
| 5064 |
% |
| 5065 |
% |
| 5066 |
% \begin{macro}{symbol} |
| 5067 |
% To be implemented. Key used during definition of new units. |
| 5068 |
% Defines the printed symbol of the unit (both do the same). |
| 5069 |
% \begin{macrocode} |
| 5070 |
definition / symbol .code:n = |
| 5071 |
{ |
| 5072 |
\bool_set_true:N \l_@@_contains_valid_key_bool |
| 5073 |
\bool_set_true:N \l_@@_symbol_was_set_by_key_bool |
| 5074 |
\tl_set:cn { l_@@_default_unit_ \l_@@_original_unit_tl _tl } {#1} |
| 5075 |
}, |
| 5076 |
definition / symbol .value_required:n = { true } , |
| 5077 |
% \end{macrocode} |
| 5078 |
% \end{macro} |
| 5079 |
% |
| 5080 |
% \begin{macro}{gender} |
| 5081 |
% To be implemented. Key used during definition of new units. |
| 5082 |
% Defines the gender of the unit. |
| 5083 |
% \begin{macrocode} |
| 5084 |
definition / gender .code:n = |
| 5085 |
{ |
| 5086 |
\bool_set_true:N \l_@@_contains_valid_key_bool |
| 5087 |
\@@_if_gender_error:nTF {#1} |
| 5088 |
{ \@@_culang_def_base:nVn { gender } \l_@@_original_unit_tl { m } } |
| 5089 |
{ \@@_culang_def_base:nVn { gender } \l_@@_original_unit_tl {#1} } |
| 5090 |
}, |
| 5091 |
definition / gender .value_required:n = { true } , |
| 5092 |
% \end{macrocode} |
| 5093 |
% \end{macro} |
| 5094 |
% |
| 5095 |
% \begin{macro}{set-option} |
| 5096 |
% To be implemented. Key used during definition of new units. |
| 5097 |
% Adds options to a specific key during definition of unit. |
| 5098 |
% \begin{macrocode} |
| 5099 |
definition / set-option .code:n = |
| 5100 |
{ |
| 5101 |
\bool_set_true:N \l_@@_contains_valid_key_bool |
| 5102 |
\@@_set_options_for:Vn \l_@@_original_unit_tl {#1} |
| 5103 |
}, |
| 5104 |
definition / set-option .value_required:n = { true } , |
| 5105 |
% \end{macrocode} |
| 5106 |
% \end{macro} |
| 5107 |
% |
| 5108 |
% \begin{macro}{add-to-group} |
| 5109 |
% To be implemented. Key used during definition of new units. |
| 5110 |
% Adds unit to given group. |
| 5111 |
% \begin{macrocode} |
| 5112 |
definition / add-to-group .code:n = |
| 5113 |
{ |
| 5114 |
\bool_set_true:N \l_@@_contains_valid_key_bool |
| 5115 |
\@@_add_to_unit_group:nV {#1} \l_@@_original_unit_tl |
| 5116 |
}, |
| 5117 |
definition / add-to-group .value_required:n = { true } , |
| 5118 |
% \end{macrocode} |
| 5119 |
% \end{macro} |
| 5120 |
% |
| 5121 |
% \begin{macro}{natural-unit} |
| 5122 |
% To be implemented. Key used during definition of new units. |
| 5123 |
% Defines this unit as a natural unit. |
| 5124 |
% \begin{macrocode} |
| 5125 |
definition / natural-unit .code:n = |
| 5126 |
{ |
| 5127 |
\bool_set_true:N \l_@@_contains_valid_key_bool |
| 5128 |
\seq_if_in:NVF \g_@@_natural_units_seq \l_@@_original_unit_tl |
| 5129 |
{ \seq_gput_right:NV \g_@@_natural_units_seq \l_@@_original_unit_tl } |
| 5130 |
}, |
| 5131 |
definition / natural-unit .default:n = { true } , |
| 5132 |
% \end{macrocode} |
| 5133 |
% \end{macro} |
| 5134 |
% |
| 5135 |
% \begin{macro}{unit-names} |
| 5136 |
% To be implemented. Key used during definition of new units. |
| 5137 |
% Defines written out unit name for \cCutext for given language. |
| 5138 |
% Also suspended. Would need to give language and it would be too |
| 5139 |
% complicated (I think) |
| 5140 |
% \begin{macrocode} |
| 5141 |
% definition / unit-names .code:n = { }, |
| 5142 |
% \end{macrocode} |
| 5143 |
% \end{macro} |
| 5144 |
% |
| 5145 |
% |
| 5146 |
% You get here during the definition of a new unit if you use the optional |
| 5147 |
% argument. As symbols cannot contain |=| the argument |#1| is going |
| 5148 |
% to be empty. I also assume that none of the above keys are used as an |
| 5149 |
% unit-symbol. If |#1| is non-empty (aka.\ the key has a value) throw an error. |
| 5150 |
% \begin{macrocode} |
| 5151 |
definition / unknown .code:n = |
| 5152 |
{ |
| 5153 |
\tl_if_empty:nF {#1} |
| 5154 |
{ |
| 5155 |
\msg_error:nnxx |
| 5156 |
{ cooking-units } |
| 5157 |
{ definition-key-mistyped? } |
| 5158 |
\l_keys_key_str |
| 5159 |
{#1} |
| 5160 |
} |
| 5161 |
}, |
| 5162 |
% \end{macrocode} |
| 5163 |
% |
| 5164 |
% |
| 5165 |
% |
| 5166 |
% \begin{macro}{nothing-special} |
| 5167 |
% Stage 0 of being bonkers. Do nothing special in this one. Reset everything. |
| 5168 |
% \begin{macrocode} |
| 5169 |
nothing-special .code:n = |
| 5170 |
{ |
| 5171 |
\prop_gclear:N \g_@@_master_changer_prop |
| 5172 |
\prop_gclear:N \g_@@_convert_bonkers_remember_prop |
| 5173 |
\bool_set_false:N \l_@@_pckopt_bonkers_bool |
| 5174 |
\tl_set_eq:NN \l_@@_bonkers_state_tl \c_@@_bonkers_state_normal_tl |
| 5175 |
}, |
| 5176 |
nothing-special .value_forbidden:n = { true } , |
| 5177 |
% \end{macrocode} |
| 5178 |
% \end{macro} |
| 5179 |
% |
| 5180 |
% \begin{macro}{going-bonkers} |
| 5181 |
% Stage 1 of being bonkers. |
| 5182 |
% \begin{macrocode} |
| 5183 |
going-bonkers .code:n = |
| 5184 |
{ |
| 5185 |
\prop_gclear:N \g_@@_convert_bonkers_remember_prop |
| 5186 |
\bool_set_true:N \l_@@_pckopt_bonkers_bool |
| 5187 |
\tl_set_eq:NN \l_@@_bonkers_state_tl \c_@@_bonkers_state_going_tl |
| 5188 |
}, |
| 5189 |
going-bonkers .value_forbidden:n = { true } , |
| 5190 |
% \end{macrocode} |
| 5191 |
% \end{macro} |
| 5192 |
% |
| 5193 |
% \begin{macro}{fully-bonkers} |
| 5194 |
% Stage 2 of being bonkers. |
| 5195 |
% \begin{macrocode} |
| 5196 |
fully-bonkers .code:n = |
| 5197 |
{ |
| 5198 |
\prop_gclear:N \g_@@_master_changer_prop |
| 5199 |
\prop_gclear:N \g_@@_convert_bonkers_remember_prop |
| 5200 |
\bool_set_true:N \l_@@_pckopt_bonkers_bool |
| 5201 |
\tl_set_eq:NN \l_@@_bonkers_state_tl \c_@@_bonkers_state_fully_tl |
| 5202 |
}, |
| 5203 |
fully-bonkers .value_forbidden:n = { true } , |
| 5204 |
% \end{macrocode} |
| 5205 |
% \end{macro} |
| 5206 |
% |
| 5207 |
% \begin{macro}{xD-lol} |
| 5208 |
% Stage 3 of being bonkers. |
| 5209 |
% \begin{macrocode} |
| 5210 |
xD-lol .code:n = |
| 5211 |
{ |
| 5212 |
\prop_gclear:N \g_@@_master_changer_prop |
| 5213 |
\prop_gclear:N \g_@@_convert_bonkers_remember_prop |
| 5214 |
\bool_set_true:N \l_@@_pckopt_bonkers_bool |
| 5215 |
\tl_set_eq:NN \l_@@_bonkers_state_tl \c_@@_bonkers_state_xD_tl |
| 5216 |
}, |
| 5217 |
xD-lol .value_forbidden:n = { true } , |
| 5218 |
% \end{macrocode} |
| 5219 |
% \end{macro} |
| 5220 |
% |
| 5221 |
% |
| 5222 |
% |
| 5223 |
% |
| 5224 |
% |
| 5225 |
% |
| 5226 |
% |
| 5227 |
% |
| 5228 |
% |
| 5229 |
% |
| 5230 |
% Ending the definition of keys. |
| 5231 |
% \begin{macrocode} |
| 5232 |
} |
| 5233 |
%\keys_set:nn { cooking-units } {#2} |
| 5234 |
% \end{macrocode} |
| 5235 |
% \end{macro} |
| 5236 |
% |
| 5237 |
% |
| 5238 |
% |
| 5239 |
% |
| 5240 |
% |
| 5241 |
% \subsection {Messages} |
| 5242 |
% |
| 5243 |
% Defining messages. |
| 5244 |
% |
| 5245 |
% \begin{macro} {Messages} |
| 5246 |
% I do not allow fractions and ranges in the same input. Maybe I will |
| 5247 |
% change this. |
| 5248 |
% \begin{macrocode} |
| 5249 |
%\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range } |
| 5250 |
% { |
| 5251 |
% You \ cannot \ use \ '/' \ ( and \ '_' )\ in \ combination \ |
| 5252 |
% with \ '\l_@@_input_range_sign_tl' \ in \ '#1'. |
| 5253 |
% }{ |
| 5254 |
% You \ cannot \ use \ fractions \ with \ a \ range. |
| 5255 |
% \msg_see_documentation_text:n { cooking-units } |
| 5256 |
% } |
| 5257 |
% \end{macrocode} |
| 5258 |
% |
| 5259 |
% \begin{macrocode} |
| 5260 |
\msg_new:nnnn { cooking-units } { range-too-many-items } |
| 5261 |
{ |
| 5262 |
A \ range \ is \ only \ allowed \ to \ have \ a \ maximum \ of |
| 5263 |
\ two \ items. \ You \ have \ #1 \ items \ in \ '#2'. |
| 5264 |
}{ |
| 5265 |
You \ cannot \ use \ more \ than \ two \ '--' . |
| 5266 |
\msg_see_documentation_text:n { cooking-units } |
| 5267 |
} |
| 5268 |
% \end{macrocode} |
| 5269 |
% |
| 5270 |
% \begin{macrocode} |
| 5271 |
\msg_new:nnnn { cooking-units } { range-and-times-not-allowed } |
| 5272 |
{ |
| 5273 |
It \ is \ not \ allowed \ to \ mix \ ranges \ ('--') \ and \ |
| 5274 |
times \ in \ '#1'. |
| 5275 |
}{ |
| 5276 |
Do \ not \ use \ times \ and \ ranges \ in \ the \ same \ command. |
| 5277 |
\msg_see_documentation_text:n { cooking-units } |
| 5278 |
} |
| 5279 |
% \end{macrocode} |
| 5280 |
% |
| 5281 |
% Do not allow a \_ without a /. |
| 5282 |
% \begin{macrocode} |
| 5283 |
\msg_new:nnnn { cooking-units } { missing-slash } |
| 5284 |
{ |
| 5285 |
You \ cannot \ use \ '_' \ without \ |
| 5286 |
'/' \ in \ '#1'. |
| 5287 |
}{ |
| 5288 |
You \ cannot \ have \ a \ mixed \ fraction \ ('_') \ without \ |
| 5289 |
a \ normal \ fraction \ ('/'). |
| 5290 |
\msg_see_documentation_text:n { cooking-units } |
| 5291 |
} |
| 5292 |
\msg_new:nnnn { cooking-units } { fraction-wrong-order } |
| 5293 |
{ |
| 5294 |
You \ cannot \ use \ '/' \ before \ '_' \ in \ '#1'. |
| 5295 |
}{ |
| 5296 |
You \ can \ only \ use \ '_' \ before \ '/'. |
| 5297 |
\msg_see_documentation_text:n { cooking-units } |
| 5298 |
} |
| 5299 |
% \end{macrocode} |
| 5300 |
% Error message if unit is not known to this package. |
| 5301 |
% \begin{macrocode} |
| 5302 |
\msg_new:nnnn { cooking-units } { unknown-unit } |
| 5303 |
{ |
| 5304 |
The \ unit \ '#1' \ is \ not \ defined. \ Use \ |
| 5305 |
\newcookingunit (or \ one \ of \ the \ others) \ to \ |
| 5306 |
define \ new \ units. |
| 5307 |
}{ |
| 5308 |
Define \ units \ before \ using \ or \ check \ if \ the \ |
| 5309 |
unit-key \ is \ written \ correctly. |
| 5310 |
\msg_see_documentation_text:n { cooking-units } |
| 5311 |
} |
| 5312 |
% \end{macrocode} |
| 5313 |
% Error if unit is already defined. |
| 5314 |
% \begin{macrocode} |
| 5315 |
\msg_new:nnnn { cooking-units } { unit-already-defined } |
| 5316 |
{ The\ unit \ '#1' \ is \ already \ defined. } |
| 5317 |
{ |
| 5318 |
The \ unit-key \ is \ already \ defined. \ Please \ use \ a \ different \ |
| 5319 |
key \ for \ a \ new \ unit. |
| 5320 |
\msg_see_documentation_text:n {cooking-units} |
| 5321 |
} |
| 5322 |
% \end{macrocode} |
| 5323 |
% |
| 5324 |
% \begin{macrocode} |
| 5325 |
\msg_new:nnnn { cooking-units } { character-not-allowed } |
| 5326 |
{ |
| 5327 |
Unit-keys \ are \ not \ allowed \ to \ either \ contain \ ',' \ or \ '/' \ |
| 5328 |
in \ '#1'. |
| 5329 |
}{ |
| 5330 |
The \ unit-key \ is \ not \ allowed \ to \ contain \ ',' \ or \ '/'. \ |
| 5331 |
Due \ to \ internal \ reasons. |
| 5332 |
\msg_see_documentation_text:n {cooking-units} |
| 5333 |
} |
| 5334 |
% \end{macrocode} |
| 5335 |
% |
| 5336 |
% Missing argument in \lstinline|\cudefinesymbols| (et all). |
| 5337 |
% \begin{macrocode} |
| 5338 |
\msg_new:nnnn { cooking-units } { missing-argument } |
| 5339 |
{ There \ is \ a \ missing \ argument. } |
| 5340 |
{ |
| 5341 |
You \ probably \ have \ forgotten \ a \ curly-brace \ pair. |
| 5342 |
\msg_see_documentation_text:n {cooking-units} |
| 5343 |
} |
| 5344 |
% \end{macrocode} |
| 5345 |
% |
| 5346 |
% |
| 5347 |
% \begin{macrocode} |
| 5348 |
\msg_new:nnnn { cooking-units } { symbol-and-special-keys-error } |
| 5349 |
{ You \ cannot \ use \ special-key \ '#1' \ with \ symbol \ '#2' \ definitions. } |
| 5350 |
{ |
| 5351 |
You \ cannot \ redefine \ a \ symbol \ of \ a \ special-key. |
| 5352 |
\msg_see_documentation_text:n {cooking-units} |
| 5353 |
} |
| 5354 |
% \end{macrocode} |
| 5355 |
% |
| 5356 |
% |
| 5357 |
% If fractions are evaluated division by zero is not allowed. |
| 5358 |
% \begin{macrocode} |
| 5359 |
\msg_new:nnnn { cooking-units } { Division-by-zero } |
| 5360 |
{ Division\ by \ zero \ is \ not \ allowed \ in \ '#1'. } |
| 5361 |
{ See \ a \ math \ book \ of \ your \ choice \ or \ for \ example \ Wikipedia. } |
| 5362 |
% \end{macrocode} |
| 5363 |
% Showing the not allowed token in the input. Hope this helps. |
| 5364 |
% \begin{macrocode} |
| 5365 |
\msg_new:nnnn { cooking-units } { Token-not-allowed } |
| 5366 |
{ The \ token \ '#1' \ is \ not \ allowed \ in \ '#2'. } |
| 5367 |
{ |
| 5368 |
The \ command \ accepts \ only \ a \ fixed \ number \ of \ tokens. |
| 5369 |
\msg_see_documentation_text:n {cooking-units} |
| 5370 |
} |
| 5371 |
% \end{macrocode} |
| 5372 |
% A second decimal sign is not allowed (No na net). |
| 5373 |
% \begin{macrocode} |
| 5374 |
\msg_new:nnnn { cooking-units } { Second-decimal-sign-not-allowed } |
| 5375 |
{ A \ second \ decimal \ sign \ is \ not \ allowed \ in \ '#1'. } |
| 5376 |
{ |
| 5377 |
Perhaps \ you \ didn't \ type \ it \ correctly. |
| 5378 |
\msg_see_documentation_text:n {cooking-units} |
| 5379 |
} |
| 5380 |
% \end{macrocode} |
| 5381 |
% |
| 5382 |
% \begin{macrocode} |
| 5383 |
\msg_new:nnnn { cooking-units } { Second-fraction-sign-not-allowed } |
| 5384 |
{ A \ second \ fraction \ sign \ is \ not \ allowed \ in \ '#1'. } |
| 5385 |
{ |
| 5386 |
Perhaps \ you \ didn't \ type \ it \ correctly. |
| 5387 |
\msg_see_documentation_text:n {cooking-units} |
| 5388 |
} |
| 5389 |
% \end{macrocode} |
| 5390 |
% |
| 5391 |
% \begin{macrocode} |
| 5392 |
\msg_new:nnnn { cooking-units } { Second-mixed-fraction-sign-not-allowed } |
| 5393 |
{ A \ second \ mixed \ fraction \ sign \ is \ not \ allowed \ in \ '#1'. } |
| 5394 |
{ |
| 5395 |
Perhaps \ you \ didn't \ type \ it \ correctly. |
| 5396 |
\msg_see_documentation_text:n {cooking-units} |
| 5397 |
} |
| 5398 |
% \end{macrocode} |
| 5399 |
% Error message for an undefined key. |
| 5400 |
% \begin{macrocode} |
| 5401 |
\msg_new:nnnn { cooking-units } { Key-not-defined } |
| 5402 |
{ |
| 5403 |
The \ key \ '#1' \ is \ not \ defined. \ Use \ \cudefinekeys or \ |
| 5404 |
\cudefinesinglekey to \ define \ keys. |
| 5405 |
} |
| 5406 |
{ |
| 5407 |
This \ key \ is \ not \ defined, \ perhaps \ you \ misspelled \ it. |
| 5408 |
\msg_see_documentation_text:n {cooking-units} |
| 5409 |
} |
| 5410 |
% \end{macrocode} |
| 5411 |
% |
| 5412 |
% Error message for an undefined key. |
| 5413 |
% \begin{macrocode} |
| 5414 |
\msg_new:nnnn { cooking-units } { Key-chain-unit-not-found } |
| 5415 |
{ |
| 5416 |
It \ appears \ that \ \token_to_str:N \cuaddtokeychain\ was \ not \ able \ to \ find |
| 5417 |
a \ key-chain-unit. Define \ key-chains \ first \ using \token_to_str:N \cudefinekeychain. |
| 5418 |
} |
| 5419 |
{ |
| 5420 |
No \ key-chain-unit\ was \ found, \ perhaps \ you \ misspelled \ it? |
| 5421 |
\msg_see_documentation_text:n {cooking-units} |
| 5422 |
} |
| 5423 |
% \end{macrocode} |
| 5424 |
% |
| 5425 |
% If the temperature is too low print this error message. |
| 5426 |
% Now prints all units for which a zero-point is defined. |
| 5427 |
% \begin{macrocode} |
| 5428 |
\msg_new:nnnn { cooking-units } { Temperature-too-low } |
| 5429 |
{ |
| 5430 |
The \ temperature \ '#1' \ is \ too \ low.\ It \ cannot \ be \ |
| 5431 |
below \ the \ absolute \ zero - point \ of \ '#2'. \ Note \ that \ |
| 5432 |
the \ temperatures \ |
| 5433 |
'\@@_seq_use_msg:N \l_@@_temperatures_to_check_seq' \ |
| 5434 |
are \ rounded \ to \ integers \ by \ default. |
| 5435 |
\\\\ |
| 5436 |
You \ can \ disable \ the \ option \ 'check-temperature' \ to \ |
| 5437 |
disable \ this \ error. |
| 5438 |
} |
| 5439 |
{ See \ for \ example \ Wikipedia. } |
| 5440 |
% \end{macrocode} |
| 5441 |
% If for an unit-key the value is wrong the following error message is shown. |
| 5442 |
% \begin{macrocode} |
| 5443 |
\msg_new:nnnn { cooking-units } { key-choice-unknown } |
| 5444 |
{ |
| 5445 |
The \ key \ '#1' \ only \ accepts \ only \ |
| 5446 |
'#3' \ as \ a \ set \ of \ choices \ and \ '#2' \ is \ non \ of \ these. |
| 5447 |
}{ |
| 5448 |
The \ key \ accepts \ only \ a \ fixed \ set \ of \ choices. \ |
| 5449 |
You \ can \ add \ new \ choices \ via \ \token_to_str:N \cuaddkeys, ~ |
| 5450 |
\token_to_str:N \cuaddsinglekeys ~ and \ \token_to_str:N \cuaddtokeys. |
| 5451 |
\msg_see_documentation_text:n {cooking-units} |
| 5452 |
} |
| 5453 |
% \end{macrocode} |
| 5454 |
% If for an unit-key the value is wrong the following error message is shown. |
| 5455 |
% \begin{macrocode} |
| 5456 |
\msg_new:nnnn { cooking-units } { key-no-knows-value } |
| 5457 |
{ |
| 5458 |
It \ appears \ that \ the \ key \ '#1' \ does \ not \ accept \ the \ value |
| 5459 |
'#2'. \ Are \ you \ sure \ it \ is \ in \ the \ same \ key-chain? |
| 5460 |
}{ |
| 5461 |
The \ key \ accepts \ only \ a \ fixed \ set \ of \ choices. \ |
| 5462 |
\msg_see_documentation_text:n {cooking-units} |
| 5463 |
} |
| 5464 |
% \end{macrocode} |
| 5465 |
% Adding a message for unit-groups. |
| 5466 |
% \begin{macrocode} |
| 5467 |
\msg_new:nnnn { cooking-units } { group-choice-not-allowed } |
| 5468 |
{ |
| 5469 |
The \ group \ key \ '#1' \ accepts \ only \ |
| 5470 |
'#3' \ as \ a \ set \ of \ choices \ and \ '#2' \ is \ non \ of \ these. |
| 5471 |
}{ |
| 5472 |
The \ key \ accepts\ only \ a \ fixed \ set \ of \ choices. \ |
| 5473 |
You \ can \ add \ new \ choices \ via \ option \ 'add-unit-to-group'. |
| 5474 |
\msg_see_documentation_text:n {cooking-units} |
| 5475 |
} |
| 5476 |
% \end{macrocode} |
| 5477 |
% |
| 5478 |
%\changes {v0.98a} {2016/06/11} {New option: 'value-not-known'.} |
| 5479 |
%\changes {v0.99} {2016/06/12} {Renamed option: 'amount-not-known'.} |
| 5480 |
% An info message for unknown messages. |
| 5481 |
% \begin{macrocode} |
| 5482 |
\msg_new:nnnn { cooking-units } { amount-not-known } |
| 5483 |
{ |
| 5484 |
The \ amount \ '#1' \ is \ not \ known \ at \ line \ |
| 5485 |
\msg_line_number: . |
| 5486 |
}{ |
| 5487 |
You \ used\ a\ special\ sign\ indicating\ that\ the\ true\ amount\ of\ the\ |
| 5488 |
specific\ ingredient\ is\ (was) \ not\ known\ to\ you. This\ message\ |
| 5489 |
reminds\ you\ about\ that\ fact. |
| 5490 |
\msg_see_documentation_text:n {cooking-units} |
| 5491 |
} |
| 5492 |
% \end{macrocode} |
| 5493 |
% |
| 5494 |
% \begin{macrocode} |
| 5495 |
\msg_new:nnnn { cooking-units } { group-key-unknown } |
| 5496 |
{ |
| 5497 |
The \ group \ key \ '#1' \ is \ not \ defined. \ Perhaps |
| 5498 |
\ you \ misspelled \ it? |
| 5499 |
}{ |
| 5500 |
The \ group \ key \ is \ not \ defined. |
| 5501 |
\msg_see_documentation_text:n { cooking-units } |
| 5502 |
} |
| 5503 |
% \end{macrocode} |
| 5504 |
% |
| 5505 |
% If a load time option is not used as a package option, this |
| 5506 |
% message is shown. |
| 5507 |
% \begin{macrocode} |
| 5508 |
\msg_new:nnnn { cooking-units } { load-time-option } |
| 5509 |
{ |
| 5510 |
The \ option \ '#1' \ is \ only \ available \ as \ a \ load-time-option. \ |
| 5511 |
Please \ set \ it \ as \ a \ package \ option. |
| 5512 |
}{ |
| 5513 |
You \ cannot \ set \ this \ option \ using \ \cusetup ~ |
| 5514 |
but \ only \ as \ a \ package \ option. |
| 5515 |
\msg_see_documentation_text:n { cooking-units } |
| 5516 |
} |
| 5517 |
% \end{macrocode} |
| 5518 |
% |
| 5519 |
% Messages for obsolete commands. |
| 5520 |
% \begin{macrocode} |
| 5521 |
\msg_new:nnnn { cooking-units } { obsolete-command } |
| 5522 |
{ |
| 5523 |
Command \ #1 is \ obsolete. \ Please \ use \ #2 instead. |
| 5524 |
}{ |
| 5525 |
Don't \ use \ this \ old \ command \ ... |
| 5526 |
\msg_see_documentation_text:n { cooking-units } |
| 5527 |
} |
| 5528 |
% \end{macrocode} |
| 5529 |
% |
| 5530 |
% \begin{macrocode} |
| 5531 |
\msg_new:nnnn { cooking-units } { No-Value-given } |
| 5532 |
{ |
| 5533 |
Please \ input \ a \ value \ for \ the \ key-value \ list \ in \ '#1' |
| 5534 |
}{ |
| 5535 |
Each \ element \ of \ the \ list \ needs \ a \ value. |
| 5536 |
\msg_see_documentation_text:n { cooking-units } |
| 5537 |
} |
| 5538 |
% \end{macrocode} |
| 5539 |
% |
| 5540 |
% \begin{macrocode} |
| 5541 |
\msg_new:nnnn { cooking-units } { Adding-single-to-multi-key-or-vice-verca } |
| 5542 |
{ |
| 5543 |
You \ are \ trying \ to \ add \ a \ single-key \ to \ a \ multi-key \ |
| 5544 |
or \ vice-versa. |
| 5545 |
}{ |
| 5546 |
This \ is \ not \ allowed! |
| 5547 |
\msg_see_documentation_text:n { cooking-units } |
| 5548 |
} |
| 5549 |
% \end{macrocode} |
| 5550 |
% |
| 5551 |
% \begin{macrocode} |
| 5552 |
\msg_new:nnnn { cooking-units } { Value-not-allowed } |
| 5553 |
{ |
| 5554 |
The \ key-list \ in \ '#1' \ does \ not \ take \ a \ value. |
| 5555 |
}{ |
| 5556 |
This \ key-list \ does \ not \ take \ a \ value. \ The \ |
| 5557 |
given \ value \ will \ be \ ignored. |
| 5558 |
\msg_see_documentation_text:n { cooking-units } |
| 5559 |
} |
| 5560 |
% \end{macrocode} |
| 5561 |
% |
| 5562 |
% Error message if a zero-point temperature is already defined. |
| 5563 |
% \begin{macrocode} |
| 5564 |
\msg_new:nnnn { cooking-units } { Minimum-already-defined } |
| 5565 |
{ |
| 5566 |
A \ minimum \ for \ '#1' \ has \ already \ been \ defined. |
| 5567 |
}{ |
| 5568 |
You \ cannot \ redefine \ it. |
| 5569 |
\msg_see_documentation_text:n { cooking-units } |
| 5570 |
} |
| 5571 |
% \end{macrocode} |
| 5572 |
% |
| 5573 |
% Using the key version of \mycs{culabel} one needs to give the number of |
| 5574 |
% people the recipe is for after a \enquote{*}. |
| 5575 |
% \begin{macrocode} |
| 5576 |
\msg_new:nnnn { cooking-units } { Number-of-persons-missing } |
| 5577 |
{ |
| 5578 |
Please \ add \ the \ number \ of \ persons \ this \ recipe \ is \ for \ in \ '#1'. \ |
| 5579 |
Note \ that\ the \ number \ must \ be \ given \ after \ a \ '*'. |
| 5580 |
}{ |
| 5581 |
Write \ 'Schweinsbraten*4' \ to \ create \ the \ label \ 'Schweinsbraten' \ |
| 5582 |
which \ is \ initially \ for \ 4 \ persons. |
| 5583 |
\msg_see_documentation_text:n { cooking-units } |
| 5584 |
} |
| 5585 |
% \end{macrocode} |
| 5586 |
% |
| 5587 |
% The number of persons, must be an integer \dots\ |
| 5588 |
% \begin{macrocode} |
| 5589 |
\msg_new:nnnn { cooking-units } { Number-of-persons-is-not-an-integer } |
| 5590 |
{ |
| 5591 |
The \ number \ of \ persons \ the \ recipe \ is \ for \ must \ be \ an \ |
| 5592 |
integer. \ '#1' \ is \ not \ allowed. |
| 5593 |
}{ |
| 5594 |
The \ number \ '#1' \ is \ not \ allowed. |
| 5595 |
\msg_see_documentation_text:n { cooking-units } |
| 5596 |
} |
| 5597 |
% \end{macrocode} |
| 5598 |
% |
| 5599 |
% Each label defined by \mycs{culabel} needs to be new. |
| 5600 |
% \begin{macrocode} |
| 5601 |
\msg_new:nnnn { cooking-units } { label-already-defined } |
| 5602 |
{ |
| 5603 |
The \ label \ '#1' \ has \ already \ been \ defined. |
| 5604 |
}{ |
| 5605 |
Each \ label \ must \ be \ unique. |
| 5606 |
\msg_see_documentation_text:n { cooking-units } |
| 5607 |
} |
| 5608 |
% \end{macrocode} |
| 5609 |
% |
| 5610 |
% Message if a label is not defined. |
| 5611 |
% \begin{macrocode} |
| 5612 |
\msg_new:nnnn { cooking-units } { label-not-defined } |
| 5613 |
{ |
| 5614 |
The \ label \ '#1' \ is \ not \ defined. \ Please \ note \ that \ a \ label |
| 5615 |
\ has \ to \ defined \ before \ it \ is \ referenced. |
| 5616 |
}{ |
| 5617 |
Define \ the \ label \ before \ using \ it. |
| 5618 |
\msg_see_documentation_text:n { cooking-units } |
| 5619 |
} |
| 5620 |
% \end{macrocode} |
| 5621 |
% |
| 5622 |
% If an unit is already defined and redefined by an \mycs{declarecookingunit}. |
| 5623 |
% \begin{macrocode} |
| 5624 |
\msg_new:nnnn { cooking-units } { redefine-unit } |
| 5625 |
{ |
| 5626 |
The \ unit \ '#1' \ is \ redefined \ by \ \declarecookingunit ~ at \ |
| 5627 |
\msg_line_context: . |
| 5628 |
}{ |
| 5629 |
\msg_see_documentation_text:n { cooking-units } |
| 5630 |
} |
| 5631 |
% \end{macrocode} |
| 5632 |
% |
| 5633 |
% A \enquote{phrase} must be an integer. |
| 5634 |
% \begin{macrocode} |
| 5635 |
\msg_new:nnnn { cooking-units } { phrase-unit-not-an-integer } |
| 5636 |
{ |
| 5637 |
A \ phrase \ must \ be \ an \ integer, \ '#1' \ is \ not \ allowed. |
| 5638 |
}{ |
| 5639 |
You \ can \ only \ use \ integers. |
| 5640 |
\msg_see_documentation_text:n { cooking-units } |
| 5641 |
} |
| 5642 |
% \end{macrocode} |
| 5643 |
% |
| 5644 |
% A translation for \cs{cutext} or \cs{Cutext} is not available. For this case |
| 5645 |
% -- instead of printing the key-name (see \pkg{translations}) -- we fall back |
| 5646 |
% to \cs{cunum}. |
| 5647 |
% \begin{macrocode} |
| 5648 |
\msg_new:nnnn { cooking-units } { cutext-no-translation-available } |
| 5649 |
{ |
| 5650 |
For \ the \ unit \ '#1' \ there \ exists \ no \ translation \ to \ be \ used \ |
| 5651 |
for \ \cutext ~ and \ \token_to_str:N \Cutext. \ |
| 5652 |
You \ can \ define \ new \ translations \ for \ a \ given \ language \ using \ |
| 5653 |
\cudefinename. |
| 5654 |
}{ |
| 5655 |
\cunum ~ is \ used \ instead. |
| 5656 |
\msg_see_documentation_text:n { cooking-units } |
| 5657 |
} |
| 5658 |
% \end{macrocode} |
| 5659 |
% |
| 5660 |
% |
| 5661 |
% \begin{macrocode} |
| 5662 |
\msg_new:nnnn { cooking-units } { Translation-not-available } |
| 5663 |
{ |
| 5664 |
The \ translation \ for \ #1 \ does \ not \ exist. |
| 5665 |
Please \ define \ it \ using \ \token_to_str:N\cudefinename. |
| 5666 |
}{ |
| 5667 |
And \ you \ may \ send \ me \ the \ translation \ as \ it \ is \ |
| 5668 |
not \ available \ yet. |
| 5669 |
\msg_see_documentation_text:n { cooking-units } |
| 5670 |
} |
| 5671 |
% \end{macrocode} |
| 5672 |
% |
| 5673 |
% \begin{macrocode} |
| 5674 |
\msg_new:nnnn { cooking-units } { formula-in-non-singlekeys } |
| 5675 |
{ |
| 5676 |
The \ conversion \ value \ '#1' \ seems \ to \ be \ a \ formula. \ |
| 5677 |
This \ is \ not \ allowed \ for \ NON-\ singlekeys! |
| 5678 |
}{ |
| 5679 |
\msg_see_documentation_text:n { cooking-units } |
| 5680 |
} |
| 5681 |
% \end{macrocode} |
| 5682 |
% |
| 5683 |
% |
| 5684 |
% \begin{macrocode} |
| 5685 |
\msg_new:nnnn { cooking-units } { <-not-allowed-as-special-sign } |
| 5686 |
{ |
| 5687 |
Currently \ (and \ probably \ forever) \ the \ sign \ '<' \ |
| 5688 |
is \ not \ allowed \ to \ be \ used \ as \ a \ special \ sign. |
| 5689 |
}{ |
| 5690 |
I \ apologize \ for \ the \ inconvenience. |
| 5691 |
\msg_see_documentation_text:n { cooking-units } |
| 5692 |
} |
| 5693 |
% \end{macrocode} |
| 5694 |
% |
| 5695 |
% |
| 5696 |
% \begin{macrocode} |
| 5697 |
\msg_new:nnnn { cooking-units } { unknown-gender } |
| 5698 |
{ |
| 5699 |
'#1' \ is \ not \ allowed \ to \ be \ used \ as \ a \ gender-specification. |
| 5700 |
Only \ 'm', \ 'f' \ or \ 'n' \ are \ allowed. |
| 5701 |
}{ |
| 5702 |
Please \ remove \ spaces \ if \ there \ are \ some. |
| 5703 |
\msg_see_documentation_text:n { cooking-units } |
| 5704 |
} |
| 5705 |
% \end{macrocode} |
| 5706 |
% |
| 5707 |
% |
| 5708 |
% \begin{macrocode} |
| 5709 |
\msg_new:nnnn { cooking-units } { no-natural-unit-known } |
| 5710 |
{ |
| 5711 |
It \ seems\ that \ I \ cannot \ convert \ '#1' \ in \ a \ natural \ |
| 5712 |
unit \ as \ there \ is \ no \ conversion-factor \ defined. |
| 5713 |
}{ |
| 5714 |
Not \ converting \ the \unit. |
| 5715 |
\msg_see_documentation_text:n { cooking-units } |
| 5716 |
} |
| 5717 |
% \end{macrocode} |
| 5718 |
% |
| 5719 |
% |
| 5720 |
% \begin{macrocode} |
| 5721 |
\msg_new:nnnn { cooking-units } { curef-not-inside-list } |
| 5722 |
{ |
| 5723 |
'#1' \ cannot \ be \ removed \ from \ the \ 'forbidden \ unit' \ list \ because |
| 5724 |
\ it \ is \ not \ inside \ the \ list. |
| 5725 |
}{ |
| 5726 |
Currently \ the \ list\ contains \ '#2'. |
| 5727 |
\msg_see_documentation_text:n { cooking-units } |
| 5728 |
} |
| 5729 |
% \end{macrocode} |
| 5730 |
% |
| 5731 |
% |
| 5732 |
% \begin{macrocode} |
| 5733 |
\msg_new:nnnn { cooking-units } { curef-forbidden-unit } |
| 5734 |
{ |
| 5735 |
The \ amount \ of \ '#1' \ cannot \ be \ changed \ using \ cooking-units` |
| 5736 |
\ label \ and \ ref \ feature. |
| 5737 |
}{ |
| 5738 |
You \ can \ remove \ the \ unit \ using \ 'curef-remove-forbidden-unit'. |
| 5739 |
\msg_see_documentation_text:n { cooking-units } |
| 5740 |
} |
| 5741 |
% \end{macrocode} |
| 5742 |
% |
| 5743 |
% \begin{macrocode} |
| 5744 |
\msg_new:nnnn { cooking-units } { define-numeral-function } |
| 5745 |
{ |
| 5746 |
You \ are \ using \ numerals \ (lowercase) \ without \ the \ load-time \ option \ |
| 5747 |
'use-fmtcount-numerals' \ as \ such \ you \ need \ to \ define \ |
| 5748 |
which \ function \ is \ to \ be \ used \ for \ numerals. \ You \ can |
| 5749 |
\ do \ that \ via \ 'numeral-function' \ and \ 'Numeral-function' |
| 5750 |
}{ |
| 5751 |
Please \ specify\ which \ function \ should \ be \ used \ to \ print \ |
| 5752 |
numerals (lowercase \ and \ uppercase). |
| 5753 |
\msg_see_documentation_text:n { cooking-units } |
| 5754 |
} |
| 5755 |
\msg_new:nnnn { cooking-units } { define-Numeral-function } |
| 5756 |
{ |
| 5757 |
You \ are \ using \ numerals \ (capitalized) \ without \ the \ load-time \ option \ |
| 5758 |
'use-fmtcount-numerals' \ as \ such \ you \ need \ to \ define \ |
| 5759 |
which \ function \ is \ to \ be \ used \ for \ numerals. \ You \ can |
| 5760 |
\ do \ that \ via \ 'numeral-function' \ and \ 'Numeral-function' |
| 5761 |
}{ |
| 5762 |
Please \ specify\ which \ function \ should \ be \ used \ to \ print \ |
| 5763 |
numerals (lowercase \ and \ uppercase). |
| 5764 |
\msg_see_documentation_text:n { cooking-units } |
| 5765 |
} |
| 5766 |
% \end{macrocode} |
| 5767 |
% |
| 5768 |
% \begin{macrocode} |
| 5769 |
\msg_new:nnnn { cooking-units } { 42-is-...-wrong? } |
| 5770 |
{ |
| 5771 |
You \ requested \ to \ set \ 42 \ to \ 'false'. \ This \ doesn't \ make |
| 5772 |
\ any \ sense! \ It \ cannot \ be \ 'false', \ it \ is \ the \ answer \ to \ the |
| 5773 |
\ question \ of \ life, \ universe \ and \ everything. \ For \ the \ sake \ of \ |
| 5774 |
the \ world \ I \ cannot \ allow \ you \ to \ set \ it \ to \ 'false', \ the \ universe |
| 5775 |
\ might \ explode \ otherwise. \\ |
| 5776 |
The \ run \ will \ be \ aborted. |
| 5777 |
}{ |
| 5778 |
Phew ... \ this \ might \ have \ ended \ disastrous. |
| 5779 |
\msg_see_documentation_text:n { cooking-units } |
| 5780 |
} |
| 5781 |
% \end{macrocode} |
| 5782 |
% |
| 5783 |
% |
| 5784 |
% \begin{macrocode} |
| 5785 |
\msg_new:nnnn { cooking-units } { empty-amount } |
| 5786 |
{ |
| 5787 |
The \ amount \ given \ is \ empty \ ( spaces \ are \ removed ). |
| 5788 |
}{ |
| 5789 |
The \ amount \ given \ is \ empty. |
| 5790 |
\msg_see_documentation_text:n { cooking-units } |
| 5791 |
} |
| 5792 |
% |
| 5793 |
\msg_new:nnnn { cooking-units } { unknown-unit-option } |
| 5794 |
{ |
| 5795 |
The \ unit-option \ '#1' \ is \ not \ defined. |
| 5796 |
}{ |
| 5797 |
Please \ define \ the \ key \ '#1' \ via \ \newcukeysadd \ and \ friends. |
| 5798 |
\msg_see_documentation_text:n { cooking-units } |
| 5799 |
} |
| 5800 |
\msg_new:nnnn { cooking-units } { unknown-option } |
| 5801 |
{ |
| 5802 |
The \ option \ '#1' \ is \ not \ defined. |
| 5803 |
}{ |
| 5804 |
Perhaps \ you \ misspelled \ the \ option. |
| 5805 |
\msg_see_documentation_text:n { cooking-units } |
| 5806 |
} |
| 5807 |
\msg_new:nnnn { cooking-units } { unknown-choice } |
| 5808 |
{ |
| 5809 |
The \ choice \ '#2' \ for \ key \ '#1' \ is \ not \ defined. |
| 5810 |
}{ |
| 5811 |
Perhaps \ you \ misspelled \ the \ choice. |
| 5812 |
\msg_see_documentation_text:n { cooking-units } |
| 5813 |
} |
| 5814 |
% \end{macrocode} |
| 5815 |
% |
| 5816 |
% |
| 5817 |
% \begin{macrocode} |
| 5818 |
\msg_new:nnnn { cooking-units } { internal-error } |
| 5819 |
{ |
| 5820 |
This \ error \ shouldn't \ show. \ This \ means \ I |
| 5821 |
\ (the \ package \ author) \ screwed |
| 5822 |
\ up. \ The \ error \ code \ is \ '#1'. \ |
| 5823 |
Addition \ is \ '#2'. |
| 5824 |
}{ |
| 5825 |
Please \ send \ me \ a \ bug \ report. |
| 5826 |
\msg_see_documentation_text:n { cooking-units } |
| 5827 |
} |
| 5828 |
% \end{macrocode} |
| 5829 |
% |
| 5830 |
% |
| 5831 |
% \begin{macrocode} |
| 5832 |
\msg_new:nnnn { cooking-units } { definition-key-mistyped? } |
| 5833 |
{ |
| 5834 |
This \ message \ shows \ during \ the \ definition \ of \ unit-keys. \ |
| 5835 |
You \ may \ have \ mistyped \ the \ key \ '#1'. \ You \ may \ see \ |
| 5836 |
this \ message \ because \ you \ have \ used \ a \ '=' \ sign \ in \ the \ |
| 5837 |
optional \ argument. \ If \ this \ is \ the \ case \ and \ you \ still \ want |
| 5838 |
\ to \ use \ '=' \ in \ a \ symbol, \ please \ wrap \ the \ symbol |
| 5839 |
\ in \ two \ braces: \ {{#1=#2}}. |
| 5840 |
}{ |
| 5841 |
Or \ try \ using \ the \ 'symbol' \ option. |
| 5842 |
\msg_see_documentation_text:n { cooking-units } |
| 5843 |
} |
| 5844 |
% \end{macrocode} |
| 5845 |
% \end{macro} |
| 5846 |
% |
| 5847 |
% \section {Helper Macros} |
| 5848 |
% |
| 5849 |
% The name says it all. |
| 5850 |
% |
| 5851 |
% |
| 5852 |
% |
| 5853 |
% |
| 5854 |
%\begin{macro} |
| 5855 |
% { |
| 5856 |
% \@@_if_unit_defined:nN, |
| 5857 |
% \@@_error_if_unit_not_defined:nNTF, |
| 5858 |
% \@@_error_if_unit_not_defined:nTF, |
| 5859 |
% \@@_error_if_unit_not_defined:VTF, |
| 5860 |
% } |
| 5861 |
% A little helper macro. Checks if the unit is defined, if not raise an error. |
| 5862 |
% \begin{macrocode} |
| 5863 |
\prg_new_protected_conditional:Npnn \@@_if_unit_defined:nN #1 #2 { TF , T } |
| 5864 |
{ |
| 5865 |
\@@_set_unit:Nn #2 {#1} |
| 5866 |
\seq_if_in:NVTF \g_@@_list_of_defined_units_seq #2 |
| 5867 |
{ \prg_return_true: } |
| 5868 |
{ \prg_return_false: } |
| 5869 |
} |
| 5870 |
\prg_new_protected_conditional:Npnn \@@_error_if_unit_not_defined:nN #1#2 { TF, T, F } |
| 5871 |
{ |
| 5872 |
\@@_if_unit_defined:nNTF {#1} #2 |
| 5873 |
{ \prg_return_false: } |
| 5874 |
{ |
| 5875 |
\msg_error:nnn { cooking-units } { unknown-unit } {#1} |
| 5876 |
\prg_return_true: |
| 5877 |
} |
| 5878 |
} |
| 5879 |
\prg_new_protected_conditional:Npnn \@@_error_if_unit_not_defined:n #1 { TF, T, F } |
| 5880 |
{ |
| 5881 |
\@@_error_if_unit_not_defined:nNTF {#1} \l_@@_scrap_tl |
| 5882 |
{ \prg_return_true: } |
| 5883 |
{ \prg_return_false: } |
| 5884 |
} |
| 5885 |
\cs_generate_variant:Nn \@@_error_if_unit_not_defined:nTF { V } |
| 5886 |
% \end{macrocode} |
| 5887 |
%\end{macro} |
| 5888 |
% |
| 5889 |
% |
| 5890 |
% |
| 5891 |
% \begin{macro} { \@@_if_unit_has_a_key:n, \@@_if_unit_has_a_key:V } |
| 5892 |
% A little helper macro. Checks if the unit is defined, if not raise an error. |
| 5893 |
% \begin{macrocode} |
| 5894 |
\prg_new_protected_conditional:Npnn \@@_if_unit_has_a_key:n #1 { T , F, TF } |
| 5895 |
{ |
| 5896 |
\keys_if_exist:nnTF { cooking-units } {#1} |
| 5897 |
{ \prg_return_true: } |
| 5898 |
{ \prg_return_false: } |
| 5899 |
} |
| 5900 |
\prg_generate_conditional_variant:Nnn \@@_if_unit_has_a_key:n { V } { T, TF } |
| 5901 |
% \end{macrocode} |
| 5902 |
%\end{macro} |
| 5903 |
% |
| 5904 |
% |
| 5905 |
% \begin{macro} { \@@_seq_use_msg:N, \@@_seq_use_msg:c } |
| 5906 |
% Used in error messages for units. Prints the units in a comma-seperated list. |
| 5907 |
% \begin{macrocode} |
| 5908 |
\cs_new:Npn \@@_seq_use_msg:N #1 |
| 5909 |
{ \seq_use:Nnnn #1 { ' , ~ ' } { ' , ~ ' } { ' ~ and ~ ' } } |
| 5910 |
\cs_generate_variant:Nn \@@_seq_use_msg:N { c } |
| 5911 |
% \end{macrocode} |
| 5912 |
% \end{macro} |
| 5913 |
% |
| 5914 |
% |
| 5915 |
% \begin{macro}{ \@@_if_integer:n , \@@_if_integer:V , \@@_if_evaluation_is_integer:nN } |
| 5916 |
% Checking if the input consists only of numbers; or only of numbers and |
| 5917 |
% the allowed math operators |
| 5918 |
% \begin{macrocode} |
| 5919 |
\prg_new_protected_conditional:Npnn \@@_if_integer:n #1 { TF , F } |
| 5920 |
{ |
| 5921 |
\tl_map_inline:nn {#1} |
| 5922 |
{ |
| 5923 |
\tl_if_in:NnF \l_@@_input_digits_tl {##1} |
| 5924 |
{ |
| 5925 |
\tl_map_break:n { \use_i:nn \prg_return_false: } |
| 5926 |
} |
| 5927 |
} |
| 5928 |
\prg_return_true: |
| 5929 |
} |
| 5930 |
\cs_generate_variant:Nn \@@_if_integer:nTF { V } |
| 5931 |
\prg_new_protected_conditional:Npnn \@@_if_evaluation_is_integer:n #1 { TF , T , F } |
| 5932 |
{ |
| 5933 |
\tl_concat:NNN \l_@@_tmpa_tl |
| 5934 |
\l_@@_input_digits_tl \l_@@_allwed_integer_math_operators_tl |
| 5935 |
\tl_map_inline:nn {#1} |
| 5936 |
{ |
| 5937 |
\tl_if_in:NnF \l_@@_tmpa_tl {##1} |
| 5938 |
{ \tl_map_break:n { \use_iii:nnn } } |
| 5939 |
} |
| 5940 |
\use_i:nn |
| 5941 |
{ \prg_return_true: } |
| 5942 |
{ \prg_return_false: } |
| 5943 |
} |
| 5944 |
% \end{macrocode} |
| 5945 |
% \end{macro} |
| 5946 |
% |
| 5947 |
% |
| 5948 |
% |
| 5949 |
% \begin{macro}{ \@@_if_integers:NNTF } |
| 5950 |
% Checking if the input consists only of numbers, which works correctly for ranges. |
| 5951 |
% \begin{macrocode} |
| 5952 |
\prg_new_conditional:Npnn \@@_if_integers:NN #1#2 { TF } |
| 5953 |
{ |
| 5954 |
\@@_if_integer:VTF #1 |
| 5955 |
{ |
| 5956 |
\@@_if_print_type_equal:nTF { range } |
| 5957 |
{ |
| 5958 |
\@@_if_integer:VTF #2 |
| 5959 |
{ \prg_return_true: } |
| 5960 |
{ \prg_return_false: } |
| 5961 |
} |
| 5962 |
{ \prg_return_true: } |
| 5963 |
} |
| 5964 |
{ \prg_return_false: } |
| 5965 |
} |
| 5966 |
% \end{macrocode} |
| 5967 |
% \end{macro} |
| 5968 |
% |
| 5969 |
% |
| 5970 |
% \begin{macro}{ \@@_if_contains_decimal:NTF , \@@_check_for_decimal:w } |
| 5971 |
% A fast check if |#1| contains a decimal point. This is only |
| 5972 |
% used for already parsed input, so the input is already safe to check. |
| 5973 |
% |
| 5974 |
% If |#1| does not contain a decimal point, |\@@_check_for_decimal:w| |
| 5975 |
% |#2| is equal to |\q_nil|, the test is true and the false branch is executed. |
| 5976 |
% |
| 5977 |
% If |#1| does contain a decimal point, |#2| is going equal to |<...>.\q_nil| |
| 5978 |
% where |<...>| is the stuff after the decimal point. The test is false, thus the |
| 5979 |
% true branch is ignored (ignoring all other tokens in |#2|). |
| 5980 |
% \begin{macrocode} |
| 5981 |
\prg_new_conditional:Npnn \@@_if_contains_decimal:N #1 { TF } |
| 5982 |
{ |
| 5983 |
\exp_after:wN \@@_check_for_decimal:w #1 . \q_nil . \q_stop |
| 5984 |
} |
| 5985 |
\cs_new:Npn \@@_check_for_decimal:w #1 . #2 . \q_stop |
| 5986 |
{ |
| 5987 |
\if_meaning:w \q_nil #2 |
| 5988 |
\exp_after:wN \prg_return_false: |
| 5989 |
\else: |
| 5990 |
\exp_after:wN \prg_return_true: |
| 5991 |
\fi: |
| 5992 |
} |
| 5993 |
% \end{macrocode} |
| 5994 |
% \end{macro} |
| 5995 |
% \begin{macro}{\@@_if_contain_decimals:NNTF} |
| 5996 |
% Same as |\@@_if_integers:NNTF| only for decimal points. |
| 5997 |
% \begin{macrocode} |
| 5998 |
\prg_new_conditional:Npnn \@@_if_contain_decimals:NN #1#2 { TF } |
| 5999 |
{ |
| 6000 |
\@@_if_contains_decimal:NTF #1 |
| 6001 |
{ \prg_return_true: } |
| 6002 |
{ |
| 6003 |
\@@_if_print_type_equal:nTF { range } |
| 6004 |
{ |
| 6005 |
\@@_if_contains_decimal:NTF #2 |
| 6006 |
{ \prg_return_true: } |
| 6007 |
{ \prg_return_false: } |
| 6008 |
} |
| 6009 |
{ \prg_return_false: } |
| 6010 |
} |
| 6011 |
} |
| 6012 |
% \end{macrocode} |
| 6013 |
% \end{macro} |
| 6014 |
% |
| 6015 |
% |
| 6016 |
% |
| 6017 |
% |
| 6018 |
% |
| 6019 |
% |
| 6020 |
% \begin{macro}{ \@@_if_gender_error:n } |
| 6021 |
% \begin{macrocode} |
| 6022 |
\prg_new_conditional:Npnn \@@_if_gender_error:n #1 { TF, F , T } |
| 6023 |
{ |
| 6024 |
\str_case:nnTF {#1} |
| 6025 |
{ |
| 6026 |
{ m } { } |
| 6027 |
{ f } { } |
| 6028 |
{ n } { } |
| 6029 |
} |
| 6030 |
{ \prg_return_false: } |
| 6031 |
{ |
| 6032 |
\msg_error:nnn { cooking-units } { unknown-gender } {#1} |
| 6033 |
\prg_return_true: |
| 6034 |
} |
| 6035 |
} |
| 6036 |
% \end{macrocode} |
| 6037 |
% \end{macro} |
| 6038 |
% |
| 6039 |
% |
| 6040 |
% |
| 6041 |
% |
| 6042 |
% |
| 6043 |
% |
| 6044 |
% \begin{macro}{\@@_error_if_group_not_defined:nN, \@@_error_if_group_not_defined:n} |
| 6045 |
% \begin{macrocode} |
| 6046 |
\prg_new_conditional:Npnn \@@_error_if_group_not_defined:nN #1#2 { F, T , TF } |
| 6047 |
{ |
| 6048 |
\@@_set_unit:Nn #2 {#1} |
| 6049 |
\seq_if_exist:cTF { l_@@_group_ #2 _seq } |
| 6050 |
{ \prg_return_false: } |
| 6051 |
{ |
| 6052 |
\msg_error:nn { cooking-units} { group-key-unknown } |
| 6053 |
\prg_return_true: |
| 6054 |
} |
| 6055 |
} |
| 6056 |
\prg_new_conditional:Npnn \@@_error_if_group_not_defined:n #1 { F } |
| 6057 |
{ |
| 6058 |
\seq_if_exist:cTF { l_@@_group_ \@@_to_unit:n {#1} _seq } |
| 6059 |
{ \prg_return_false: } |
| 6060 |
{ |
| 6061 |
\msg_error:nn { cooking-units} { group-key-unknown } |
| 6062 |
\prg_return_true: |
| 6063 |
} |
| 6064 |
} |
| 6065 |
% \end{macrocode} |
| 6066 |
% \end{macro} |
| 6067 |
% |
| 6068 |
% |
| 6069 |
% |
| 6070 |
% \begin{macro}{\@@_define_clear_unit_group:n} |
| 6071 |
% \begin{macrocode} |
| 6072 |
\cs_new:Npn \@@_define_clear_unit_group:n #1 |
| 6073 |
{ |
| 6074 |
\@@_set_unit:Nn \l_@@_tmpa_tl {#1} |
| 6075 |
\seq_clear_new:c { l_@@_group_ \l_@@_tmpa_tl _seq } |
| 6076 |
\keys_define:nn { cooking-units } |
| 6077 |
{ |
| 6078 |
#1 .code:n = { \@@_unit_group_convert_units:nn {#1} {##1} } , |
| 6079 |
#1 .groups:n = { change-unit } , |
| 6080 |
} |
| 6081 |
} |
| 6082 |
% \end{macrocode} |
| 6083 |
% \end{macro} |
| 6084 |
% |
| 6085 |
% |
| 6086 |
% \begin{macro}{\@@_unit_group_convert_units:nn} |
| 6087 |
% \begin{macrocode} |
| 6088 |
\cs_new:Npn \@@_unit_group_convert_units:nn #1#2 |
| 6089 |
{ |
| 6090 |
\bool_set_true:N \l_@@_tmpa_bool |
| 6091 |
\@@_error_if_group_not_defined:nNT {#1} \l_@@_curr_group_tl |
| 6092 |
{ \bool_set_false:N \l_@@_tmpa_bool } |
| 6093 |
\@@_error_if_unit_not_defined:nNT {#2} \l_@@_curr_unit_tl |
| 6094 |
{ \bool_set_false:N \l_@@_tmpa_bool } |
| 6095 |
\bool_if:NT \l_@@_tmpa_bool |
| 6096 |
{ |
| 6097 |
\seq_if_in:cVTF { l_@@_group_ \l_@@_curr_group_tl _seq } \l_@@_curr_unit_tl |
| 6098 |
{ |
| 6099 |
\seq_map_inline:cn { l_@@_group_ \l_@@_curr_group_tl _seq } |
| 6100 |
{ \@@_keys_set:nnn { cooking-units } {##1} {#2} } |
| 6101 |
}{ |
| 6102 |
\msg_error:nnxxx |
| 6103 |
{ cooking-units } |
| 6104 |
{ group-choice-not-allowed } |
| 6105 |
{ \l_@@_curr_group_tl } { \l_@@_curr_unit_tl } |
| 6106 |
{ \@@_seq_use_msg:c { l_@@_group_ \l_@@_curr_group_tl _seq } } |
| 6107 |
} |
| 6108 |
} |
| 6109 |
} |
| 6110 |
% \end{macrocode} |
| 6111 |
% \end{macro} |
| 6112 |
% |
| 6113 |
% |
| 6114 |
% |
| 6115 |
% \begin{macro}{\@@_add_to_unit_group_error:n , \@@_add_to_unit_group:nn } |
| 6116 |
% \begin{macrocode} |
| 6117 |
\cs_new:Npn \@@_add_to_unit_group_error:n #1 |
| 6118 |
{ \msg_error:nnn { cooking-units } { No-Value-given } { add-unit-to-group } } |
| 6119 |
% \end{macrocode} |
| 6120 |
% \begin{macrocode} |
| 6121 |
\cs_new:Npn \@@_add_to_unit_group:nn #1#2 |
| 6122 |
{ |
| 6123 |
\@@_error_if_group_not_defined:nNF {#1} \l_@@_curr_group_tl |
| 6124 |
{ |
| 6125 |
\clist_map_inline:nn {#2} |
| 6126 |
{ |
| 6127 |
\@@_error_if_unit_not_defined:nNF {##1} \l_@@_curr_unit_tl |
| 6128 |
{ |
| 6129 |
\seq_if_in:cVF { l_@@_group_ \l_@@_curr_group_tl _seq } \l_@@_curr_unit_tl |
| 6130 |
{ |
| 6131 |
\seq_put_right:cV |
| 6132 |
{ l_@@_group_ \l_@@_curr_group_tl _seq } |
| 6133 |
\l_@@_curr_unit_tl |
| 6134 |
} |
| 6135 |
} |
| 6136 |
} |
| 6137 |
} |
| 6138 |
} |
| 6139 |
\cs_generate_variant:Nn \@@_add_to_unit_group:nn { nV } |
| 6140 |
% \end{macrocode} |
| 6141 |
% \end{macro} |
| 6142 |
% |
| 6143 |
% |
| 6144 |
% |
| 6145 |
% |
| 6146 |
% \begin{macro}{\@@_convert_to_eV:} |
| 6147 |
% Still work in progress. Will probably forever be. Changes all |
| 6148 |
% predefined units into natural units (except for those who cannot |
| 6149 |
% be changed, like |Msp.| for example). |
| 6150 |
% |
| 6151 |
% \begin{macrocode} |
| 6152 |
\cs_new:Npn \@@_seq_get_overlap:NNTF #1#2 #3#4 |
| 6153 |
{ |
| 6154 |
\seq_map_inline:Nn #1 |
| 6155 |
{ |
| 6156 |
\seq_if_in:NnT #2 {##1} |
| 6157 |
{ #3 \seq_map_break:n { \use_none:nn } } |
| 6158 |
} |
| 6159 |
\use:n {#4} |
| 6160 |
} |
| 6161 |
% \end{macrocode} |
| 6162 |
% \begin{macrocode} |
| 6163 |
\cs_new:Npn \@@_keys_set:nnn #1#2#3 |
| 6164 |
{ \keys_set:nn {#1} { #2 = #3 } } |
| 6165 |
\cs_generate_variant:Nn \@@_keys_set:nnn { nVV , nVn } |
| 6166 |
% \end{macrocode} |
| 6167 |
% \begin{macrocode} |
| 6168 |
\cs_new:Npn \@@_convert_to_eV:N #1 |
| 6169 |
{ |
| 6170 |
\prop_get:NVNTF \g_@@_convert_to_eV_remember_prop |
| 6171 |
#1 \l_@@_tmpa_tl |
| 6172 |
{ \@@_keys_set:nVV { cooking-units } #1 \l_@@_tmpa_tl } |
| 6173 |
{ |
| 6174 |
% #1 is already a string |
| 6175 |
\@@_if_unit_has_a_key:VTF #1 |
| 6176 |
{ |
| 6177 |
\tl_set_eq:Nc \l_@@_tmp_unit_tl { l_@@_base_key_unit_ #1 _tl } |
| 6178 |
\prop_get:cnNT { l_@@_rf_cukeys_ \l_@@_tmp_unit_tl _prop } |
| 6179 |
{ Liste } \l_@@_tmpa_seq |
| 6180 |
{ |
| 6181 |
\@@_seq_get_overlap:NNTF \g_@@_natural_units_seq \l_@@_tmpa_seq |
| 6182 |
{ |
| 6183 |
\prop_gput:NVn \g_@@_convert_to_eV_remember_prop #1 {##1} |
| 6184 |
\@@_keys_set:nVn { cooking-units } #1 {##1} |
| 6185 |
} |
| 6186 |
{ \msg_warning:nnx { cooking-units } { no-natural-unit-known } {#1} } |
| 6187 |
} |
| 6188 |
} |
| 6189 |
{ \msg_warning:nnx { cooking-units } { Key-not-defined } {#1} } |
| 6190 |
} |
| 6191 |
} |
| 6192 |
% \end{macrocode} |
| 6193 |
%\end{macro} |
| 6194 |
% |
| 6195 |
% \begin{macrocode} |
| 6196 |
\cs_new:Npn \@@_changing_unit_bonkers:N #1 |
| 6197 |
{ |
| 6198 |
\prop_get:NVNTF \g_@@_convert_bonkers_remember_prop |
| 6199 |
#1 \l_@@_tmpa_tl |
| 6200 |
{ \@@_keys_set:nVV { cooking-units } #1 \l_@@_tmpa_tl } |
| 6201 |
{ |
| 6202 |
\tl_case:NnF \l_@@_bonkers_state_tl |
| 6203 |
{ |
| 6204 |
\c_@@_bonkers_state_going_tl { \@@_convert_going_bonkers:N #1 } |
| 6205 |
\c_@@_bonkers_state_fully_tl { \@@_convert_fully_bonkers:N #1 } |
| 6206 |
\c_@@_bonkers_state_xD_tl { \@@_convert_xD_bonkers:N #1 } |
| 6207 |
} |
| 6208 |
{ \@@_create_internal_error:nN { going-bonkers } \l_@@_bonkers_state_tl } |
| 6209 |
} |
| 6210 |
} |
| 6211 |
\cs_new:Npn \@@_convert_going_bonkers:N #1 |
| 6212 |
{ |
| 6213 |
\@@_if_unit_has_a_key:VT #1 |
| 6214 |
{ |
| 6215 |
\@@_prepare_going_bonkers:N #1 |
| 6216 |
\keys_set:nn { cooking-units } { eval-fraction = true } |
| 6217 |
\@@_keys_set:nVV { cooking-units } #1 \l_@@_tmpa_tl |
| 6218 |
\prop_gput:NVV \g_@@_convert_bonkers_remember_prop #1 \l_@@_tmpa_tl |
| 6219 |
} |
| 6220 |
} |
| 6221 |
\cs_new:Npn \@@_convert_fully_bonkers:N #1 |
| 6222 |
{ |
| 6223 |
\@@_if_unit_has_a_key:VT #1 |
| 6224 |
{ |
| 6225 |
\@@_prepare_going_bonkers:N #1 |
| 6226 |
\keys_set:nn { cooking-units } |
| 6227 |
{ eval-fraction = true , curef-clear-forbidden-units = true } |
| 6228 |
\prop_put:NVV \l_@@_change_unit_prop {#1} \l_@@_tmpa_tl |
| 6229 |
\@@_cukeys_calculate_change_value:VVV #1 \l_@@_tmpa_tl \l_@@_tmp_unit_tl |
| 6230 |
} |
| 6231 |
} |
| 6232 |
\cs_new:Npn \@@_prepare_going_bonkers:N #1 |
| 6233 |
{ |
| 6234 |
\tl_set_eq:Nc \l_@@_tmp_unit_tl { l_@@_base_key_unit_ #1 _tl } |
| 6235 |
\prop_get:cnN { l_@@_rf_cukeys_ \l_@@_tmp_unit_tl _prop } { Liste } \l_@@_tmpa_seq |
| 6236 |
\bool_set_false:N \l_@@_tmpa_bool |
| 6237 |
\bool_until_do:Nn \l_@@_tmpa_bool |
| 6238 |
{ |
| 6239 |
\tl_set:Nf \l_@@_tmpa_tl { \seq_rand_item:N \l_@@_tmpa_seq } |
| 6240 |
\seq_if_in:NVF \g_@@_natural_units_seq \l_@@_tmpa_tl |
| 6241 |
{ \bool_set_true:N \l_@@_tmpa_bool } |
| 6242 |
} |
| 6243 |
} |
| 6244 |
\cs_new:Npn \@@_convert_xD_bonkers:N #1 |
| 6245 |
{ |
| 6246 |
\keys_set:nn { cooking-units } { eval-fraction = true , curef-clear-forbidden-units = true } |
| 6247 |
\bool_set_false:N \l_@@_tmpa_bool |
| 6248 |
\bool_until_do:Nn \l_@@_tmpa_bool |
| 6249 |
{ |
| 6250 |
\tl_set:Nx \l_@@_tmpa_tl { \seq_rand_item:N \g_@@_list_of_defined_units_seq } |
| 6251 |
\@@_if_no_unit_marker:NF \l_@@_tmpa_tl |
| 6252 |
{ \bool_set_true:N \l_@@_tmpa_bool } |
| 6253 |
} |
| 6254 |
\prop_put:NVV \l_@@_change_unit_prop {#1} \l_@@_tmpa_tl |
| 6255 |
\tl_set:cf { l_@@_unit_change_ #1 _tl } { \fp_eval:n { rand() * randint(255) } } |
| 6256 |
} |
| 6257 |
% \end{macrocode} |
| 6258 |
% |
| 6259 |
% |
| 6260 |
% |
| 6261 |
% \begin{macro}{\@@_tl_set_eval:Nn} |
| 6262 |
% I am using this construction often enough, so \dots\ yeah. |
| 6263 |
% \begin{macrocode} |
| 6264 |
\cs_new:Npn \@@_tl_set_eval:Nn #1#2 { \tl_set:Nf #1 { \fp_eval:n {#2} } } |
| 6265 |
\cs_generate_variant:Nn \@@_tl_set_eval:Nn { Nv, cn } |
| 6266 |
% \end{macrocode} |
| 6267 |
% \end{macro} |
| 6268 |
% |
| 6269 |
% \begin{macro}{ \@@_bool_reverse:N } |
| 6270 |
% Also used sometimes. |
| 6271 |
% \begin{macrocode} |
| 6272 |
\cs_new:Npn \@@_bool_reverse:N #1 |
| 6273 |
{ \bool_if:NTF #1 { \bool_set_false:N } { \bool_set_true:N } #1 } |
| 6274 |
% \end{macrocode} |
| 6275 |
% \end{macro} |
| 6276 |
% |
| 6277 |
% \begin{macro}{\@@_rf_seq_put_right:Nnnnnn, \@@_rf_seq_put_right:NnVVVV, \@@_rf_seq_put_right:NnnnnV} |
| 6278 |
% Nothing special here, just a wrapper used later. |
| 6279 |
% \begin{macrocode} |
| 6280 |
\cs_new:Npn \@@_rf_seq_put_right:Nnnnnn #1 #2#3#4#5#6 |
| 6281 |
{ \seq_put_right:Nn #1 { {#2} {#3} {#4} {#5} {#6} } } |
| 6282 |
\cs_generate_variant:Nn \@@_rf_seq_put_right:Nnnnnn { NnVVVV, NnnVVV, NnnnnV } |
| 6283 |
% \end{macrocode} |
| 6284 |
% \end{macro} |
| 6285 |
% |
| 6286 |
% |
| 6287 |
% \begin{macro}{ \@@_change_unit:TF } |
| 6288 |
% I am using this construction often enough, so \dots\ yeah. |
| 6289 |
% Note that if the evaluation is |true|, the path taken is the |false| one. |
| 6290 |
% \begin{macrocode} |
| 6291 |
\prg_new_conditional:Npnn \@@_change_unit: { TF } |
| 6292 |
{ |
| 6293 |
\@@_if_state_equal:nTF { special_sign } |
| 6294 |
{ \prg_return_false: } |
| 6295 |
{ |
| 6296 |
\bool_if:NTF \l_@@_rf_contains_fraction_bool |
| 6297 |
{ |
| 6298 |
\bool_if:NTF \l_@@_lokal_eval_fractions_bool |
| 6299 |
{ \prg_return_true: } |
| 6300 |
{ \prg_return_false: } |
| 6301 |
} |
| 6302 |
{ \prg_return_true: } |
| 6303 |
} |
| 6304 |
% \bool_if:NTF \l_@@_rf_contains_fraction_bool |
| 6305 |
% { \prg_return_false: } |
| 6306 |
% { |
| 6307 |
% \@@_if_state_equal:nTF { special_sign } |
| 6308 |
% { \prg_return_false: } |
| 6309 |
% { \prg_return_true: } |
| 6310 |
% } |
| 6311 |
} |
| 6312 |
% \end{macrocode} |
| 6313 |
% \end{macro} |
| 6314 |
% |
| 6315 |
% |
| 6316 |
% \begin{macro}{\@@_temperature_to_check_print_error:n,\@@_temperatures_to_check_define:nn} |
| 6317 |
% Commands used in the option \texttt{temperature-to-check}. |
| 6318 |
% If no value is given (first command) it raises an error. If a value |
| 6319 |
% is given the unit is added to a check-list and a new |
| 6320 |
% constant is defined. |
| 6321 |
% \begin{macrocode} |
| 6322 |
\cs_new:Npn \@@_temperature_to_check_print_error:n #1 |
| 6323 |
{ |
| 6324 |
\@@_error_if_unit_not_defined:n {#1} |
| 6325 |
\msg_error:nnn { cooking-units } { No-Value-given } { add-temperature-to-check } |
| 6326 |
} |
| 6327 |
\cs_new:Npn \@@_temperatures_to_check_define:nn #1#2 |
| 6328 |
{ |
| 6329 |
\@@_error_if_unit_not_defined:nNF {#1} \l_@@_curr_unit_tl |
| 6330 |
{ |
| 6331 |
\fp_if_exist:cF { l_@@_ \l_@@_curr_unit_tl _min_fp } |
| 6332 |
{ |
| 6333 |
\seq_put_right:NV \l_@@_temperatures_to_check_seq \l_@@_curr_unit_tl |
| 6334 |
\fp_new:c { l_@@_ \l_@@_curr_unit_tl _min_fp } |
| 6335 |
} |
| 6336 |
\fp_set:cn { l_@@_ \l_@@_curr_unit_tl _min_fp } {#2} |
| 6337 |
} |
| 6338 |
} |
| 6339 |
% \end{macrocode} |
| 6340 |
% \end{macro} |
| 6341 |
% |
| 6342 |
% \begin{macro}{ \@@_set_options_for_error:n } |
| 6343 |
% \begin{macrocode} |
| 6344 |
\cs_new:Npn \@@_set_options_for_error:n #1 |
| 6345 |
{ |
| 6346 |
\@@_error_if_unit_not_defined:n {#1} |
| 6347 |
\msg_error:nnn { cooking-units } { No-Value-given } { set-option-for } |
| 6348 |
} |
| 6349 |
% \end{macrocode} |
| 6350 |
% \end{macro} |
| 6351 |
% |
| 6352 |
% \begin{macro}{ \@@_add_options_for_error:n } |
| 6353 |
% \begin{macrocode} |
| 6354 |
\cs_new:Npn \@@_add_options_for_error:n #1 |
| 6355 |
{ |
| 6356 |
\@@_error_if_unit_not_defined:n {#1} |
| 6357 |
\msg_error:nnn { cooking-units } { No-Value-given } { add-option-for } |
| 6358 |
} |
| 6359 |
% \end{macrocode} |
| 6360 |
% \end{macro} |
| 6361 |
% |
| 6362 |
% \begin{macro}{\@@_rounding_function:n} |
| 6363 |
% I think this definition is somewhat stupid, but I don't have a better idea. |
| 6364 |
% \begin{macrocode} |
| 6365 |
\cs_new:Npn \@@_rounding_function:n #1 |
| 6366 |
{ |
| 6367 |
#1 |
| 6368 |
, \l_@@_round_precision_int |
| 6369 |
\bool_if:NT \l_@@_pckopt_round_commercial_bool |
| 6370 |
{ , #1 } |
| 6371 |
} |
| 6372 |
% \end{macrocode} |
| 6373 |
% \end{macro} |
| 6374 |
% |
| 6375 |
% \begin{macro}{\@@_label_and_persons:n} |
| 6376 |
% \begin{macrocode} |
| 6377 |
\cs_new:Npn \@@_label_and_persons:n #1 |
| 6378 |
{ |
| 6379 |
\str_if_in:nnTF {#1} { * } |
| 6380 |
{ \@@_label_and_persons_times_persons:ww #1 \q_stop } |
| 6381 |
{ \msg_error:nnn { cooking-units} { Number-of-persons-missing } {#1} } |
| 6382 |
} |
| 6383 |
% \end{macrocode} |
| 6384 |
% \end{macro} |
| 6385 |
% |
| 6386 |
% \begin{macrocode} |
| 6387 |
\cs_new:Npn \@@_label_and_persons_times_persons:ww #1 * #2 \q_stop |
| 6388 |
{ |
| 6389 |
\@@_culabel:nn {#1} {#2} |
| 6390 |
} |
| 6391 |
% \end{macrocode} |
| 6392 |
% |
| 6393 |
% \begin{macro}{ \@@_culabel:nn } |
| 6394 |
% \begin{macrocode} |
| 6395 |
\cs_new:Npn \@@_culabel:nn #1#2 |
| 6396 |
{ |
| 6397 |
\int_if_exist:cTF { g_@@_number_of_persons_ #1 _int } |
| 6398 |
{ \msg_error:nnn { cooking-units } { label-already-defined } {#1} } |
| 6399 |
{ |
| 6400 |
\@@_if_evaluation_is_integer:nTF {#2} |
| 6401 |
{ |
| 6402 |
\int_set:Nn \l_@@_tmpa_int {#2} |
| 6403 |
\int_new:c { g_@@_number_of_persons_ #1 _int } |
| 6404 |
\int_gset_eq:cN { g_@@_number_of_persons_ #1 _int } \l_@@_tmpa_int |
| 6405 |
} |
| 6406 |
{ \msg_error:nnn { cooking-units } { Number-of-persons-is-not-an-integer } {#2} } |
| 6407 |
} |
| 6408 |
} |
| 6409 |
% \end{macrocode} |
| 6410 |
% \end{macro} |
| 6411 |
% |
| 6412 |
% \begin{macro}{ \@@_reference_label_and_persons:n } |
| 6413 |
% \begin{macrocode} |
| 6414 |
\cs_new:Npn \@@_reference_label_and_persons:n #1 |
| 6415 |
{ |
| 6416 |
\int_if_exist:cTF { g_@@_number_of_persons_ #1 _int } |
| 6417 |
{ |
| 6418 |
\bool_set_true:N \l_@@_reference_given_bool |
| 6419 |
\int_set_eq:Nc \l_@@_local_number_of_persons_int |
| 6420 |
{ g_@@_number_of_persons_ #1 _int } |
| 6421 |
} |
| 6422 |
{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} } |
| 6423 |
} |
| 6424 |
% \end{macrocode} |
| 6425 |
% \end{macro} |
| 6426 |
% |
| 6427 |
% \begin{macro}{ \@@_curef:n } |
| 6428 |
% \begin{macrocode} |
| 6429 |
\cs_new:Npn \@@_curef:n #1 |
| 6430 |
{ |
| 6431 |
\int_if_exist:cTF { g_@@_number_of_persons_ #1 _int } |
| 6432 |
{ |
| 6433 |
\bool_if:NTF \l_@@_pckopt_recalculate_amount_bool |
| 6434 |
{ \int_use:N \l_@@_wanted_number_of_persons_int } |
| 6435 |
{ \int_use:c { g_@@_number_of_persons_ #1 _int } } |
| 6436 |
}{ \msg_error:nnn { cooking-units } { label-not-defined } {#1} } |
| 6437 |
} |
| 6438 |
% \end{macrocode} |
| 6439 |
% \end{macro} |
| 6440 |
% |
| 6441 |
% \begin{macro}{ \culabel , \curef } |
| 6442 |
% \begin{macrocode} |
| 6443 |
\NewDocumentCommand \culabel { m m } { \@@_culabel:nn {#1} {#2} } |
| 6444 |
\NewExpandableDocumentCommand \curef { m } { \@@_curef:n {#1} } |
| 6445 |
% \end{macrocode} |
| 6446 |
% \end{macro} |
| 6447 |
% |
| 6448 |
% |
| 6449 |
% |
| 6450 |
% |
| 6451 |
% \begin{macro}{ \@@_check_minus_remove_and_reverse:NN } |
| 6452 |
% Can probably optimize this as the sign is always at the first place |
| 6453 |
% (this is done after cheking the input, so the assumption is safe), but yeah \dots |
| 6454 |
% \begin{macrocode} |
| 6455 |
\cs_new:Npn \@@_check_minus_remove_and_reverse:NN #1#2 |
| 6456 |
{ |
| 6457 |
\quark_if_nil:NF #2 |
| 6458 |
{ |
| 6459 |
%% Maybe simplify by a command? |
| 6460 |
\tl_if_in:NnT #2 { - } |
| 6461 |
{ |
| 6462 |
\tl_remove_once:Nn #2 { - } |
| 6463 |
\@@_bool_reverse:N #1 |
| 6464 |
} |
| 6465 |
\@@_check_minus_remove_and_reverse:NN #1 |
| 6466 |
} |
| 6467 |
} |
| 6468 |
% \end{macrocode} |
| 6469 |
% \end{macro} |
| 6470 |
% |
| 6471 |
% |
| 6472 |
% |
| 6473 |
% |
| 6474 |
% |
| 6475 |
% |
| 6476 |
% |
| 6477 |
% |
| 6478 |
% |
| 6479 |
% \begin{macrocode} |
| 6480 |
\cs_new:Npn \@@_add_forbidden_unit:n #1 |
| 6481 |
{ |
| 6482 |
\seq_set_from_clist:Nn \l_@@_tmpa_seq {#1} |
| 6483 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 6484 |
{ |
| 6485 |
\@@_error_if_unit_not_defined:nNF {##1} \l_@@_curr_unit_tl |
| 6486 |
{ |
| 6487 |
\seq_if_in:NVF \l_@@_curef_do_not_change_seq \l_@@_curr_unit_tl |
| 6488 |
{ \seq_put_right:NV \l_@@_curef_do_not_change_seq \l_@@_curr_unit_tl } |
| 6489 |
} |
| 6490 |
} |
| 6491 |
} |
| 6492 |
\cs_new:Npn \@@_remove_forbidden_unit:n #1 |
| 6493 |
{ |
| 6494 |
\seq_set_from_clist:Nn \l_@@_tmpa_seq {#1} |
| 6495 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 6496 |
{ |
| 6497 |
\@@_error_if_unit_not_defined:nNF {##1} \l_@@_curr_unit_tl |
| 6498 |
{ |
| 6499 |
\seq_if_in:NVTF \l_@@_curef_do_not_change_seq \l_@@_curr_unit_tl |
| 6500 |
{ \seq_remove_all:NV \l_@@_curef_do_not_change_seq \l_@@_curr_unit_tl } |
| 6501 |
{ |
| 6502 |
\msg_warning:nnnn { cooking-units } { curef-not-inside-list } {##1} |
| 6503 |
{ \@@_seq_use_msg:N \l_@@_curef_do_not_change_seq } |
| 6504 |
} |
| 6505 |
} |
| 6506 |
} |
| 6507 |
} |
| 6508 |
\cs_new:Npn \@@_clear_forbidden_unit: |
| 6509 |
{ \seq_clear:N \l_@@_curef_do_not_change_seq } |
| 6510 |
% \end{macrocode} |
| 6511 |
% |
| 6512 |
% |
| 6513 |
% |
| 6514 |
% |
| 6515 |
% |
| 6516 |
% |
| 6517 |
% \begin{macrocode} |
| 6518 |
\NewDocumentCommand \cudeclareunitgroup { m m } |
| 6519 |
{ |
| 6520 |
\@@_define_clear_unit_group:n {#1} |
| 6521 |
\@@_add_to_unit_group:nn {#1} {#2} |
| 6522 |
} |
| 6523 |
\NewDocumentCommand \cuaddtounitgroup { m m } |
| 6524 |
{ |
| 6525 |
\@@_add_to_unit_group:nn {#1} {#2} |
| 6526 |
} |
| 6527 |
\NewDocumentCommand \cuclearunitgroup { m } |
| 6528 |
{ |
| 6529 |
\@@_error_if_group_not_defined:nF {#1} |
| 6530 |
{ \@@_define_clear_unit_group:n {#1} } |
| 6531 |
} |
| 6532 |
% \end{macrocode} |
| 6533 |
% |
| 6534 |
% |
| 6535 |
% |
| 6536 |
% |
| 6537 |
% |
| 6538 |
% |
| 6539 |
% |
| 6540 |
% |
| 6541 |
% \begin{macro}{ \cusetoptionfor , \cuaddoptionfor , \cuclearoptionfor} |
| 6542 |
% \pkg{cooking-units} allows to attach options to units. Every time the unit |
| 6543 |
% is used, the option is executed (technically it is similar or equal to a hook). |
| 6544 |
% Using these commands, one can set (overwrites all previous options), |
| 6545 |
% add or clear options for a unit or a list of units. |
| 6546 |
% \begin{macrocode} |
| 6547 |
\NewDocumentCommand \cusetoptionfor { m m } |
| 6548 |
{ \@@_set_options_for:nn {#1} {#2} } |
| 6549 |
\NewDocumentCommand \cuaddoptionfor { m m } |
| 6550 |
{ \@@_add_options_for:nn {#1} {#2} } |
| 6551 |
\NewDocumentCommand \cuclearoptionfor { m } |
| 6552 |
{ \@@_clear_options_for:n {#1} } |
| 6553 |
% \end{macrocode} |
| 6554 |
% \end{macro} |
| 6555 |
% |
| 6556 |
% \begin{macro}{\@@_set_options_for:nn , \@@_add_options_for:nn , \@@_clear_options_for:n} |
| 6557 |
% These commands are quite similar, excpet for a few details. |
| 6558 |
% First, store the unit or list of units |#1| and the list of options |#2|. |
| 6559 |
% At the end, for each unit in |#1| a clist will be created (if not already existing) |
| 6560 |
% where the options will be put \emph{via} |\clist_set:cn|, |\clist_put_right:cn| |
| 6561 |
% or will be cleared (see there). |
| 6562 |
% |
| 6563 |
% E.g.\ |\clist_set:cn| will get something like |\clist_set:cV {...unit...clist} \clist_containing_options_clist|. |
| 6564 |
% As |\clist_clear:c| does not take a second argument, we will eat it \emph{via} |
| 6565 |
% |\use_i_ii:nnn|. |
| 6566 |
% \begin{macrocode} |
| 6567 |
\cs_new:Npn \@@_set_options_for:nn #1#2 |
| 6568 |
{ |
| 6569 |
\@@_map_trough_valid_unit_options:nnn {#1} {#2} { \clist_set:cV } |
| 6570 |
} |
| 6571 |
\cs_new:Npn \@@_add_options_for:nn #1#2 |
| 6572 |
{ |
| 6573 |
\@@_map_trough_valid_unit_options:nnn {#1} {#2} { \clist_put_right:cV } |
| 6574 |
} |
| 6575 |
\cs_new:Npn \@@_clear_options_for:n #1 |
| 6576 |
{ |
| 6577 |
\@@_map_trough_valid_unit_options:nnn {#1} { \q_no_value } { \clist_clear:c } |
| 6578 |
} |
| 6579 |
\cs_generate_variant:Nn \@@_set_options_for:nn { V } |
| 6580 |
\cs_generate_variant:Nn \@@_clear_options_for:n { V } |
| 6581 |
% \end{macrocode} |
| 6582 |
% \end{macro} |
| 6583 |
% |
| 6584 |
% \begin{macro}{\@@_map_trough_valid_unit_options:nnn} |
| 6585 |
% The first thing is command does is to map through the given unit list |#1| |
| 6586 |
% and check if the unit(s) exist or not. If they exist, store them in the sequence |
| 6587 |
% |\l_@@_tmpa_seq| for later use. Else, ignore it and print a warning. |
| 6588 |
% |
| 6589 |
% If |#2| is a |\q_no_value| we know that there is no need to map through |#2|. |
| 6590 |
% Whatever the command |#3| does, it does so only to the clist |
| 6591 |
% |l_@@_unit_option_ <unit> _clist|. |
| 6592 |
% |
| 6593 |
% If |#2| is anything else, follow the |else| branch. After veryfing that |#2| |
| 6594 |
% is non-empty map through the option list given in |#2|. All valid keys |
| 6595 |
% (and their agrument) is stored in |\l_@@_tmpa_clist|. |
| 6596 |
% Afterwards, the clist for each unit in |\l_@@_tmpa_seq| is modified by the command |
| 6597 |
% in |#3| and is given the list of options |\l_@@_tmpa_clist| as an argument. |
| 6598 |
% (Note: |\l_@@_tmpa_clist| can be empty). |
| 6599 |
% \begin{macrocode} |
| 6600 |
\cs_new:Npn \@@_map_trough_valid_unit_options:nnn #1#2 #3 |
| 6601 |
{ |
| 6602 |
\seq_clear:N \l_@@_tmpa_seq |
| 6603 |
\clist_clear:N \l_@@_tmpa_clist |
| 6604 |
\clist_map_inline:nn {#1} |
| 6605 |
{ |
| 6606 |
\@@_error_if_unit_not_defined:nNF {##1} \l_@@_curr_unit_tl |
| 6607 |
{ \seq_put_right:NV \l_@@_tmpa_seq \l_@@_curr_unit_tl } |
| 6608 |
} |
| 6609 |
\quark_if_no_value:nTF {#2} |
| 6610 |
{ |
| 6611 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 6612 |
{ #3 { l_@@_unit_option_ ##1 _clist } } |
| 6613 |
}{ |
| 6614 |
\tl_if_empty:nF {#2} |
| 6615 |
{ \@@_unit_options_check_validity:n {#2} } |
| 6616 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 6617 |
{ #3 { l_@@_unit_option_ ##1 _clist } \l_@@_tmpa_clist } |
| 6618 |
} |
| 6619 |
} |
| 6620 |
% \end{macrocode} |
| 6621 |
% \end{macro} |
| 6622 |
% |
| 6623 |
% \begin{macro}{ \@@_unit_options_check_validity:n } |
| 6624 |
% If the list of options is non-empty, we parse over them using |
| 6625 |
% |\keyval_parse:NNn|. For this we need two commands, one for keys |
| 6626 |
% with argument, one without arguments. All the commands do is to check |
| 6627 |
% if the key given does exist. And if they do, store them in |\l_@@_tmpa_clist|. |
| 6628 |
% \begin{macrocode} |
| 6629 |
\cs_new:Npn \@@_unit_options_check_validity:n #1 |
| 6630 |
{ |
| 6631 |
\keyval_parse:NNn |
| 6632 |
\@@_unit_options_check_validity_aux_i:n |
| 6633 |
\@@_unit_options_check_validity_aux_ii:nn |
| 6634 |
{#1} |
| 6635 |
} |
| 6636 |
% \end{macrocode} |
| 6637 |
% \end{macro} |
| 6638 |
% |
| 6639 |
% \begin{macro}{ \@@_unit_options_check_validity_aux_i:n , |
| 6640 |
% \@@_unit_options_check_validity_aux_ii:nn } |
| 6641 |
% Check if the key exist; if it is then put it in |\l_@@_tmpa_clist| (just the key, or with the value). |
| 6642 |
% Sadly, checking if the value |#2| can be accepted by the key is not really testable. |
| 6643 |
% \begin{macrocode} |
| 6644 |
\cs_new:Npn \@@_unit_options_check_validity_aux_i:n #1 |
| 6645 |
{ |
| 6646 |
\keys_if_exist:nnTF { cooking-units } {#1} |
| 6647 |
{ \clist_put_right:Nn \l_@@_tmpa_clist {#1} } |
| 6648 |
{ \msg_error:nnn { cooking-units } { unknown-option } {#1} } |
| 6649 |
} |
| 6650 |
\cs_new:Npn \@@_unit_options_check_validity_aux_ii:nn #1#2 |
| 6651 |
{ |
| 6652 |
\keys_if_exist:nnTF { cooking-units } {#1} |
| 6653 |
{ |
| 6654 |
\clist_put_right:Nn \l_@@_tmpa_clist { #1= {#2} } |
| 6655 |
% \keys_if_choice_exist:nnnTF { cooking-units } {#1} {#2} |
| 6656 |
% { \clist_put_right:Nn \l_@@_tmpa_clist { #1= {#2} } } |
| 6657 |
% { \msg_error:nnnn { cooking-units } { unknown-choice } {#1} {#2} } |
| 6658 |
} |
| 6659 |
{ \msg_error:nnn { cooking-units } { unknown-option } {#1} } |
| 6660 |
} |
| 6661 |
% \end{macrocode} |
| 6662 |
% \end{macro} |
| 6663 |
% |
| 6664 |
% |
| 6665 |
% |
| 6666 |
% |
| 6667 |
% |
| 6668 |
% |
| 6669 |
% |
| 6670 |
% |
| 6671 |
% |
| 6672 |
% |
| 6673 |
% \subsection{Language Macros} |
| 6674 |
% |
| 6675 |
% |
| 6676 |
% The following commands are just wrapper around the commands from the |
| 6677 |
% \pkg{translations} package. |
| 6678 |
% |
| 6679 |
% \begin{macro}{ \@@_culang_def_base:nnn , \@@_culang_def_base:nnv , \@@_culang_def_base:nVn} |
| 6680 |
% \begin{macrocode} |
| 6681 |
\cs_new:Npn \@@_culang_def_base:nnn #1#2#3 |
| 6682 |
{ \declaretranslationfallback { #2 - #1 (@@) } {#3} } |
| 6683 |
\cs_generate_variant:Nn \@@_culang_def_base:nnn { nnv, nVn } |
| 6684 |
% \end{macrocode} |
| 6685 |
% \end{macro} |
| 6686 |
% |
| 6687 |
% \begin{macro}{ \@@_culang_def_for:nnnn, \@@_culang_def_for:VnnV , \@@_culang_def_for:Vnnn } |
| 6688 |
% \begin{macrocode} |
| 6689 |
\cs_new:Npn \@@_culang_def_for:nnnn #1#2#3#4 |
| 6690 |
{ \declaretranslation {#1} { #3 - #2 (@@) } {#4} } |
| 6691 |
\cs_generate_variant:Nn \@@_culang_def_for:nnnn { VnnV, V } |
| 6692 |
% \end{macrocode} |
| 6693 |
% \end{macro} |
| 6694 |
% |
| 6695 |
% \begin{macro}{ \@@_culang_print:nn , \@@_culang_print:nV } |
| 6696 |
% \begin{macrocode} |
| 6697 |
\cs_new:Npn \@@_culang_print:nn #1#2 |
| 6698 |
{ \GetTranslation { #2 - #1 (@@) } } |
| 6699 |
\cs_generate_variant:Nn \@@_culang_print:nn { nV } |
| 6700 |
% \end{macrocode} |
| 6701 |
% \end{macro} |
| 6702 |
% |
| 6703 |
% \begin{macro}{ \@@_culang_let:nnN } |
| 6704 |
% \begin{macrocode} |
| 6705 |
\cs_new:Npn \@@_culang_let:nnN #1#2#3 |
| 6706 |
{ \SaveTranslation #3 { #2 - #1 (@@) } } |
| 6707 |
% \end{macrocode} |
| 6708 |
% \end{macro} |
| 6709 |
% |
| 6710 |
% \begin{macro}{ \@@_culang_let_for:nnnN , \@@_culang_let_for:VnnN } |
| 6711 |
% \begin{macrocode} |
| 6712 |
\cs_new:Npn \@@_culang_let_for:nnnN #1#2#3#4 |
| 6713 |
{ \SaveTranslationFor #4 {#1} { #3-#2 (@@) } } |
| 6714 |
\cs_generate_variant:Nn \@@_culang_let_for:nnnN { V } |
| 6715 |
% \end{macrocode} |
| 6716 |
% \end{macro} |
| 6717 |
% |
| 6718 |
% \begin{macro}[TF]{ \@@_culang_if_translation_exists_for:nnn, \@@_culang_if_translation_exists_for:Vnn} |
| 6719 |
% \begin{macrocode} |
| 6720 |
\cs_new:Npn \@@_culang_if_translation_exists_for:nnnTF #1#2#3 |
| 6721 |
{ \IfTranslation {#1} { #3 - #2 (@@) } } |
| 6722 |
\cs_generate_variant:Nn \@@_culang_if_translation_exists_for:nnnTF { V } |
| 6723 |
% \end{macrocode} |
| 6724 |
% \end{macro} |
| 6725 |
% |
| 6726 |
% |
| 6727 |
% |
| 6728 |
% |
| 6729 |
% |
| 6730 |
% \begin{macro}[TF, F]{\@@_culang_unitname_let:Nn , \@@_culang_unitname_let:NV } |
| 6731 |
% \begin{macrocode} |
| 6732 |
\prg_new_conditional:Npnn \@@_culang_unitname_let:Nn #1#2 { TF, F , T } |
| 6733 |
{ |
| 6734 |
\@@_culang_let:nnN { name } {#2} #1 |
| 6735 |
\tl_if_eq:NNTF #1 \c_@@_no_translation_str |
| 6736 |
{ \prg_return_false: } |
| 6737 |
{ \prg_return_true: } |
| 6738 |
} |
| 6739 |
\cs_generate_variant:Nn \@@_culang_unitname_let:NnTF { NV, Nx } |
| 6740 |
\cs_generate_variant:Nn \@@_culang_unitname_let:NnT { Nx } |
| 6741 |
% \end{macrocode} |
| 6742 |
% \end{macro} |
| 6743 |
% |
| 6744 |
% \begin{macro}{ \@@_culang_one_let:Nn , \@@_culang_one_let:NV , |
| 6745 |
% \@@_culang_one_let_by_gender:Nn , \@@_culang_one_let_by_gender:NV |
| 6746 |
% } |
| 6747 |
% \begin{macrocode} |
| 6748 |
\prg_new_conditional:Npnn \@@_culang_one_let:Nn #1#2 { T } |
| 6749 |
{ |
| 6750 |
\@@_culang_let:nnN { gender } {#2} \l_@@_tmpa_tl |
| 6751 |
\@@_culang_one_let_by_gender:NVTF #1 \l_@@_tmpa_tl |
| 6752 |
{ \prg_return_true: } |
| 6753 |
{ |
| 6754 |
\tl_set:Nn #1 { 1 } |
| 6755 |
\prg_return_false: |
| 6756 |
} |
| 6757 |
} |
| 6758 |
\cs_generate_variant:Nn \@@_culang_one_let:NnT { NV } |
| 6759 |
\prg_new_conditional:Npnn \@@_culang_one_let_by_gender:Nn #1#2 { TF } |
| 6760 |
{ |
| 6761 |
\@@_culang_unitname_let:NnTF #1 { one (#2) } |
| 6762 |
{ \prg_return_true: } |
| 6763 |
{ |
| 6764 |
\msg_error:nnx { cooking-units } { Translation-not-available } { one (#2) } |
| 6765 |
\prg_return_false: |
| 6766 |
} |
| 6767 |
} |
| 6768 |
\cs_generate_variant:Nn \@@_culang_one_let_by_gender:NnTF { NV } |
| 6769 |
% \end{macrocode} |
| 6770 |
% \end{macro} |
| 6771 |
% |
| 6772 |
% \begin{macro}{ \g_@@_allowed_special_keys_seq } |
| 6773 |
% Defining the translation for the decimal-mark. Note that those |
| 6774 |
% 'phrases' are stored inside |
| 6775 |
% \verb|\g_@@_allowed_special_keys_seq|. |
| 6776 |
% Furthermore some translations are defined. |
| 6777 |
% \begin{macrocode} |
| 6778 |
\seq_gset_from_clist:Nn \g_@@_allowed_special_keys_seq |
| 6779 |
{ |
| 6780 |
cutext-range-sign , |
| 6781 |
cutext-range-phrase , |
| 6782 |
decimal-mark , |
| 6783 |
one (m) , |
| 6784 |
one (f) , |
| 6785 |
one (n) |
| 6786 |
} |
| 6787 |
% \end{macrocode} |
| 6788 |
% \end{macro} |
| 6789 |
% |
| 6790 |
% \begin{macrocode} |
| 6791 |
\@@_culang_def_base:nnn { name } { decimal-mark } { . } |
| 6792 |
\@@_culang_def_base:nnn { name-pl } { decimal-mark } { \c_@@_no_translation_str } |
| 6793 |
\@@_culang_def_for:nnnn { German } { name-pl } { decimal-mark } { , } |
| 6794 |
\@@_culang_def_for:nnnn { French } { name-pl } { decimal-mark } { , } |
| 6795 |
% \end{macrocode} |
| 6796 |
% Note that the plural versions just exist for completing the set. |
| 6797 |
% \begin{macrocode} |
| 6798 |
\@@_culang_def_base:nnn { name } { one (m) } { \c_@@_no_translation_str } |
| 6799 |
\@@_culang_def_base:nnn { name } { one (f) } { \c_@@_no_translation_str } |
| 6800 |
\@@_culang_def_base:nnn { name } { one (n) } { \c_@@_no_translation_str } |
| 6801 |
\@@_culang_def_base:nnn { name-pl } { one (m) } { \c_@@_no_translation_str } |
| 6802 |
\@@_culang_def_base:nnn { name-pl } { one (f) } { \c_@@_no_translation_str } |
| 6803 |
\@@_culang_def_base:nnn { name-pl } { one (n) } { \c_@@_no_translation_str } |
| 6804 |
% \end{macrocode} |
| 6805 |
% \begin{macrocode} |
| 6806 |
\@@_culang_def_for:nnnn { English } { name } { one (m) } { one } |
| 6807 |
\@@_culang_def_for:nnnn { English } { name } { one (f) } { one } |
| 6808 |
\@@_culang_def_for:nnnn { English } { name } { one (n) } { one } |
| 6809 |
% \end{macrocode} |
| 6810 |
% \begin{macrocode} |
| 6811 |
\@@_culang_def_for:nnnn { German } { name } { one (m) } { ein } |
| 6812 |
\@@_culang_def_for:nnnn { German } { name } { one (f) } { eine } |
| 6813 |
\@@_culang_def_for:nnnn { German } { name } { one (n) } { ein } |
| 6814 |
% \end{macrocode} |
| 6815 |
% \begin{macrocode} |
| 6816 |
\@@_culang_def_for:nnnn { French } { name } { one (m) } { un } |
| 6817 |
\@@_culang_def_for:nnnn { French } { name } { one (f) } { une } |
| 6818 |
\@@_culang_def_for:nnnn { French } { name } { one (n) } { un } |
| 6819 |
% \end{macrocode} |
| 6820 |
% |
| 6821 |
% \begin{macrocode} |
| 6822 |
\@@_culang_def_base:nnn { name } { cutext-range-phrase } { -- } |
| 6823 |
%\@@_culang_def_base:nnn { name } { cutext-range-sign } { -- } |
| 6824 |
%\@@_culang_def_base:nnn { name-pl } { cutext-range-sign } { \c_@@_no_translation_str } |
| 6825 |
\@@_culang_def_base:nnn { name-pl } { cutext-range-phrase } { \c_@@_no_translation_str } |
| 6826 |
%\@@_culang_def_for:nnnn { German } { name } { cutext-range-sign } { ~bis~ } |
| 6827 |
%\@@_culang_def_for:nnnn { English } { name } { cutext-range-sign } { ~to~ } |
| 6828 |
%\@@_culang_def_for:nnnn { French } { name } { cutext-range-sign } { ~\`{a}~ } |
| 6829 |
\@@_culang_def_for:nnnn { German } { name } { cutext-range-phrase } { ~bis~ } |
| 6830 |
\@@_culang_def_for:nnnn { English } { name } { cutext-range-phrase } { ~to~ } |
| 6831 |
\@@_culang_def_for:nnnn { French } { name } { cutext-range-phrase } { ~\`{a}~ } |
| 6832 |
% \end{macrocode} |
| 6833 |
% |
| 6834 |
% |
| 6835 |
% \section{General} |
| 6836 |
% |
| 6837 |
% This section collects commands which are used by all four main commands |
| 6838 |
% (\mycs{cunum}, \cCutext, \mycs{cuam}), hence the name. |
| 6839 |
% |
| 6840 |
% |
| 6841 |
% \subsection{Enums \& States} |
| 6842 |
% |
| 6843 |
% These variables decide what the main commands (\cs{cunum}, etc.) should do. |
| 6844 |
% Is there an error? Special-sign? Fraction? Range? Which command is used? |
| 6845 |
% This is defined here. |
| 6846 |
% |
| 6847 |
% \begin{macro}{ \@@_def_new_type:nnn , \@@_def_new_type_aux:cnn , \@@_def_new_type_aux:Nnn} |
| 6848 |
% Defines my variants, all in one handy command (well, two commands). |
| 6849 |
% |#1| is the base name of the new state. |#2| are the conditions for |
| 6850 |
% |\prg_new_conditional|. |#3| are the possible states, given as a comma list. |
| 6851 |
% \begin{macrocode} |
| 6852 |
\cs_new:Npn \@@_def_new_type:nnn #1#2#3 |
| 6853 |
{ |
| 6854 |
\tl_new:c { l_@@_ #1 _tl } |
| 6855 |
\clist_map_inline:nn {#3} |
| 6856 |
{ \tl_const:cn { c_@@_ #1 _ ##1 _tl } {##1} } |
| 6857 |
\@@_def_new_type_aux:cnn { l_@@_ #1 _tl } {#1} {#2} |
| 6858 |
} |
| 6859 |
% \end{macrocode} |
| 6860 |
% Defines the commands |@@_set_<base name>_to:n| and (if wanted) |
| 6861 |
% |@@_if_ <base name> _equal:n|. For maybe optimization (not sure why) |
| 6862 |
% I decided that |#1| is the token varable which stores the state we are currently |
| 6863 |
% in. |
| 6864 |
% \begin{macrocode} |
| 6865 |
\cs_new:Npn \@@_def_new_type_aux:Nnn #1#2#3 |
| 6866 |
{ |
| 6867 |
\cs_new_nopar:cpn { @@_set_ #2 _to:n } ##1 |
| 6868 |
{ |
| 6869 |
\tl_if_exist:cF { c_@@_#2_ ##1 _tl } |
| 6870 |
{ \msg_error:nnn {cooking-units } { internal-error } { Type } { ERROR-set-#2-##1 } } |
| 6871 |
\tl_set_eq:Nc #1 { c_@@_#2_ ##1 _tl } |
| 6872 |
} |
| 6873 |
\tl_if_empty:nF {#3} |
| 6874 |
{ |
| 6875 |
\prg_new_conditional:cpnn { @@_if_ #2 _equal:n } ##1 {#3} |
| 6876 |
{ |
| 6877 |
\tl_if_exist:cF { c_@@_#2_ ##1 _tl } |
| 6878 |
{ \msg_error:nnnn {cooking-units } { internal-error } { Type-2 } { ERROR-set-#2-##1 } } |
| 6879 |
\tl_if_eq:NcTF #1 { c_@@_#2_ ##1 _tl } |
| 6880 |
{ \prg_return_true: } |
| 6881 |
{ \prg_return_false: } |
| 6882 |
} |
| 6883 |
} |
| 6884 |
} |
| 6885 |
\cs_generate_variant:Nn \@@_def_new_type_aux:Nnn { c } |
| 6886 |
% \end{macrocode} |
| 6887 |
% \end{macro} |
| 6888 |
% |
| 6889 |
% Defining some states. |
| 6890 |
% \begin{macrocode} |
| 6891 |
\@@_def_new_type:nnn { state } { TF , T , F , p } |
| 6892 |
{ normal , special_sign , 42 , error } |
| 6893 |
\@@_def_new_type:nnn { cmd_type } { TF , T , p } |
| 6894 |
{ cunum , cCutext , cuam } |
| 6895 |
\@@_def_new_type:nnn { bonkers_state } { } |
| 6896 |
{ normal , going , fully , xD } |
| 6897 |
% \end{macrocode} |
| 6898 |
% |
| 6899 |
% Setting a default state.. |
| 6900 |
% \begin{macrocode} |
| 6901 |
\tl_set_eq:NN \l_@@_bonkers_state_tl \c_@@_bonkers_state_normal_tl |
| 6902 |
% \end{macrocode} |
| 6903 |
% |
| 6904 |
% |
| 6905 |
% \subsection{The main stuff} |
| 6906 |
% |
| 6907 |
% \begin{macro} { \@@_expand_unit_input:Nn , \@@_expand_amount_input:Nn } |
| 6908 |
% \begin{macrocode} |
| 6909 |
\cs_new:Npn \@@_expand_unit_input:Nn #1#2 |
| 6910 |
{ |
| 6911 |
\cs_if_exist_use:c { exp_args:NN \l_@@_unit_argument_spec_tl } |
| 6912 |
\@@_set_unit:Nn #1 {#2} |
| 6913 |
} |
| 6914 |
\cs_new:Npn \@@_expand_amount_input:Nn #1#2 |
| 6915 |
{ |
| 6916 |
\cs_if_exist_use:c { exp_args:NN \l_@@_expand_amount_tl } |
| 6917 |
\@@_set_amount:Nn #1 {#2} |
| 6918 |
} |
| 6919 |
% \end{macrocode} |
| 6920 |
% \end{macro} |
| 6921 |
% |
| 6922 |
% |
| 6923 |
% |
| 6924 |
% \begin{macro}{ \@@_rf_main_command:nnnnnnm \@@_rf_main_command:nnnnnV } |
| 6925 |
% \begin{macrocode} |
| 6926 |
\cs_new:Npn \@@_rf_main_command:nnnnnn #1#2#3#4#5#6 |
| 6927 |
{ |
| 6928 |
% #1 -- label |
| 6929 |
% #2 -- options |
| 6930 |
% #3 -- amount |
| 6931 |
% #4 -- space |
| 6932 |
% #5 -- unit |
| 6933 |
\@@_rf_initialice:nnnn {#1} {#2} {#5} {#4} |
| 6934 |
\@@_rf_use_hook_accordingly: |
| 6935 |
\@@_rf_parse_the_amount:n {#3} |
| 6936 |
\@@_rf_general_checkups: |
| 6937 |
\@@_if_state_equal:nTF { normal } |
| 6938 |
{ |
| 6939 |
\@@_rf_process_amount_normally:n {#2} |
| 6940 |
\@@_rf_post_process_amount: |
| 6941 |
}{ |
| 6942 |
\@@_rf_process_amount_special: |
| 6943 |
} |
| 6944 |
\@@_rf_prepare_amount_printing:N \l_@@_processed_seq |
| 6945 |
\@@_rf_print_amount_correctly: |
| 6946 |
\@@_rf_print_unit_correctly: |
| 6947 |
} |
| 6948 |
\cs_generate_variant:Nn \@@_rf_main_command:nnnnnn { nnnnV } |
| 6949 |
% \end{macrocode} |
| 6950 |
% \end{macro} |
| 6951 |
% |
| 6952 |
% |
| 6953 |
% \subsubsection{Initialization} |
| 6954 |
% |
| 6955 |
% \begin{macro}{\@@_rf_initialice:nnnn } |
| 6956 |
% A hub command for several steps. See the inividual commands for more |
| 6957 |
% details. As each command is slightly different in execution, do some setup |
| 6958 |
% depending on which command is currently in use. |
| 6959 |
% \begin{macrocode} |
| 6960 |
\cs_new:Npn \@@_rf_initialice:nnnn #1#2#3#4 |
| 6961 |
{ |
| 6962 |
\@@_rf_initialice_default:nnn {#1} {#2} {#3} |
| 6963 |
\@@_rf_initialize_units: |
| 6964 |
\@@_rf_setup_bools_for_process_and_prints: |
| 6965 |
\tl_case:NnF \l_@@_cmd_type_tl |
| 6966 |
{ |
| 6967 |
\c_@@_cmd_type_cunum_tl { \tl_set:Nn \l_@@_phantom_tl {#4} } |
| 6968 |
\c_@@_cmd_type_cCutext_tl { \@@_initialice_addon_cutext: } |
| 6969 |
\c_@@_cmd_type_cuam_tl { } |
| 6970 |
} |
| 6971 |
{ \@@_create_internal_error:nN { init-acc } \l_@@_cmd_type_tl } |
| 6972 |
} |
| 6973 |
% \end{macrocode} |
| 6974 |
% \end{macro} |
| 6975 |
|
| 6976 |
% \begin{macro}{\@@_rf_initialice_default:nnn} |
| 6977 |
% Set some variables to their default value, set the options (unit changes, etc.), check if |
| 6978 |
% a label |
| 6979 |
% is used and make sure the units are defined. |
| 6980 |
% |
| 6981 |
% We set the state to |42| in case of using the \opt{42} option to later proceeed to the |
| 6982 |
% special post-processing case. |
| 6983 |
% \begin{macrocode} |
| 6984 |
\cs_new:Npn \@@_rf_initialice_default:nnn #1#2#3 |
| 6985 |
{ |
| 6986 |
\tl_clear:N \l_@@_phantom_tl |
| 6987 |
\tl_clear:N \l_@@_option_unit_tl |
| 6988 |
\tl_clear:N \l_@@_precompiled_options_tl |
| 6989 |
\bool_set_false:N \l_@@_lokal_recalc_for_people_bool |
| 6990 |
\bool_set_false:N \l_@@_lokal_eval_fractions_bool |
| 6991 |
\tl_if_empty:nF {#2} |
| 6992 |
{ |
| 6993 |
\keys_precompile:nnN { cooking-units } {#2} \l_@@_precompiled_options_tl |
| 6994 |
\l_@@_precompiled_options_tl |
| 6995 |
} |
| 6996 |
\IfNoValueF {#1} |
| 6997 |
{ \@@_reference_label_and_persons:n {#1} } |
| 6998 |
\@@_expand_unit_input:Nn \l_@@_original_unit_tl {#3} |
| 6999 |
\@@_error_if_unit_not_defined:VTF \l_@@_original_unit_tl |
| 7000 |
{ |
| 7001 |
\@@_set_state_to:n { error } |
| 7002 |
\bool_set_true:N \l_@@_unit_error_bool |
| 7003 |
} |
| 7004 |
{ \@@_set_state_to:n { normal } } |
| 7005 |
\bool_if:NT \l_@@_pckopt_fourty_two_bool |
| 7006 |
{ \@@_set_state_to:n { 42 } } |
| 7007 |
} |
| 7008 |
% \end{macrocode} |
| 7009 |
% \end{macro} |
| 7010 |
% \begin{macro}{\@@_rf_initialize_units:} |
| 7011 |
% Looks more complicated than it is. |\l_@@_option_unit_tl| is the conversion unit (aka.\ |
| 7012 |
% the unit that should be printed if a unit-change is requested). |
| 7013 |
% If |\cuam| is used there is no unit, but |
| 7014 |
% a special marker instead: Set the option unit to the original unit as it does not matter. |
| 7015 |
% |
| 7016 |
% A bonkers unit change overrules a \enquote{eV} unit change; so if both are true, |
| 7017 |
% prefer the bonkers one. All currently active unit-conversions are stored in the property |
| 7018 |
% list |\l_@@_change_unit_prop|; get the conversion unit (if exists) and store it into |
| 7019 |
% |\l_@@_option_unit_tl|. |
| 7020 |
% \begin{macrocode} |
| 7021 |
\cs_new:Npn \@@_rf_initialize_units: |
| 7022 |
{ |
| 7023 |
\@@_if_no_unit_marker:NTF \l_@@_original_unit_tl |
| 7024 |
{ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_original_unit_tl } |
| 7025 |
{ |
| 7026 |
\bool_if:NTF \l_@@_pckopt_bonkers_bool |
| 7027 |
{ \@@_changing_unit_bonkers:N \l_@@_original_unit_tl } |
| 7028 |
{ |
| 7029 |
\bool_if:NT \l_@@_pckopt_convert_to_eV_bool |
| 7030 |
{ \@@_convert_to_eV:N \l_@@_original_unit_tl } |
| 7031 |
} |
| 7032 |
\prop_get:NVNF \l_@@_change_unit_prop \l_@@_original_unit_tl \l_@@_option_unit_tl |
| 7033 |
{ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_original_unit_tl } |
| 7034 |
} |
| 7035 |
} |
| 7036 |
% \end{macrocode} |
| 7037 |
% \end{macro} |
| 7038 |
% \begin{macro}{\@@_rf_setup_bools_for_process_and_prints:} |
| 7039 |
% Set some booleans for later use (after parsing). Funnily enough, we can already |
| 7040 |
% decide some future interactions like a evaluation of fractions or if the amount should |
| 7041 |
% be recalculated to fit the references number of persons. We can do this, as for |
| 7042 |
% errors or special-signs we skip the process where those booleans would be needed. |
| 7043 |
% \begin{macrocode} |
| 7044 |
\cs_new:Npn \@@_rf_setup_bools_for_process_and_prints: |
| 7045 |
{ |
| 7046 |
\bool_lazy_and:nnT |
| 7047 |
{ \l_@@_reference_given_bool } |
| 7048 |
{ \l_@@_pckopt_recalculate_amount_bool } |
| 7049 |
{ |
| 7050 |
\int_compare:nNnF |
| 7051 |
{ \l_@@_wanted_number_of_persons_int } |
| 7052 |
= |
| 7053 |
{ \l_@@_local_number_of_persons_int } |
| 7054 |
{ \bool_set_true:N \l_@@_lokal_recalc_for_people_bool } |
| 7055 |
} |
| 7056 |
\bool_lazy_or:nnTF |
| 7057 |
{ \l_@@_pckopt_eval_fractions_bool } |
| 7058 |
{ \l_@@_lokal_recalc_for_people_bool } |
| 7059 |
{ \bool_set_true:N \l_@@_lokal_eval_fractions_bool } |
| 7060 |
{ |
| 7061 |
% "Convert" fractions \emph{only} if a unit change is requested. |
| 7062 |
\bool_lazy_and:nnT |
| 7063 |
{ \l_@@_pckopt_convert_fractions_bool } |
| 7064 |
{ ! \tl_if_eq_p:NN \l_@@_option_unit_tl \l_@@_original_unit_tl } |
| 7065 |
{ \bool_set_true:N \l_@@_lokal_eval_fractions_bool } |
| 7066 |
} |
| 7067 |
} |
| 7068 |
% \end{macrocode} |
| 7069 |
% \end{macro} |
| 7070 |
% \begin{macro}{\@@_initialice_addon_cutext:} |
| 7071 |
% For \cCutext\ we first check if the user wants to use \cCutext\ at all. |
| 7072 |
% If not, change it to |\cunum|. |
| 7073 |
% \begin{macrocode} |
| 7074 |
\cs_new:Npn \@@_initialice_addon_cutext: |
| 7075 |
{ |
| 7076 |
\bool_set_false:N \l_@@_cutext_use_single_bool |
| 7077 |
\bool_if:NT \l_@@_pckopt_cutext_to_cunum_bool |
| 7078 |
{ \@@_set_cmd_type_to:n { cunum } } |
| 7079 |
} |
| 7080 |
% \end{macrocode} |
| 7081 |
% \end{macro} |
| 7082 |
% |
| 7083 |
% \subsubsection{Hooks} |
| 7084 |
% |
| 7085 |
% \begin{macro}{ \@@_rf_use_hook_accordingly: } |
| 7086 |
% Hooks are straightforward. I know the current command and thus use the |
| 7087 |
% respective hook. |
| 7088 |
% \begin{macrocode} |
| 7089 |
\cs_new:Npn \@@_rf_use_hook_accordingly: |
| 7090 |
{ |
| 7091 |
\l_@@_cmd_hook_tl |
| 7092 |
\tl_case:NnF \l_@@_cmd_type_tl |
| 7093 |
{ |
| 7094 |
\c_@@_cmd_type_cunum_tl { \l_@@_cunum_hook_tl } |
| 7095 |
\c_@@_cmd_type_cCutext_tl |
| 7096 |
{ |
| 7097 |
\bool_if:NTF \l_@@_cutext_uppercase_word_bool |
| 7098 |
{ \l_@@_Cutext_hook_tl } |
| 7099 |
{ \l_@@_cutext_hook_tl } |
| 7100 |
} |
| 7101 |
\c_@@_cmd_type_cuam_tl { \l_@@_cuam_hook_tl } |
| 7102 |
} |
| 7103 |
{ \@@_create_internal_error:nN { use-hook-acc } \l_@@_cmd_type_tl } |
| 7104 |
} |
| 7105 |
% \end{macrocode} |
| 7106 |
% \end{macro} |
| 7107 |
% |
| 7108 |
% |
| 7109 |
% |
| 7110 |
% \subsubsection{Parsing} |
| 7111 |
% |
| 7112 |
% \begin{macro}{\@@_rf_parse_the_amount:n} |
| 7113 |
% We finally set the amount. Afterwards make sure some tokens have the correct |
| 7114 |
% catcode (and remove all spaces). Not quite sure if I should also set the catcode for |
| 7115 |
% |-| or others. |
| 7116 |
% |
| 7117 |
% If the amount is empty or the draft mode is active do some preperations to just print |
| 7118 |
% the input, else parse the amount. |
| 7119 |
% \begin{macrocode} |
| 7120 |
\cs_new:Npn \@@_rf_parse_the_amount:n #1 |
| 7121 |
{ |
| 7122 |
\@@_expand_amount_input:Nn \l_@@_original_amount_tl {#1} |
| 7123 |
\tl_set_rescan:NnV \l_@@_original_amount_tl |
| 7124 |
{ |
| 7125 |
\char_set_catcode_letter:N \_ % |
| 7126 |
\char_set_catcode_ignore:N \ % |
| 7127 |
\char_set_catcode_other:N ? % |
| 7128 |
} \l_@@_original_amount_tl |
| 7129 |
\bool_lazy_any:nTF |
| 7130 |
{ |
| 7131 |
{ \tl_if_empty_p:N \l_@@_original_amount_tl } |
| 7132 |
{ \l_@@_pckopt_draft_bool } |
| 7133 |
} |
| 7134 |
{ \@@_rf_prepare_just_print_input: } |
| 7135 |
{ |
| 7136 |
\@@_rf_split_and_parse_input:N \l_@@_original_amount_tl |
| 7137 |
} |
| 7138 |
} |
| 7139 |
% \end{macrocode} |
| 7140 |
% \end{macro} |
| 7141 |
% \begin{macro}{\@@_rf_prepare_just_print_input:} |
| 7142 |
% There is no \enquote{real} \enquote{print the input}, instead act as if there |
| 7143 |
% was an error (which is the same as just printing the input). |
| 7144 |
% \begin{macrocode} |
| 7145 |
\cs_new:Npn \@@_rf_prepare_just_print_input: |
| 7146 |
{ |
| 7147 |
\@@_set_state_to:n { error } |
| 7148 |
\tl_if_empty:NT \l_@@_original_amount_tl |
| 7149 |
{ \@@_create_error:nn { cooking-units } { empty-amount } } |
| 7150 |
} |
| 7151 |
% \end{macrocode} |
| 7152 |
% \end{macro} |
| 7153 |
|
| 7154 |
% \begin{macro}{ \@@_rf_split_and_parse_input:N } |
| 7155 |
% Here we split and parse the amount. First it is split (separating ranges and |
| 7156 |
% times into their separate values). Afterwards the split parts are parsed for |
| 7157 |
% special signs, if they contain the allowed input-tokens, etc. |
| 7158 |
% |
| 7159 |
% |\use_none_delimit_by_q_nil:w \q_nil| allows me to \enquote{jump} here in case |
| 7160 |
% of an error. |
| 7161 |
% |
| 7162 |
% After everything is done everything is stored into |\l_@@_parsed_seq|. |
| 7163 |
% \begin{macrocode} |
| 7164 |
\cs_new:Npn \@@_rf_split_and_parse_input:N #1 |
| 7165 |
{ |
| 7166 |
\tl_set_eq:NN \l_@@_tmpa_tl #1 |
| 7167 |
\@@_rf_prepare_input_before_split:N \l_@@_tmpa_tl |
| 7168 |
\@@_rf_split_input:V \l_@@_tmpa_tl |
| 7169 |
\@@_rf_parse_input:N \l_@@_split_input_seq |
| 7170 |
\use_none_delimit_by_q_nil:w \q_nil |
| 7171 |
} |
| 7172 |
% \end{macrocode} |
| 7173 |
% \end{macro} |
| 7174 |
% |
| 7175 |
% \begin{macro}{\@@_rf_prepare_input_before_split:N } |
| 7176 |
% As the name suggests we make some preparations before we split. |
| 7177 |
% We could do this (especially checking for a special sign) during the parsing, |
| 7178 |
% but I think it is cleaner to do it now. First checks if a special sign is in the amount, |
| 7179 |
% second replaces the times (|\times|, |xX|) or range-sign (|--|) with an internal |
| 7180 |
% token. |
| 7181 |
% \begin{macrocode} |
| 7182 |
\cs_new:Npn \@@_rf_prepare_input_before_split:N #1 |
| 7183 |
{ |
| 7184 |
\@@_rf_prepare_input_check_for_special_sign:N #1 |
| 7185 |
\@@_rf_prepare_input_check_for_range_or_times_sign:N #1 |
| 7186 |
} |
| 7187 |
% \end{macrocode} |
| 7188 |
% \end{macro} |
| 7189 |
% |
| 7190 |
% \begin{macro}{\@@_rf_prepare_input_check_for_special_sign:N, |
| 7191 |
% \@@_rf_prepare_input_check_for_range_or_times_sign:N} |
| 7192 |
% Loops over all user-given (or predefined) special signs and tests the input |
| 7193 |
% for their appearances. If we find one (more are not really necessary), set the state |
| 7194 |
% to |special_sign|. |
| 7195 |
% \begin{macrocode} |
| 7196 |
\cs_new:Npn \@@_rf_prepare_input_check_for_special_sign:N #1 |
| 7197 |
{ |
| 7198 |
\tl_map_inline:Nn \l_@@_input_allowed_special_signs_tl |
| 7199 |
{ |
| 7200 |
\tl_if_in:NnT #1 {##1} |
| 7201 |
{ |
| 7202 |
\@@_if_state_equal:nF { error } |
| 7203 |
{ \@@_set_state_to:n { special_sign } } |
| 7204 |
\tl_map_break: |
| 7205 |
} |
| 7206 |
} |
| 7207 |
} |
| 7208 |
% \end{macrocode} |
| 7209 |
% Here we replace all valid \enquote{times} signs and \enquote{range} signs |
| 7210 |
% with |\q_@@_range|. Both use the same marker as a combination between those |
| 7211 |
% two is not allowed (cannot use ranges and times). |
| 7212 |
% |
| 7213 |
% Doing the times-loop first (for no real particular reason), all occurrences of a valid |
| 7214 |
% times-sign are replaced. No breaking the loop here as a mix of different signs may |
| 7215 |
% be used. |
| 7216 |
% |
| 7217 |
% Afterwards all occurences of the one valid range sign are replaced by |\q_@@_range|. |
| 7218 |
% Furthermore, create an error if times signs and ranges are used both at once. |
| 7219 |
% \begin{macrocode} |
| 7220 |
\cs_new:Npn \@@_rf_prepare_input_check_for_range_or_times_sign:N #1 |
| 7221 |
{ |
| 7222 |
\tl_map_inline:Nn \l_@@_input_times_sign_tl |
| 7223 |
{ |
| 7224 |
\tl_if_in:NnT #1 {##1} |
| 7225 |
{ |
| 7226 |
\tl_replace_all:Nnn #1 {##1} { \q_@@_range } |
| 7227 |
\bool_set_true:N \l_@@_rf_contains_times_bool |
| 7228 |
} |
| 7229 |
} |
| 7230 |
\tl_if_in:NVT #1 \l_@@_input_range_sign_tl |
| 7231 |
{ |
| 7232 |
\tl_replace_all:NVn #1 \l_@@_input_range_sign_tl { \q_@@_range } |
| 7233 |
\bool_set_true:N \l_@@_rf_contains_range_bool |
| 7234 |
\bool_if:NT \l_@@_rf_contains_times_bool |
| 7235 |
{ \@@_create_error:n { range-and-times-not-allowed } } |
| 7236 |
} |
| 7237 |
} |
| 7238 |
% \end{macrocode} |
| 7239 |
% \end{macro} |
| 7240 |
% |
| 7241 |
% \begin{macro}{\@@_rf_split_input:n, \@@_rf_split_input:V} |
| 7242 |
% Here the splitting the amount into a sequence of values is done. |
| 7243 |
% Sequences are quite handy here as we can just loop over all split items |
| 7244 |
% and we have an arbitrary number of parts (1, 2 or even 20). |
| 7245 |
% |
| 7246 |
% Not quite sure if keeping the spaces is necessary, but I guess this is a minor |
| 7247 |
% optimisation (as |keep_spaces| does not actively remove spaces). |
| 7248 |
% |
| 7249 |
% After the \enquote{main} splitting we still need to make some furhter splitting |
| 7250 |
% for frations. This does not result into additional seq-items. |
| 7251 |
% |
| 7252 |
% After everything is done, the split parts are stored into the sequence |
| 7253 |
% |\l_@@_split_input_seq|. |
| 7254 |
% \begin{macrocode} |
| 7255 |
\cs_new:Npn \@@_rf_split_input:n #1 |
| 7256 |
{ |
| 7257 |
\seq_clear:N \l_@@_split_input_seq |
| 7258 |
\seq_set_split_keep_spaces:Nnn \l_@@_tmpa_seq { \q_@@_range } {#1} |
| 7259 |
\int_set:Nn \l_@@_nr_of_items { \seq_count:N \l_@@_tmpa_seq } |
| 7260 |
\bool_if:NT \l_@@_rf_contains_range_bool |
| 7261 |
{ |
| 7262 |
\int_compare:nNnT { \l_@@_nr_of_items } > { 2 } |
| 7263 |
{ |
| 7264 |
\@@_create_error:nf { range-too-many-items } |
| 7265 |
{ \int_use:N \l_@@_nr_of_items } |
| 7266 |
} |
| 7267 |
} |
| 7268 |
\seq_map_function:NN \l_@@_tmpa_seq \@@_rf_split_inividual_item:n |
| 7269 |
} |
| 7270 |
\cs_generate_variant:Nn \@@_rf_split_input:n { V } |
| 7271 |
% \end{macrocode} |
| 7272 |
% \end{macro} |
| 7273 |
% |
| 7274 |
% \begin{macro}{\@@_rf_split_inividual_item:n} |
| 7275 |
% For a fraction the |/| token is neccessary. Thus, if not |/| is found we have a normal |
| 7276 |
% number. |
| 7277 |
% |
| 7278 |
% |\l_@@_split_input_seq| contains 4 brace-pairs. First contains a boolean denoting if |
| 7279 |
% we have a fraction or not. 2nd, 3rd and 4th contains the inivdual parts of the fraction |
| 7280 |
% (2nd contains the mixed-fraction part; 3rd the numerator and 4th the denominator). |
| 7281 |
% If there is no fraction we store the number in the 4th brace-pair. |
| 7282 |
% \begin{macrocode} |
| 7283 |
\cs_new:Npn \@@_rf_split_inividual_item:n #1 |
| 7284 |
{ |
| 7285 |
\tl_if_in:nnTF {#1} { / } |
| 7286 |
{ \@@_rf_split_fraction:ww #1 \q_stop } |
| 7287 |
{ |
| 7288 |
%% normal number |
| 7289 |
\tl_if_empty:nT {#1} |
| 7290 |
{ \@@_create_error:n { empty-argument } } |
| 7291 |
\seq_put_right:Nn \l_@@_split_input_seq { { \c_false_bool } {} {} {#1} } |
| 7292 |
} |
| 7293 |
} |
| 7294 |
% \end{macrocode} |
| 7295 |
% \end{macro} |
| 7296 |
% |
| 7297 |
% \begin{macro}{\@@_rf_split_fraction:ww, \@@_rf_split_mixed_fraction:wwn} |
| 7298 |
% Here we split the fractions into numerator |#1| and denominator |#2|. |
| 7299 |
% A mixed-fraction sign is only allowed in the numerator part, having it in |#2| throws |
| 7300 |
% an error (case: |1/2_3|). If a mixed fraction sign is found in |#1| we do furhter splitting, |
| 7301 |
% else we store the values in |\l_@@_split_input_seq|. |
| 7302 |
% |
| 7303 |
% Furthermore we set |\l_@@_rf_contains_fraction_bool| to true. This is done for all |
| 7304 |
% sequence parts as it changes unit-chaning behavior. |
| 7305 |
% \begin{macrocode} |
| 7306 |
\cs_new:Npn \@@_rf_split_fraction:ww #1 / #2 \q_stop |
| 7307 |
{ |
| 7308 |
\bool_set_true:N \l_@@_rf_contains_fraction_bool |
| 7309 |
\tl_if_in:nnT {#2} { _ } |
| 7310 |
{ \@@_create_error:n { fraction-wrong-order } } |
| 7311 |
\tl_if_empty:nT {#2} |
| 7312 |
{ \@@_create_error:n { empty-argument } } |
| 7313 |
\tl_if_in:nnTF {#1} { _ } |
| 7314 |
{ |
| 7315 |
\@@_rf_split_mixed_fraction:wwn #1 \q_stop {#2} |
| 7316 |
}{ |
| 7317 |
\tl_if_empty:nT {#1} |
| 7318 |
{ \@@_create_error:n { empty-argument } } |
| 7319 |
\seq_put_right:Nn \l_@@_split_input_seq { { \c_true_bool } {} {#1} {#2} } |
| 7320 |
} |
| 7321 |
} |
| 7322 |
% \end{macrocode} |
| 7323 |
% Straighforward. |#1| is the mixed-fraction part, |#2| is the numerator and |#3| |
| 7324 |
% is the denominator. Make sure they are not empty and store them. |
| 7325 |
% \begin{macrocode} |
| 7326 |
\cs_new:Npn \@@_rf_split_mixed_fraction:wwn #1 _ #2 \q_stop #3 |
| 7327 |
{ |
| 7328 |
\tl_if_empty:nT {#1} |
| 7329 |
{ \@@_create_error:n { empty-argument } } |
| 7330 |
\tl_if_empty:nT {#2} |
| 7331 |
{ \@@_create_error:n { empty-argument } } |
| 7332 |
\seq_put_right:Nn \l_@@_split_input_seq { { \c_true_bool } {#1} {#2} {#3} } |
| 7333 |
} |
| 7334 |
% \end{macrocode} |
| 7335 |
% \end{macro} |
| 7336 |
% |
| 7337 |
% |
| 7338 |
% |
| 7339 |
% \begin{macro}{\@@_rf_parse_input:N} |
| 7340 |
% Now that splitting is done, we start parsing! Using sequences, we jus loop ober |
| 7341 |
% every item. (Which is extremly useful as we can loop over 1 or 100 items). |
| 7342 |
% \begin{macrocode} |
| 7343 |
\cs_new:Npn \@@_rf_parse_input:N #1 |
| 7344 |
{ |
| 7345 |
\seq_clear:N \l_@@_parsed_seq |
| 7346 |
\seq_map_inline:Nn #1 |
| 7347 |
{ \@@_rf_parse_input:nnnn ##1 } |
| 7348 |
} |
| 7349 |
% \end{macrocode} |
| 7350 |
% \end{macro} |
| 7351 |
% |
| 7352 |
% \begin{macro}{\@@_rf_parse_input:nnnn} |
| 7353 |
% Looks more intimidating than it is. The 4 arguments are the ones from |
| 7354 |
% |\l_@@_split_input_seq| and are thus: |
| 7355 |
% \begin{itemize} |
| 7356 |
% \item |#1|: Contains this item a fraction? |
| 7357 |
% \item |#2|: mixed-fraction part (if it exists for this item). |
| 7358 |
% \item |#3|: numerator part (if it exists for this item). |
| 7359 |
% \item |#4|: number part or (if it is a fraction) or denominator. |
| 7360 |
% \end{itemize} |
| 7361 |
% |
| 7362 |
% If we have a fraction we parse the inividual parts and store them temporarily in |
| 7363 |
% tl's. Afterwards we remove all minus signs, but remember if the whole fraction is |
| 7364 |
% positive or negative. Store the parsed parts into |\l_@@_parsed_seq| (this time with |
| 7365 |
% 5 items!). |
| 7366 |
% |
| 7367 |
% If we just have a single number, parse it and store it in |\l_@@_parsed_seq|. |
| 7368 |
% |
| 7369 |
% |\l_@@_parsed_seq| contains 5 items. First is, again, if the item contains a fraction. |
| 7370 |
% 2nd is new, is only used in combination with fractions (else it is empty) and stores |
| 7371 |
% if the fraction is positive or negative (aka.\ if there is a minus sign in front of it |
| 7372 |
% during printing). |
| 7373 |
% \begin{macrocode} |
| 7374 |
\cs_new:Npn \@@_rf_parse_input:nnnn #1 #2#3#4 |
| 7375 |
{ |
| 7376 |
\bool_set_eq:NN \l_@@_rf_check_fraction_bool #1 |
| 7377 |
\bool_if:NTF #1 |
| 7378 |
{ |
| 7379 |
\@@_parse_input_and_safe_in:nN {#2} \l_@@_mixed_fraction_tl |
| 7380 |
\@@_parse_input_and_safe_in:nN {#3} \l_@@_number_tmpa_tl |
| 7381 |
\@@_parse_input_and_safe_in:nN {#4} \l_@@_number_tmpb_tl |
| 7382 |
\@@_rf_frac_remove_minus:NNN |
| 7383 |
\l_@@_mixed_fraction_tl |
| 7384 |
\l_@@_number_tmpa_tl |
| 7385 |
\l_@@_number_tmpb_tl |
| 7386 |
\@@_rf_seq_put_right:NnVVVV |
| 7387 |
\l_@@_parsed_seq |
| 7388 |
{#1} \l_@@_minus_bool |
| 7389 |
\l_@@_mixed_fraction_tl |
| 7390 |
\l_@@_number_tmpa_tl |
| 7391 |
\l_@@_number_tmpb_tl |
| 7392 |
}{ |
| 7393 |
\@@_parse_input_and_safe_in:nN {#4} \l_@@_number_tmpb_tl |
| 7394 |
\@@_rf_seq_put_right:NnnnnV \l_@@_parsed_seq |
| 7395 |
{#1} { } { } { } \l_@@_number_tmpb_tl |
| 7396 |
} |
| 7397 |
} |
| 7398 |
% \end{macrocode} |
| 7399 |
% \end{macro} |
| 7400 |
% |
| 7401 |
% |
| 7402 |
% \begin{macro}{\@@_rf_frac_remove_minus:NNN} |
| 7403 |
% Removes the minus signs from the inividual fraction parts, but remembers |
| 7404 |
% if we have removed an odd or even number of minus signs. This will determine |
| 7405 |
% if the whole fraction is negative or not. |
| 7406 |
% \begin{macrocode} |
| 7407 |
\cs_new:Npn \@@_rf_frac_remove_minus:NNN #1#2#3 |
| 7408 |
{ |
| 7409 |
\bool_set_false:N \l_@@_minus_bool |
| 7410 |
\tl_if_empty:NF #1 |
| 7411 |
{ |
| 7412 |
\exp_last_unbraced:NNV |
| 7413 |
\@@_rf_frac_remove_minus_aux:Nww #1 #1 \q_stop |
| 7414 |
} |
| 7415 |
\exp_last_unbraced:NNV |
| 7416 |
\@@_rf_frac_remove_minus_aux:Nww #2 #2 \q_stop |
| 7417 |
\exp_last_unbraced:NNV |
| 7418 |
\@@_rf_frac_remove_minus_aux:Nww #3 #3 \q_stop |
| 7419 |
} |
| 7420 |
% \end{macrocode} |
| 7421 |
% Not sure if |\token_if_eq_charcode| is the best choice, but I think I stole it from |
| 7422 |
% \pkg{siunitx}, so it should be fine. |
| 7423 |
% \begin{macrocode} |
| 7424 |
\cs_new:Npn \@@_rf_frac_remove_minus_aux:Nww #1 #2#3 \q_stop |
| 7425 |
{ |
| 7426 |
\token_if_eq_charcode:NNTF #2 - |
| 7427 |
{ |
| 7428 |
\@@_bool_reverse:N \l_@@_minus_bool |
| 7429 |
\tl_set:Nn #1 {#3} |
| 7430 |
} |
| 7431 |
{ \tl_set:Nn #1 {#2#3} } |
| 7432 |
} |
| 7433 |
% \end{macrocode} |
| 7434 |
% \end{macro} |
| 7435 |
% |
| 7436 |
% |
| 7437 |
% \subsubsection{Processing} |
| 7438 |
% |
| 7439 |
% |
| 7440 |
% |
| 7441 |
% \begin{macro}{\@@_rf_process_amount_special:} |
| 7442 |
% In case the current state is not-normal we end up here. No (real) processing is |
| 7443 |
% done here, just a warning message is printed. Here we also change the input |
| 7444 |
% if \opt{42} is used. |
| 7445 |
% \begin{macrocode} |
| 7446 |
\cs_new:Npn \@@_rf_process_amount_special: |
| 7447 |
{ |
| 7448 |
\@@_if_state_equal:nT { special_sign } |
| 7449 |
{ \msg_warning:nnV { cooking-units } { amount-not-known } \l_@@_original_amount_tl } |
| 7450 |
\bool_if:NTF \l_@@_pckopt_fourty_two_bool |
| 7451 |
{ \@@_rf_prepare_fourty_two_amount: } |
| 7452 |
{ \seq_set_eq:NN \l_@@_processed_seq \l_@@_parsed_seq } |
| 7453 |
} |
| 7454 |
% \end{macrocode} |
| 7455 |
% \end{macro} |
| 7456 |
% |
| 7457 |
% \begin{macro}{\@@_rf_process_amount_normally:n} |
| 7458 |
% Now that we know e.g.\ if we have an unit change (no special sign, fractions?, etc.) |
| 7459 |
% we do some more initializing. Afterwards, process the input (e.g.\ evaluate fractions |
| 7460 |
% if needed, scale the amount depending on the unit, etc.). |
| 7461 |
% \begin{macrocode} |
| 7462 |
\cs_new:Npn \@@_rf_process_amount_normally:n #1 |
| 7463 |
{ |
| 7464 |
\@@_rf_initialise_after_parsing:n {#1} |
| 7465 |
\seq_clear:N \l_@@_processed_seq |
| 7466 |
\seq_map_inline:Nn \l_@@_parsed_seq |
| 7467 |
{ |
| 7468 |
\@@_rf_process_amount_normally:nnnnn ##1 |
| 7469 |
} |
| 7470 |
} |
| 7471 |
% \end{macrocode} |
| 7472 |
% \end{macro} |
| 7473 |
% |
| 7474 |
% \begin{macro}{\@@_rf_process_amount_normally:nnnnn} |
| 7475 |
% Looks more intimidating (again) as it is. Here are the arguments: |
| 7476 |
% |
| 7477 |
% \begin{itemize} |
| 7478 |
% \item |#1|: Contains this item a fraction? (Boolean) |
| 7479 |
% \item |#2|: (Only non-empty for fractions) Is the fraction negative? |
| 7480 |
% \item |#2|: mixed-fraction part (if it exists for this item). |
| 7481 |
% \item |#3|: numerator part (if it exists for this item). |
| 7482 |
% \item |#4|: number part or denominator (if it is a fraction) . |
| 7483 |
% \end{itemize} |
| 7484 |
% |
| 7485 |
% Two cases here: Do we have a fraction or not. |
| 7486 |
% |
| 7487 |
% If we have a fraction and no evaluation is done, do nothing essentially. |
| 7488 |
% Else an evaluation of the fraction is required and the whole thing is calculated. |
| 7489 |
% Do some Division-by-zero checks; make sure the resulting number is negative |
| 7490 |
% (|#2| argument) and do some further calculations with the resulting number. |
| 7491 |
% Afterwards, store the number in |\l_@@_processed_seq|. (Note that we define the |
| 7492 |
% fraction-boolean as |\c_false_bool|). |
| 7493 |
% |
| 7494 |
% If the current item is simply a number, do some further calculations and store the result |
| 7495 |
% in |\l_@@_processed_seq|. |
| 7496 |
% |
| 7497 |
% \begin{macrocode} |
| 7498 |
\cs_new:Npn \@@_rf_process_amount_normally:nnnnn #1#2#3#4#5 |
| 7499 |
{ |
| 7500 |
\bool_if:NTF #1 |
| 7501 |
{ |
| 7502 |
\bool_if:NTF \l_@@_lokal_eval_fractions_bool |
| 7503 |
{ |
| 7504 |
\bool_set_false:N \l_@@_rf_contains_fraction_bool |
| 7505 |
\fp_compare:nNnT {#5} = { 0 } |
| 7506 |
{ \@@_create_error:n { Division-by-zero } } |
| 7507 |
\@@_tl_set_eval:Nn \l_@@_number_tmpb_tl { #3 + #4/#5 } |
| 7508 |
\int_compare:nNnT {#2} = { \c_one_int } |
| 7509 |
{ \tl_put_left:Nn \l_@@_number_tmpb_tl { - } } |
| 7510 |
\@@_calculate_and_store_in:N \l_@@_number_tmpb_tl |
| 7511 |
\@@_rf_seq_put_right:NnnnnV \l_@@_processed_seq |
| 7512 |
{ \c_false_bool } { } {} {} \l_@@_number_tmpb_tl |
| 7513 |
}{ |
| 7514 |
\@@_rf_seq_put_right:Nnnnnn \l_@@_processed_seq |
| 7515 |
{#1} {#2} {#3} {#4} {#5} |
| 7516 |
} |
| 7517 |
}{ |
| 7518 |
\tl_if_empty:nF {#2} |
| 7519 |
{ \@@_create_internal_error:nN |
| 7520 |
{ non-empty-sign-for-non-fraction } \l_@@_original_amount_tl |
| 7521 |
} |
| 7522 |
\tl_set:Nn \l_@@_number_tmpb_tl {#5} |
| 7523 |
\@@_calculate_and_store_in:N \l_@@_number_tmpb_tl |
| 7524 |
\@@_rf_seq_put_right:NnnnnV \l_@@_processed_seq |
| 7525 |
{#1} { } { } { } \l_@@_number_tmpb_tl |
| 7526 |
} |
| 7527 |
} |
| 7528 |
% \end{macrocode} |
| 7529 |
% \end{macro} |
| 7530 |
% |
| 7531 |
% \begin{macro}{\@@_rf_post_process_amount:} |
| 7532 |
% Doing some post-processing. This is dependend on which command was used |
| 7533 |
% (\cCutext\ has some other functionalities than |\cuam|). |
| 7534 |
% \begin{macrocode} |
| 7535 |
\cs_new:Npn \@@_rf_post_process_amount: |
| 7536 |
{ |
| 7537 |
\tl_case:NnF \l_@@_cmd_type_tl |
| 7538 |
{ |
| 7539 |
\c_@@_cmd_type_cunum_tl { \@@_rf_cunum_post_process:N \l_@@_processed_seq } |
| 7540 |
\c_@@_cmd_type_cCutext_tl { \@@_rf_cutext_post_process:N \l_@@_processed_seq } |
| 7541 |
\c_@@_cmd_type_cuam_tl { \@@_cuam_post_process:N \l_@@_processed_seq } |
| 7542 |
}{ |
| 7543 |
\@@_create_internal_error:nN { post-process } \l_@@_cmd_type_tl |
| 7544 |
} |
| 7545 |
} |
| 7546 |
% \end{macrocode} |
| 7547 |
% \end{macro} |
| 7548 |
% |
| 7549 |
% |
| 7550 |
% \begin{macro}{\@@_rf_cunum_post_process:N} |
| 7551 |
% Nothing is done here. |
| 7552 |
% \begin{macrocode} |
| 7553 |
\cs_new:Npn \@@_rf_cunum_post_process:N #1 { } |
| 7554 |
% \end{macrocode} |
| 7555 |
% \end{macro} |
| 7556 |
% |
| 7557 |
% \begin{macro}{\@@_rf_cutext_post_process:N} |
| 7558 |
% Ok, first decide if we need the plural or singular version of the unit. We can do it |
| 7559 |
% now as we will not \enquote{reduce} the amounts (as |\cuam| is able to do). |
| 7560 |
% |
| 7561 |
% If numerals should be used and we do \emph{not} have a fraction (in all items) |
| 7562 |
% we first check if all items only contain integers. If they all are integers, check if numerals |
| 7563 |
% can be used. |
| 7564 |
% \begin{macrocode} |
| 7565 |
\cs_new:Npn \@@_rf_cutext_post_process:N #1 |
| 7566 |
{ |
| 7567 |
\@@_rf_check_plural:N #1 |
| 7568 |
\bool_lazy_and:nnT |
| 7569 |
{ \l_@@_lokal_numeral_bool } |
| 7570 |
{ ! \l_@@_rf_contains_fraction_bool } |
| 7571 |
{ |
| 7572 |
\@@_rf_check_if_decimal:NNTF #1 \l_@@_numbers_to_check_seq |
| 7573 |
{ \bool_set_false:N \l_@@_lokal_numeral_bool } |
| 7574 |
{ \@@_rf_check_if_numerals_can_be_used:N \l_@@_numbers_to_check_seq } |
| 7575 |
} |
| 7576 |
} |
| 7577 |
% \end{macrocode} |
| 7578 |
% \end{macro} |
| 7579 |
% |
| 7580 |
% \begin{macro}{ \@@_rf_check_plural:N } |
| 7581 |
% For plural-checking we alawys use the last item (and hope that in no language we would |
| 7582 |
% need to e.g.\ use the first item). |\l_@@_tmpa_tl| contains 5 braced pairs; so one |
| 7583 |
% expansion allows |\@@_rf_check_plural_aux:nnnnn| to get them. |
| 7584 |
% \begin{macrocode} |
| 7585 |
\cs_new:Npn \@@_rf_check_plural:N #1 |
| 7586 |
{ |
| 7587 |
\seq_get_right:NN #1 \l_@@_tmpa_tl |
| 7588 |
\exp_after:wN \@@_rf_check_plural_aux:nnnnn \l_@@_tmpa_tl |
| 7589 |
} |
| 7590 |
% \end{macrocode} |
| 7591 |
% \end{macro} |
| 7592 |
% |
| 7593 |
% \begin{macro}{\@@_rf_check_plural_aux:nnnnn} |
| 7594 |
% So \dots\ the algorithm used to determine plural or singular is depending on the |
| 7595 |
% current language (french has other rules than english or german) and if we have a |
| 7596 |
% fraction or not. Call the respective command and hope that the result is correct. |
| 7597 |
% \begin{macrocode} |
| 7598 |
\cs_new:Npn \@@_rf_check_plural_aux:nnnnn #1#2#3#4#5 |
| 7599 |
{ |
| 7600 |
\bool_if:NTF #1 |
| 7601 |
{ |
| 7602 |
\@@_culang_let:nnN { pluraltest } { fraction } \l_@@_translation_tmpa_tl |
| 7603 |
\use:c { @@_pluraltest_fraction_ \l_@@_translation_tmpa_tl :nnn } |
| 7604 |
{#3} {#4} {#5} |
| 7605 |
}{ |
| 7606 |
\@@_culang_let:nnN { pluraltest } { normal } \l_@@_translation_tmpa_tl |
| 7607 |
\use:c { @@_pluraltest_normal_ \l_@@_translation_tmpa_tl :n } {#5} |
| 7608 |
} |
| 7609 |
} |
| 7610 |
% \end{macrocode} |
| 7611 |
% \end{macro} |
| 7612 |
% |
| 7613 |
% |
| 7614 |
% \begin{macro}{\@@_rf_check_if_decimal:NN, \@@_rf_check_if_decimal_aux:Nnnnnn} |
| 7615 |
% Test if all items are integers or not. As the numbers are stored in tl's and not in |
| 7616 |
% fp's or int's we can just check for a |.|. If one is found, we have a decimal. To do this |
| 7617 |
% efficiently we loop through all items, get the needed number (we have no fractions, |
| 7618 |
% we checked that earlier), store it in |#2| for later use and |\tl_put_right:Nn| it into |
| 7619 |
% |\l_@@_tmpa_tl|. |\l_@@_tmpa_tl| will then contain all numbers that need to be |
| 7620 |
% checked as a single string. |#2| is a sequence we can use in the future (is is more |
| 7621 |
% practical as it only contains a single number and not 6 braced pairs; making looping |
| 7622 |
% easier it can be placed directly where we need it). |
| 7623 |
% \begin{macrocode} |
| 7624 |
\prg_new_conditional:Npnn \@@_rf_check_if_decimal:NN #1#2 { TF } |
| 7625 |
{ |
| 7626 |
\tl_clear:N \l_@@_tmpa_tl |
| 7627 |
\seq_clear:N #2 |
| 7628 |
\seq_map_inline:Nn #1 |
| 7629 |
{ |
| 7630 |
\@@_rf_check_if_decimal_aux:Nnnnnn #2 ##1 |
| 7631 |
} |
| 7632 |
\tl_if_in:NnTF \l_@@_tmpa_tl { . } |
| 7633 |
{ \prg_return_true: } |
| 7634 |
{ \prg_return_false: } |
| 7635 |
} |
| 7636 |
% \end{macrocode} |
| 7637 |
% |
| 7638 |
% \begin{macrocode} |
| 7639 |
\cs_new:Npn \@@_rf_check_if_decimal_aux:Nnnnnn #1#2#3#4#5#6 |
| 7640 |
{ |
| 7641 |
\tl_put_right:Nn \l_@@_tmpa_tl {#6} |
| 7642 |
\seq_put_right:Nn #1 {#6} |
| 7643 |
} |
| 7644 |
% \end{macrocode} |
| 7645 |
% \end{macro} |
| 7646 |
% |
| 7647 |
% |
| 7648 |
% |
| 7649 |
% \begin{macro}{\@@_rf_check_if_numerals_can_be_used:N} |
| 7650 |
% The items of sequence in |#1| only contains a number and not the 6 braced pairs. |
| 7651 |
% This makes this loop a lot more straightforward to write. |
| 7652 |
% \begin{macrocode} |
| 7653 |
\cs_new:Npn \@@_rf_check_if_numerals_can_be_used:N #1 |
| 7654 |
{ |
| 7655 |
\seq_map_inline:Nn #1 |
| 7656 |
{ |
| 7657 |
\bool_lazy_and:nnF |
| 7658 |
{ \int_compare_p:nNn {##1} < { \l_@@_print_numerals_below_int } } |
| 7659 |
{ \int_compare_p:nNn {##1} > { 0 } } |
| 7660 |
{ |
| 7661 |
\bool_set_false:N \l_@@_lokal_numeral_bool |
| 7662 |
\seq_map_break: |
| 7663 |
} |
| 7664 |
} |
| 7665 |
} |
| 7666 |
% \end{macrocode} |
| 7667 |
% \end{macro} |
| 7668 |
% |
| 7669 |
% |
| 7670 |
% \begin{macro}{\@@_cuam_post_process:N} |
| 7671 |
% Ok, shit gets real at this point. Compared to the other post process stuffs (especially |
| 7672 |
% |\cunum|) here we do more complicated things. This is mostly due to |\cuam| allowing |
| 7673 |
% phrases (\enquote{12} to \enquote{1 Dutzend}). This needs its own processing algorithm. |
| 7674 |
% Furthermore, we still allow numerals (and we need to be careful because both can be used |
| 7675 |
% at the same time). Of course, all this is only done if the input conists of only integers (and |
| 7676 |
% no fractions) |
| 7677 |
% \begin{macrocode} |
| 7678 |
\cs_new:Npn \@@_cuam_post_process:N #1 |
| 7679 |
{ |
| 7680 |
\bool_if:NF \l_@@_rf_contains_fraction_bool |
| 7681 |
{ |
| 7682 |
\@@_rf_check_if_decimal:NNTF #1 \l_@@_numbers_to_check_seq |
| 7683 |
{ \bool_set_false:N \l_@@_lokal_numeral_bool } |
| 7684 |
{ |
| 7685 |
\bool_if:NT \l_@@_pckopt_use_phrases_bool |
| 7686 |
{ \@@_rf_cuam_post_process_input_phrases:NN #1 \l_@@_numbers_to_check_seq } |
| 7687 |
\bool_if:NT \l_@@_lokal_numeral_bool |
| 7688 |
{ \@@_rf_check_if_numerals_can_be_used:N \l_@@_numbers_to_check_seq } |
| 7689 |
} |
| 7690 |
} |
| 7691 |
} |
| 7692 |
% \end{macrocode} |
| 7693 |
% \end{macro} |
| 7694 |
% |
| 7695 |
% \begin{macro}{\@@_rf_cuam_post_process_input_phrases:NN} |
| 7696 |
% This algorithm is thankfully much simpler compared to the old one! |
| 7697 |
% First, we get the property list for the current language that contains |
| 7698 |
% the phrases. If there are none (aka.\ if it is equal to |\c_@@_no_translation_str|) |
| 7699 |
% we just skip to the end. Else we get the number-sequence from the property |
| 7700 |
% list. |#2| is the list of numbers from the input. |\l_@@_number_tmpa_tl| will contain the |
| 7701 |
% largest common divisor $l$ between those numbers (e.g. $2$, $4$ and $6$ have the |
| 7702 |
% largest common divisor of $l=2$; $12$ and $16$ have $l=4$). If it is $l=1$ we do |
| 7703 |
% nothing (as there is none). Else, take it as a upper cap (there cannot be a common |
| 7704 |
% divisor above $l$; thus only check phrase numbers $n \leq l$). |
| 7705 |
% \begin{macrocode} |
| 7706 |
\cs_new:Npn \@@_rf_cuam_post_process_input_phrases:NN #1#2 |
| 7707 |
{ |
| 7708 |
\@@_culang_get_phrase_prop:N \l_@@_phrase_prop |
| 7709 |
\tl_if_eq:NNT \c_@@_no_translation_str \l_@@_phrase_prop |
| 7710 |
{ \use_none_delimit_by_q_stop:w } |
| 7711 |
\prop_get:NnN \l_@@_phrase_prop { seq } \l_@@_phrase_numbers_seq |
| 7712 |
\@@_get_largest_common_divisor:NN #2 \l_@@_largest_common_divisor_int |
| 7713 |
\int_compare:nNnF { \l_@@_largest_common_divisor_int } = { 1 } |
| 7714 |
{ |
| 7715 |
\@@_find_common_phrase:NNV #1#2 \l_@@_largest_common_divisor_int |
| 7716 |
} |
| 7717 |
\use_none_delimit_by_q_stop:w |
| 7718 |
\q_stop |
| 7719 |
} |
| 7720 |
% \end{macrocode} |
| 7721 |
% \end{macro} |
| 7722 |
% |
| 7723 |
% \begin{macro}{\@@_get_largest_common_divisor:NN, \@@_get_largest_common_divisor_aux:Nn} |
| 7724 |
% |#1| is the sequence of numbers we want to check (we need in later; thus no |
| 7725 |
% \enquote{pop}); in |#2| we will store the largest common |
| 7726 |
% divisor $l$. The \enquote{find the largest common divisor} algorithm is only needed |
| 7727 |
% if we have more than $1$ item (so if we have a range or a times). |
| 7728 |
% |
| 7729 |
% $l$ must be the same for all numbers. |
| 7730 |
% |
| 7731 |
% \begin{macrocode} |
| 7732 |
\cs_new:Npn \@@_get_largest_common_divisor:NN #1#2 |
| 7733 |
{ |
| 7734 |
\seq_get_left:NN #1 \l_@@_tmpa_tl |
| 7735 |
\int_set:Nn #2 { \l_@@_tmpa_tl } |
| 7736 |
\bool_lazy_or:nnT |
| 7737 |
\l_@@_rf_contains_range_bool |
| 7738 |
\l_@@_rf_contains_times_bool |
| 7739 |
{ |
| 7740 |
\seq_map_inline:Nn #1 |
| 7741 |
{ |
| 7742 |
\@@_get_largest_common_divisor_aux:Nn #2 {##1} |
| 7743 |
\int_compare:nNnT {#2} = { 1 } |
| 7744 |
{ \seq_map_break: } |
| 7745 |
} |
| 7746 |
} |
| 7747 |
} |
| 7748 |
% \end{macrocode} |
| 7749 |
% |
| 7750 |
% The source for the algorithm is \url{https://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations}. |
| 7751 |
% To make my future life easier, here is the copy-and-pasted code: |
| 7752 |
% \begin{verbatim} |
| 7753 |
% function gcd(a, b) |
| 7754 |
% while b \neq 0 |
| 7755 |
% t := b |
| 7756 |
% b := a mod b |
| 7757 |
% a := t |
| 7758 |
% return a |
| 7759 |
% \end{verbatim} |
| 7760 |
% and here is the algorithm with the current variables: |
| 7761 |
% \begin{verbatim} |
| 7762 |
% function gcd(#1, b) |
| 7763 |
% while b \neq 0 |
| 7764 |
% a := b |
| 7765 |
% b := #1 mod b |
| 7766 |
% #1 := a |
| 7767 |
% return #2 |
| 7768 |
% \end{verbatim} |
| 7769 |
% |
| 7770 |
% \begin{macrocode} |
| 7771 |
\cs_new:Npn \@@_get_largest_common_divisor_aux:Nn #1#2 |
| 7772 |
{ |
| 7773 |
\int_set:Nn \l_@@_tmpb_int {#2} |
| 7774 |
\int_until_do:nNnn { \l_@@_tmpb_int } = { 0 } |
| 7775 |
{ |
| 7776 |
\int_set_eq:NN \l_@@_tmpa_int \l_@@_tmpb_int |
| 7777 |
\int_set:Nn \l_@@_tmpb_int |
| 7778 |
{ \int_mod:nn {#1} { \l_@@_tmpb_int } } |
| 7779 |
\int_set_eq:NN #1 \l_@@_tmpa_int |
| 7780 |
} |
| 7781 |
} |
| 7782 |
% \end{macrocode} |
| 7783 |
% \end{macro} |
| 7784 |
% |
| 7785 |
% |
| 7786 |
% |
| 7787 |
% \begin{macro}{\@@_find_common_phrase:NNn} |
| 7788 |
% Ok, this one is complicated. |
| 7789 |
% |#1| is the original prcoess sequence; |#2| is the sequence of numbers-to-check |
| 7790 |
% (which were extracted from |#1| in a previous step to make loops easier); |
| 7791 |
% |#3| is the largest common divisor $l$ which requires $l>1|$. |
| 7792 |
% |
| 7793 |
% As a reminder, |\l_@@_phrase_numbers_seq| contains two braced-pairs: |
| 7794 |
% first is the phrase-number, second is a boolean which defines if multiples of the |
| 7795 |
% phrase-number should be checked too. The phrase-number is thus gained by |
| 7796 |
% |\use_i:nn ##1| which must be smaller or equal to $l$ (I explain why in a previous |
| 7797 |
% function). So do nothing if it is larger. |\l_@@_phrase_numbers_seq| is also sorted |
| 7798 |
% from largest to smallest, so no |\seq_map_break:| unless we found a number. |
| 7799 |
% |
| 7800 |
% If for the current phrase number all values have an integer quotient (|\l_@@_tmpa_bool| |
| 7801 |
% remains |true| after |\@@_find_common_phrase_aux:Nnn|) (integer quotients are stored in |
| 7802 |
% |\l_@@_reduced_numbers_seq|) we gain the other properties from this phrase-number |
| 7803 |
% like the phrase-text (\enquote{Dutzend}) and its gender; break the loop. |
| 7804 |
% |
| 7805 |
% If the loop was terminated via a break |\l_@@_tmpa_bool| remains |true| and |
| 7806 |
% we continue with updating the values in sequences |#1| and |#2|. |
| 7807 |
% \begin{macrocode} |
| 7808 |
\cs_new:Npn \@@_find_common_phrase:NNn #1 #2#3 |
| 7809 |
{ |
| 7810 |
\bool_set_false:N \l_@@_lokal_phrase_bool |
| 7811 |
\seq_map_inline:Nn \l_@@_phrase_numbers_seq |
| 7812 |
{ |
| 7813 |
\int_compare:nNnF { \use_i:nn ##1 } > {#3} |
| 7814 |
{ |
| 7815 |
\bool_set_true:N \l_@@_tmpa_bool |
| 7816 |
\seq_clear:N \l_@@_reduced_numbers_seq |
| 7817 |
\@@_find_common_phrase_aux:Nnn #2 ##1 |
| 7818 |
\bool_if:NT \l_@@_tmpa_bool |
| 7819 |
{ |
| 7820 |
\int_compare:nNnTF { \l_@@_tmpa_int } = { 1 } |
| 7821 |
{ \prop_get:NnN \l_@@_phrase_prop { ##1 } \l_@@_phrase_text_tl } |
| 7822 |
{ \prop_get:NnN \l_@@_phrase_prop { ##1 - pl } \l_@@_phrase_text_tl } |
| 7823 |
\prop_get:NnN \l_@@_phrase_prop { ##1 - gender } \l_@@_phrase_gender_tl |
| 7824 |
\seq_map_break: |
| 7825 |
} |
| 7826 |
} |
| 7827 |
} |
| 7828 |
\bool_if:NT \l_@@_tmpa_bool |
| 7829 |
{ |
| 7830 |
\bool_set_true:N \l_@@_lokal_phrase_bool |
| 7831 |
\seq_set_eq:NN #2 \l_@@_reduced_numbers_seq |
| 7832 |
\@@_update_values:NN #1 \l_@@_reduced_numbers_seq |
| 7833 |
} |
| 7834 |
} |
| 7835 |
\cs_generate_variant:Nn \@@_find_common_phrase:NNn { NNV } |
| 7836 |
% \end{macrocode} |
| 7837 |
% \end{macro} |
| 7838 |
% |
| 7839 |
% \begin{macro}{\@@_find_common_phrase_aux:Nnn} |
| 7840 |
% Thankfully a lot more simplified compared to a previous version. |
| 7841 |
% The idea is simple: loop over all numbers in |#1| (the \enquote{numbers-to-check} |
| 7842 |
% sequence) and figure out if all its items are a multiple of the phrase-number |#2|. |
| 7843 |
% If multiples should not be checked (boolean |#3|) we set the multiple to be |
| 7844 |
% $1$. Else we use |\int_div_truncate:nn| to find the closest (checks Wikipedia for |
| 7845 |
% terminology) integer quotient. Afterwards we see if the quotient (calculated ot $1$) |
| 7846 |
% times the phrase number |#2| is equal to the original value (We check if the modulo is |
| 7847 |
% $0$). We do not use the modulo directly as we need the quotient for further uses |
| 7848 |
% (if an integer quotient without reminder exists). |
| 7849 |
% |
| 7850 |
% If integer quotient times phrase number equals the original one, we store the |
| 7851 |
% quotient in |\l_@@_reduced_numbers_seq| for later usage. If we have one whiff |
| 7852 |
% we break the loop as there are no integer quotients for the current phrase-number. |
| 7853 |
% |
| 7854 |
% \begin{macrocode} |
| 7855 |
\cs_new:Npn \@@_find_common_phrase_aux:Nnn #1 #2#3 |
| 7856 |
{ |
| 7857 |
\seq_map_inline:Nn #1 |
| 7858 |
{ |
| 7859 |
\bool_if:NTF #3 |
| 7860 |
{ \int_set:Nn \l_@@_tmpa_int { 1 } } |
| 7861 |
{ \int_set:Nn \l_@@_tmpa_int { \int_div_truncate:nn {##1} {#2} } } |
| 7862 |
\int_compare:nNnTF { \l_@@_tmpa_int * #2 } = {##1} |
| 7863 |
{ \seq_put_right:NV \l_@@_reduced_numbers_seq \l_@@_tmpa_int } |
| 7864 |
{ \bool_set_false:N \l_@@_tmpa_bool \seq_map_break: } |
| 7865 |
} |
| 7866 |
} |
| 7867 |
% \end{macrocode} |
| 7868 |
% \end{macro} |
| 7869 |
% |
| 7870 |
% |
| 7871 |
% \begin{macro}{\@@_update_values:NN, \@@_update_values_aux:Nnnnnn} |
| 7872 |
% Here we update the numbers in |\l_@@_processed_seq| (given in |#1|) with |
| 7873 |
% the integer quotient numbers in |#2|). Do a copy of |#1| (to loop over it) than clear |
| 7874 |
% the process-sequence |#1|. Looping is not necessary as we technically know |
| 7875 |
% every information, but this makes it a bit easier in case I change things in the future |
| 7876 |
% (I can also add some tests). |
| 7877 |
\cs_new:Npn \@@_update_values:NN #1#2 |
| 7878 |
{ |
| 7879 |
\seq_set_eq:NN \l_@@_tmpa_seq #1 |
| 7880 |
\seq_clear:N #1 |
| 7881 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 7882 |
{ |
| 7883 |
\@@_update_values_aux:NNnnnnn #1 #2 ##1 |
| 7884 |
} |
| 7885 |
} |
| 7886 |
\cs_new:Npn \@@_update_values_aux:NNnnnnn #1 #2#3#4#5#6#7 |
| 7887 |
{ |
| 7888 |
\bool_if:NT #3 |
| 7889 |
{ \@@_create_internal_error:nn { fraction-wrong-value } {#3} } |
| 7890 |
\tl_if_empty:nF {#4#5#6} |
| 7891 |
{ \@@_create_internal_error:nn { update-values-non-empty } {#4;;#5;;#6} } |
| 7892 |
\seq_pop_left:NN #2 \l_@@_tmpa_tl |
| 7893 |
\@@_rf_seq_put_right:NnnnnV #1 |
| 7894 |
{#3} {#4} {#5} {#6} \l_@@_tmpa_tl |
| 7895 |
} |
| 7896 |
% \end{macrocode} |
| 7897 |
% \end{macro} |
| 7898 |
% |
| 7899 |
% |
| 7900 |
% \subsubsection{Printing} |
| 7901 |
% |
| 7902 |
% \begin{macro}{\@@_rf_prepare_amount_printing:N} |
| 7903 |
% Printing the amount depends on the commands and the results-to-be-printed |
| 7904 |
% are stored into |\l_@@_prepared_printing_seq|. If fractions and ranges are combined, |
| 7905 |
% a small space is inserted between the fraction and the range sign, but \emph{only} |
| 7906 |
% if it is \emph{not} the last item in the sequence. |\l_@@_nr_of_items| stores the number |
| 7907 |
% of items in the sequence. If the last item in the loop is encountered (by checking if |
| 7908 |
% the index |##1| is equal to |\l_@@_tmpa_int|) give the auxiliary function |\c_true_bool| |
| 7909 |
% and it will figure out the rest. |
| 7910 |
% \begin{macrocode} |
| 7911 |
\cs_new:Npn \@@_rf_prepare_amount_printing:N #1 |
| 7912 |
{ |
| 7913 |
\tl_case:NnF \l_@@_cmd_type_tl |
| 7914 |
{ |
| 7915 |
\c_@@_cmd_type_cunum_tl |
| 7916 |
{ \cs_set_eq:NN \@@_print_number:n \@@_print_number_default:n } |
| 7917 |
\c_@@_cmd_type_cCutext_tl |
| 7918 |
{ \cs_set_eq:NN \@@_print_number:n \@@_cutext_print_number:n } |
| 7919 |
\c_@@_cmd_type_cuam_tl |
| 7920 |
{ \cs_set_eq:NN \@@_print_number:n \@@_cuam_print_number:n } |
| 7921 |
} |
| 7922 |
{ \@@_create_internal_error:nN { post-process } \l_@@_cmd_type_tl } |
| 7923 |
\bool_set_false:N \l_@@_seperator_after_fraction_bool |
| 7924 |
\seq_clear:N \l_@@_prepared_printing_seq |
| 7925 |
\seq_map_indexed_inline:Nn #1 |
| 7926 |
{ |
| 7927 |
\int_compare:nNnTF { \l_@@_nr_of_items } = {##1} |
| 7928 |
{ \@@_rf_prepare_amount_printing_aux:nnnnnn { \c_true_bool } } |
| 7929 |
{ \@@_rf_prepare_amount_printing_aux:nnnnnn { \c_false_bool } } |
| 7930 |
##2 |
| 7931 |
} |
| 7932 |
} |
| 7933 |
% \end{macrocode} |
| 7934 |
% \end{macro} |
| 7935 |
% |
| 7936 |
% \begin{macro}{\@@_rf_prepare_amount_printing_aux:nnnnnn} |
| 7937 |
% |#1| is a boolean which signifies if the last item of the sequence is encountered. |
| 7938 |
% |#2| to |#6| are our typical sequence-arguments. All this function acutally does |
| 7939 |
% is to store the to-be-printed stuff into |\l_@@_prepared_printing_seq|. Could be |
| 7940 |
% optimized a bit more. The booleans are set here so that later on |\seq_use:Nn| can |
| 7941 |
% be used. |
| 7942 |
% \begin{macrocode} |
| 7943 |
\cs_new:Npn \@@_rf_prepare_amount_printing_aux:nnnnnn #1#2#3#4#5#6 |
| 7944 |
{ |
| 7945 |
\bool_if:NTF #2 |
| 7946 |
{ |
| 7947 |
\seq_put_right:Nn \l_@@_prepared_printing_seq |
| 7948 |
{ |
| 7949 |
\@@_print_fraction:nnnn {#3} {#4} {#5} {#6} |
| 7950 |
\bool_set_false:N \l_@@_cutext_uppercase_word_bool |
| 7951 |
\bool_if:NTF #1 |
| 7952 |
{ \bool_set_false:N \l_@@_seperator_after_fraction_bool } |
| 7953 |
{ \bool_set_true:N \l_@@_seperator_after_fraction_bool } |
| 7954 |
} |
| 7955 |
}{ |
| 7956 |
\seq_put_right:Nn \l_@@_prepared_printing_seq |
| 7957 |
{ |
| 7958 |
\@@_print_number:n {#6} |
| 7959 |
\bool_set_false:N \l_@@_cutext_uppercase_word_bool |
| 7960 |
} |
| 7961 |
} |
| 7962 |
} |
| 7963 |
% \end{macrocode} |
| 7964 |
% \end{macro} |
| 7965 |
% |
| 7966 |
% |
| 7967 |
% \begin{macro}{\@@_print_fraction:nnnn} |
| 7968 |
% Printing a fraction is quite easy and straightforward. Use |\@@_print_number_default:n| |
| 7969 |
% for correct decimal-printing. |
| 7970 |
% \begin{macrocode} |
| 7971 |
\cs_new:Npn \@@_print_fraction:nnnn #1#2#3#4 |
| 7972 |
{ |
| 7973 |
\int_compare:nNnT {#1} = { 1 } { \c_@@_minus_tl } |
| 7974 |
\tl_if_empty:nF {#2} |
| 7975 |
{ |
| 7976 |
\@@_print_number_default:n {#2} |
| 7977 |
\skip_horizontal:N \l_@@_mixed_frac_dim |
| 7978 |
} |
| 7979 |
\@@_frac:nn { \@@_print_number_default:n {#3} } { \@@_print_number_default:n {#4} } |
| 7980 |
} |
| 7981 |
% \end{macrocode} |
| 7982 |
% \end{macro} |
| 7983 |
% |
| 7984 |
% |
| 7985 |
% |
| 7986 |
% \begin{macro}{\@@_print_number:n} |
| 7987 |
% This command will be redefined. |
| 7988 |
% \begin{macrocode} |
| 7989 |
\cs_new:Npn \@@_print_number:n #1 {} |
| 7990 |
% \end{macrocode} |
| 7991 |
% \end{macro} |
| 7992 |
% |
| 7993 |
% \begin{macro}{\@@_print_number_default:n} |
| 7994 |
% Do two things: Replace the dot with the correct decimal-sign of the current language |
| 7995 |
% and replace the |-| token with the correct minus sign. |
| 7996 |
% \begin{macrocode} |
| 7997 |
\cs_new:Npn \@@_print_number_default:n #1 |
| 7998 |
{ |
| 7999 |
\tl_set:Nn \l_@@_tmpa_tl {#1} |
| 8000 |
\tl_if_in:NnT \l_@@_tmpa_tl { . } |
| 8001 |
{ |
| 8002 |
\@@_culang_let:nnN { name } { decimal-mark } \l_@@_translation_tmpa_tl |
| 8003 |
\tl_replace_once:Nnn \l_@@_tmpa_tl { . } { \l_@@_translation_tmpa_tl } |
| 8004 |
} |
| 8005 |
\tl_replace_once:Nnn \l_@@_tmpa_tl { - } \c_@@_minus_tl |
| 8006 |
\l_@@_tmpa_tl |
| 8007 |
} |
| 8008 |
% \end{macrocode} |
| 8009 |
% \end{macro} |
| 8010 |
% |
| 8011 |
% \begin{macro}{\@@_cutext_print_number:n, \@@_cutext_print_input_aux:nn, \@@_cutext_print_input_aux:nV} |
| 8012 |
% For \cCutext\ we pretty much always print the numbers using |\@@_print_number_default:n| (like |\cunum| does). However, \cCutext\ have the |
| 8013 |
% ability to print numerals (if the input can be transformed into one). |
| 8014 |
% |
| 8015 |
% For numerals we captialize in the case of |\Cutext| and print it normally (assuming |
| 8016 |
% lowercase) for |\cutext|. If the number is equal to $1$ we use the special |
| 8017 |
% |one(m)|, |one(f)| or |one(n)| translation (which also gets captialized if needed). |
| 8018 |
% \begin{macrocode} |
| 8019 |
\cs_new_protected:Npn \@@_cutext_print_number:n #1 |
| 8020 |
{ |
| 8021 |
\bool_if:NTF \l_@@_lokal_numeral_bool |
| 8022 |
{ \@@_cutext_print_input_aux:nV {#1} \l_@@_decided_unit_tl } |
| 8023 |
{ \@@_print_number_default:n {#1} } |
| 8024 |
} |
| 8025 |
\cs_new_protected:Npn \@@_cutext_print_input_aux:nn #1#2 |
| 8026 |
{ |
| 8027 |
\int_compare:nNnTF {#1} = { 1 } |
| 8028 |
{ |
| 8029 |
\@@_culang_one_let:NnT \l_@@_translation_tmpa_tl {#2} |
| 8030 |
{ |
| 8031 |
\bool_if:NT \l_@@_cutext_uppercase_word_bool |
| 8032 |
{ |
| 8033 |
\text_uppercase:x { \tl_head:V \l_@@_translation_tmpa_tl } |
| 8034 |
\tl_tail:V |
| 8035 |
} |
| 8036 |
} |
| 8037 |
\l_@@_translation_tmpa_tl |
| 8038 |
}{ |
| 8039 |
\bool_if:NTF \l_@@_cutext_uppercase_word_bool |
| 8040 |
{ \@@_print_Numeral:n {#1} } |
| 8041 |
{ \@@_print_numeral:n {#1} } |
| 8042 |
} |
| 8043 |
} |
| 8044 |
\cs_generate_variant:Nn \@@_cutext_print_input_aux:nn { nV } |
| 8045 |
% \end{macrocode} |
| 8046 |
% \end{macro} |
| 8047 |
% |
| 8048 |
% \begin{macro}{\@@_cuam_print_number:n, \@@_cuam_print_numerical_input_aux:nn, \@@_cuam_print_numerical_input_aux:nV } |
| 8049 |
% If both a phrase and a numeral is requested we do some more complicated stuff, |
| 8050 |
% else just print a number. |
| 8051 |
% |
| 8052 |
% If the numeral is \emph{not} equal to $1$ use the |\@@_print_numeral:n| function. |
| 8053 |
% Else get the translation for |one(m)|, |one(f)| or |one(n)| (depends). |
| 8054 |
% \begin{macrocode} |
| 8055 |
\cs_new_protected:Npn \@@_cuam_print_number:n #1 |
| 8056 |
{ |
| 8057 |
\bool_lazy_and:nnTF |
| 8058 |
{ \l_@@_lokal_phrase_bool } |
| 8059 |
{ \l_@@_lokal_numeral_bool } |
| 8060 |
{ |
| 8061 |
\@@_cuam_print_numerical_input_aux:nV {#1} \l_@@_phrase_number_tl |
| 8062 |
} |
| 8063 |
{ \@@_print_number_default:n {#1} } |
| 8064 |
} |
| 8065 |
\cs_new:Npn \@@_cuam_print_numerical_input_aux:nn #1#2 |
| 8066 |
{ |
| 8067 |
\int_compare:nNnTF {#1} = { 1 } |
| 8068 |
{ |
| 8069 |
\@@_culang_one_let_by_gender:NVTF |
| 8070 |
\l_@@_translation_tmpa_tl \l_@@_phrase_gender_tl |
| 8071 |
{ \l_@@_translation_tmpa_tl } |
| 8072 |
{ |
| 8073 |
\@@_print_numeral:n {#1} |
| 8074 |
\bool_set_false:N \l_@@_lokal_numeral_bool |
| 8075 |
} |
| 8076 |
} |
| 8077 |
{ \@@_print_numeral:n {#1} } |
| 8078 |
} |
| 8079 |
\cs_generate_variant:Nn \@@_cuam_print_numerical_input_aux:nn { nV } |
| 8080 |
% \end{macrocode} |
| 8081 |
% \end{macro} |
| 8082 |
% |
| 8083 |
% |
| 8084 |
% \begin{macro}{\@@_rf_print_amount_correctly:} |
| 8085 |
% In case of an error just print the original input. |
| 8086 |
% |
| 8087 |
% Else we check how many items the printing sequence has. If it is $1$ |
| 8088 |
% print the sequence with an empty argument. |
| 8089 |
% |
| 8090 |
% Else: Do we print ranges? Do we print times? If neither, there is something wrong. |
| 8091 |
% \begin{macrocode} |
| 8092 |
\cs_new:Npn \@@_rf_print_amount_correctly: |
| 8093 |
{ |
| 8094 |
\@@_if_state_equal:nTF { error } |
| 8095 |
{ |
| 8096 |
\l_@@_original_amount_tl |
| 8097 |
}{ |
| 8098 |
\int_compare:nNnTF { \l_@@_nr_of_items } = { 1 } |
| 8099 |
{ \seq_use:Nn \l_@@_prepared_printing_seq { } } |
| 8100 |
{ |
| 8101 |
\bool_if:NTF \l_@@_rf_contains_range_bool |
| 8102 |
{ \seq_use:Nn \l_@@_prepared_printing_seq { \@@_rf_print_range_sign: } } |
| 8103 |
{ |
| 8104 |
\bool_if:NTF \l_@@_rf_contains_times_bool |
| 8105 |
{ \seq_use:Nn \l_@@_prepared_printing_seq { \@@_print_times_sign: } } |
| 8106 |
{ |
| 8107 |
\@@_create_internal_error:nx { neither-range-nor-times } |
| 8108 |
{ |
| 8109 |
\fp_eval:n |
| 8110 |
{ \l_@@_rf_contains_range_bool + 2*\l_@@_rf_contains_times_bool } |
| 8111 |
} |
| 8112 |
} |
| 8113 |
} |
| 8114 |
} |
| 8115 |
} |
| 8116 |
} |
| 8117 |
% \end{macrocode} |
| 8118 |
% \end{macro} |
| 8119 |
% |
| 8120 |
% \begin{macro}{\@@_rf_print_unit_correctly:} |
| 8121 |
% Quite straightforward. |
| 8122 |
% \begin{macrocode} |
| 8123 |
\cs_new:Npn \@@_rf_print_unit_correctly: |
| 8124 |
{ |
| 8125 |
\@@_if_state_equal:nTF { error } |
| 8126 |
{ |
| 8127 |
\tl_if_eq:NNF \l_@@_cmd_type_tl \c_@@_cmd_type_cuam_tl |
| 8128 |
{ \@@_rf_print_unit_in_case_of_error: } |
| 8129 |
} |
| 8130 |
{ \@@_rf_print_unit_or_phrase: } |
| 8131 |
} |
| 8132 |
% \end{macrocode} |
| 8133 |
% \end{macro} |
| 8134 |
% |
| 8135 |
% \begin{macro}{\@@_rf_print_unit_or_phrase:} |
| 8136 |
% Printing the unit depends on the unit; nothing more or less. |
| 8137 |
% \begin{macrocode} |
| 8138 |
\cs_new:Npn \@@_rf_print_unit_or_phrase: |
| 8139 |
{ |
| 8140 |
\tl_case:NnF \l_@@_cmd_type_tl |
| 8141 |
{ |
| 8142 |
\c_@@_cmd_type_cunum_tl { \@@_cunum_print_correct_unit: } |
| 8143 |
\c_@@_cmd_type_cCutext_tl { \@@_cutext_print_correct_unitname: } |
| 8144 |
\c_@@_cmd_type_cuam_tl { \@@_cuam_print_correct_unitphrase: } |
| 8145 |
} |
| 8146 |
{ \@@_create_internal_error:nN { print-unit-acc } \l_@@_cmd_type_tl } |
| 8147 |
} |
| 8148 |
% \end{macrocode} |
| 8149 |
% \end{macro} |
| 8150 |
% |
| 8151 |
% |
| 8152 |
% |
| 8153 |
% |
| 8154 |
% |
| 8155 |
% \begin{macro}{\@@_rf_initialise_after_parsing:n} |
| 8156 |
% As the name suggests, this one is used \emph{after} parsing the amount. |
| 8157 |
% This is done in order to know if there is an error, if the unit needs |
| 8158 |
% to be changed and if this command needs to be called at all. |
| 8159 |
% |
| 8160 |
% It is kinda difficult to decide which unit is the correct one, as it may change |
| 8161 |
% due to unit-options. In theory this could lead to an infinite loop, |
| 8162 |
% so I decide in this place how things are printed and which unit |
| 8163 |
% is used. |
| 8164 |
% |
| 8165 |
% Well, in the end I only decide if a fraction is printed or not. The case of error or |
| 8166 |
% special signs were already sorted out. |
| 8167 |
% |
| 8168 |
% To make sure the lokal options override the unit-options, we set |
| 8169 |
% the options again after unit-options. |
| 8170 |
% \begin{macrocode} |
| 8171 |
\cs_new_protected:Npn \@@_rf_initialise_after_parsing:n #1 |
| 8172 |
{ |
| 8173 |
\clist_if_empty:cF { l_@@_unit_option_ \l_@@_decided_unit_tl _clist } |
| 8174 |
{ |
| 8175 |
\keys_set_groups:nnv |
| 8176 |
{ cooking-units } |
| 8177 |
{ unit-hook } |
| 8178 |
{ l_@@_unit_option_ \l_@@_decided_unit_tl _clist } |
| 8179 |
} |
| 8180 |
\tl_if_empty:nF {#1} { \l_@@_precompiled_options_tl } |
| 8181 |
\@@_if_cmd_type_equal:nTF { cunum } |
| 8182 |
{ \bool_set_false:N \l_@@_lokal_numeral_bool } |
| 8183 |
{ \bool_set_eq:NN \l_@@_lokal_numeral_bool \l_@@_pckopt_print_numeral_bool } |
| 8184 |
} |
| 8185 |
\cs_new:Npn \@@_decide_unit: |
| 8186 |
{ |
| 8187 |
\@@_change_unit:TF |
| 8188 |
{ \tl_set_eq:NN \l_@@_decided_unit_tl \l_@@_option_unit_tl } |
| 8189 |
{ \tl_set_eq:NN \l_@@_decided_unit_tl \l_@@_original_unit_tl } |
| 8190 |
} |
| 8191 |
% \end{macrocode} |
| 8192 |
% \end{macro} |
| 8193 |
% |
| 8194 |
% |
| 8195 |
% |
| 8196 |
% |
| 8197 |
% |
| 8198 |
% \begin{macro}{ \@@_rf_general_checkups: } |
| 8199 |
% Doing some general stuff and tests which are done before further processing |
| 8200 |
% the amount. |
| 8201 |
% \begin{macrocode} |
| 8202 |
\cs_new:Npn \@@_rf_general_checkups: |
| 8203 |
{ |
| 8204 |
\@@_decide_unit: |
| 8205 |
\@@_if_cmd_type_equal:nT { cCutext } |
| 8206 |
{ \@@_rf_cutext_check_if_translation_available: } |
| 8207 |
} |
| 8208 |
% \end{macrocode} |
| 8209 |
% \end{macro} |
| 8210 |
% |
| 8211 |
% |
| 8212 |
% |
| 8213 |
% \begin{macro}{ \@@_rf_prepare_fourty_two_amount: } |
| 8214 |
% Simply replaces all variables with |42|. We can change all (except for the mixed fraction tl) |
| 8215 |
% as we know if we are going to print a \enquote{number}, \enquote{range} or |
| 8216 |
% \enquote{fraction}. |
| 8217 |
% \begin{macrocode} |
| 8218 |
\cs_new:Npn \@@_rf_prepare_fourty_two_amount: |
| 8219 |
{ |
| 8220 |
\seq_map_inline:Nn \l_@@_parsed_seq |
| 8221 |
{ |
| 8222 |
\@@_rf_prepare_fourty_two_amount_aux:nnnnn |
| 8223 |
##1 |
| 8224 |
} |
| 8225 |
} |
| 8226 |
\tl_const:Nn \c_@@_fourty_two_tl { 42 } |
| 8227 |
\tl_const:Nn \c_@@_fourty_two_unknown_tl { 42(!) } |
| 8228 |
\cs_new:Npn \@@_rf_prepare_fourty_two_amount_aux:nnnnn #1#2#3#4#5 |
| 8229 |
{ |
| 8230 |
\tl_clear:N \l_@@_mixed_fraction_tl |
| 8231 |
\tl_clear:N \l_@@_number_tmpa_tl |
| 8232 |
\@@_if_state_equal:nTF { special_sign } |
| 8233 |
{ \tl_set_eq:NN \l_@@_number_tmpb_tl \c_@@_fourty_two_unknown_tl } |
| 8234 |
{ \tl_set_eq:NN \l_@@_number_tmpb_tl \c_@@_fourty_two_tl } |
| 8235 |
\bool_if:NT #1 |
| 8236 |
{ |
| 8237 |
\tl_if_empty:nF {#3} |
| 8238 |
{ \tl_set_eq:NN \l_@@_mixed_fraction_tl \l_@@_number_tmpb_tl } |
| 8239 |
\tl_if_empty:nF {#4} |
| 8240 |
{ \tl_set_eq:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl } |
| 8241 |
} |
| 8242 |
\@@_rf_seq_put_right:NnnVVV \l_@@_processed_seq |
| 8243 |
{#1} {#2} \l_@@_mixed_fraction_tl \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl |
| 8244 |
} |
| 8245 |
% \end{macrocode} |
| 8246 |
% \end{macro} |
| 8247 |
% |
| 8248 |
% |
| 8249 |
% |
| 8250 |
% \subsubsection{Process the input} |
| 8251 |
% |
| 8252 |
% |
| 8253 |
% \begin{macro}{ \@@_rf_print_unit_in_case_of_error: } |
| 8254 |
% Prints the unit in case of error. Make sure the unit is printed correctly |
| 8255 |
% with the correct spacing. If the unit is unknown, just print the input. |
| 8256 |
% \begin{macrocode} |
| 8257 |
\cs_new:Npn \@@_rf_print_unit_in_case_of_error: |
| 8258 |
{ |
| 8259 |
\tl_if_empty:NF \l_@@_phantom_tl { \phantom { \l_@@_phantom_tl } } |
| 8260 |
\tl_use:N \l_@@_value_unit_space_tl |
| 8261 |
\bool_if:NTF \l_@@_unit_error_bool |
| 8262 |
{ \l_@@_original_unit_tl } |
| 8263 |
{ \@@_culang_print:nV { unit-symbol } \l_@@_original_unit_tl } |
| 8264 |
} |
| 8265 |
% \end{macrocode} |
| 8266 |
% \end{macro} |
| 8267 |
% |
| 8268 |
% |
| 8269 |
% |
| 8270 |
% \begin{macro} { \@@_rf_print_range_sign: , \@@_print_times_sign: } |
| 8271 |
% Prints ranges. It simply prints the numbers twice, inbetween a range sign. |
| 8272 |
% \begin{macrocode} |
| 8273 |
\cs_new:Npn \@@_rf_print_range_sign: |
| 8274 |
{ |
| 8275 |
% \@@_if_cmd_type_equal:nTF { cunum } |
| 8276 |
% { |
| 8277 |
% \bool_if:NT \l_@@_seperator_after_fraction_bool { \, } |
| 8278 |
% \tl_use:N \l_@@_cunum_range_sign_tl |
| 8279 |
% }{ |
| 8280 |
\bool_lazy_or:nnTF |
| 8281 |
{ \@@_if_cmd_type_equal_p:n { cCutext } } |
| 8282 |
{ \l_@@_lokal_numeral_bool } |
| 8283 |
{ |
| 8284 |
\tl_if_empty:NTF \l_@@_cutext_range_sign_tl |
| 8285 |
{ |
| 8286 |
\@@_culang_print:nn { name } { cutext-range-phrase } |
| 8287 |
} |
| 8288 |
{ \tl_use:N \l_@@_cutext_range_sign_tl } |
| 8289 |
}{ |
| 8290 |
\bool_if:NT \l_@@_seperator_after_fraction_bool { \, } |
| 8291 |
\tl_use:N \l_@@_cunum_range_sign_tl |
| 8292 |
} |
| 8293 |
% } |
| 8294 |
} |
| 8295 |
\cs_new:Npn \@@_print_times_sign: |
| 8296 |
{ |
| 8297 |
\l_@@_times_space_tl \l_@@_times_sign_tl \l_@@_times_space_tl |
| 8298 |
} |
| 8299 |
% \end{macrocode} |
| 8300 |
% \end{macro} |
| 8301 |
% |
| 8302 |
% |
| 8303 |
% \begin{macro}{ \@@_print_numerical_input:N } |
| 8304 |
% The base printing command for numbers. Makes sure the minus sign |
| 8305 |
% and decimal-mark are correct. |
| 8306 |
% \begin{macrocode} |
| 8307 |
\cs_new_protected:Npn \@@_print_numerical_input:N #1 |
| 8308 |
{ |
| 8309 |
\tl_if_in:NnT #1 { . } |
| 8310 |
{ |
| 8311 |
\@@_culang_let:nnN { name } { decimal-mark } \l_@@_translation_tmpa_tl |
| 8312 |
\tl_replace_once:Nnn #1 { . } { \l_@@_translation_tmpa_tl } |
| 8313 |
} |
| 8314 |
\tl_replace_once:Nnn #1 { - } \c_@@_minus_tl |
| 8315 |
#1 |
| 8316 |
} |
| 8317 |
% \end{macrocode} |
| 8318 |
% \end{macro} |
| 8319 |
% |
| 8320 |
% |
| 8321 |
% |
| 8322 |
% |
| 8323 |
% |
| 8324 |
% \subsection {Parsing and checking numbers} |
| 8325 |
% |
| 8326 |
% This subsection contains macros for splitting and checking the input. |
| 8327 |
% |
| 8328 |
% \begin{macro}{\@@_create_error:n, \@@_create_error_and_stop:n , \@@_create_error:nn } |
| 8329 |
% Create error messages and set case to \enquote{error}. |
| 8330 |
% \begin{macrocode} |
| 8331 |
\cs_new:Npn \@@_create_internal_error:nN #1#2 |
| 8332 |
{ |
| 8333 |
\@@_set_state_to:n { error } |
| 8334 |
\msg_error:nnnV { cooking-units } { internal-error } {#1} #2 |
| 8335 |
} |
| 8336 |
\cs_new:Npn \@@_create_internal_error:nn #1#2 |
| 8337 |
{ |
| 8338 |
\@@_set_state_to:n { error } |
| 8339 |
\msg_error:nnnn { cooking-units } { internal-error } {#1} #2 |
| 8340 |
} |
| 8341 |
\cs_generate_variant:Nn \@@_create_internal_error:nn { nx } |
| 8342 |
\cs_new:Npn \@@_create_error:n #1 |
| 8343 |
{ |
| 8344 |
\@@_set_state_to:n { error } |
| 8345 |
\msg_error:nnV { cooking-units } {#1} \l_@@_original_amount_tl |
| 8346 |
} |
| 8347 |
\cs_new:Npn \@@_create_error_and_stop:n #1 |
| 8348 |
{ |
| 8349 |
\@@_create_error:n {#1} |
| 8350 |
\use_none_delimit_by_q_nil:w |
| 8351 |
} |
| 8352 |
\cs_new:Npn \@@_create_error:nn #1#2 |
| 8353 |
{ |
| 8354 |
\@@_set_state_to:n { error } |
| 8355 |
\msg_error:nnnV { cooking-units } {#1} {#2} \l_@@_original_amount_tl |
| 8356 |
} |
| 8357 |
\cs_generate_variant:Nn \@@_create_error:nn { nf } |
| 8358 |
% \end{macrocode} |
| 8359 |
% \end{macro} |
| 8360 |
% |
| 8361 |
% \begin{macro}{\@@_prepare_just_print_input: } |
| 8362 |
% If we decide the input is just to be printed, set it to \enquote{error} |
| 8363 |
% (because I am lazy and do not want to create another case to check). |
| 8364 |
% \begin{macrocode} |
| 8365 |
\cs_new:Npn \@@_prepare_just_print_input: |
| 8366 |
{ |
| 8367 |
\@@_set_state_to:n { error } |
| 8368 |
\tl_if_empty:NT \l_@@_original_amount_tl |
| 8369 |
{ \@@_create_error:nn { cooking-units } { empty-amount } } |
| 8370 |
} |
| 8371 |
% \end{macrocode} |
| 8372 |
% \end{macro} |
| 8373 |
% |
| 8374 |
% |
| 8375 |
% |
| 8376 |
% |
| 8377 |
% |
| 8378 |
% |
| 8379 |
% \begin{macro}{ \@@_parse_input_and_safe_in:nN } |
| 8380 |
% Parses through |#1| and makes sure it is correct. This includes checking if there |
| 8381 |
% is only one decimal sign and other stuff. The \enquote{correct} |
| 8382 |
% parsed stuff is stored in |\l_@@_tmpa_tl|. |
| 8383 |
% \begin{macrocode} |
| 8384 |
\cs_new:Npn \@@_parse_input_and_safe_in:nN #1 #2 |
| 8385 |
{ |
| 8386 |
\tl_clear:N \l_@@_tmpa_tl |
| 8387 |
\bool_set_false:N \l_@@_check_decimal_bool |
| 8388 |
\bool_set_false:N \l_@@_minus_bool |
| 8389 |
\cs_set_eq:NN \@@_parse:N \@@_start_loop:N |
| 8390 |
\tl_map_function:nN {#1} \@@_parse:N |
| 8391 |
\@@_if_state_equal:nF { error } |
| 8392 |
{ \tl_set_eq:NN #2 \l_@@_tmpa_tl } |
| 8393 |
} |
| 8394 |
% \end{macrocode} |
| 8395 |
% \end{macro} |
| 8396 |
% |
| 8397 |
% \begin{macro}{ \@@_start_loop:N } |
| 8398 |
% First, check for signs ($+$ and $-$ by default). If a sign is found and is $+$, do nothing |
| 8399 |
% and repat the sign-checking-process. If the sign is a $-$ reverese the boolean |
| 8400 |
% |\l_@@_minus_bool|. Reversing it is necessary to simulate mathematics of e.g. $+-+-1$ |
| 8401 |
% or $-+-+-1$, etc. If a non-sign is found, check if a minus sign is added and parse |
| 8402 |
% the rest. |\token_if_eq_charcode:NNF| is stolen from \pkg{siunitx}. |
| 8403 |
% \begin{macrocode} |
| 8404 |
\cs_new:Npn \@@_start_loop:N #1 |
| 8405 |
{ |
| 8406 |
\tl_if_in:NnTF \l_@@_input_value_signs_tl {#1} |
| 8407 |
{ |
| 8408 |
\token_if_eq_charcode:NNT #1 - |
| 8409 |
{ \@@_bool_reverse:N \l_@@_minus_bool } |
| 8410 |
}{ |
| 8411 |
\bool_if:NT \l_@@_minus_bool |
| 8412 |
{ \tl_put_left:Nn \l_@@_tmpa_tl { - } } |
| 8413 |
\cs_set_eq:NN \@@_parse:N \@@_parse_input_loop_aux:N |
| 8414 |
\tl_map_function:nN {#1} \@@_parse:N |
| 8415 |
} |
| 8416 |
} |
| 8417 |
% \end{macrocode} |
| 8418 |
% \end{macro} |
| 8419 |
% |
| 8420 |
% \begin{macro}{ \@@_parse_input_loop_aux:N , \@@_check_which_error:n , \@@_check_repitition:N } |
| 8421 |
% Parses the input. It also is more or less (more less then more) copied from |
| 8422 |
% \texttt{siunitx}. Checks if the input consists only of numbers, |
| 8423 |
% one decimal-sign and the allowed special input. |
| 8424 |
% In other cases, raise an error. Note that the state special-sign |
| 8425 |
% can only be set if there is no error. |
| 8426 |
% |
| 8427 |
% \begin{macrocode} |
| 8428 |
\cs_new:Npn \@@_parse_input_loop_aux:N #1 |
| 8429 |
{ |
| 8430 |
\tl_if_in:NnTF \l_@@_input_digits_tl {#1} |
| 8431 |
{ \tl_put_right:Nn \l_@@_tmpa_tl {#1} } |
| 8432 |
{ |
| 8433 |
\tl_if_in:NnTF \l_@@_input_decimal_mark_tl {#1} |
| 8434 |
{ |
| 8435 |
\@@_check_repitition:N \l_@@_check_decimal_bool |
| 8436 |
\tl_put_right:Nn \l_@@_tmpa_tl { . } |
| 8437 |
}{ |
| 8438 |
\tl_if_in:NnTF \l_@@_input_allowed_special_signs_tl {#1} |
| 8439 |
{ |
| 8440 |
\@@_if_state_equal:nF { error } |
| 8441 |
{ \@@_set_state_to:n { special_sign } } |
| 8442 |
\tl_put_right:Nn \l_@@_tmpa_tl {#1} |
| 8443 |
} |
| 8444 |
{ \@@_check_which_error:n {#1} } |
| 8445 |
} |
| 8446 |
} |
| 8447 |
} |
| 8448 |
% \end{macrocode} |
| 8449 |
% The idea behind this error checking is the following: |
| 8450 |
% At this point I already split the input. This means, a fraction |
| 8451 |
% is already split into nominator and denominator and as such, all allowed |
| 8452 |
% |/| in the input are already removed. The same goes for |_| (an error message |
| 8453 |
% for |_| without |/| would happen before parsing starts). Therefore |
| 8454 |
% all |/| and |_| in the input \emph{must} (hopefully) be inside a second time. |
| 8455 |
% \begin{macrocode} |
| 8456 |
\cs_new:Npn \@@_check_which_error:n #1 |
| 8457 |
{ |
| 8458 |
\tl_if_in:NnTF \l_@@_input_fraction_sign_tl {#1} |
| 8459 |
{ \@@_create_error:n { Second-fraction-sign-not-allowed } } |
| 8460 |
{ |
| 8461 |
\tl_if_in:NnTF \l_@@_input_mixed_fraction_sign_tl {#1} |
| 8462 |
{ |
| 8463 |
\bool_if:NTF \l_@@_rf_check_fraction_bool |
| 8464 |
{ \@@_create_error:n { Second-mixed-fraction-sign-not-allowed } } |
| 8465 |
{ \@@_create_error:n { missing-slash } } |
| 8466 |
} |
| 8467 |
{ \@@_create_error:nn { Token-not-allowed } {#1} } |
| 8468 |
} |
| 8469 |
} |
| 8470 |
% \end{macrocode} |
| 8471 |
% Back then this contained more checks, but now it just checks |
| 8472 |
% if we have a second error decimal sign. |
| 8473 |
% \begin{macrocode} |
| 8474 |
\cs_new:Npn \@@_check_repitition:N #1 |
| 8475 |
{ |
| 8476 |
\bool_if:NTF #1 |
| 8477 |
{ \@@_create_error:n { Second-decimal-sign-not-allowed } } |
| 8478 |
{ \bool_set_true:N #1 } |
| 8479 |
} |
| 8480 |
% \end{macrocode} |
| 8481 |
% \end{macro} |
| 8482 |
% |
| 8483 |
% |
| 8484 |
% |
| 8485 |
% |
| 8486 |
% |
| 8487 |
% \subsection {Formatiere \& Calculiere} |
| 8488 |
% |
| 8489 |
% |
| 8490 |
% |
| 8491 |
% |
| 8492 |
% \begin{macro}{ \@@_calculate_and_store_in:N } |
| 8493 |
% |
| 8494 |
% \changes {v0.98a} {2016/06/11} {Added warning to show if an unknown value is used.} |
| 8495 |
% |
| 8496 |
% The main calculation command. The split amount is given to this |
| 8497 |
% command. It is seperated into several smaller macros. Unit-changing |
| 8498 |
% the amount, referencing, rounding and temperature checks are done |
| 8499 |
% here. Note that we are only here if the state is \enquote{normal}. |
| 8500 |
% \begin{macrocode} |
| 8501 |
\cs_new:Npn \@@_calculate_and_store_in:N #1 |
| 8502 |
{ |
| 8503 |
\@@_calculate_input_and_store_in:N #1 |
| 8504 |
\@@_calc_references_and_store_in:N #1 |
| 8505 |
\@@_round_calculated_input_and_store_in:N #1 |
| 8506 |
\@@_check_temperature_limit:N #1 |
| 8507 |
} |
| 8508 |
% \end{macrocode} |
| 8509 |
% \end{macro} |
| 8510 |
% |
| 8511 |
% \begin{macro}{ \@@_calculate_input_and_store_in:NN } |
| 8512 |
% Well \dots\ this function calculates the input. |
| 8513 |
% First check if the units need to be changes at all (if no unit change |
| 8514 |
% is wanted, |\l_@@_option_unit_tl| is set to |\l_@@_original_unit_tl| at the |
| 8515 |
% beginning. If we are in one case were no unit change is happening |
| 8516 |
% (\enquote{special-sign}, \enquote{error}, \enquote{fraction}) we wouldn't be |
| 8517 |
% here in the first place, so need to worry about this. |
| 8518 |
% |
| 8519 |
% As the input is parsed and good for evaluation, store it in |
| 8520 |
% |\l_@@_tmpa_fp|. |
| 8521 |
% |
| 8522 |
% If the key definition contained a |#1| (aka, is a single key), |
| 8523 |
% it was replaced by |\l_@@_tmpa_fp|. |
| 8524 |
% Thus simply evaluate the tl if one or more |\l_@@_tmpa_fp| are inside. |
| 8525 |
% |
| 8526 |
% If no |\l_@@_tmpa_fp| is found, we have a simple multiplication with the |
| 8527 |
% current amount. |
| 8528 |
% \begin{macrocode} |
| 8529 |
\cs_new:Npn \@@_calculate_input_and_store_in:N #1 |
| 8530 |
{ |
| 8531 |
\tl_if_eq:NNF \l_@@_decided_unit_tl \l_@@_original_unit_tl |
| 8532 |
{ |
| 8533 |
\fp_set:Nn \l_@@_tmpa_fp {#1} |
| 8534 |
\tl_if_in:cnTF { l_@@_unit_change_ \l_@@_original_unit_tl _tl } { \l_@@_tmpa_fp } |
| 8535 |
{ |
| 8536 |
\@@_tl_set_eval:Nv #1 { l_@@_unit_change_ \l_@@_original_unit_tl _tl } |
| 8537 |
}{ |
| 8538 |
\@@_tl_set_eval:Nn #1 |
| 8539 |
{ \l_@@_tmpa_fp * \tl_use:c { l_@@_unit_change_ \l_@@_original_unit_tl _tl } } |
| 8540 |
} |
| 8541 |
} |
| 8542 |
} |
| 8543 |
% \end{macrocode} |
| 8544 |
% \end{macro} |
| 8545 |
% |
| 8546 |
% \begin{macro}{ \@@_calc_references_and_store_in:N,\@@_calc_references_and_store_in_aux:N } |
| 8547 |
% All necessary checks were already done at the beginning. |
| 8548 |
% so we know that a reference was given and that the wanted number of |
| 8549 |
% persons is different then the one given by |\culabel|. Before |
| 8550 |
% evaluation, check if the unit is one of those that cannot be changed. |
| 8551 |
% \begin{macrocode} |
| 8552 |
\bool_new:N \l_@@_curef_forbidden_unit_msg_used_bool |
| 8553 |
\cs_new:Npn \@@_calc_references_and_store_in:N #1 |
| 8554 |
{ |
| 8555 |
\bool_if:NT \l_@@_lokal_recalc_for_people_bool |
| 8556 |
{ |
| 8557 |
\seq_if_in:NVTF \l_@@_curef_do_not_change_seq \l_@@_decided_unit_tl |
| 8558 |
{ |
| 8559 |
\bool_if:NF \l_@@_curef_forbidden_unit_msg_used_bool |
| 8560 |
{ |
| 8561 |
\msg_error:nnV { cooking-units } { curef-forbidden-unit } \l_@@_decided_unit_tl |
| 8562 |
\bool_set_true:N \l_@@_curef_forbidden_unit_msg_used_bool |
| 8563 |
} |
| 8564 |
} |
| 8565 |
{ \@@_calc_references_and_store_in_aux:N #1 } |
| 8566 |
} |
| 8567 |
} |
| 8568 |
% \end{macrocode} |
| 8569 |
% Just calculate the stuff |
| 8570 |
% \begin{macrocode} |
| 8571 |
\cs_new:Npn \@@_calc_references_and_store_in_aux:N #1 |
| 8572 |
{ |
| 8573 |
\@@_tl_set_eval:Nn #1 |
| 8574 |
{ |
| 8575 |
#1 * |
| 8576 |
\l_@@_wanted_number_of_persons_int / |
| 8577 |
\l_@@_local_number_of_persons_int |
| 8578 |
} |
| 8579 |
} |
| 8580 |
% \end{macrocode} |
| 8581 |
% \end{macro} |
| 8582 |
% |
| 8583 |
% |
| 8584 |
% \begin{macro}{ \@@_round_calculated_input_and_store_in:Nn,\@@_round_calculated_input_and_store_in:NV } |
| 8585 |
% After calculation, the numbers are rounded (if needed). |
| 8586 |
% If the rounding precision is negative (can be), just set the bool to true and go |
| 8587 |
% to the rounding function. |
| 8588 |
% Else check if the number needs rounding at all. |
| 8589 |
% Afterwards, round if necessary |
| 8590 |
% \begin{macrocode} |
| 8591 |
\cs_new:Npn \@@_round_calculated_input_and_store_in:N #1 |
| 8592 |
{ |
| 8593 |
\bool_if:NTF \l_@@_pckopt_round_precision_negative_bool |
| 8594 |
{ \bool_set_true:N \l_@@_round_number_bool } |
| 8595 |
{ \@@_check_number_for_rounding:V #1 } |
| 8596 |
\bool_if:NT \l_@@_round_number_bool |
| 8597 |
{ \@@_tl_set_eval:Nn #1 { round ( \@@_rounding_function:n {#1} ) } } |
| 8598 |
} |
| 8599 |
% \end{macrocode} |
| 8600 |
% \end{macro} |
| 8601 |
% |
| 8602 |
% \begin{macro}{\@@_check_number_for_rounding:n,\@@_check_number_after_dot_aux:ww} |
| 8603 |
% Check if rounding is needed. The auxilary function splits the number into |
| 8604 |
% the integer and non-integer part ($12.45$ to $12$ and $45$). |
| 8605 |
% |
| 8606 |
% Set |\l_@@_round_number_bool| to |false| in case of no decimal places found. |
| 8607 |
% |
| 8608 |
% If the rounding precision is positive, use the helper function to split the |
| 8609 |
% amount. |
| 8610 |
% \begin{macrocode} |
| 8611 |
\cs_new:Npn \@@_check_number_for_rounding:n #1 |
| 8612 |
{ |
| 8613 |
\bool_set_false:N \l_@@_round_number_bool |
| 8614 |
\@@_check_number_after_dot_aux:ww #1 . \q_recursion_tail . |
| 8615 |
\q_recursion_stop |
| 8616 |
} |
| 8617 |
\cs_generate_variant:Nn \@@_check_number_for_rounding:n { V } |
| 8618 |
% \end{macrocode} |
| 8619 |
% The function splitting the amount. So $a.b$ is split into $a$ and $b$. |
| 8620 |
% If $b$ does not exist (so the amount is an integer), no rounding is needed. |
| 8621 |
% If $b$ does exist, count how many tokens it conists of (e.g.\ $12$ = 2 tokens; |
| 8622 |
% $1755$ = 4 tokens). If the number of tokens is larger then the wanted round precision, |
| 8623 |
% round the input. |
| 8624 |
% \begin{macrocode} |
| 8625 |
\cs_new:Npn \@@_check_number_after_dot_aux:ww #1 . #2 . |
| 8626 |
{ |
| 8627 |
\quark_if_recursion_tail_stop:n {#2} |
| 8628 |
\int_compare:nNnT |
| 8629 |
{ \tl_count:n {#2} } > |
| 8630 |
{ \l_@@_round_precision_int } |
| 8631 |
{ \bool_set_true:N \l_@@_round_number_bool } |
| 8632 |
\use_none_delimit_by_q_recursion_stop:w |
| 8633 |
} |
| 8634 |
% \end{macrocode} |
| 8635 |
% \end{macro} |
| 8636 |
% |
| 8637 |
% |
| 8638 |
% |
| 8639 |
% |
| 8640 |
% |
| 8641 |
% |
| 8642 |
% |
| 8643 |
% |
| 8644 |
% |
| 8645 |
% \begin{macro}{\@@_check_temperature_limit:N} |
| 8646 |
% If \lstinline|check_temperature_bool| is set to true it now checks |
| 8647 |
% if the value is below the absolute temperature. Maybe this should be done |
| 8648 |
% before rounding? |
| 8649 |
% \begin{macrocode} |
| 8650 |
\cs_new:Npn \@@_check_temperature_limit:N #1 |
| 8651 |
{ |
| 8652 |
\bool_if:NT \l_@@_pckopt_check_temperature_bool |
| 8653 |
{ |
| 8654 |
\seq_if_in:NVT \l_@@_temperatures_to_check_seq \l_@@_decided_unit_tl |
| 8655 |
{ |
| 8656 |
\fp_compare:vNnT |
| 8657 |
{ l_@@_ \l_@@_decided_unit_tl _min_fp } > {#1} |
| 8658 |
{ |
| 8659 |
\msg_error:nnxx { cooking-units } |
| 8660 |
{ Temperature-too-low } |
| 8661 |
{ #1 \space \l_@@_decided_unit_tl } |
| 8662 |
{ |
| 8663 |
\fp_use:c { l_@@_ \l_@@_decided_unit_tl _min_fp } |
| 8664 |
\space \l_@@_decided_unit_tl |
| 8665 |
} |
| 8666 |
} |
| 8667 |
} |
| 8668 |
} |
| 8669 |
} |
| 8670 |
% \end{macrocode} |
| 8671 |
% \end{macro} |
| 8672 |
% |
| 8673 |
% |
| 8674 |
% |
| 8675 |
% |
| 8676 |
% |
| 8677 |
% |
| 8678 |
% |
| 8679 |
% |
| 8680 |
% |
| 8681 |
% |
| 8682 |
% \subsection {Main commands helper} |
| 8683 |
% |
| 8684 |
% \begin{macro}{ \@@_if_arrow_grab_until_close_do:nnTF , |
| 8685 |
% \@@_grab_arrows_for_safety_do_afterwards:nN } |
| 8686 |
% I really do not like this constuction, but due to catcodes it can happen |
| 8687 |
% that the main commands are unable to get the first command inside <>. |
| 8688 |
% In order to fix this, I use this bloody construction. |
| 8689 |
% \begin{macrocode} |
| 8690 |
\cs_new_nopar:Npn \@@_if_arrow_grab_until_close_do:nnTF #1#2#3#4 |
| 8691 |
{ |
| 8692 |
\str_if_eq:nnTF {#1} { < } |
| 8693 |
{ |
| 8694 |
\tl_if_in:NoT \l_@@_input_allowed_special_signs_tl { < } |
| 8695 |
{ \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } } |
| 8696 |
\tl_clear:N \l_@@_tmpa_tl |
| 8697 |
\tl_put_right:Nx \l_@@_tmpa_tl { \tl_to_str:N < } |
| 8698 |
\@@_grab_arrows_for_safety_do_afterwards:nN {#3} #2 |
| 8699 |
} |
| 8700 |
{#4} |
| 8701 |
} |
| 8702 |
\cs_new_nopar:Npn \@@_grab_arrows_for_safety_do_afterwards:nN #1#2 |
| 8703 |
{ |
| 8704 |
\str_if_eq:nnTF {#2} { > } |
| 8705 |
{ |
| 8706 |
\tl_put_right:Nx \l_@@_tmpa_tl { \tl_to_str:N > } |
| 8707 |
\exp_last_unbraced:NV #1 \l_@@_tmpa_tl |
| 8708 |
}{ |
| 8709 |
\tl_put_right:Nn \l_@@_tmpa_tl {#2} |
| 8710 |
\@@_grab_arrows_for_safety_do_afterwards:nN {#1} |
| 8711 |
} |
| 8712 |
} |
| 8713 |
% \end{macrocode} |
| 8714 |
% \end{macro} |
| 8715 |
% |
| 8716 |
% |
| 8717 |
% \subsection {\mycs{cunum}} |
| 8718 |
% |
| 8719 |
% |
| 8720 |
% \begin{macro}{ \cunum } |
| 8721 |
% The main command of this package. |
| 8722 |
% \begin{macrocode} |
| 8723 |
\NewDocumentCommand \cunum { d<> O{} m O{} m } |
| 8724 |
{ |
| 8725 |
\@@_if_arrow_grab_until_close_do:nnTF {#3} {#5} |
| 8726 |
{ \cunum } |
| 8727 |
{ |
| 8728 |
\group_begin: |
| 8729 |
\@@_cunum:nnnnn {#1} {#2} {#3} {#4} {#5} |
| 8730 |
\group_end: |
| 8731 |
} |
| 8732 |
} |
| 8733 |
% \end{macrocode} |
| 8734 |
% \end{macro} |
| 8735 |
% |
| 8736 |
% |
| 8737 |
% \begin{macro}{ \@@_cunum:nnnnn } |
| 8738 |
% The \enquote{helper} command. It essentially only sets |
| 8739 |
% the command type to \enquote{cunum} and calls the command that does |
| 8740 |
% everything else. |
| 8741 |
% \begin{macrocode} |
| 8742 |
\cs_new:Npn \@@_cunum:nnnnn #1#2#3#4#5 |
| 8743 |
{ |
| 8744 |
\@@_set_cmd_type_to:n { cunum } |
| 8745 |
\@@_rf_main_command:nnnnnn {#1} {#2} {#3} {#4} {#5} { } |
| 8746 |
} |
| 8747 |
% \end{macrocode} |
| 8748 |
% \end{macro} |
| 8749 |
% |
| 8750 |
% |
| 8751 |
% \begin{macro}{ \@@_cunum_print_correct_unit: } |
| 8752 |
% The invisible space is added by a \lstinline|\phantom|, afterwards |
| 8753 |
% \lstinline|value_unit_space_tl| is used (which is set to |
| 8754 |
% \lstinline|\thinspace| by default) and if either special signs or |
| 8755 |
% fractions are parsed the input-unit is printed else the converted |
| 8756 |
% unit is. |
| 8757 |
% \begin{macrocode} |
| 8758 |
\cs_new:Npn \@@_cunum_print_correct_unit: |
| 8759 |
{ |
| 8760 |
\tl_if_empty:NF \l_@@_phantom_tl { \phantom { \l_@@_phantom_tl } } |
| 8761 |
\tl_use:N \l_@@_value_unit_space_tl |
| 8762 |
\@@_culang_print:nV { unit-symbol } \l_@@_decided_unit_tl |
| 8763 |
} |
| 8764 |
% \end{macrocode} |
| 8765 |
% \end{macro} |
| 8766 |
% |
| 8767 |
% |
| 8768 |
% \section { cutext \& Cutext } |
| 8769 |
% |
| 8770 |
% |
| 8771 |
% \begin{macro}{\cutext} |
| 8772 |
% The other main command It is essentially similar to \mycs{cunum}, |
| 8773 |
% only that we also need to take care of uppercasing the word if necessary |
| 8774 |
% (which it is not for this command). |
| 8775 |
% \begin{macrocode} |
| 8776 |
\NewDocumentCommand \cutext { d<> O{} m m } |
| 8777 |
{ |
| 8778 |
\@@_if_arrow_grab_until_close_do:nnTF {#3} {#4} |
| 8779 |
{ \cutext } |
| 8780 |
{ |
| 8781 |
\group_begin: |
| 8782 |
\bool_set_false:N \l_@@_cutext_uppercase_word_bool |
| 8783 |
\@@_cutext:nnnn {#1} {#2} {#3} {#4} |
| 8784 |
\group_end: |
| 8785 |
} |
| 8786 |
} |
| 8787 |
% \end{macrocode} |
| 8788 |
% \end{macro} |
| 8789 |
% |
| 8790 |
% \begin{macro}{\Cutext} |
| 8791 |
% Here we do need the uppercasing. |
| 8792 |
% \begin{macrocode} |
| 8793 |
\NewDocumentCommand \Cutext { d<> O{} m m } |
| 8794 |
{ |
| 8795 |
\@@_if_arrow_grab_until_close_do:nnTF {#3} {#4} |
| 8796 |
{ \Cutext } |
| 8797 |
{ |
| 8798 |
\group_begin: |
| 8799 |
\bool_set_true:N \l_@@_cutext_uppercase_word_bool |
| 8800 |
\@@_cutext:nnnn {#1} {#2} {#3} {#4} |
| 8801 |
\group_end: |
| 8802 |
} |
| 8803 |
} |
| 8804 |
% \end{macrocode} |
| 8805 |
% \end{macro} |
| 8806 |
% |
| 8807 |
% |
| 8808 |
% \begin{macro}{ \@@_cutext:nnnn } |
| 8809 |
% Same as the \mycs{cunum} equivalent, just setting the command to |
| 8810 |
% \enquote{cCutext}. |
| 8811 |
% \begin{macrocode} |
| 8812 |
\cs_new:Npn \@@_cutext:nnnn #1#2#3#4 |
| 8813 |
{ |
| 8814 |
\@@_set_cmd_type_to:n { cCutext } |
| 8815 |
\@@_rf_main_command:nnnnnn {#1} {#2} {#3} { } {#4} { } |
| 8816 |
} |
| 8817 |
% \end{macrocode} |
| 8818 |
% \end{macro} |
| 8819 |
% |
| 8820 |
% |
| 8821 |
% |
| 8822 |
% \begin{macro} {\@@_cutext_print_input:N , \@@_cutext_print_input_aux:Nn , \@@_cutext_print_input_aux:NV } |
| 8823 |
% \changes {2016/06/11} {0.99} {New.} |
| 8824 |
% |
| 8825 |
% This prints the amount for the \enquote{cCutext} commands. |
| 8826 |
% At first, check if a numeral should be used (\enquote{1} to \enquote{one}, etc.). |
| 8827 |
% If not, just print the number. If a numeral should be used, make sure the correct |
| 8828 |
% unit is used and go to the next command. |
| 8829 |
% \begin{macrocode} |
| 8830 |
\cs_new_protected:Npn \@@_cutext_print_input:N #1 |
| 8831 |
{ |
| 8832 |
\bool_if:NTF \l_@@_lokal_numeral_bool |
| 8833 |
{ |
| 8834 |
\@@_cutext_print_input_aux:NV #1 \l_@@_decided_unit_tl |
| 8835 |
} |
| 8836 |
{ \@@_print_numerical_input:N #1 } |
| 8837 |
} |
| 8838 |
% \end{macrocode} |
| 8839 |
% If a numeral is used, make sure the correct one is printed. |
| 8840 |
% If the amount is equal to \enquote{1}, get the gender correct \enquote{one}. |
| 8841 |
% Else, print the numeral either in upperacse of lowercase. |
| 8842 |
% |
| 8843 |
% As we could be in a range, we cannot check via a bool if |#1| is 1. |
| 8844 |
% |
| 8845 |
% Furthermore, make sure the translation of \enquote{1} exists. If not, |
| 8846 |
% set input it set to \enquote{1}. |
| 8847 |
% \begin{macrocode} |
| 8848 |
\cs_new_protected:Npn \@@_cutext_print_input_aux:Nn #1#2 |
| 8849 |
{ |
| 8850 |
\int_compare:nNnTF {#1} = { 1 } |
| 8851 |
{ |
| 8852 |
\@@_culang_one_let:NnT \l_@@_translation_tmpa_tl {#2} |
| 8853 |
{ |
| 8854 |
\bool_if:NT \l_@@_cutext_uppercase_word_bool |
| 8855 |
{ |
| 8856 |
\text_uppercase:x { \tl_head:V \l_@@_translation_tmpa_tl } |
| 8857 |
\tl_tail:V |
| 8858 |
} |
| 8859 |
} |
| 8860 |
\l_@@_translation_tmpa_tl |
| 8861 |
}{ |
| 8862 |
\bool_if:NTF \l_@@_cutext_uppercase_word_bool |
| 8863 |
{ \@@_print_Numeral:V #1 } |
| 8864 |
{ \@@_print_numeral:V #1 } |
| 8865 |
} |
| 8866 |
} |
| 8867 |
\cs_generate_variant:Nn \@@_cutext_print_input_aux:Nn { NV } |
| 8868 |
% \end{macrocode} |
| 8869 |
% \end{macro} |
| 8870 |
% |
| 8871 |
% \begin{macro}{\@@_cutext_print_correct_unitname:} |
| 8872 |
% As the name suggests, it prints the unitname. At this point we already |
| 8873 |
% know that a translation exists, so no bother checking again. |
| 8874 |
% \begin{macrocode} |
| 8875 |
\cs_new:Npn \@@_cutext_print_correct_unitname: |
| 8876 |
{ |
| 8877 |
\bool_if:NTF \l_@@_lokal_numeral_bool |
| 8878 |
{ \l_@@_cutext_numeral_space_tl } |
| 8879 |
{ \l_@@_cutext_space_tl } |
| 8880 |
\bool_if:NTF \l_@@_cutext_use_single_bool |
| 8881 |
{ \@@_culang_print:nV { name } \l_@@_decided_unit_tl } |
| 8882 |
{ \@@_culang_print:nV { name-pl } \l_@@_decided_unit_tl } |
| 8883 |
} |
| 8884 |
% \end{macrocode} |
| 8885 |
% \end{macro} |
| 8886 |
% |
| 8887 |
% \begin{macro}{ \@@_rf_cutext_check_if_translation_available: } |
| 8888 |
% Checks if a unitname of the current unit exists. If yes, continue. |
| 8889 |
% here we can also decide if the unit should be kept the same or not |
| 8890 |
% as we know that we stay in \enquote{cCutext}. |
| 8891 |
% If not, change the command to \enquote{cunum}. |
| 8892 |
% \begin{macrocode} |
| 8893 |
\cs_new:Npn \@@_rf_cutext_check_if_translation_available: |
| 8894 |
{ |
| 8895 |
\bool_if:NTF \l_@@_pckopt_cutext_keep_unit_bool |
| 8896 |
{ \tl_set_eq:NN \l_@@_curr_unit_tl \l_@@_original_unit_tl } |
| 8897 |
{ \tl_set_eq:NN \l_@@_curr_unit_tl \l_@@_decided_unit_tl } |
| 8898 |
\@@_culang_unitname_let:NVTF \l_@@_scrap_tl \l_@@_curr_unit_tl |
| 8899 |
{ |
| 8900 |
\bool_if:NT \l_@@_pckopt_cutext_keep_unit_bool |
| 8901 |
{ |
| 8902 |
\tl_set_eq:NN \l_@@_decided_unit_tl \l_@@_original_unit_tl |
| 8903 |
\tl_set_eq:NN \l_@@_option_unit_tl \l_@@_original_unit_tl |
| 8904 |
} |
| 8905 |
}{ |
| 8906 |
\msg_warning:nnx |
| 8907 |
{ cooking-units } |
| 8908 |
{ cutext-no-translation-available } |
| 8909 |
\l_@@_curr_unit_tl |
| 8910 |
\@@_set_cmd_type_to:n { cunum } |
| 8911 |
\@@_decide_unit: |
| 8912 |
} |
| 8913 |
} |
| 8914 |
% \end{macrocode} |
| 8915 |
% \end{macro} |
| 8916 |
% |
| 8917 |
% |
| 8918 |
% \begin{macro}{ \@@_cutext_post_process_input:NN } |
| 8919 |
% |#1| is always a number, |#2| only is valid if we have a range. |
| 8920 |
% For later, check if either |#1| or |#2| is equal to one. |
| 8921 |
% |
| 8922 |
% Then (Than?) check if a numeral is requested. If yes, |#1| (and if range also |#2|) |
| 8923 |
% need to be integers. If they are not, numerals cannot be used. If one or both |
| 8924 |
% are integers, if they are below |\l_@@_print_numerals_below_int|. |
| 8925 |
% \begin{macrocode} |
| 8926 |
|
| 8927 |
% \end{macrocode} |
| 8928 |
% \end{macro} |
| 8929 |
% \begin{macro} { \@@_cutext_post_process_fraction_input:NNN } |
| 8930 |
% \begin{macrocode} |
| 8931 |
|
| 8932 |
% \end{macrocode} |
| 8933 |
% \end{macro} |
| 8934 |
% \begin{macro} { \@@_cutext_check_if_plural_is_needed:N } |
| 8935 |
% Check if the input is equal to |#1|. Use fp as it is not necessary an integer. |
| 8936 |
% Set the boolean according to the result. |
| 8937 |
% \begin{macrocode} |
| 8938 |
%\cs_new:Npn \@@_cutext_check_if_plural_is_needed:N #1 |
| 8939 |
% { |
| 8940 |
% \fp_compare:nNnTF {#1} = { 1.0 } |
| 8941 |
% { \bool_set_true:N } { \bool_set_false:N } |
| 8942 |
% \l_@@_cutext_use_single_bool |
| 8943 |
% } |
| 8944 |
% \end{macrocode} |
| 8945 |
% \end{macro} |
| 8946 |
% |
| 8947 |
% |
| 8948 |
% |
| 8949 |
% |
| 8950 |
% |
| 8951 |
% |
| 8952 |
% |
| 8953 |
% |
| 8954 |
% |
| 8955 |
% |
| 8956 |
% |
| 8957 |
% \section{cuam} |
| 8958 |
% |
| 8959 |
% \begin{macro}{ \c_@@_no_unit_marker_tl , \@@_if_no_unit_marker:NTF } |
| 8960 |
% A marker used for \mycs{cuam}. It essentially tells that no unit is used. |
| 8961 |
% Define some commands to avoid some errors and add it to the unit list. |
| 8962 |
% \begin{macrocode} |
| 8963 |
\tl_const:Nx \c_@@_no_unit_marker_tl { \@@_to_unit:n { @@_no_unit } } |
| 8964 |
\prg_new_conditional:Npnn \@@_if_no_unit_marker:N #1 { TF , F } |
| 8965 |
{ |
| 8966 |
\tl_if_eq:NNTF \c_@@_no_unit_marker_tl #1 |
| 8967 |
{ |
| 8968 |
\tl_if_eq:NNF \l_@@_cmd_type_tl \c_@@_cmd_type_cuam_tl |
| 8969 |
{ |
| 8970 |
\@@_create_internal_error:nN { cmd-type-no-unit-maker } \l_@@_cmd_type_tl |
| 8971 |
} |
| 8972 |
\prg_return_true: |
| 8973 |
} |
| 8974 |
{ \prg_return_false: } |
| 8975 |
} |
| 8976 |
\seq_gput_right:NV \g_@@_list_of_defined_units_seq \c_@@_no_unit_marker_tl |
| 8977 |
\tl_new:c { l_@@_unit_change_ \c_@@_no_unit_marker_tl _tl } |
| 8978 |
\tl_set:cn { l_@@_unit_change_ \c_@@_no_unit_marker_tl _tl } { 1.0 } |
| 8979 |
\clist_new:c { l_@@_unit_option_ \c_@@_no_unit_marker_tl _clist } |
| 8980 |
% \end{macrocode} |
| 8981 |
% |
| 8982 |
% \begin{macro}{\cuam} |
| 8983 |
% Replaces and extends \mycs{cufrac}. Essentially the same as the other commands. |
| 8984 |
% \begin{macrocode} |
| 8985 |
\NewDocumentCommand \cuam { d<> O{} m } |
| 8986 |
{ |
| 8987 |
\@@_if_arrow_grab_until_close_do:nnTF {#3} { } |
| 8988 |
{ \cuam } |
| 8989 |
{ |
| 8990 |
\group_begin: |
| 8991 |
\@@_cuam:nnn {#1} {#2} {#3} |
| 8992 |
\group_end: |
| 8993 |
} |
| 8994 |
} |
| 8995 |
% \end{macrocode} |
| 8996 |
% \end{macro} |
| 8997 |
% |
| 8998 |
% \begin{macro}{\@@_cuam:nnn} |
| 8999 |
% Nothing really special happening here. Use |\c_@@_no_unit_marker_tl| |
| 9000 |
% to tell the internal thing that we have a valid no-unit-exists case. |
| 9001 |
% \begin{macrocode} |
| 9002 |
\cs_new:Npn \@@_cuam:nnn #1#2#3 |
| 9003 |
{ |
| 9004 |
\@@_set_cmd_type_to:n { cuam } |
| 9005 |
\@@_rf_main_command:nnnnVn {#1} {#2} {#3} { } \c_@@_no_unit_marker_tl { } |
| 9006 |
} |
| 9007 |
% \end{macrocode} |
| 9008 |
% \end{macro} |
| 9009 |
% |
| 9010 |
% \begin{macro}{\@@_cuam_post_process_input} |
| 9011 |
% |
| 9012 |
% |
| 9013 |
% Just a helper macro to tidy up the main macro. The first thing to |
| 9014 |
% do is to check if the numerical input consits of integers. This |
| 9015 |
% is done both both numerical values (if a range exists). |
| 9016 |
% Afterwards check if phrases are used and can be used at all. This needs |
| 9017 |
% to be done before the numeral check as it can change the input. |
| 9018 |
% \begin{macrocode} |
| 9019 |
|
| 9020 |
% \end{macrocode} |
| 9021 |
% \end{macro} |
| 9022 |
%\begin{macro}{ \@@_cuam_post_process_input_phrases:NN} |
| 9023 |
% |
| 9024 |
% I really do not like this command, but I still do not have a bette idea |
| 9025 |
% how to handle the whole thing. |
| 9026 |
% |
| 9027 |
% Does a list of phrases exist |
| 9028 |
% for the current language? If yes, parse the input and check if phrases are used. |
| 9029 |
% It is important for ranges to check both values and then decide if phrases |
| 9030 |
% are used or not. |
| 9031 |
% \begin{macrocode} |
| 9032 |
|
| 9033 |
% \end{macrocode} |
| 9034 |
% \begin{macrocode} |
| 9035 |
|
| 9036 |
% \end{macrocode} |
| 9037 |
% \end{macro} |
| 9038 |
% |
| 9039 |
% |
| 9040 |
% \begin{macro}{\@@_cuam_print_numerical_input:N, \@@_cuam_print_numerical_input_aux:Nn, \@@_cuam_print_numerical_input_aux:NV } |
| 9041 |
% Printing the numerical input for \mycs{cuam}. If both phrases and numerals |
| 9042 |
% are requested, go to the helper macro. Else, just print the numerical input. |
| 9043 |
% We need both to be true or else it can happen that numerals are used |
| 9044 |
% without anything to follow it up (Instead of \enquote{zwei Dutzend} we simply would |
| 9045 |
% have \enquote{zwei}). |
| 9046 |
% \begin{macrocode} |
| 9047 |
\cs_new_protected:Npn \@@_cuam_print_numerical_input:N #1 |
| 9048 |
{ |
| 9049 |
\bool_lazy_and:nnTF |
| 9050 |
{ \l_@@_lokal_phrase_bool } |
| 9051 |
{ \l_@@_lokal_numeral_bool } |
| 9052 |
{ |
| 9053 |
\@@_cuam_print_numerical_input_aux:NV #1\l_@@_phrase_number_tl |
| 9054 |
} |
| 9055 |
{ \@@_print_numerical_input:N #1 } |
| 9056 |
} |
| 9057 |
% \end{macrocode} |
| 9058 |
% Currently \mycs{cuam} only allows for lowercase numerals. |
| 9059 |
% \begin{macrocode} |
| 9060 |
\cs_new:Npn \@@_cuam_print_numerical_input_aux:Nn #1#2 |
| 9061 |
{ |
| 9062 |
\int_compare:nNnTF {#1} = { 1 } |
| 9063 |
{ |
| 9064 |
\@@_culang_one_let_by_gender:NVTF |
| 9065 |
\l_@@_translation_tmpa_tl \l_@@_phrase_gender_tl |
| 9066 |
{ |
| 9067 |
\l_@@_translation_tmpa_tl |
| 9068 |
} |
| 9069 |
{ |
| 9070 |
\@@_print_numeral:V #1 |
| 9071 |
\bool_set_false:N \l_@@_lokal_numeral_bool |
| 9072 |
} |
| 9073 |
} |
| 9074 |
{ \@@_print_numeral:V #1 } |
| 9075 |
} |
| 9076 |
\cs_generate_variant:Nn \@@_cuam_print_numerical_input_aux:Nn { NV } |
| 9077 |
% \end{macrocode} |
| 9078 |
% \end{macro} |
| 9079 |
% |
| 9080 |
% \begin{macro} { \@@_cuam_print_correct_unitphrase: } |
| 9081 |
% THis one is thankfully straightforward. |
| 9082 |
% \begin{macrocode} |
| 9083 |
\cs_new:Npn \@@_cuam_print_correct_unitphrase: |
| 9084 |
{ |
| 9085 |
\bool_if:NT \l_@@_lokal_phrase_bool |
| 9086 |
{ |
| 9087 |
\l_@@_cuphrase_space_tl |
| 9088 |
\l_@@_phrase_text_tl |
| 9089 |
} |
| 9090 |
} |
| 9091 |
% \end{macrocode} |
| 9092 |
% \end{macro} |
| 9093 |
% |
| 9094 |
% |
| 9095 |
% |
| 9096 |
% |
| 9097 |
% \subsection{Public Primitives} |
| 9098 |
% |
| 9099 |
% Two public commands. |
| 9100 |
% \begin{macro}{ \cookingunits_print_fraction:nnn } |
| 9101 |
% \begin{macrocode} |
| 9102 |
\cs_new:Npn \cookingunits_print_fraction:nnn #1#2#3 |
| 9103 |
{ |
| 9104 |
\group_begin: |
| 9105 |
\@@_print_fraction:nnnn { 0 } {#1} {#2} {#3} |
| 9106 |
\group_end: |
| 9107 |
} |
| 9108 |
% \end{macrocode} |
| 9109 |
% \end{macro} |
| 9110 |
% \begin{macro}{ \cookingunits_print_range:nn } |
| 9111 |
% \begin{macrocode} |
| 9112 |
\cs_new:Npn \cookingunits_print_range:nn #1#2 |
| 9113 |
{ |
| 9114 |
\group_begin: |
| 9115 |
\@@_set_cmd_type_to:n { cunum } |
| 9116 |
\@@_print_number_default:n {#1} |
| 9117 |
\@@_rf_print_range_sign: |
| 9118 |
\@@_print_number_default:n {#2} |
| 9119 |
\group_end: |
| 9120 |
} |
| 9121 |
% \end{macrocode} |
| 9122 |
% \end{macro} |
| 9123 |
% |
| 9124 |
% \subsection{\mycs{cucomp}} |
| 9125 |
% |
| 9126 |
% |
| 9127 |
% \begin{macrocode} |
| 9128 |
%\NewDocumentCommand \cucomp { d<> O{} m m m } |
| 9129 |
% { |
| 9130 |
% \group_begin: |
| 9131 |
% \@@_cucomp:nnnnn {#1} {#2} {#3} {#4} {#5} |
| 9132 |
% \group_end: |
| 9133 |
% } |
| 9134 |
% \end{macrocode} |
| 9135 |
% \begin{macrocode} |
| 9136 |
%\cs_new:Npn \@@_cucomp:nnnnn #1#2 #3#4#5 |
| 9137 |
% { |
| 9138 |
% \group_begin: |
| 9139 |
% \@@_set_cmd_type_to:n { cunum } |
| 9140 |
% \@@_do_the_stuff:nnnnnn {#1} {#2} {#3} { } {#4} { } |
| 9141 |
% / |
| 9142 |
% \@@_do_the_stuff:nnnnnn {#1} {#4=#5} {#3} { } {#4} { } |
| 9143 |
% \group_end: |
| 9144 |
% } |
| 9145 |
% \end{macrocode} |
| 9146 |
% |
| 9147 |
% \begin{macrocode} |
| 9148 |
%\cs_new:Npn \@@_do_cucomp_stuff:nnnnn #1#2 #3#4#5 |
| 9149 |
% { |
| 9150 |
% \group_begin: |
| 9151 |
% \@@_set_cmd_to:n { cucomp } |
| 9152 |
% \@@_do_the_stuff:nnnnnn {#1} {#2} {#3} { } {#4} |
| 9153 |
% \@@_do_the_stuff:nnnnnn {#1} {#2} {#3} { } {#5} |
| 9154 |
% \group_end: |
| 9155 |
% } |
| 9156 |
% \end{macrocode} |
| 9157 |
% |
| 9158 |
% \begin{macrocode} |
| 9159 |
%\cs_new:Npn \@@_new_process_compare_in_input: |
| 9160 |
% { |
| 9161 |
% \tl_set_eq:NN \l_@@_number_tmpb_tl \l_@@_number_tmpa_tl |
| 9162 |
% \tl_set_eq:NN \l_@@_tmpa_unit_tl \l_@@_option_unit_tl |
| 9163 |
% \@@_calculate_and_store_in:N \l_@@_number_tmpa_tl |
| 9164 |
% \@@_calculate_and_store_in:N \l_@@_number_tmpb_tl |
| 9165 |
% \@@_post_process_accordingly:NN \l_@@_number_tmpa_tl \q_no_value |
| 9166 |
% } |
| 9167 |
% \end{macrocode} |
| 9168 |
% |
| 9169 |
% |
| 9170 |
% |
| 9171 |
% \section {cukeys} |
| 9172 |
% |
| 9173 |
% \subsection {Define Keys} |
| 9174 |
% |
| 9175 |
% \begin{macro}{ } |
| 9176 |
% Defining keys. |
| 9177 |
% \begin{macrocode} |
| 9178 |
|
| 9179 |
%% To be deleted. In order to remove error messages. |
| 9180 |
%\newcommand \cudefinekeys {} |
| 9181 |
%\newcommand \cudefinesinglekey {} |
| 9182 |
%\newcommand \cuaddkeys {} |
| 9183 |
%\newcommand \cuaddsinglekeys {} |
| 9184 |
%\newcommand \cuaddtokeys {} |
| 9185 |
% \end{macrocode} |
| 9186 |
% \end{macro} |
| 9187 |
% |
| 9188 |
% |
| 9189 |
% |
| 9190 |
% |
| 9191 |
% \begin{macro}{ \cudefinekeys , \cudefinesinglekey } |
| 9192 |
% Commands used for defining unit-keys. Their main differences |
| 9193 |
% is in setting |\l_@@_single_key_bool| to the respective value |
| 9194 |
% and for single-keys to rescan |#2| as it can contain |#1| in its argument. |
| 9195 |
% |
| 9196 |
% The other stuff is imply a intialization using the unit in |#1| as a base |
| 9197 |
% and parsing the rest. |
| 9198 |
% \begin{macrocode} |
| 9199 |
\NewDocumentCommand \cudefinekeys { m m } |
| 9200 |
{ |
| 9201 |
\bool_set_false:N \l_@@_single_key_bool |
| 9202 |
\@@_initialice_cukeys_define:n {#1} |
| 9203 |
\@@_cukeys_prepare_parsing_keys:nn {#1} {#2} |
| 9204 |
} |
| 9205 |
\NewDocumentCommand \cudefinesinglekey { m m } |
| 9206 |
{ |
| 9207 |
\bool_set_true:N \l_@@_single_key_bool |
| 9208 |
\@@_initialice_cukeys_define:n {#1} |
| 9209 |
\tl_set_rescan:Nno \l_@@_tmpa_tl |
| 9210 |
{ \char_set_catcode_letter:N \# } {#2} |
| 9211 |
\@@_cukeys_prepare_parsing_keys:nV {#1} \l_@@_tmpa_tl |
| 9212 |
} |
| 9213 |
% \end{macrocode} |
| 9214 |
% \end{macro} |
| 9215 |
% |
| 9216 |
% \begin{macro}{ \@@_initialice_cukeys_define:n } |
| 9217 |
% Using |#1| as the base unit for the following keys we set some variables. |
| 9218 |
% |\l_@@_tmpa_seq| will contain the parsed units; |\l_@@_tmpb_seq| the values. |
| 9219 |
% We also make sure the unit |#1| is defined, else create an error. |
| 9220 |
% Also of importance is to set |\l_@@_new_key_base_tl| to $1$. This variable |
| 9221 |
% is important while adding keys as it sets the base conversion value so to speak. |
| 9222 |
% \begin{macrocode} |
| 9223 |
\cs_new:Npn \@@_initialice_cukeys_define:n #1 |
| 9224 |
{ |
| 9225 |
\@@_set_state_to:n { normal } |
| 9226 |
\seq_clear:N \l_@@_tmpa_seq |
| 9227 |
\seq_clear:N \l_@@_tmpb_seq |
| 9228 |
\prop_clear:N \l_@@_tmpa_prop |
| 9229 |
\tl_set:Nn \l_@@_new_key_base_tl { 1 } |
| 9230 |
\@@_error_if_unit_not_defined:nNT {#1} \l_@@_original_unit_tl |
| 9231 |
{ \@@_set_state_to:n { error } } |
| 9232 |
} |
| 9233 |
% \end{macrocode} |
| 9234 |
% \end{macro} |
| 9235 |
% |
| 9236 |
% |
| 9237 |
% \begin{macro}{\cudefinekeychain} |
| 9238 |
% The command that is going to replace \mycs{cudefinekeys} and friends |
| 9239 |
% (but \emph{not} the single key variants). Nothing going on here. |
| 9240 |
% The biggest difference to \mycs{cudefinekeys} is that we do not know |
| 9241 |
% the base key by default. Thus we make a short detour to grab the first unit |
| 9242 |
% we encounter in |#1| (and its value) and the rest proceeeds as before. |
| 9243 |
% \begin{macrocode} |
| 9244 |
\NewDocumentCommand \cudefinekeychain { m } |
| 9245 |
{ |
| 9246 |
\bool_set_false:N \l_@@_single_key_bool |
| 9247 |
\@@_initialice_cukeychain_define:n {#1} |
| 9248 |
\@@_cukeys_prepare_parsing_keys:n {#1} |
| 9249 |
} |
| 9250 |
% \end{macrocode} |
| 9251 |
% \end{macro} |
| 9252 |
% \begin{macro}{\@@_initialice_cukeychain_define:n} |
| 9253 |
% Initializing the key-chain. First, grab the first unit in |#1|. This needs to |
| 9254 |
% be done as the old code expects us to already know a base unit. Here the first |
| 9255 |
% unit that is encountered is taken as the base unit. Its value is stored in |\l_@@_base_tl|. |
| 9256 |
% This is needed to normalice the values in relation to the base unit. Remember, |
| 9257 |
% the base unit is defined to be exactly |1|, thus all further values need to be |
| 9258 |
% changed to reflect that. The normalization factor is stored inside |\l_@@_new_key_base_tl|. |
| 9259 |
% |\l_@@_curr_unit_tl| is cleared to remind me, that it is not a unit per se |
| 9260 |
% (as it is not set \emph{via} |\@@_set_unit:Nn|. |
| 9261 |
% \begin{macrocode} |
| 9262 |
\cs_new:Npn \@@_initialice_cukeychain_define:n #1 |
| 9263 |
{ |
| 9264 |
\@@_cukeychain_get_first_unit_aux:nn #1 |
| 9265 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 9266 |
\@@_if_state_equal:nF { error } |
| 9267 |
{ |
| 9268 |
\exp_args:NV \@@_initialice_cukeys_define:n \l_@@_curr_unit_tl |
| 9269 |
\@@_tl_set_eval:Nn \l_@@_new_key_base_tl { 1 / (\l_@@_base_tl) } |
| 9270 |
\tl_clear:N \l_@@_curr_unit_tl |
| 9271 |
} |
| 9272 |
} |
| 9273 |
% \end{macrocode} |
| 9274 |
% \end{macro} |
| 9275 |
% \begin{macro}{\@@_cukeychain_get_first_unit_aux:nn} |
| 9276 |
% Nothing fancy here. Just grab the first unit and its value. |
| 9277 |
% \begin{macrocode} |
| 9278 |
\cs_new:Npn \@@_cukeychain_get_first_unit_aux:nn #1#2 |
| 9279 |
{ |
| 9280 |
\quark_if_recursion_tail_stop_do:nn {#1} |
| 9281 |
{ \@@_set_state_to:n { error } } |
| 9282 |
\quark_if_recursion_tail_stop_do:nn {#2} |
| 9283 |
{ |
| 9284 |
\msg_error:nn { cooking-units } { missing-argument } |
| 9285 |
\@@_set_state_to:n { error } |
| 9286 |
} |
| 9287 |
\tl_set:Nn \l_@@_curr_unit_tl {#1} |
| 9288 |
\tl_set:Nn \l_@@_base_tl {#2} |
| 9289 |
\use_none_delimit_by_q_recursion_stop:w |
| 9290 |
\@@_cukeychain_get_first_unit_aux:nn |
| 9291 |
} |
| 9292 |
% \end{macrocode} |
| 9293 |
% \end{macro} |
| 9294 |
% |
| 9295 |
% |
| 9296 |
% |
| 9297 |
% |
| 9298 |
% |
| 9299 |
% |
| 9300 |
% |
| 9301 |
% \begin{macro}{ \cuaddkeys , \cuaddtokeys , \cuaddsinglekeys } |
| 9302 |
% Thanks to rewriting the code the |add| commands and the |define| |
| 9303 |
% commands share a lot of code. The difference is the initialicing, which is a bit |
| 9304 |
% different. |
| 9305 |
% \begin{macrocode} |
| 9306 |
\NewDocumentCommand \cuaddkeys { m m } |
| 9307 |
{ |
| 9308 |
\bool_set_false:N \l_@@_single_key_bool |
| 9309 |
\@@_initialice_cukeys_add:n {#1} |
| 9310 |
\@@_cukeys_prepare_parsing_keys:nn {#1} {#2} |
| 9311 |
} |
| 9312 |
\NewDocumentCommand \cuaddtokeys { m m m } |
| 9313 |
{ |
| 9314 |
\bool_set_false:N \l_@@_single_key_bool |
| 9315 |
\@@_initialice_cukeys_add:n {#1} |
| 9316 |
\tl_set:Nn \l_@@_tmpa_tl { {#2} { \fp_eval:n { 1.0 / (#3) } } } |
| 9317 |
\@@_cukeys_prepare_parsing_keys:nV {#1} \l_@@_tmpa_tl |
| 9318 |
} |
| 9319 |
\NewDocumentCommand \cuaddsinglekeys { m m } |
| 9320 |
{ |
| 9321 |
\bool_set_true:N \l_@@_single_key_bool |
| 9322 |
\@@_initialice_cukeys_add:n {#1} |
| 9323 |
\tl_set_rescan:Nno \l_@@_tmpa_tl |
| 9324 |
{ \char_set_catcode_letter:N \# } {#2} |
| 9325 |
\@@_cukeys_prepare_parsing_keys:nV {#1} \l_@@_tmpa_tl |
| 9326 |
} |
| 9327 |
% \end{macrocode} |
| 9328 |
% \end{macro} |
| 9329 |
% |
| 9330 |
% \begin{macro}{ \@@_initialice_cukeys_add:n } |
| 9331 |
% This one is quite different compared to |\@@_initialice_cukeys_define:n| as it |
| 9332 |
% needs a bit more stuff to do. |
| 9333 |
% |
| 9334 |
% The beginning is checking if |#1| exists and later if |#1| is a key at all. |
| 9335 |
% If it not a key already we cannot add keys, in either case print an error and |
| 9336 |
% go to the end. |
| 9337 |
% |
| 9338 |
% If the checks passed without error we go to the \enquote{retrieving} step. |
| 9339 |
% As we are adding (potentially) new keys to existing ones we need to retrive |
| 9340 |
% the values we stored and got during the definition of keys. |
| 9341 |
% |
| 9342 |
% First, get the |\l_@@_original_unit_tl|. This one is the unit given in the first argument |
| 9343 |
% of either |cudefinekeys| or |\cudefinesinglekey|. It is the base unit |
| 9344 |
% for those keys. Afterwards retrieve the other values. Get the property list |
| 9345 |
% which stores the unit-value pairs, get the list of units we can transform the unit to |
| 9346 |
% and -- to make sure -- make sure a single key is only added to a single key and vice versa. |
| 9347 |
% |
| 9348 |
% Afterwards, this cs is done. |
| 9349 |
% \begin{macrocode} |
| 9350 |
\cs_new:Npn \@@_initialice_cukeys_add:n #1 |
| 9351 |
{ |
| 9352 |
\seq_clear:N \l_@@_tmpa_seq |
| 9353 |
\seq_clear:N \l_@@_tmpb_seq |
| 9354 |
\@@_set_state_to:n { normal } |
| 9355 |
\@@_error_if_unit_not_defined:nNT {#1} \l_@@_curr_unit_tl |
| 9356 |
{ |
| 9357 |
\@@_set_state_to:n { error } |
| 9358 |
\use_none_delimit_by_q_stop:w |
| 9359 |
} |
| 9360 |
\@@_if_unit_has_a_key:nF {#1} |
| 9361 |
{ |
| 9362 |
\msg_error:nnx { cooking-units } { Key-not-defined } \l_@@_curr_unit_tl |
| 9363 |
\@@_set_state_to:n { error } |
| 9364 |
\use_none_delimit_by_q_stop:w |
| 9365 |
} |
| 9366 |
\tl_set_eq:Nc \l_@@_original_unit_tl { l_@@_base_key_unit_ \l_@@_curr_unit_tl _tl } |
| 9367 |
\prop_set_eq:Nc \l_@@_tmpa_prop { l_@@_rf_cukeys_ \l_@@_original_unit_tl _prop } |
| 9368 |
\prop_get:NnN \l_@@_tmpa_prop {#1} \l_@@_new_key_base_tl |
| 9369 |
\prop_get:NnN \l_@@_tmpa_prop { Liste } \l_@@_tmpa_seq |
| 9370 |
\prop_get:NnN \l_@@_tmpa_prop { single } \l_@@_tmpa_tl |
| 9371 |
\int_compare:nNnF { \l_@@_single_key_bool } = { \l_@@_tmpa_tl } |
| 9372 |
{ |
| 9373 |
\msg_error:nn { cooking-units } { Adding-single-to-multi-key-or-vice-verca } |
| 9374 |
\@@_set_state_to:n { error } |
| 9375 |
} |
| 9376 |
\use_none_delimit_by_q_stop:w \q_stop |
| 9377 |
} |
| 9378 |
\cs_generate_variant:Nn \@@_initialice_cukeys_add:n { V } |
| 9379 |
% \end{macrocode} |
| 9380 |
% \end{macro} |
| 9381 |
% |
| 9382 |
% |
| 9383 |
% \begin{macro}{\cuaddtokeychain} |
| 9384 |
% This command is going to replace \mycs{cuaddkeys} and \mycs{cuaddtokeys}. |
| 9385 |
% It is similar to \mycs{cudefinekeychain}. Just with some more hoops before the keys |
| 9386 |
% can be defined. |
| 9387 |
% \begin{macrocode} |
| 9388 |
\NewDocumentCommand \cuaddtokeychain { m } |
| 9389 |
{ |
| 9390 |
\bool_set_false:N \l_@@_single_key_bool |
| 9391 |
\@@_initialice_cukeys_keychain_add:n {#1} |
| 9392 |
\@@_cukeys_prepare_parsing_keys:n {#1} |
| 9393 |
} |
| 9394 |
% \end{macrocode} |
| 9395 |
% \end{macro} |
| 9396 |
% |
| 9397 |
% \begin{macro}{\@@_initialice_cukeys_keychain_add:n} |
| 9398 |
% Initiliazing the key-chain. Like \mycs{cudefinekeychain} we first need to get |
| 9399 |
% the base unit. Afterwards, the \enquote{normal} initialization command is used |
| 9400 |
% (with the found base key) and |\l_@@_new_key_base_tl| is normalized. |
| 9401 |
% \begin{macrocode} |
| 9402 |
\cs_new:Npn \@@_initialice_cukeys_keychain_add:n #1 |
| 9403 |
{ |
| 9404 |
\@@_cukeys_keychain_get_first_valid_unit:n {#1} |
| 9405 |
\@@_if_state_equal:nF { error } |
| 9406 |
{ |
| 9407 |
\@@_initialice_cukeys_add:V \l_@@_curr_unit_tl |
| 9408 |
\@@_tl_set_eval:Nn \l_@@_new_key_base_tl { (\l_@@_new_key_base_tl) / (\l_@@_base_tl) } |
| 9409 |
} |
| 9410 |
} |
| 9411 |
% \end{macrocode} |
| 9412 |
% \end{macro} |
| 9413 |
% \begin{macro}{\@@_cukeys_keychain_get_first_valid_unit:n |
| 9414 |
% , \@@_cukeys_keychain_get_first_valid_unit_aux:nn |
| 9415 |
% } |
| 9416 |
% |
| 9417 |
% Just a wrapper for the loop. |
| 9418 |
% \begin{macrocode} |
| 9419 |
\cs_new:Npn \@@_cukeys_keychain_get_first_valid_unit:n #1 |
| 9420 |
{ |
| 9421 |
\@@_cukeys_keychain_get_first_valid_unit_aux:nn #1 |
| 9422 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 9423 |
} |
| 9424 |
% \end{macrocode} |
| 9425 |
% Finding the base unit is a bit more complex than just taking the first |
| 9426 |
% one found, but not by much. The idea is simple: Loop through the units |
| 9427 |
% till one is found that has an existing key. This allows the user to set the |
| 9428 |
% new unit(s) first in the loop and the base unit at last place (or an arbitrary place). |
| 9429 |
% We set this unit to be the |\l_@@_original_unit_tl| and its value as |\l_@@_base_tl| |
| 9430 |
% (not evaluated at this place). If a unit is found, break the loop. |
| 9431 |
% \begin{macrocode} |
| 9432 |
\cs_new:Npn \@@_cukeys_keychain_get_first_valid_unit_aux:nn #1#2 |
| 9433 |
{ |
| 9434 |
\quark_if_recursion_tail_stop_do:nn {#1} |
| 9435 |
{ |
| 9436 |
\msg_error:nn { cooking-units } { Key-chain-unit-not-found } |
| 9437 |
\@@_set_state_to:n { error } |
| 9438 |
} |
| 9439 |
\quark_if_recursion_tail_stop_do:nn {#2} |
| 9440 |
{ |
| 9441 |
\msg_error:nn { cooking-units } { missing-argument } |
| 9442 |
\@@_set_state_to:n { error } |
| 9443 |
} |
| 9444 |
\@@_if_unit_has_a_key:nT {#1} |
| 9445 |
{ |
| 9446 |
\@@_error_if_unit_not_defined:nNT {#1} \l_@@_curr_unit_tl |
| 9447 |
{ \@@_set_state_to:n { error } } |
| 9448 |
\tl_set_eq:NN \l_@@_original_unit_tl \l_@@_curr_unit_tl |
| 9449 |
\tl_set:Nn \l_@@_base_tl {#2} |
| 9450 |
\use_none_delimit_by_q_recursion_stop:w |
| 9451 |
} |
| 9452 |
\@@_cukeys_keychain_get_first_valid_unit_aux:nn |
| 9453 |
} |
| 9454 |
% \end{macrocode} |
| 9455 |
% \end{macro} |
| 9456 |
% |
| 9457 |
% |
| 9458 |
% |
| 9459 |
% |
| 9460 |
% |
| 9461 |
% \begin{macro}{ \@@_cukeys_prepare_parsing_keys:n |
| 9462 |
% , \@@_cukeys_prepare_parsing_keys:nn |
| 9463 |
% } |
| 9464 |
% Just a wrapper. |#1| is the base unit and thus defined to be |1|. |
| 9465 |
% \begin{macrocode} |
| 9466 |
\cs_new:Npn \@@_cukeys_prepare_parsing_keys:nn #1#2 |
| 9467 |
{ |
| 9468 |
\@@_cukeys_prepare_parsing_keys:n { {#1} { 1.0 } #2 } |
| 9469 |
} |
| 9470 |
% After initialising the variables we go to this command. |
| 9471 |
% At first it seperates the input in |#1| into unit-value pairs via |\@@_cukeys_parse_keys|. |
| 9472 |
% If no error happened, we go to the definition of keys. |
| 9473 |
% |
| 9474 |
% As we add new keys and potentially change the values of old ones we need |
| 9475 |
% to globally clear |\g_@@_master_changer_prop|. |
| 9476 |
\cs_new:Npn \@@_cukeys_prepare_parsing_keys:n #1 |
| 9477 |
{ |
| 9478 |
\@@_cukeys_parse_keys:n {#1} |
| 9479 |
\bool_lazy_or:nnF |
| 9480 |
{ \int_compare_p:nNn \l_@@_nr_of_units_int = 0 } |
| 9481 |
{ \@@_if_state_equal_p:n { error } } |
| 9482 |
{ |
| 9483 |
\prop_gclear:N \g_@@_master_changer_prop |
| 9484 |
\@@_cukeys_prepare_lists:N \l_@@_original_unit_tl |
| 9485 |
\@@_rf_cukeys_create_keys:V \l_@@_original_unit_tl |
| 9486 |
} |
| 9487 |
} |
| 9488 |
\cs_generate_variant:Nn \@@_cukeys_prepare_parsing_keys:nn { nV } |
| 9489 |
% \end{macrocode} |
| 9490 |
% \end{macro} |
| 9491 |
% |
| 9492 |
% \begin{macro}{ \@@_cukeys_parse_keys:nn , \@@_cukeys_parse_keys_aux:nn} |
| 9493 |
% Seperates the input into key-value pairs. This cs doesn't do much as the main |
| 9494 |
% stuff is done in |\@@_cukeys_parse_keys_aux:nn|. |
| 9495 |
% \begin{macrocode} |
| 9496 |
\cs_new:Npn \@@_cukeys_parse_keys:n #1 |
| 9497 |
{ |
| 9498 |
\int_zero:N \l_@@_nr_of_units_int |
| 9499 |
\@@_cukeys_parse_keys_aux:nn #1 |
| 9500 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 9501 |
} |
| 9502 |
% \end{macrocode} |
| 9503 |
% |
| 9504 |
% Note for the beginning: |
| 9505 |
% Keys used for definining (#1) are converted into strings! |
| 9506 |
% No need to keep catcodes. Just string everything! |
| 9507 |
% |
| 9508 |
% This command does a lot. The first is the stopping condition, then two |
| 9509 |
% checks for error messages. Either a \enquote{missing-argument} or a \enquote{unit |
| 9510 |
% not defined} thingy. |
| 9511 |
% |
| 9512 |
% The value is stored in |\l_@@_tmpb_tl|. Afterwards check if a |##1| is found inside. |
| 9513 |
% If it is, replace |##1| by |\l_@@_tmpa_fp|. So we do not store a command with an |
| 9514 |
% argument, but rather a formula with a variable inside, which we can set. |
| 9515 |
% If on ther other side it contains a |##1|, but is not a single key, we raise an error. |
| 9516 |
% |
| 9517 |
% Afterwards -- if nor error -- we calculate the value in |\l_@@_tmpb_tl| if we have no |
| 9518 |
% single key. Here |\l_@@_new_key_base_tl| comes into play. The idea is the following: |
| 9519 |
% the base key is \enquote{kg} with \enquote{1}, furthermore we have the key |
| 9520 |
% \enquote{dag} with value \enquote{100}. Now we add \enquote{g} to \enquote{dag} |
| 9521 |
% with \enquote{10} ($1$ dag equals 10 g). In order to have the correct relation betwen |
| 9522 |
% the base key \enquote{kg} and \enquote{g}, we set |\l_@@_new_key_base_tl| during |
| 9523 |
% the initialization to \enquote{100}. Then the relation between \enquote{kg} and |
| 9524 |
% \enquote{g} is correct with \enquote{(10)*100=1000}. |
| 9525 |
% |
| 9526 |
% Add the unit to the list of units; add the unit-value to the propery-list. |
| 9527 |
% \begin{macrocode} |
| 9528 |
\cs_new:Npn \@@_cukeys_parse_keys_aux:nn #1#2 |
| 9529 |
{ |
| 9530 |
\quark_if_recursion_tail_stop:n {#1} |
| 9531 |
\quark_if_recursion_tail_stop_do:nn {#2} |
| 9532 |
{ |
| 9533 |
\msg_error:nn { cooking-units } { missing-argument } |
| 9534 |
\@@_set_state_to:n { error } |
| 9535 |
} |
| 9536 |
\@@_error_if_unit_not_defined:nNT {#1} \l_@@_option_unit_tl |
| 9537 |
{ \@@_set_state_to:n { error } } |
| 9538 |
% |
| 9539 |
\tl_set:Nn \l_@@_tmpb_tl {#2} |
| 9540 |
\tl_if_in:NVT \l_@@_tmpb_tl \g_@@_input_str_hash_one_tl |
| 9541 |
{ |
| 9542 |
\bool_if:NTF \l_@@_single_key_bool |
| 9543 |
{ \tl_replace_all:NVn \l_@@_tmpb_tl \g_@@_input_str_hash_one_tl { \l_@@_tmpa_fp } } |
| 9544 |
{ |
| 9545 |
\msg_error:nnx { cooking-units } { formula-in-non-singlekeys } \l_@@_tmpb_tl |
| 9546 |
\@@_set_state_to:n { error } |
| 9547 |
} |
| 9548 |
} |
| 9549 |
\@@_if_state_equal:nF { error } |
| 9550 |
{ |
| 9551 |
\int_incr:N \l_@@_nr_of_units_int |
| 9552 |
\bool_if:NF \l_@@_single_key_bool |
| 9553 |
{ \@@_tl_set_eval:Nn \l_@@_tmpb_tl { (\l_@@_tmpb_tl) * (\l_@@_new_key_base_tl) } } |
| 9554 |
\seq_if_in:NVF \l_@@_tmpa_seq \l_@@_option_unit_tl |
| 9555 |
{ \seq_put_right:NV \l_@@_tmpa_seq \l_@@_option_unit_tl } |
| 9556 |
\prop_put:NnV \l_@@_tmpa_prop {#1} \l_@@_tmpb_tl |
| 9557 |
} |
| 9558 |
\@@_cukeys_parse_keys_aux:nn |
| 9559 |
} |
| 9560 |
% \end{macrocode} |
| 9561 |
% \end{macro} |
| 9562 |
% |
| 9563 |
% \begin{macro}{ \@@_cukeys_prepare_lists:N } |
| 9564 |
% At this point we can assume everything to be correct. |
| 9565 |
% |#1| the main unit aka.\ the \enquote{original unit} or \enquote{base unit}. |
| 9566 |
% |
| 9567 |
% First we clear/create new the property list which will contains the conversion values for |
| 9568 |
% for each unit. There we will safe the the values we collected in the last step, |
| 9569 |
% the list of units in this set and if the key is single or not. |
| 9570 |
% |
| 9571 |
% For simplification, each unit in the key-list always points to the \enquote{base unit}, |
| 9572 |
% so \enquote{g}, \enquote{kg}, \enquote{dag}, etc.\ will all show to \enquote{kg}. |
| 9573 |
% This is not needed if we have a single-key (due to how single-keys work). |
| 9574 |
% Furhtermore, if no single-key, set the default transformation value to \enquote{1}; |
| 9575 |
% not sure if the last step is necessary, but eh. |
| 9576 |
% \begin{macrocode} |
| 9577 |
\cs_new:Npn \@@_cukeys_prepare_lists:N #1 |
| 9578 |
{ |
| 9579 |
\prop_clear_new:c { l_@@_rf_cukeys_ #1 _prop } |
| 9580 |
\prop_set_eq:cN { l_@@_rf_cukeys_ #1 _prop } \l_@@_tmpa_prop |
| 9581 |
\prop_put:cnV { l_@@_rf_cukeys_ #1 _prop } { Liste } \l_@@_tmpa_seq |
| 9582 |
\prop_put:cnV { l_@@_rf_cukeys_ #1 _prop } { single } \l_@@_single_key_bool |
| 9583 |
\tl_set:cn { l_@@_unit_change_ #1 _tl } { 1 } |
| 9584 |
\tl_set_eq:cN { l_@@_base_key_unit_ #1 _tl } #1 |
| 9585 |
\bool_if:NF \l_@@_single_key_bool |
| 9586 |
{ |
| 9587 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 9588 |
{ |
| 9589 |
\tl_set_eq:cN { l_@@_base_key_unit_ ##1 _tl } #1 |
| 9590 |
\tl_set:cn { l_@@_unit_change_ ##1 _tl } { 1 } |
| 9591 |
} |
| 9592 |
} |
| 9593 |
} |
| 9594 |
% \end{macrocode} |
| 9595 |
% \end{macro} |
| 9596 |
% |
| 9597 |
% \begin{macro}{ \@@_rf_cukeys_create_keys:n , \@@_rf_cukeys_create_keys:V } |
| 9598 |
% Here we start creating the keys. If seperate into two cases: |
| 9599 |
% Do we have a single-key or not. If yes, just create the key |#1| |
| 9600 |
% and do what needs to be done. If not, we need to create a bunch of |
| 9601 |
% keys for each unit in the list. |
| 9602 |
% \begin{macrocode} |
| 9603 |
\cs_new:Npn \@@_rf_cukeys_create_keys:n #1 |
| 9604 |
{ |
| 9605 |
% % #1: original_unit |
| 9606 |
\clist_set_from_seq:NN \l_@@_tmpa_clist \l_@@_tmpa_seq |
| 9607 |
\bool_if:NTF \l_@@_single_key_bool |
| 9608 |
{ |
| 9609 |
\@@_rf_cukeys_define_key:nVn |
| 9610 |
{#1} \l_@@_tmpa_clist {#1} |
| 9611 |
}{ |
| 9612 |
\seq_map_inline:Nn \l_@@_tmpa_seq |
| 9613 |
{ |
| 9614 |
\@@_rf_cukeys_define_key:nVn |
| 9615 |
{##1} \l_@@_tmpa_clist {#1} |
| 9616 |
} |
| 9617 |
} |
| 9618 |
} |
| 9619 |
\cs_generate_variant:Nn \@@_rf_cukeys_create_keys:n { V } |
| 9620 |
% \end{macrocode} |
| 9621 |
% \end{macro} |
| 9622 |
% |
| 9623 |
% \begin{macro}{ \@@_rf_cukeys_define_key:nnn , \@@_rf_cukeys_define_key:nVn } |
| 9624 |
% Now we define some key(s). |#1| is the unit and key-to-be-defined. |
| 9625 |
% As |#1| is not expanded, this can contain control sequences, etc. not need for worry |
| 9626 |
% here. |
| 9627 |
% |
| 9628 |
% We define the key |#1| with a list of choices |#2| (which is the list of units |
| 9629 |
% collected in the parse step). |#3| plays an important role as it is the |
| 9630 |
% \enquote{base unit}. We mainly need this to do some shortcuts later on. |
| 9631 |
% So instead of getting the the base unit for \enquote{g} \emph{via} |
| 9632 |
% |l_@@_base_key_unit_g_tl| (which would be \enquote{kg}), we give \enquote{kg} |
| 9633 |
% directly as the argument |#3|. It was made sure that |#3| \emph{not} a |
| 9634 |
% control sequence, but text. |
| 9635 |
% |
| 9636 |
% In order to remind the user which choices each key have, define an error |
| 9637 |
% message for unknown keys. |
| 9638 |
% \begin{macrocode} |
| 9639 |
\cs_new:Npn \@@_rf_cukeys_define_key:nnn #1#2#3 |
| 9640 |
{ |
| 9641 |
\@@_if_unit_has_a_key:nF {#1} |
| 9642 |
{ \seq_put_right:Nn \l_@@_list_of_defined_keys_seq {#1} } |
| 9643 |
\keys_define:nn { cooking-units } |
| 9644 |
{ |
| 9645 |
#1 .choices:nn = |
| 9646 |
{#2} |
| 9647 |
{ \@@_change_unit_from_to:nVn {#1} \l_keys_choice_tl {#3} } , |
| 9648 |
#1 / unknown .code:n= |
| 9649 |
{ |
| 9650 |
\seq_set_split:Nnn \l_tmpa_seq { , } {#2} |
| 9651 |
\msg_error:nnxxx |
| 9652 |
{ cooking-units } |
| 9653 |
{ key-choice-unknown } |
| 9654 |
{#1} |
| 9655 |
{##1} |
| 9656 |
{ \@@_seq_use_msg:N \l_tmpa_seq } |
| 9657 |
} , |
| 9658 |
#1 .default:n = {#1} , |
| 9659 |
#1 .groups:n = { change-unit } |
| 9660 |
} |
| 9661 |
} |
| 9662 |
\cs_generate_variant:Nn \@@_rf_cukeys_define_key:nnn { nVn } |
| 9663 |
% \end{macrocode} |
| 9664 |
% \end{macro} |
| 9665 |
% |
| 9666 |
% \begin{macro}{ \@@_change_unit_from_to:nnn } |
| 9667 |
% Our main \enquote{get the conversion value} command. |
| 9668 |
% |#1| is the current unit, |#2| is the unit it is converted into, |
| 9669 |
% |#3| is the \enquote{base unit}, given in order to make some shortcuts. |
| 9670 |
% |
| 9671 |
% |\l_@@_change_unit_prop| stores which unit should be converted into which by |
| 9672 |
% a key-value list. If the unit is later used we restore the value from this property list. |
| 9673 |
% |
| 9674 |
% Now to the calculation. |\g_@@_master_changer_prop| stores the the conversion values |
| 9675 |
% globally in a | <old-unit> ~->~ <new-unit>| way. If we already have a conversion |
| 9676 |
% from |#1| to |#2| we simply restore this value and store it in |l_@@_unit_change_ #1_tl|. |
| 9677 |
% |
| 9678 |
% If the unit-change is requested for the first time we need to calculate the |
| 9679 |
% conversion value first. Afterwards, store it (globally) into |\g_@@_master_changer_prop| |
| 9680 |
% to not recalculate it in the future. |
| 9681 |
% \begin{macrocode} |
| 9682 |
\cs_new:Npn \@@_change_unit_from_to:nnn #1#2#3 |
| 9683 |
{ |
| 9684 |
\prop_put:Nnn \l_@@_change_unit_prop {#1} {#2} |
| 9685 |
\prop_get:NncF |
| 9686 |
\g_@@_master_changer_prop |
| 9687 |
{ #1 ~->~ #2 } |
| 9688 |
{ l_@@_unit_change_ #1_tl } |
| 9689 |
{ |
| 9690 |
\@@_cukeys_calculate_change_value:nnn {#1} {#2} {#3} |
| 9691 |
\prop_gput:Nnv \g_@@_master_changer_prop |
| 9692 |
{ #1 ~->~ #2 } |
| 9693 |
{ l_@@_unit_change_ #1 _tl } |
| 9694 |
} |
| 9695 |
} |
| 9696 |
\cs_generate_variant:Nn \@@_change_unit_from_to:nnn { nVn } |
| 9697 |
% \end{macrocode} |
| 9698 |
% \end{macro} |
| 9699 |
% |
| 9700 |
% \begin{macro}{ \@@_cukeys_calculate_change_value:nnn } |
| 9701 |
% Great, an unit-change is requested for the first time, thus calculate |
| 9702 |
% the conversion value. |
| 9703 |
% |
| 9704 |
% First we check if the old unit |#1| is the same as the \enquote{base unit} |
| 9705 |
% |#3|. This is a nice shortcut, as the property list is stored with |#3| as a base, |
| 9706 |
% so direct retrival of the value is possible in this case. |
| 9707 |
% |
| 9708 |
% If |#1| and |#3| are different, we need to do some work. First, get the list |
| 9709 |
% of key-values |l_@@_rf_cukeys_ #3 _prop| and store it in |\l_@@_tmpa_prop|. |
| 9710 |
% Now eval. |
| 9711 |
% |
| 9712 |
% Having unit |a| and wanting unit |b|, we need the value to go from |a| to |b| |
| 9713 |
% which is done by the realtion $|b|/|a|$. This is checked easily as $|a|*|b|/|a|=|b|$. |
| 9714 |
% Replace this by |#1| and |#2| and we get: |#2|=|#1|*|#2|/|#1|, which we |
| 9715 |
% evaluate and store in |l_@@_unit_change_ #1 _tl|. |
| 9716 |
% \begin{macrocode} |
| 9717 |
\cs_new:Npn \@@_cukeys_calculate_change_value:nnn #1 #2 #3 |
| 9718 |
{ |
| 9719 |
\str_if_eq:nnTF {#1} {#3} |
| 9720 |
{ |
| 9721 |
\prop_get:cnc { l_@@_rf_cukeys_ #1 _prop } {#2} { l_@@_unit_change_ #1 _tl } |
| 9722 |
}{ |
| 9723 |
\prop_set_eq:Nc \l_@@_tmpa_prop { l_@@_rf_cukeys_ #3 _prop } |
| 9724 |
\@@_tl_set_eval:cn { l_@@_unit_change_ #1 _tl } |
| 9725 |
{ |
| 9726 |
( \prop_item:Nn \l_@@_tmpa_prop {#2} ) / |
| 9727 |
( \prop_item:Nn \l_@@_tmpa_prop {#1} ) |
| 9728 |
} |
| 9729 |
} |
| 9730 |
} |
| 9731 |
\cs_generate_variant:Nn \@@_cukeys_calculate_change_value:nnn { VVV } |
| 9732 |
% \end{macrocode} |
| 9733 |
% \end{macro} |
| 9734 |
% |
| 9735 |
% |
| 9736 |
% |
| 9737 |
% |
| 9738 |
% |
| 9739 |
% |
| 9740 |
% |
| 9741 |
% |
| 9742 |
% |
| 9743 |
% |
| 9744 |
% |
| 9745 |
% |
| 9746 |
% |
| 9747 |
% |
| 9748 |
% |
| 9749 |
% |
| 9750 |
% \section {Creating New Units} |
| 9751 |
% |
| 9752 |
% |
| 9753 |
%\begin{macro}{ \declarecookingunit , \newcookingunit , \providecookingunit } |
| 9754 |
% Defining new units. Defining an unit is split into two parts: defining |
| 9755 |
% the necassary tl's and clist's and seq's; and setting them. Depending on which |
| 9756 |
% command is used, things are handled differently. |
| 9757 |
% |
| 9758 |
% We always make sure that the unit |#1| is first converted into a string. |
| 9759 |
% \begin{macrocode} |
| 9760 |
\NewDocumentCommand \declarecookingunit { o m } |
| 9761 |
{ |
| 9762 |
\@@_if_unit_defined:nNTF {#2} \l_@@_original_unit_tl |
| 9763 |
{ \msg_info:nnx { cooking-units } { redefine-unit } { \l_@@_original_unit_tl } } |
| 9764 |
{ \@@_new_cooking_unit:V \l_@@_original_unit_tl } |
| 9765 |
\@@_set_cooking_unit:nnV {#1} {#2} \l_@@_original_unit_tl |
| 9766 |
} |
| 9767 |
\NewDocumentCommand \newcookingunit { o m } |
| 9768 |
{ |
| 9769 |
\@@_if_unit_defined:nNTF {#2} \l_@@_original_unit_tl |
| 9770 |
{ \msg_error:nnV { cooking-units } { unit-already-defined } \l_@@_original_unit_tl } |
| 9771 |
{ |
| 9772 |
\@@_new_cooking_unit:V \l_@@_original_unit_tl |
| 9773 |
\@@_set_cooking_unit:nnV {#1} {#2} \l_@@_original_unit_tl |
| 9774 |
} |
| 9775 |
} |
| 9776 |
\NewDocumentCommand \providecookingunit { o m } |
| 9777 |
{ |
| 9778 |
\@@_if_unit_defined:nNT {#2} \l_@@_original_unit_tl |
| 9779 |
{ |
| 9780 |
\@@_new_cooking_unit:V \l_@@_original_unit_tl |
| 9781 |
\@@_set_cooking_unit:nnV {#1} {#2} \l_@@_original_unit_tl |
| 9782 |
} |
| 9783 |
} |
| 9784 |
% \end{macrocode} |
| 9785 |
%\end{macro} |
| 9786 |
% |
| 9787 |
%\begin{macro}{ \@@_new_cooking_unit:n } |
| 9788 |
% Creates the token and other lists for the unit |#1| (which at this point is a string). |
| 9789 |
% Nothing really expectional here. |
| 9790 |
% \begin{macrocode} |
| 9791 |
\cs_new:Npn \@@_new_cooking_unit:n #1 |
| 9792 |
{ |
| 9793 |
\tl_map_inline:nn {#1} |
| 9794 |
{ |
| 9795 |
\tl_if_in:NnT \l_@@_unit_letter_not_allowed_tl {##1} |
| 9796 |
{ \msg_error:nnn { cooking-units } { character-not-allowed } {#1} } |
| 9797 |
} |
| 9798 |
\seq_gput_right:Nn \g_@@_list_of_defined_units_seq {#1} |
| 9799 |
\tl_new:c { l_@@_unit_change_ #1 _tl } |
| 9800 |
\tl_new:c { l_@@_base_key_unit_ #1 _tl } |
| 9801 |
\tl_new:c { l_@@_default_unit_ #1 _tl } |
| 9802 |
\clist_new:c { l_@@_unit_option_ #1 _clist } |
| 9803 |
\tl_set:cn { l_@@_unit_change_ #1 _tl } { 1 } |
| 9804 |
\keys_define:nn { cooking-units } |
| 9805 |
{ |
| 9806 |
set-unit-hook-#1 .code:n = { \@@_set_options_for:nn {#1} {##1} } , |
| 9807 |
add-unit-hook-#1 .code:n = { \@@_add_options_for:nn {#1} {##1} }, |
| 9808 |
set-option-for-#1 .meta:n = { set-unit-hook-#1 = {##1} } , |
| 9809 |
add-option-for-#1 .meta:n = { add-unit-hook-#1 = {##1} } , |
| 9810 |
} |
| 9811 |
} |
| 9812 |
\cs_generate_variant:Nn \@@_new_cooking_unit:n { V } |
| 9813 |
% \end{macrocode} |
| 9814 |
% \end{macro} |
| 9815 |
% |
| 9816 |
%\begin{macro}{ \@@_set_cooking_unit:nnn , \@@_set_cooking_unit:nnV } |
| 9817 |
% Here we set the in the last step defined lists to their respective value. |
| 9818 |
% |#3| is the unit-string; |#2| is the unit given by the user (as it can be a command |
| 9819 |
% like |/%]; |#1| is either the wanted unit-symbol \emph{or} a key-val |
| 9820 |
% list. Depending on that, we either set the printed symbol to |#1| or parse the |
| 9821 |
% key-val list. |
| 9822 |
% |
| 9823 |
% This is done in a three step procedure (if |#1| is a value): First, check if |
| 9824 |
% the head of |#1| is a group. This happens if the user embraces |#1| in two |
| 9825 |
% curly brace pairs (e.g.\ |{{Test}}|). This is only needed if the user really wants |
| 9826 |
% the symbol to contain |=|. |
| 9827 |
% |
| 9828 |
% If |#1| is not protected by braces it is parsed as key(s) |
| 9829 |
% \begin{macrocode} |
| 9830 |
\cs_new:Npn \@@_set_cooking_unit:nnn #1#2#3 |
| 9831 |
{ |
| 9832 |
\@@_set_cooking_unit_base_translation:n {#3} |
| 9833 |
\bool_set_false:N \l_@@_symbol_was_set_by_key_bool |
| 9834 |
\bool_set_false:N \l_@@_contains_valid_key_bool |
| 9835 |
\IfNoValueF {#1} |
| 9836 |
{ |
| 9837 |
\tl_if_head_is_group:nF {#1} |
| 9838 |
{ \keys_set:nn { cooking-units / definition } {#1} } |
| 9839 |
} |
| 9840 |
\bool_if:NF \l_@@_symbol_was_set_by_key_bool |
| 9841 |
{ |
| 9842 |
\IfNoValueTF {#1} |
| 9843 |
{ \tl_set:cn { l_@@_default_unit_ #3 _tl } {#2} } |
| 9844 |
{ |
| 9845 |
\bool_if:NTF \l_@@_contains_valid_key_bool |
| 9846 |
{ \tl_set:cn { l_@@_default_unit_ #3 _tl } {#2} } |
| 9847 |
{ \tl_set:cn { l_@@_default_unit_ #3 _tl } {#1} } |
| 9848 |
} |
| 9849 |
} |
| 9850 |
\@@_culang_def_base:nnv { unit-symbol } {#3} { l_@@_default_unit_ #3 _tl } |
| 9851 |
} |
| 9852 |
\cs_generate_variant:Nn \@@_set_cooking_unit:nnn { nnV } |
| 9853 |
% \end{macrocode} |
| 9854 |
% \end{macro} |
| 9855 |
% |
| 9856 |
%\begin{macro}{ \@@_set_cooking_unit_base_translation:n } |
| 9857 |
% Just an auxilary command. Sets the base translations to their default value. |
| 9858 |
% \begin{macrocode} |
| 9859 |
\cs_new:Npn \@@_set_cooking_unit_base_translation:n #1 |
| 9860 |
{ |
| 9861 |
\@@_culang_def_base:nnn { name } {#1} \c_@@_no_translation_str |
| 9862 |
\@@_culang_def_base:nnn { name-pl } {#1} \c_@@_no_translation_str |
| 9863 |
\@@_culang_def_base:nnn { gender } {#1} { m } |
| 9864 |
} |
| 9865 |
% \end{macrocode} |
| 9866 |
% \end{macro} |
| 9867 |
% |
| 9868 |
% |
| 9869 |
% |
| 9870 |
% \begin{macro}{\declarecookingderivatives} |
| 9871 |
% Now this is an experimental command. The idea is simple: Combine units |
| 9872 |
% (like meter and second giving meter per second or in any way possible). |
| 9873 |
% The first argument contains a list of the units that should be connected, one of every type is enough. |
| 9874 |
% Second is the unit-key, containing |#1|, \dots\ |#(number of units in first argument)|. |
| 9875 |
% Third is the calculation. The formula for the new unit should be written in here. |
| 9876 |
% And last, but not least: The last argument contains the unit-symbol. |
| 9877 |
% |
| 9878 |
% Now this command simply defines a bunch of units, declaring them makes things easier. |
| 9879 |
% \begin{macrocode} |
| 9880 |
\NewDocumentCommand \declarecookingderivatives { m m m m } |
| 9881 |
{ |
| 9882 |
\@@_declare_cooking_derivative:nnnn {#1} {#2} {#3} {#4} |
| 9883 |
} |
| 9884 |
% \end{macrocode} |
| 9885 |
% \end{macro} |
| 9886 |
% |
| 9887 |
% |
| 9888 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 9889 |
% This command has the following parts: |
| 9890 |
% \begin{enumerate} |
| 9891 |
% \item Get list of units in |#1|, check if they are defined, |
| 9892 |
% count their number and store in |\l_@@_nr_of_units_int| |
| 9893 |
% \item Use |\cs_generate_from_arg_count:NNnn| to create the commands |
| 9894 |
% that store the final parsed unit-keys, unit-symbols und unit-formulas inside. |
| 9895 |
% \item Prepare for the following loop. |
| 9896 |
% \item The main part: Do the loop. |
| 9897 |
% \item Declare keys and store their formula relation into a property-list. |
| 9898 |
% \item Clean up. |
| 9899 |
% \end{enumerate} |
| 9900 |
% \begin{macrocode} |
| 9901 |
\cs_new:Npn \@@_declare_cooking_derivative:nnnn #1#2#3#4 |
| 9902 |
{ |
| 9903 |
\seq_clear:N \l_@@_list_of_units_seq |
| 9904 |
\@@_set_state_to:n { normal } |
| 9905 |
\clist_map_inline:nn {#1} |
| 9906 |
{ |
| 9907 |
\@@_if_unit_defined:nNTF {##1} \l_@@_tmpa_tl |
| 9908 |
{ |
| 9909 |
\@@_if_unit_has_a_key:VTF \l_@@_tmpa_tl |
| 9910 |
{ \seq_put_right:NV \l_@@_list_of_units_seq \l_@@_tmpa_tl } |
| 9911 |
{ |
| 9912 |
\tl_show:n { Error-no-key-defined } {##1} |
| 9913 |
\@@_set_state_to:n { error } |
| 9914 |
} |
| 9915 |
} { \@@_set_state_to:n { error } } |
| 9916 |
} |
| 9917 |
\@@_if_state_equal:nT { error } |
| 9918 |
{ \use_none_delimit_by_q_recursion_stop:w } |
| 9919 |
\int_set:Nn \l_@@_nr_of_units_int { \seq_count:N \l_@@_list_of_units_seq } |
| 9920 |
% \end{macrocode} |
| 9921 |
% Now we generate the functions. The first takes the unit-keys and plugs it into |
| 9922 |
% the formula |#2| (unit-key) and |#4| (unit-symbol). |
| 9923 |
% The second function get's the nummerical values and stores it in a sequcence. |
| 9924 |
% Example: \\ |
| 9925 |
% Assuming |kg|, |m| and |s| with unit key |#1*#2-#3|, formula |#1*#2/#3| |
| 9926 |
% and symbol |#1\,\sfrac{#2}{#3}|. Looping through the units, the first |
| 9927 |
% function creates |kg*m-s|, |kg*m-min|, \dots, |oz*in-h|; and |kg\,\sfrac{m}{s}|, |
| 9928 |
% \dots, |oz\,\sfrac{in}{h}|. |
| 9929 |
% |
| 9930 |
% The second function creates their nummerical relation: for |kg|, |m| and |s| |
| 9931 |
% this would be |1*1/86400|. |kg|, |in|, |s| would be |1*(36/0.9144)/86400|. |
| 9932 |
% If we then transform the first ones |kg*m-s| into the second one |kg*in-s| |
| 9933 |
% we will later calculate $ \frac{1*(36/0.9144)/86400}{1*1/86400} $ which will get |
| 9934 |
% us the correct transformation. May explanation my not be very good, |
| 9935 |
% but it makes sense (later). |
| 9936 |
% \begin{macrocode} |
| 9937 |
\cs_generate_from_arg_count:NNnn \@@_create_unit:w \cs_set:Npn |
| 9938 |
{ \l_@@_nr_of_units_int } |
| 9939 |
{ |
| 9940 |
\seq_gpush:Nn \g_@@_stored_derived_unit_symbol_seq {#2} |
| 9941 |
\seq_gpush:Nn \g_@@_stored_derived_unit_print_seq {#4} |
| 9942 |
} |
| 9943 |
\cs_generate_from_arg_count:NNnn \@@_create_formula:w \cs_set:Npn |
| 9944 |
{ \l_@@_nr_of_units_int } |
| 9945 |
{ |
| 9946 |
\seq_gpush:Nn \g_@@_stored_derived_formula_seq {#3} |
| 9947 |
} |
| 9948 |
% \end{macrocode} |
| 9949 |
% Preparing and startidoingng the loop. |
| 9950 |
% \begin{macrocode} |
| 9951 |
\@@_prepare_sequence_loop: |
| 9952 |
\@@_step_loop_start:n { } |
| 9953 |
% \end{macrocode} |
| 9954 |
% Now we create new cooking-units with the unit-keys and unit-symbols |
| 9955 |
% we created \emph{via} loop. As we need a \enquote{master unit} we use |
| 9956 |
% the most right unit in the derived unit list. This is because the most right one |
| 9957 |
% is created by the other base units. |
| 9958 |
% \begin{macrocode} |
| 9959 |
\seq_get_right:NN \g_@@_stored_derived_unit_symbol_seq \l_@@_curr_unit_tl |
| 9960 |
\seq_map_inline:Nn \g_@@_stored_derived_unit_symbol_seq |
| 9961 |
{ |
| 9962 |
\seq_pop:NN \g_@@_stored_derived_formula_seq \l_@@_tmpb_tl |
| 9963 |
\prop_put:NnV \l_@@_derived_units_prop {##1} \l_@@_tmpb_tl |
| 9964 |
% \end{macrocode} |
| 9965 |
% First create the unit, \emph{then} set the reference to the base unit. |
| 9966 |
% (Else it is not yet defined) |
| 9967 |
% \begin{macrocode} |
| 9968 |
\seq_pop:NN \g_@@_stored_derived_unit_print_seq \l_@@_tmpa_tl |
| 9969 |
\exp_args:NNx \declarecookingunit [ {symbol={\l_@@_tmpa_tl}} ] {##1} |
| 9970 |
\tl_set_eq:cN { l_@@_base_key_unit_ ##1 _tl } \l_@@_curr_unit_tl |
| 9971 |
} |
| 9972 |
% \end{macrocode} |
| 9973 |
% Clean-up. Do not know if this is necessary, but eh. |
| 9974 |
% \begin{macrocode} |
| 9975 |
\seq_gclear:N \g_@@_stored_derived_unit_symbol_seq |
| 9976 |
\seq_gclear:N \g_@@_stored_derived_unit_print_seq |
| 9977 |
\seq_gclear:N \g_@@_stored_derived_formula_seq |
| 9978 |
\cs_undefine:N \@@_create_unit:w |
| 9979 |
\cs_undefine:N \@@_create_formula:w |
| 9980 |
% \end{macrocode} |
| 9981 |
% If we had an error beforehand, we would jump to this place ignoring everything |
| 9982 |
% inbetween. |
| 9983 |
% \begin{macrocode} |
| 9984 |
\use_none_delimit_by_q_recursion_stop:w |
| 9985 |
\q_recursion_stop |
| 9986 |
} |
| 9987 |
% \end{macrocode} |
| 9988 |
% \end{macro} |
| 9989 |
% |
| 9990 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 9991 |
% \begin{macrocode} |
| 9992 |
\cs_new:Npn \@@_prepare_sequence_loop: |
| 9993 |
{ |
| 9994 |
\seq_map_indexed_inline:Nn \l_@@_list_of_units_seq |
| 9995 |
{ |
| 9996 |
\prop_clear_new:c { l_@@_keys_ ##1 _prop } |
| 9997 |
\seq_clear_new:c { l_@@_list_ ##1 _seq } |
| 9998 |
\tl_set_eq:Nc \l_@@_curr_unit_tl { l_@@_base_key_unit_ ##2 _tl } |
| 9999 |
\prop_set_eq:cc { l_@@_keys_ ##1 _prop } |
| 10000 |
{ l_@@_rf_cukeys_ \l_@@_curr_unit_tl _prop } |
| 10001 |
\prop_get:cnc { l_@@_keys_ ##1 _prop } { Liste } { l_@@_list_ ##1 _seq } |
| 10002 |
} |
| 10003 |
} |
| 10004 |
% \end{macrocode} |
| 10005 |
% \end{macro} |
| 10006 |
% |
| 10007 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 10008 |
% \begin{macrocode} |
| 10009 |
\cs_new:Npn \@@_step_loop_start:n #1 |
| 10010 |
{ |
| 10011 |
\tl_clear:N \l_@@_stored_units_tl |
| 10012 |
\tl_clear:N \l_@@_stored_formula_tl |
| 10013 |
\int_set:Nn \l_@@_depth_int { 1 } |
| 10014 |
\seq_map_function:cN |
| 10015 |
{ l_@@_list_ \int_use:N \l_@@_depth_int _seq } \@@_seq_recursive_loop_function:n |
| 10016 |
} |
| 10017 |
% \end{macrocode} |
| 10018 |
% \end{macro} |
| 10019 |
% |
| 10020 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 10021 |
% \begin{macrocode} |
| 10022 |
\cs_new:Npn \@@_seq_recursive_loop_function:n #1 |
| 10023 |
{ |
| 10024 |
\group_begin: |
| 10025 |
\tl_put_right:Nn \l_@@_stored_units_tl { {#1} } |
| 10026 |
\tl_set_eq:Nc \l_@@_original_unit_tl { l_@@_base_key_unit_ #1 _tl } |
| 10027 |
\tl_put_right:Nx \l_@@_stored_formula_tl |
| 10028 |
{ { ( |
| 10029 |
\exp_not:N \prop_item:Nn |
| 10030 |
\exp_not:c { l_@@_rf_cukeys_ \l_@@_original_unit_tl _prop } {#1} |
| 10031 |
) } } |
| 10032 |
\int_compare:nNnTF { \l_@@_depth_int } = { \l_@@_nr_of_units_int } |
| 10033 |
{ |
| 10034 |
\exp_after:wN \@@_create_unit:w \l_@@_stored_units_tl |
| 10035 |
\exp_after:wN \@@_create_formula:w \l_@@_stored_formula_tl |
| 10036 |
}{ |
| 10037 |
\int_incr:N \l_@@_depth_int |
| 10038 |
\seq_map_function:cN |
| 10039 |
{ l_@@_list_ \int_use:N \l_@@_depth_int _seq } \@@_seq_recursive_loop_function:n |
| 10040 |
} |
| 10041 |
\group_end: |
| 10042 |
} |
| 10043 |
% \end{macrocode} |
| 10044 |
% \end{macro} |
| 10045 |
% |
| 10046 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 10047 |
% \begin{macrocode} |
| 10048 |
\keys_define:nn { cooking-units } |
| 10049 |
{ |
| 10050 |
unknown .code:n = |
| 10051 |
{ |
| 10052 |
\@@_if_key_ais_derived_unit:VTF \l_keys_key_str |
| 10053 |
{ \@@_convert_derived_unit:Vn \l_keys_key_str {#1} } |
| 10054 |
{ |
| 10055 |
\msg_error:nnxx { cooking-units } { key-unknown } |
| 10056 |
{ \l_keys_path_str } { cooking-units } |
| 10057 |
} |
| 10058 |
} |
| 10059 |
} |
| 10060 |
% \end{macrocode} |
| 10061 |
% \end{macro} |
| 10062 |
% |
| 10063 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 10064 |
% \begin{macrocode} |
| 10065 |
\prg_new_conditional:Npnn \@@_if_key_ais_derived_unit:n #1 { TF } |
| 10066 |
{ |
| 10067 |
\tl_if_exist:cTF { l_@@_base_key_unit_ #1 _tl } |
| 10068 |
{ \prg_return_true: } |
| 10069 |
{ \prg_return_false: } |
| 10070 |
} |
| 10071 |
\cs_generate_variant:Nn \@@_if_key_ais_derived_unit:nTF { V } |
| 10072 |
% \end{macrocode} |
| 10073 |
% \end{macro} |
| 10074 |
% |
| 10075 |
% \begin{macro} { \@@_declare_cooking_derivative:nnnn } |
| 10076 |
% The idea is the following. The relation between the units are given as |
| 10077 |
% |(#1)/(#2)| (e.g.). The idea is the following: |
| 10078 |
% \begin{enumerate} |
| 10079 |
% \item The derivative contains two units. |
| 10080 |
% \item The mathematical relationship is given by |(#1)/(#2)| |
| 10081 |
% \item Define |\@@_tmp:w| to be |(#1)/(#2)|. |
| 10082 |
% \item Parse through all values and store them in a list (e.g. |\l_tmpa_t|) as | {value-1}{value-2} | |
| 10083 |
% \item Use |\exp_after:wN \@@_tmp:w \l_tmpa_t | to expand to |\@@_tmp:w {value-1} {value-2} | |
| 10084 |
% \item Let |\@@_tmp:w| do its job. |
| 10085 |
% \end{enumerate} |
| 10086 |
% \begin{macrocode} |
| 10087 |
\cs_new:Npn \@@_convert_derived_unit:nn #1#2 |
| 10088 |
{ |
| 10089 |
\tl_if_eq:ccTF |
| 10090 |
{ l_@@_base_key_unit_ #1 _tl } |
| 10091 |
{ l_@@_base_key_unit_ #2 _tl } |
| 10092 |
{ |
| 10093 |
\prop_get:NnN \l_@@_derived_units_prop {#1} \l_@@_tmpa_tl |
| 10094 |
\prop_get:NnN \l_@@_derived_units_prop {#2} \l_@@_tmpb_tl |
| 10095 |
\prop_put:Nnn \l_@@_change_unit_prop {#1} {#2} |
| 10096 |
\@@_tl_set_eval:cn { l_@@_unit_change_ #1 _tl } |
| 10097 |
{ |
| 10098 |
(\l_@@_tmpb_tl) / (\l_@@_tmpa_tl) |
| 10099 |
} |
| 10100 |
\prop_gput:Nnv \g_@@_master_changer_prop |
| 10101 |
{ #1 ~->~ #2 } |
| 10102 |
{ l_@@_unit_change_ #1 _tl } |
| 10103 |
}{ |
| 10104 |
\msg_error:nnnn { cooking-units } { key-no-knows-value } {#1} {#2} |
| 10105 |
} |
| 10106 |
} |
| 10107 |
\cs_generate_variant:Nn \@@_convert_derived_unit:nn { V } |
| 10108 |
% \end{macrocode} |
| 10109 |
% \end{macro} |
| 10110 |
% |
| 10111 |
% |
| 10112 |
% |
| 10113 |
% |
| 10114 |
% |
| 10115 |
% |
| 10116 |
% |
| 10117 |
% \section {Names} |
| 10118 |
% |
| 10119 |
% Stolen from \pkg{l3keys.dtx} |
| 10120 |
% \begin{macrocode} |
| 10121 |
\tl_new:N \l_@@_sanitise_tl |
| 10122 |
\cs_new_protected:Npn \@@_sanitise_aux:w #1 \q_mark |
| 10123 |
{ \tl_set:Nn \l_@@_sanitise_tl {#1} } |
| 10124 |
\group_begin: |
| 10125 |
\char_set_catcode_active:n { `\< } |
| 10126 |
\char_set_catcode_active:n { `\> } |
| 10127 |
\cs_new:Npn \@@_sanitize_open_arrow: |
| 10128 |
{ |
| 10129 |
\exp_after:wN \@@_sanitize_open_arrow_auxi:w \l_@@_sanitise_tl |
| 10130 |
\q_mark < \q_nil < |
| 10131 |
\exp_after:wN \@@_sanitise_aux:w \l_@@_sanitise_tl |
| 10132 |
} |
| 10133 |
\cs_new_protected:Npn \@@_sanitize_open_arrow_auxi:w #1 < |
| 10134 |
{ |
| 10135 |
\tl_set:Nn \l_@@_sanitise_tl {#1} |
| 10136 |
\@@_sanitize_open_arrow_auxii:w |
| 10137 |
} |
| 10138 |
\cs_new_protected:Npn \@@_sanitize_open_arrow_auxii:w #1 < |
| 10139 |
{ |
| 10140 |
\quark_if_nil:nF {#1} |
| 10141 |
{ |
| 10142 |
\tl_set:Nx \l_@@_sanitise_tl |
| 10143 |
{ |
| 10144 |
\exp_not:V \l_@@_sanitise_tl |
| 10145 |
\token_to_str:N < |
| 10146 |
\exp_not:n {#1} |
| 10147 |
} |
| 10148 |
\exp_after:wN \@@_sanitize_open_arrow_auxii:w |
| 10149 |
} |
| 10150 |
} |
| 10151 |
\cs_new:Npn \@@_sanitize_close_arrow: |
| 10152 |
{ |
| 10153 |
\exp_after:wN \@@_sanitize_close_arrow_auxi:w \l_@@_sanitise_tl |
| 10154 |
\q_mark > \q_nil > |
| 10155 |
\exp_after:wN \@@_sanitise_aux:w \l_@@_sanitise_tl |
| 10156 |
} |
| 10157 |
\cs_new_protected:Npn \@@_sanitize_close_arrow_auxi:w #1 > |
| 10158 |
{ |
| 10159 |
\tl_set:Nn \l_@@_sanitise_tl {#1} |
| 10160 |
\@@_sanitize_close_arrow_auxii:w |
| 10161 |
} |
| 10162 |
\cs_new_protected:Npn \@@_sanitize_close_arrow_auxii:w #1 > |
| 10163 |
{ |
| 10164 |
\quark_if_nil:nF {#1} |
| 10165 |
{ |
| 10166 |
\tl_set:Nx \l_@@_sanitise_tl |
| 10167 |
{ |
| 10168 |
\exp_not:V \l_@@_sanitise_tl |
| 10169 |
\token_to_str:N > |
| 10170 |
\exp_not:n {#1} |
| 10171 |
} |
| 10172 |
\exp_after:wN \@@_sanitize_close_arrow_auxii:w |
| 10173 |
} |
| 10174 |
} |
| 10175 |
\group_end: |
| 10176 |
\cs_new_protected:Npn \@@_sanitize_arrows:n #1 |
| 10177 |
{ |
| 10178 |
\tl_set:Nn \l_@@_sanitise_tl {#1} |
| 10179 |
\@@_sanitize_open_arrow: |
| 10180 |
\@@_sanitize_close_arrow: |
| 10181 |
} |
| 10182 |
% \end{macrocode} |
| 10183 |
% |
| 10184 |
% |
| 10185 |
% \begin{macro}{\cudefinename} |
| 10186 |
% This command allows to (re)define \enquote{names} for units to be used |
| 10187 |
% in \cCutext\ for given language. We need to sanitize the arrows (|<| and |>|) |
| 10188 |
% in case they are active. Afterwards, parse through the list. |
| 10189 |
% \begin{macrocode} |
| 10190 |
\NewDocumentCommand \cudefinename { m m } |
| 10191 |
{ |
| 10192 |
\tl_set:Nn \l_@@_language_tl {#1} |
| 10193 |
\@@_sanitize_arrows:n {#2} |
| 10194 |
\exp_after:wN |
| 10195 |
\@@_parse_definename_start_cycle: \l_@@_sanitise_tl |
| 10196 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 10197 |
} |
| 10198 |
% \end{macrocode} |
| 10199 |
% \end{macro} |
| 10200 |
% |
| 10201 |
% \begin{macro}{\@@_parse_definename_start_cycle:} |
| 10202 |
% Initializes the parse cycle. Set state to \enquote{normal} and clear some variables. |
| 10203 |
% Start by grabbing the first argument which is the unit. |
| 10204 |
% \begin{macrocode} |
| 10205 |
\cs_new:Npn \@@_parse_definename_start_cycle: |
| 10206 |
{ |
| 10207 |
\@@_set_state_to:n { normal } |
| 10208 |
\tl_clear:N \l_@@_curr_unit_tl |
| 10209 |
\prop_clear:N \l_@@_tmpa_prop |
| 10210 |
\bool_set_false:N \l_@@_tmpa_bool |
| 10211 |
\@@_parse_definename_unit:n |
| 10212 |
} |
| 10213 |
% \end{macrocode} |
| 10214 |
% \end{macro} |
| 10215 |
% \begin{macro}{ \@@_parse_definename_unit:n } |
| 10216 |
% Grab the unit. This can be either an actual unit (defined by |\newcookingunit| and Co.) |
| 10217 |
% or it is one of the allowed \enquote{special-keys} like \enquote{decimal-marker}, |
| 10218 |
% etc. In case neither of those two is found, issue an error, but continue parsing |
| 10219 |
% to catch more errors. |
| 10220 |
% |
| 10221 |
% The next optional argument is the unit-symbol, which can also be set by this |
| 10222 |
% command. If it is not found, grab the next mandatory argument, which is the |
| 10223 |
% unit-name. |
| 10224 |
% \begin{macrocode} |
| 10225 |
\cs_new:Npn \@@_parse_definename_unit:n #1 |
| 10226 |
{ |
| 10227 |
\quark_if_recursion_tail_stop:n {#1} |
| 10228 |
\seq_if_in:NnTF \g_@@_allowed_special_keys_seq {#1} |
| 10229 |
{ |
| 10230 |
\str_if_eq:nnTF { cutext-range-sign } {#1} |
| 10231 |
{ \@@_set_unit:Nn \l_@@_curr_unit_tl { cutext-range-phrase } } |
| 10232 |
{ \@@_set_unit:Nn \l_@@_curr_unit_tl {#1} } |
| 10233 |
\bool_set_true:N \l_@@_tmpa_bool |
| 10234 |
}{ |
| 10235 |
\@@_error_if_unit_not_defined:nNT {#1} \l_@@_curr_unit_tl |
| 10236 |
{ \@@_set_state_to:n { error } } |
| 10237 |
} |
| 10238 |
\peek_remove_spaces:n |
| 10239 |
{ |
| 10240 |
\peek_meaning:NTF [ |
| 10241 |
{ \@@_parse_definename_optional_unitsymbol:w } |
| 10242 |
{ \@@_parse_definename_singular:n } |
| 10243 |
} |
| 10244 |
} |
| 10245 |
% \end{macrocode} |
| 10246 |
% \end{macro} |
| 10247 |
% |
| 10248 |
% \begin{macro}{ \@@_parse_definename_optional_unitsymbol:w } |
| 10249 |
% The frst optional argument has be found; it is thus the unit-symbol. |
| 10250 |
% Changing the unit-symbol is only allowed for actual units, so no \enquote{special-keys} |
| 10251 |
% allowed. If we have an unit, store it into |\l_@@_tmpa_prop|. |
| 10252 |
% \begin{macrocode} |
| 10253 |
\cs_new:Npn \@@_parse_definename_optional_unitsymbol:w [#1] |
| 10254 |
{ |
| 10255 |
\bool_if:NTF \l_@@_tmpa_bool |
| 10256 |
{ |
| 10257 |
\@@_set_state_to:n { error } |
| 10258 |
\msg_error:nnxn { cooking-units } { symbol-and-special-keys-error } |
| 10259 |
\l_@@_curr_unit_tl {#1} |
| 10260 |
} |
| 10261 |
{ \prop_put:Nnn \l_@@_tmpa_prop { unit-symbol } {#1} } |
| 10262 |
\@@_parse_definename_singular:n |
| 10263 |
} |
| 10264 |
% \end{macrocode} |
| 10265 |
% \end{macro} |
| 10266 |
% |
| 10267 |
% \begin{macro}{ \@@_parse_definename_singular:n } |
| 10268 |
% Parses the \enquote{name} of the unit (or special key). |
| 10269 |
% Do an error check, store the input in the property list and go to the |
| 10270 |
% next one, which is the plural form. The next (optional) argument is |
| 10271 |
% the plural form of the \enquote{name}. If there is none, also use |#1| for plural. |
| 10272 |
% \begin{macrocode} |
| 10273 |
\cs_new:Npn \@@_parse_definename_singular:n #1 |
| 10274 |
{ |
| 10275 |
\quark_if_recursion_tail_stop_do:nn {#1} |
| 10276 |
{ \msg_error:nn { cooking-units } { missing-argument } } |
| 10277 |
\prop_put:Nnn \l_@@_tmpa_prop { name } {#1} |
| 10278 |
\peek_remove_spaces:n |
| 10279 |
{ |
| 10280 |
\peek_meaning:NTF [ |
| 10281 |
{ \@@_parse_definename_optional_plural:w } |
| 10282 |
{ \@@_parse_definename_optional_plural:w [#1] } |
| 10283 |
} |
| 10284 |
} |
| 10285 |
% \end{macrocode} |
| 10286 |
% \end{macro} |
| 10287 |
% |
| 10288 |
% \begin{macro}{ \@@_parse_definename_optional_plural:w } |
| 10289 |
% Nothing new here. The next one is the gender. If no gender is found |
| 10290 |
% I assume it to be male \enquote{m}. |
| 10291 |
% \begin{macrocode} |
| 10292 |
\cs_new:Npn \@@_parse_definename_optional_plural:w [#1] |
| 10293 |
{ |
| 10294 |
\prop_put:Nnn \l_@@_tmpa_prop { name-pl } {#1} |
| 10295 |
\peek_remove_spaces:n |
| 10296 |
{ |
| 10297 |
\peek_meaning:NTF < |
| 10298 |
{ \@@_parse_definename_optional_gender:w } |
| 10299 |
{ \@@_parse_definename_optional_gender:w <m> } |
| 10300 |
} |
| 10301 |
} |
| 10302 |
% \end{macrocode} |
| 10303 |
% \end{macro} |
| 10304 |
% |
| 10305 |
% \begin{macro}{ \@@_parse_definename_optional_plural:w } |
| 10306 |
% Check if the gender is correct. Then store it in the property-list |
| 10307 |
% and finish the cycle. |
| 10308 |
% \begin{macrocode} |
| 10309 |
\cs_new:Npn \@@_parse_definename_optional_gender:w <#1> |
| 10310 |
{ |
| 10311 |
\@@_if_gender_error:nT {#1} |
| 10312 |
{ \@@_set_state_to:n { error } } |
| 10313 |
\prop_put:Nnn \l_@@_tmpa_prop { gender } {#1} |
| 10314 |
\@@_parse_name_finish_cycle_and_start_new:VV |
| 10315 |
\l_@@_language_tl \l_@@_curr_unit_tl |
| 10316 |
} |
| 10317 |
% \end{macrocode} |
| 10318 |
% \end{macro} |
| 10319 |
% |
| 10320 |
% \begin{macro}{ \@@_parse_name_finish_cycle_and_start_new:nn } |
| 10321 |
% Now it makes sense why we used property list before. |
| 10322 |
% Each unit has some basic definitions for each language (see |\newcookingunit| and Co.): |
| 10323 |
% \enquote{unit-symbol}, \enquote{name}, \enquote{name\_pl} and \enquote{gender}. |
| 10324 |
% |
| 10325 |
% So going through the property list (where we stored the given values) |
| 10326 |
% we set for the given language and unit those definitions (\enquote{unit-symbol} only |
| 10327 |
% if found). |
| 10328 |
% |
| 10329 |
% Afterwards, start the next cycle. |
| 10330 |
% \begin{macrocode} |
| 10331 |
\cs_new:Npn \@@_parse_name_finish_cycle_and_start_new:nn #1#2 |
| 10332 |
{ |
| 10333 |
\@@_if_state_equal:nT { normal } |
| 10334 |
{ |
| 10335 |
\prop_map_inline:Nn \l_@@_tmpa_prop |
| 10336 |
{ \@@_culang_def_for:nnnn {#1} {##1} {#2} {##2} } |
| 10337 |
} |
| 10338 |
\@@_parse_definename_start_cycle: |
| 10339 |
} |
| 10340 |
\cs_generate_variant:Nn \@@_parse_name_finish_cycle_and_start_new:nn { VV } |
| 10341 |
% \end{macrocode} |
| 10342 |
% \end{macro} |
| 10343 |
% |
| 10344 |
% |
| 10345 |
% \subsection {Define plural-usage for \cCutext} |
| 10346 |
% |
| 10347 |
% \begin{macro}{ pluraltest: normal/range/fraction } |
| 10348 |
% Some translations used in a second. Define one for \enquote{normal} |
| 10349 |
% (just a number), \enquote{range} and \enquote{fraction}. |
| 10350 |
% \begin{macrocode} |
| 10351 |
\@@_culang_def_base:nnn { pluraltest } { normal } { \c_@@_no_translation_str } |
| 10352 |
\@@_culang_def_base:nnn { pluraltest } { fraction } { \c_@@_no_translation_str } |
| 10353 |
% \end{macrocode} |
| 10354 |
% \end{macro} |
| 10355 |
% \begin{macro}{ @@_pluraltest_normal_<default>:N, |
| 10356 |
% @@_pluraltest_range_<default>:NN, |
| 10357 |
% @@_pluraltest_fraction_<default>:NNN } |
| 10358 |
% Here we define the default behavior, if no explicit rule is given for a language. |
| 10359 |
% By default, use the singular only if the value in question is equal to $1$. |
| 10360 |
% For ranges take the last value, for fractions make sure there are no mixed fractions |
| 10361 |
% and that the nominator is equal to $1$. |
| 10362 |
% \begin{macrocode} |
| 10363 |
\cs_set:cpn { @@_pluraltest_normal_ \c_@@_no_translation_str :n } #1 |
| 10364 |
{ |
| 10365 |
\fp_compare:nNnTF {#1} = { 1.0 } |
| 10366 |
{ \bool_set_true:N } { \bool_set_false:N } |
| 10367 |
\l_@@_cutext_use_single_bool |
| 10368 |
} |
| 10369 |
\cs_set:cpn { @@_pluraltest_fraction_ \c_@@_no_translation_str :nnn } #1#2#3 |
| 10370 |
{ |
| 10371 |
\tl_if_empty:nTF {#1} |
| 10372 |
{ \fp_compare:nNnTF {#2} = { \c_one_fp } } { \use_ii:nn } |
| 10373 |
{ \bool_set_true:N } { \bool_set_false:N } |
| 10374 |
\l_@@_cutext_use_single_bool |
| 10375 |
} |
| 10376 |
% \end{macrocode} |
| 10377 |
% \end{macro} |
| 10378 |
% \begin{macro}{ \@@_pluraltest_define:nn , \@@_pluraltest_define_range:nn , \@@_pluraltest_define_fraction:nn } |
| 10379 |
% Allow to define a when to use the singular/plural for a given language. |
| 10380 |
% Nothing more happens here. The default was already defined in the last step. |
| 10381 |
% \begin{macrocode} |
| 10382 |
\cs_new:Npn \@@_pluraltest_define:nn #1#2 |
| 10383 |
{ |
| 10384 |
\@@_culang_def_for:nnnn {#1} { pluraltest } { normal } {#1} |
| 10385 |
\cs_set:cpn { @@_pluraltest_normal_ #1 :n } ##1 {#2} |
| 10386 |
} |
| 10387 |
\cs_new:Npn \@@_pluraltest_define_fraction:nn #1#2 |
| 10388 |
{ |
| 10389 |
\@@_culang_def_for:nnnn {#1} { pluraltest } { fraction } {#1} |
| 10390 |
\cs_set:cpn { @@_pluraltest_fraction_ #1 :nnn } ##1##2##3 {#2} |
| 10391 |
} |
| 10392 |
% \end{macrocode} |
| 10393 |
% \end{macro} |
| 10394 |
% \begin{macro}{ Pluraltest: French } |
| 10395 |
% As source see |
| 10396 |
% \begin{itemize} |
| 10397 |
% \item \url{https://github.com/Vidabe/cooking-units/pull/29#issue-1190629683} |
| 10398 |
% \item \url{https://www.dictionnaire-academie.fr/article/A9P2979} |
| 10399 |
% \end{itemize} |
| 10400 |
% Note: At this point the minus signs were already removed from fractions; thus |
| 10401 |
% all their values are positive. |
| 10402 |
% \begin{macrocode} |
| 10403 |
\@@_pluraltest_define:nn { French } |
| 10404 |
{ |
| 10405 |
\fp_compare:nNnTF { \fp_abs:n {#1} } < { 2.0 } |
| 10406 |
{ \bool_set_true:N } { \bool_set_false:N } |
| 10407 |
\l_@@_cutext_use_single_bool |
| 10408 |
} |
| 10409 |
\@@_pluraltest_define_fraction:nn { French } |
| 10410 |
{ |
| 10411 |
\tl_if_empty:nTF {#1} |
| 10412 |
{ \fp_compare:nNnTF { #2/#3 } < { 2.0 } } |
| 10413 |
{ \fp_compare:nNnTF { #1 + #2/#3 } < { 2.0 } } |
| 10414 |
{ \bool_set_true:N } { \bool_set_false:N } |
| 10415 |
\l_@@_cutext_use_single_bool |
| 10416 |
} |
| 10417 |
% \end{macrocode} |
| 10418 |
% \end{macro} |
| 10419 |
% |
| 10420 |
% |
| 10421 |
% \subsection {cudefinesymbol} |
| 10422 |
% |
| 10423 |
% \begin{macro}{ \cudefinesymbol } |
| 10424 |
% A small and rather straightforward command. |
| 10425 |
% No special sanitizing here, just setting the language and parsing. |
| 10426 |
% \begin{macrocode} |
| 10427 |
\NewDocumentCommand \cudefinesymbol { m m } |
| 10428 |
{ |
| 10429 |
\tl_set:Nn \l_@@_language_tl {#1} |
| 10430 |
\@@_cuprint_define_printed_unit:nn #2 |
| 10431 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 10432 |
} |
| 10433 |
% \end{macrocode} |
| 10434 |
% \end{macro} |
| 10435 |
% |
| 10436 |
% \begin{macro}{ \@@_cuprint_define_printed_unit:nn } |
| 10437 |
% Sets the symbol for given units or \enquote{special keys}. |
| 10438 |
% Nothing extraordinary is done here. We we have an unit we |
| 10439 |
% set its \enquote{unit-symbol} for given language, for an \enquote{special key} |
| 10440 |
% we set its name. Rinse and repeat. |
| 10441 |
% \begin{macrocode} |
| 10442 |
\cs_new:Npn \@@_cuprint_define_printed_unit:nn #1#2 |
| 10443 |
{ |
| 10444 |
\quark_if_recursion_tail_stop:n {#1} |
| 10445 |
\quark_if_recursion_tail_stop_do:nn {#2} |
| 10446 |
{ \msg_error:nn { cooking-units } { missing-argument } } |
| 10447 |
\seq_if_in:NnTF \g_@@_allowed_special_keys_seq {#1} |
| 10448 |
{ |
| 10449 |
\str_if_eq:nnTF { cutext-range-sign } {#1} |
| 10450 |
{ \@@_culang_def_for:Vnnn \l_@@_language_tl { name } { cutext-range-phrase } {#2} } |
| 10451 |
{ \@@_culang_def_for:Vnnn \l_@@_language_tl { name } {#1} {#2} } |
| 10452 |
}{ |
| 10453 |
\@@_error_if_unit_not_defined:nTF {#1} |
| 10454 |
{ \use_none:nn {#1} {#2} } |
| 10455 |
{ \@@_culang_def_for:Vnnn \l_@@_language_tl { unit-symbol } {#1} {#2} } |
| 10456 |
} |
| 10457 |
\@@_cuprint_define_printed_unit:nn |
| 10458 |
} |
| 10459 |
% \end{macrocode} |
| 10460 |
% \end{macro} |
| 10461 |
% |
| 10462 |
% |
| 10463 |
% \subsection {Phrases} |
| 10464 |
% |
| 10465 |
% |
| 10466 |
% |
| 10467 |
% \begin{macro}{ phrase } |
| 10468 |
% Defining phrases. Phrases (sadly) depend on the language. |
| 10469 |
% The idea is going to be: Each language has its own property list |
| 10470 |
% which is going to be stored for each language. Later, the property |
| 10471 |
% list is recoverd for the language currently used. If no phrase is defined |
| 10472 |
% the fallback |\c_@@_no_translation_str| is returned. |
| 10473 |
% \begin{macrocode} |
| 10474 |
\@@_culang_def_base:nnn { phrase } { phrase-prop } { \c_@@_no_translation_str } |
| 10475 |
\@@_culang_def_base:nnn { phrase } { phrase-lang } { Humphry-Drumphy } |
| 10476 |
% \end{macrocode} |
| 10477 |
% \end{macro} |
| 10478 |
% |
| 10479 |
% \begin{macro}{ \@@_culang_get_phrase_prop:N } |
| 10480 |
% \begin{macrocode} |
| 10481 |
\cs_new:Npn \@@_culang_get_phrase_prop:N #1 |
| 10482 |
{ |
| 10483 |
\@@_culang_let:nnN { phrase } { phrase-lang } \l_@@_language_tl |
| 10484 |
\prop_if_exist:cTF { l_@@_ \l_@@_language_tl _phrase_prop } |
| 10485 |
{ |
| 10486 |
\prop_set_eq:Nc #1 { l_@@_ \l_@@_language_tl _phrase_prop } |
| 10487 |
} |
| 10488 |
{ \tl_set_eq:NN #1 \c_@@_no_translation_str } |
| 10489 |
} |
| 10490 |
\cs_new:Npn \@@_culang_get_phrase_prop_for:nN #1#2 |
| 10491 |
{ |
| 10492 |
\prop_set_eq:Nc #2 { l_@@_ #1 _phrase_prop } |
| 10493 |
% \prop_if_exist:cT { l_@@_ #1 _phrase_prop } |
| 10494 |
% { \prop_set_eq:Nc \l_@@_phrase_prop { l_@@_ #1 _phrase_prop } } |
| 10495 |
} |
| 10496 |
% \end{macrocode} |
| 10497 |
% \end{macro} |
| 10498 |
% |
| 10499 |
% \begin{macro}{ \cudefinephrase } |
| 10500 |
% Defining some phrases. This command is just a wrapper for the |
| 10501 |
% subcommand. |
| 10502 |
% \begin{macrocode} |
| 10503 |
\tl_new:N \l_@@_phrase_tmp_tl |
| 10504 |
\tl_new:N \l_@@_phrase_tmpb_tl |
| 10505 |
\seq_new:N \l_@@_phrase_full_seq |
| 10506 |
\NewDocumentCommand \cudefinephrase { m m } |
| 10507 |
{ |
| 10508 |
\@@_rf_cuphrase_add:nn {#1} {#2} |
| 10509 |
} |
| 10510 |
% \end{macrocode} |
| 10511 |
% \end{macro} |
| 10512 |
% |
| 10513 |
% \begin{macro}{ \@@_rf_cuphrase_add:nn } |
| 10514 |
% |#1| is the language, |#2| is something to be parsed. |
| 10515 |
% I am also not quite happy with this construction, but it works. |
| 10516 |
% |
| 10517 |
% First, check if we already have existing phrases for the language. |
| 10518 |
% If so, recover it, we add the parsed one to them. Else, clear |
| 10519 |
% some variables. |
| 10520 |
% |
| 10521 |
% Next step, sanitize |<| and |>|. I hate this so much. |
| 10522 |
% |
| 10523 |
% Using |\@@_parse_phrase:V| we parse through the argument |#2|. |
| 10524 |
% The results are added to |\l_@@_phrase_prop| and |\l_@@_phrase_numbers_seq|. |
| 10525 |
% |
| 10526 |
% By our rules, we prefer big numbers over small ones. For example, |
| 10527 |
% 120 can be translated into \enquote{2 Schocks} ($2\times60$) or |
| 10528 |
% \enquote{10 Dutzend} ($10\times12$). We prefer the bigger number first, |
| 10529 |
% so we will always get \enquote{2 Schocks}. Thus we sort the numbers in the |
| 10530 |
% sequence from highest to lowest. We also have negative numbers (phrases only |
| 10531 |
% used for one specific number). We prefer the negative over the positive ones |
| 10532 |
% if possible. |
| 10533 |
% |
| 10534 |
% Then store the variables and thats it. |
| 10535 |
% \begin{macrocode} |
| 10536 |
\cs_new:Npn \@@_rf_cuphrase_add:nn #1#2 |
| 10537 |
{ |
| 10538 |
\tl_set:Nn \l_@@_language_tl {#1} |
| 10539 |
\@@_culang_if_translation_exists_for:VnnTF \l_@@_language_tl |
| 10540 |
{ phrase } { phrase-lang } |
| 10541 |
{ |
| 10542 |
\prop_set_eq:Nc \l_@@_phrase_prop { l_@@_ \l_@@_language_tl _phrase_prop } |
| 10543 |
\prop_get:NnN \l_@@_phrase_prop { seq } \l_@@_phrase_numbers_seq |
| 10544 |
}{ |
| 10545 |
\prop_new:c { l_@@_ \l_@@_language_tl _phrase_prop } |
| 10546 |
\prop_clear:N \l_@@_phrase_prop |
| 10547 |
\seq_clear:N \l_@@_phrase_numbers_seq |
| 10548 |
\seq_clear:N \l_@@_phrase_full_seq |
| 10549 |
} |
| 10550 |
\@@_sanitize_arrows:n {#2} |
| 10551 |
\@@_parse_phrase:V \l_@@_sanitise_tl |
| 10552 |
\@@_rf_cuphrase_sort_sequence:N \l_@@_phrase_numbers_seq |
| 10553 |
\prop_put:NnV \l_@@_phrase_prop { seq } \l_@@_phrase_numbers_seq |
| 10554 |
\prop_set_eq:cN { l_@@_ \l_@@_language_tl _phrase_prop } \l_@@_phrase_prop |
| 10555 |
\@@_culang_def_for:VnnV |
| 10556 |
\l_@@_language_tl { phrase } { phrase-lang } \l_@@_language_tl |
| 10557 |
} |
| 10558 |
% \end{macrocode} |
| 10559 |
% \end{macro} |
| 10560 |
% |
| 10561 |
% \begin{macro}{ \@@_parse_phrase:n } |
| 10562 |
% Wrapper around the parsing cycles. Nothing new. |
| 10563 |
% \begin{macrocode} |
| 10564 |
\cs_new:Npn \@@_parse_phrase:n #1 |
| 10565 |
{ |
| 10566 |
\@@_parse_phrase_start_cycle: #1 |
| 10567 |
\q_recursion_tail \q_recursion_tail \q_recursion_stop |
| 10568 |
} |
| 10569 |
\cs_generate_variant:Nn \@@_parse_phrase:n { V } |
| 10570 |
% \end{macrocode} |
| 10571 |
% \end{macro} |
| 10572 |
% |
| 10573 |
% \begin{macro}{ \@@_parse_phrase_start_cycle: } |
| 10574 |
% Starts the parsing cycle. Clear some variables, set state to normal. |
| 10575 |
% \begin{macrocode} |
| 10576 |
\cs_new:Npn \@@_parse_phrase_start_cycle: |
| 10577 |
{ |
| 10578 |
\@@_set_state_to:n { normal } |
| 10579 |
\bool_set_false:N \l_@@_tmpa_bool |
| 10580 |
\tl_clear:N \l_@@_curr_unit_tl |
| 10581 |
\tl_clear:N \l_@@_phrase_tmp_tl |
| 10582 |
\tl_clear:N \l_@@_phrase_tmpb_tl |
| 10583 |
\prop_clear:N \l_@@_tmpa_prop |
| 10584 |
\@@_parse_stuff_mandatories_plus_star:nn |
| 10585 |
} |
| 10586 |
% \end{macrocode} |
| 10587 |
% \end{macro} |
| 10588 |
% |
| 10589 |
% \begin{macro}{ \@@_parse_stuff_mandatories_plus_star:nn } |
| 10590 |
% Now. We have two cases: two mandatroy arguments following each other |
| 10591 |
% (number plus phrase) \emph{or} number plus star plus phrase (so three arguments). |
| 10592 |
% In order to not need explicetly test for the star I do the following: |
| 10593 |
% Just grab the first two things. |#1| is always the number. |#2| can either be |
| 10594 |
% the star |*| \emph{or} a phrase. If it is a star, set a boolean, and restart the command |
| 10595 |
% with |#1| already given. |
| 10596 |
% |
| 10597 |
% Then check if |#2| is a number (with a primitve test). Star-numbers are stored |
| 10598 |
% negatively. This makes defining a property list easier for me. |
| 10599 |
% |
| 10600 |
% Note that the key in the first |\l_@@_tmpa_prop| is empty. This is done |
| 10601 |
% in order to not screw up the later |\prop_map_inline| loop. We also store |
| 10602 |
% if the phrase is only used for one number (aka.\ if there is a star). |
| 10603 |
% |
| 10604 |
% Then, parse the optionals. |
| 10605 |
% \begin{macrocode} |
| 10606 |
\cs_new:Npn \@@_parse_stuff_mandatories_plus_star:nn #1#2 |
| 10607 |
{ |
| 10608 |
\quark_if_recursion_tail_stop:n {#1} |
| 10609 |
\quark_if_recursion_tail_stop_do:nn {#2} |
| 10610 |
{ \msg_error:nn { cooking-units } { missing-argument } } |
| 10611 |
\str_if_eq:nnTF {#2} { * } |
| 10612 |
{ |
| 10613 |
\bool_set_true:N \l_@@_tmpa_bool |
| 10614 |
\@@_parse_stuff_mandatories_plus_star:nn {#1} |
| 10615 |
}{ |
| 10616 |
\@@_if_evaluation_is_integer:nTF {#1} |
| 10617 |
{ |
| 10618 |
\int_set:Nn \l_@@_tmpa_int {#1} |
| 10619 |
\tl_set:NV \l_@@_curr_unit_tl \l_@@_tmpa_int |
| 10620 |
\tl_put_right:Nx \l_@@_phrase_tmpb_tl { { \l_@@_curr_unit_tl } } |
| 10621 |
}{ |
| 10622 |
\@@_set_state_to:n { error } |
| 10623 |
\msg_error:nnn { cooking-units} { phrase-unit-not-an-integer } {#1} |
| 10624 |
} |
| 10625 |
\bool_if:NTF \l_@@_tmpa_bool |
| 10626 |
{ |
| 10627 |
\tl_put_right:Nn \l_@@_phrase_tmpb_tl { { \c_true_bool } } |
| 10628 |
}{ |
| 10629 |
\tl_put_right:Nn \l_@@_phrase_tmpb_tl { { \c_false_bool } } |
| 10630 |
} |
| 10631 |
% |
| 10632 |
\prop_put:Nnn \l_@@_tmpa_prop { } {#2} |
| 10633 |
\tl_put_right:Nn \l_@@_phrase_tmp_tl { {#2} } |
| 10634 |
\prop_put:NnV \l_@@_tmpa_prop { - singlebool } \l_@@_tmpa_bool |
| 10635 |
\@@_parse_phrase_optionals:n {#2} |
| 10636 |
} |
| 10637 |
} |
| 10638 |
% \end{macrocode} |
| 10639 |
% \end{macro} |
| 10640 |
% |
| 10641 |
% \begin{macro}{ \@@_parse_phrase_optionals:n } |
| 10642 |
% Get the plural form of the phrase. If the next token is an open bracket, |
| 10643 |
% get the plural form, else set the plural form equal to the singular form. |
| 10644 |
% \begin{macrocode} |
| 10645 |
\cs_new:Npn \@@_parse_phrase_optionals:n #1 |
| 10646 |
{ |
| 10647 |
\peek_remove_spaces:n |
| 10648 |
{ |
| 10649 |
\peek_meaning:NTF [ |
| 10650 |
{ \@@_parse_stuff_plural:w } |
| 10651 |
{ \@@_parse_stuff_plural:w [#1] } |
| 10652 |
} |
| 10653 |
} |
| 10654 |
% \end{macrocode} |
| 10655 |
% \end{macro} |
| 10656 |
% |
| 10657 |
% \begin{macro}{ \@@_parse_stuff_plural:w } |
| 10658 |
% Store the pluarl form in the property list. |
| 10659 |
% Next, parse gender. Pretty much the same as before. By default we use |
| 10660 |
% a male gender. |
| 10661 |
% \begin{macrocode} |
| 10662 |
\cs_new:Npn \@@_parse_stuff_plural:w [#1] |
| 10663 |
{ |
| 10664 |
\prop_put:Nnn \l_@@_tmpa_prop { -pl } {#1} |
| 10665 |
\tl_put_right:Nn \l_@@_phrase_tmp_tl { {#1} } |
| 10666 |
\peek_remove_spaces:n |
| 10667 |
{ |
| 10668 |
\peek_meaning:NTF < |
| 10669 |
{ \@@_parse_stuff_gender:w } |
| 10670 |
{ \@@_parse_stuff_gender:w <m> } |
| 10671 |
} |
| 10672 |
} |
| 10673 |
% \end{macrocode} |
| 10674 |
% \end{macro} |
| 10675 |
% |
| 10676 |
% \begin{macro}{ \@@_parse_stuff_gender:w } |
| 10677 |
% Check if the gender-input is correct, add it to the property list. |
| 10678 |
% Then finish the cycle and start a new one. |
| 10679 |
% \begin{macrocode} |
| 10680 |
\cs_new:Npn \@@_parse_stuff_gender:w <#1> |
| 10681 |
{ |
| 10682 |
\@@_if_gender_error:nTF {#1} |
| 10683 |
{ \@@_set_state_to:n { error } } |
| 10684 |
{ |
| 10685 |
\prop_put:Nnn \l_@@_tmpa_prop { -gender } {#1} |
| 10686 |
\tl_put_right:Nn \l_@@_phrase_tmp_tl { {#1} } |
| 10687 |
} |
| 10688 |
\@@_parse_phrase_finish_cycle_and_start_anew:VVV |
| 10689 |
\l_@@_curr_unit_tl \l_@@_phrase_tmp_tl \l_@@_phrase_tmpb_tl |
| 10690 |
} |
| 10691 |
% \end{macrocode} |
| 10692 |
% \end{macro} |
| 10693 |
% |
| 10694 |
% \begin{macro}{ \@@_parse_phrase_finish_cycle_and_start_anew:n } |
| 10695 |
% If not errors were found: Add the number to the other numbers (if not already inside). |
| 10696 |
% Afterwards map through the property list and set the variations for each number. |
| 10697 |
% |
| 10698 |
% As an example, if we had \enquote{12}, |\l_@@_phrase_prop| would then contain |
| 10699 |
% the keys \enquote{12}, \enquote{12-pl}, \enquote{12-gender}, \enquote{12-singlebool}. |
| 10700 |
% \begin{macrocode} |
| 10701 |
\cs_new:Npn \@@_parse_phrase_finish_cycle_and_start_anew:nnn #1#2#3 |
| 10702 |
{ |
| 10703 |
\@@_if_state_equal:nT { normal } |
| 10704 |
{ |
| 10705 |
\seq_if_in:NnF \l_@@_phrase_numbers_seq {#3} |
| 10706 |
{ \seq_push:Nn \l_@@_phrase_numbers_seq {#3} } |
| 10707 |
\prop_map_inline:Nn \l_@@_tmpa_prop |
| 10708 |
{ |
| 10709 |
\prop_put:Nnn \l_@@_phrase_prop { #3 ##1 } {##2} |
| 10710 |
} |
| 10711 |
\prop_put:Nnn \l_@@_phrase_prop { #3 -all } {#2} |
| 10712 |
} |
| 10713 |
\@@_parse_phrase_start_cycle: |
| 10714 |
} |
| 10715 |
\cs_generate_variant:Nn \@@_parse_phrase_finish_cycle_and_start_anew:nnn { VVV } |
| 10716 |
% \end{macrocode} |
| 10717 |
% \end{macro} |
| 10718 |
% |
| 10719 |
% \begin{macro}{ \@@_rf_cuphrase_sort_sequence:N } |
| 10720 |
% Sorting the sequence of numbers from highest to lowest (in absolute values). |
| 10721 |
% And if two absolute values are equal, negative numbers are preferred over |
| 10722 |
% positive ones. |
| 10723 |
% \begin{macrocode} |
| 10724 |
\cs_new:Npn \@@_rf_cuphrase_sort_sequence:N #1 |
| 10725 |
{ |
| 10726 |
\seq_sort:Nn #1 |
| 10727 |
{ |
| 10728 |
\int_set:Nn \l_@@_tmpa_int { \use_i:nn ##1 } |
| 10729 |
\int_set:Nn \l_@@_tmpb_int { \use_i:nn ##2 } |
| 10730 |
\int_compare:nNnTF { \l_@@_tmpa_int } < { \l_@@_tmpb_int } |
| 10731 |
{ \sort_return_swapped: } |
| 10732 |
{ |
| 10733 |
\int_compare:nNnTF { \l_@@_tmpa_int } > { \l_@@_tmpb_int } |
| 10734 |
{ \sort_return_same: } |
| 10735 |
{ |
| 10736 |
\bool_if:nTF { \use_ii:nn ##1 } |
| 10737 |
{ \sort_return_same: } |
| 10738 |
{ \sort_return_swapped: } |
| 10739 |
} |
| 10740 |
} |
| 10741 |
} |
| 10742 |
} |
| 10743 |
% \end{macrocode} |
| 10744 |
% \end{macro} |
| 10745 |
% |
| 10746 |
% \begin{macro}{ \cudefinephrase } |
| 10747 |
% \begin{macrocode} |
| 10748 |
%\NewDocumentCommand \cudefinephrase { m m } |
| 10749 |
% { |
| 10750 |
%% \@@_cuphrase:nn {#1} {#2} |
| 10751 |
% } |
| 10752 |
% \end{macrocode} |
| 10753 |
% \end{macro} |
| 10754 |
% |
| 10755 |
% |
| 10756 |
% \subsection{Old stuff} |
| 10757 |
% |
| 10758 |
% \begin{macro} { \@@_old_cutext:nnn } |
| 10759 |
% \begin{macrocode} |
| 10760 |
\cs_new:Npn \@@_old_cutext:nnn #1#2#3 |
| 10761 |
{ |
| 10762 |
\tl_set_eq:NN \l_@@_option_unit_tl \l_@@_original_unit_tl |
| 10763 |
\@@_old_cutext_default:nnn {#1} {#2} {#3} |
| 10764 |
} |
| 10765 |
% \end{macrocode} |
| 10766 |
% \end{macro} |
| 10767 |
% |
| 10768 |
% |
| 10769 |
% |
| 10770 |
% \begin{macro} { \@@_old_cutext_default:nnn } |
| 10771 |
% \changes {2016/06/11} {0.98a} { New command } |
| 10772 |
% \begin{macrocode} |
| 10773 |
\cs_new:Npn \@@_old_cutext_default:nnn #1#2#3 |
| 10774 |
{ |
| 10775 |
\bool_if:NTF \l_@@_pckopt_draft_bool |
| 10776 |
{#2} |
| 10777 |
{ |
| 10778 |
\tl_set:Nn \l_@@_cutext_last_value_tl {#2} |
| 10779 |
\tl_if_in:NVTF \l_@@_cutext_last_value_tl \l_@@_input_range_sign_tl |
| 10780 |
{ |
| 10781 |
\tl_replace_once:NVn \l_@@_cutext_last_value_tl |
| 10782 |
\l_@@_input_range_sign_tl { \q_@@_range } |
| 10783 |
\@@_old_cutext_parse_range:Vn \l_@@_cutext_last_value_tl {#3} |
| 10784 |
}{ |
| 10785 |
\@@_old_cutext_print_input:Nn \l_@@_cutext_last_value_tl {#3} |
| 10786 |
} |
| 10787 |
} |
| 10788 |
} |
| 10789 |
% \end{macrocode} |
| 10790 |
% \begin{macrocode} |
| 10791 |
\cs_new_protected:Npn \@@_old_cutext_print_input:Nn #1#2 |
| 10792 |
{ |
| 10793 |
\@@_old_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:NTF #1 |
| 10794 |
{ |
| 10795 |
\int_compare:nNnTF {#1} = { 1 } |
| 10796 |
{ |
| 10797 |
\@@_culang_one_let:NnT \l_@@_translation_tmpa_tl {#2} |
| 10798 |
{ |
| 10799 |
\bool_if:NT \l_@@_cutext_uppercase_word_bool |
| 10800 |
{ |
| 10801 |
\text_uppercase:x { \tl_head:V \l_@@_translation_tmpa_tl } |
| 10802 |
\tl_tail:V |
| 10803 |
} |
| 10804 |
} |
| 10805 |
\l_@@_translation_tmpa_tl |
| 10806 |
}{ |
| 10807 |
\bool_if:NTF \l_@@_cutext_uppercase_word_bool |
| 10808 |
{ \@@_print_Numeral:V #1 } |
| 10809 |
{ \@@_print_numeral:V #1 } |
| 10810 |
} |
| 10811 |
} |
| 10812 |
{ \@@_print_numerical_input:N #1 } |
| 10813 |
} |
| 10814 |
% \end{macrocode} |
| 10815 |
% \end{macro} |
| 10816 |
% |
| 10817 |
% \begin{macro} {\@@_old_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N} |
| 10818 |
% \begin{macrocode} |
| 10819 |
\prg_new_conditional:Npnn \@@_old_cutext_if_numeral_is_int_and_parse_and_smaller_then_print_numerals:N #1 { TF } |
| 10820 |
{ |
| 10821 |
\bool_if:NTF \l_@@_lokal_numeral_bool |
| 10822 |
{ |
| 10823 |
\@@_if_integer:VTF #1 |
| 10824 |
{ |
| 10825 |
\int_compare:nNnTF {#1} < { \l_@@_print_numerals_below_int } |
| 10826 |
{ \prg_return_true: } |
| 10827 |
{ \prg_return_false: } |
| 10828 |
}{ \prg_return_false: } |
| 10829 |
}{ \prg_return_false: } |
| 10830 |
} |
| 10831 |
% \end{macrocode} |
| 10832 |
% \end{macro} |
| 10833 |
% |
| 10834 |
% \begin{macrocode} |
| 10835 |
\cs_new:Npn \@@_old_cutext_parse_range:nn #1 #2 |
| 10836 |
{ |
| 10837 |
\@@_old_cutext_parse_range_aux:nww {#2} #1 \q_stop |
| 10838 |
} |
| 10839 |
\cs_generate_variant:Nn \@@_old_cutext_parse_range:nn { V } |
| 10840 |
\cs_new:Npn \@@_old_cutext_parse_range_aux:nww #1 #2 \q_@@_range #3 \q_stop |
| 10841 |
{ |
| 10842 |
\tl_set:Nn \l_@@_tmpa_tl {#2} |
| 10843 |
\tl_set:Nn \l_@@_cutext_last_value_tl {#3} |
| 10844 |
\@@_old_cutext_print_input:Nn \l_@@_tmpa_tl {#1} |
| 10845 |
\tl_use:N \l_@@_cutext_range_sign_tl |
| 10846 |
\@@_old_cutext_print_input:Nn \l_@@_cutext_last_value_tl {#1} |
| 10847 |
} |
| 10848 |
% \end{macrocode} |
| 10849 |
% |
| 10850 |
% |
| 10851 |
% \begin{macro}{\@@_cuam_old:n} |
| 10852 |
% \begin{macrocode} |
| 10853 |
\cs_new:Npn \@@_cuam_old:n #1 |
| 10854 |
{ |
| 10855 |
\tl_set_rescan:Nnn \l_@@_tmpa_tl |
| 10856 |
{ |
| 10857 |
\char_set_catcode_letter:N \_ % |
| 10858 |
\char_set_catcode_ignore:N\ % |
| 10859 |
} {#1} |
| 10860 |
\bool_if:NTF \l_@@_pckopt_draft_bool |
| 10861 |
{ \l_@@_tmpa_tl } |
| 10862 |
{ \@@_cuam_old_parse:V \l_@@_tmpa_tl } |
| 10863 |
} |
| 10864 |
% \end{macrocode} |
| 10865 |
% \end{macro} |
| 10866 |
% |
| 10867 |
% \begin{macrocode} |
| 10868 |
\cs_new_protected:Npn \@@_cuam_old_parse:n #1 |
| 10869 |
{ |
| 10870 |
\tl_if_in:nVTF {#1} \l_@@_input_range_sign_tl |
| 10871 |
{ |
| 10872 |
\tl_set:Nn \l_@@_tmpa_tl {#1} |
| 10873 |
\tl_replace_once:NVn \l_@@_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range } |
| 10874 |
\@@_cuam_old_parse_range:V \l_@@_tmpa_tl |
| 10875 |
}{ |
| 10876 |
\tl_if_in:nnTF {#1} { / } |
| 10877 |
{ |
| 10878 |
\tl_if_in:nnTF {#1} { _ } |
| 10879 |
{ \@@_cuam_old_parse_mixed_frac:www #1 \q_stop } |
| 10880 |
{ \@@_cuam_old_parse_frac:ww #1 \q_stop } |
| 10881 |
}{ |
| 10882 |
\tl_if_in:nnTF {#1} { _ } |
| 10883 |
{ \msg_error:nnn { cooking-units } { missing-slash } {#1} } |
| 10884 |
{ \@@_cuam_old_parse_scale:n {#1} } |
| 10885 |
} |
| 10886 |
} |
| 10887 |
} |
| 10888 |
\cs_generate_variant:Nn \@@_cuam_old_parse:n { V } |
| 10889 |
% \end{macrocode} |
| 10890 |
% |
| 10891 |
% \begin{macrocode} |
| 10892 |
\cs_new:Npn \@@_cuam_old_parse_range:n #1 |
| 10893 |
{ |
| 10894 |
\@@_cuam_old_parse_range_aux:ww #1 \q_nil |
| 10895 |
} |
| 10896 |
\cs_generate_variant:Nn \@@_cuam_old_parse_range:n { V } |
| 10897 |
\cs_new:Npn \@@_cuam_old_parse_range_aux:ww #1 \q_@@_range #2 \q_nil |
| 10898 |
{ |
| 10899 |
#1 \l_@@_cunum_range_sign_tl #2 |
| 10900 |
} |
| 10901 |
% \end{macrocode} |
| 10902 |
% |
| 10903 |
% |
| 10904 |
% \begin{macrocode} |
| 10905 |
\cs_new:Npn \@@_cuam_old_parse_scale:n #1 {#1} |
| 10906 |
% \end{macrocode} |
| 10907 |
% |
| 10908 |
% \begin{macrocode} |
| 10909 |
\cs_new:Npn \@@_cuam_old_parse_frac:ww #1/#2 \q_stop |
| 10910 |
{ \@@_frac:nn {#1} {#2} } |
| 10911 |
% \end{macrocode} |
| 10912 |
% |
| 10913 |
% \begin{macrocode} |
| 10914 |
\cs_new:Npn \@@_cuam_old_parse_mixed_frac:www #1_#2/#3 \q_stop |
| 10915 |
{ |
| 10916 |
#1 |
| 10917 |
\skip_horizontal:N \l_@@_mixed_frac_dim |
| 10918 |
\@@_frac:nn {#2} {#3} |
| 10919 |
} |
| 10920 |
% \end{macrocode} |
| 10921 |
% |
| 10922 |
% |
| 10923 |
% \subsubsection {cufrac} |
| 10924 |
% |
| 10925 |
% Obsolete. |
| 10926 |
% \begin{macrocode} |
| 10927 |
\NewDocumentCommand \cufrac { O{} m } |
| 10928 |
{ |
| 10929 |
\msg_error:nnnn { cooking-units } { obsolete-command } { \cufrac } { \cuam } |
| 10930 |
\group_begin: |
| 10931 |
\tl_if_empty:nF {#1} |
| 10932 |
{ \keys_set:nn { cooking-units } {#1} } |
| 10933 |
\@@_cufrac:n {#2} |
| 10934 |
\group_end: |
| 10935 |
} |
| 10936 |
\cs_new:Npn \@@_cufrac:n #1 |
| 10937 |
{ |
| 10938 |
\tl_set_rescan:Nnn \l_@@_tmpa_tl |
| 10939 |
{ |
| 10940 |
\char_set_catcode_letter:N \_ % |
| 10941 |
\char_set_catcode_ignore:N\ % |
| 10942 |
} {#1} |
| 10943 |
\@@_cufrac_parse:V \l_@@_tmpa_tl |
| 10944 |
} |
| 10945 |
\cs_new:Npn \@@_cufrac_parse:n #1 |
| 10946 |
{ |
| 10947 |
\tl_if_in:nnTF {#1} { / } |
| 10948 |
{ |
| 10949 |
\tl_if_in:nnTF {#1} { _ } |
| 10950 |
{ \@@_cufrac_parse_mixed_frac:www #1 \q_stop } |
| 10951 |
{ \@@_cufrac_parse_frac:ww #1 \q_stop } |
| 10952 |
}{ |
| 10953 |
\tl_if_in:nnTF {#1} { _ } |
| 10954 |
{ \msg_error:nnn { cooking-units } { missing-slash } {#1} } |
| 10955 |
{ \@@_cufrac_parse_scale:n {#1} } |
| 10956 |
} |
| 10957 |
} |
| 10958 |
\cs_generate_variant:Nn \@@_cufrac_parse:n { V } |
| 10959 |
\cs_new:Npn \@@_cufrac_parse_scale:n #1 {#1} |
| 10960 |
\cs_new:Npn \@@_cufrac_parse_frac:ww #1/#2 \q_stop |
| 10961 |
{ \@@_frac:nn {#1} {#2} } |
| 10962 |
\cs_new:Npn \@@_cufrac_parse_mixed_frac:www #1_#2/#3 \q_stop |
| 10963 |
{ |
| 10964 |
#1 |
| 10965 |
\skip_horizontal:N \l_@@_mixed_frac_dim |
| 10966 |
\@@_frac:nn {#2} {#3} |
| 10967 |
} |
| 10968 |
% \end{macrocode} |
| 10969 |
% |
| 10970 |
% |
| 10971 |
% |
| 10972 |
% |
| 10973 |
% |
| 10974 |
% |
| 10975 |
% |
| 10976 |
% \subsection {cusetup} |
| 10977 |
% |
| 10978 |
% \begin{macrocode} |
| 10979 |
\NewDocumentCommand \cusetup { m } |
| 10980 |
{ |
| 10981 |
\keys_set:nn { cooking-units } {#1} |
| 10982 |
} |
| 10983 |
% \end{macrocode} |
| 10984 |
% |
| 10985 |
% |
| 10986 |
% |
| 10987 |
% \subsection{Definitions et all} |
| 10988 |
% |
| 10989 |
% Plase note that at his point we are still inside the Expl3 \enquote{Environment} |
| 10990 |
% and that spaces are ignored! |
| 10991 |
% |
| 10992 |
% \begin{macrocode} |
| 10993 |
\newcookingunit { kg } |
| 10994 |
\newcookingunit { dag } |
| 10995 |
\newcookingunit { g } |
| 10996 |
\newcookingunit { oz } |
| 10997 |
\newcookingunit { lb } |
| 10998 |
\newcookingunit { stick } |
| 10999 |
\newcookingunit [ |
| 11000 |
symbol={\ensuremath{ \@@_frac:nn { eV } { c^2 } } } , |
| 11001 |
natural-unit |
| 11002 |
] { eVc-2 } |
| 11003 |
% \end{macrocode} |
| 11004 |
% |
| 11005 |
% \begin{macrocode} |
| 11006 |
\newcookingunit { K } |
| 11007 |
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace C ] { C } |
| 11008 |
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace F ] { F } |
| 11009 |
\newcookingunit [ \ensuremath{ {} ^ { \circ } } \kern-\scriptspace R\'{e} ] { Re } |
| 11010 |
% \end{macrocode} |
| 11011 |
% |
| 11012 |
% \begin{macrocode} |
| 11013 |
\newcookingunit { d } |
| 11014 |
\newcookingunit { h } |
| 11015 |
\newcookingunit { min } |
| 11016 |
\newcookingunit { s } |
| 11017 |
\newcookingunit [ |
| 11018 |
symbol={\ensuremath{ \@@_frac:nn { \hbar } { eV } } }, |
| 11019 |
natural-unit |
| 11020 |
] { hbareV-1 } |
| 11021 |
% \end{macrocode} |
| 11022 |
% |
| 11023 |
% \begin{macrocode} |
| 11024 |
\newcookingunit { m } |
| 11025 |
\newcookingunit { cm } |
| 11026 |
\newcookingunit { dm } |
| 11027 |
\newcookingunit { mm } |
| 11028 |
\newcookingunit { in } |
| 11029 |
\newcookingunit [ |
| 11030 |
symbol={ \ensuremath{ \@@_frac:nn { c\hbar } { eV } } } , natural-unit |
| 11031 |
] { chbareV-1 } |
| 11032 |
% \end{macrocode} |
| 11033 |
% |
| 11034 |
% \begin{macrocode} |
| 11035 |
\newcookingunit { l } |
| 11036 |
\newcookingunit { dl } |
| 11037 |
\newcookingunit { cl } |
| 11038 |
\newcookingunit { ml } |
| 11039 |
\newcookingunit [ |
| 11040 |
symbol={ \ensuremath { \@@_frac:nn { c^3 \hbar^3 } { eV^3 } } }, natural-unit |
| 11041 |
] { (chbareV-1)3 } |
| 11042 |
% \end{macrocode} |
| 11043 |
% |
| 11044 |
% \begin{macrocode} |
| 11045 |
\newcookingunit { cal } |
| 11046 |
\newcookingunit { kcal } |
| 11047 |
\newcookingunit { J } |
| 11048 |
\newcookingunit { kJ } |
| 11049 |
\newcookingunit [ natural-unit ] { eV } |
| 11050 |
% \end{macrocode} |
| 11051 |
% |
| 11052 |
% \begin{macrocode} |
| 11053 |
\newcookingunit [ pinch ] { pn } |
| 11054 |
\newcookingunit { EL } |
| 11055 |
\newcookingunit { TL } |
| 11056 |
\newcookingunit [ ssp. ] { ssp } %% saltspoonful |
| 11057 |
\newcookingunit [ csp. ] { csp } %% coffeespoonful |
| 11058 |
\newcookingunit [ dsp. ] { dsp } |
| 11059 |
\newcookingunit [ Msp. ] { Msp } |
| 11060 |
% \end{macrocode} |
| 11061 |
% |
| 11062 |
% \begin{macrocode} |
| 11063 |
\DeclareLanguageAlias { AmericanEnglish } { American } |
| 11064 |
% \end{macrocode} |
| 11065 |
% |
| 11066 |
% \begin{macrocode} |
| 11067 |
\cudefinename { German } |
| 11068 |
{ |
| 11069 |
{ kg } { Kilogramm } < n > |
| 11070 |
{ dag } { Dekagramm } < n > |
| 11071 |
{ g } { Gramm } < n > |
| 11072 |
{ oz } { Unze } < f > |
| 11073 |
{ lb } { Pfund } < n > |
| 11074 |
% \end{macrocode} |
| 11075 |
% \begin{macrocode} |
| 11076 |
{ d } { Tag } [ Tage ] |
| 11077 |
{ h } { Stunde } [ Stunden ] < f > |
| 11078 |
{ min } { Minute } [ Minuten ] < f > |
| 11079 |
{ s } { Sekunde } [ Sekunden ] < f > |
| 11080 |
% \end{macrocode} |
| 11081 |
% \begin{macrocode} |
| 11082 |
{ C } { Grad \space Celsius } |
| 11083 |
{ K } { Kelvin } < n > |
| 11084 |
{ F } { Grad \space Fahrenheit } |
| 11085 |
{ Re } { Grad \space R\'{e}amur } |
| 11086 |
% \end{macrocode} |
| 11087 |
% \begin{macrocode} |
| 11088 |
{ m } { Meter } < n > |
| 11089 |
{ dm } { Dezimeter } < n > |
| 11090 |
{ cm } { Centimeter } < n > |
| 11091 |
{ mm } { Millimeter } < n > |
| 11092 |
{ in } { Zoll } |
| 11093 |
% \end{macrocode} |
| 11094 |
% \begin{macrocode} |
| 11095 |
{ l } [ l ] { Liter } |
| 11096 |
{ dl } { Deziliter } |
| 11097 |
{ cl } { Centiliter } |
| 11098 |
{ ml } { Milliliter } |
| 11099 |
% \end{macrocode} |
| 11100 |
% \begin{macrocode} |
| 11101 |
{ cal } { Kalorie } [ Kalorien ] < f > |
| 11102 |
{ kcal } { Kilokalorie } [ Kilokalorien ] < f > |
| 11103 |
{ J } { Joule } |
| 11104 |
{ kJ } { Kilojoule } |
| 11105 |
{ eV } { Elektronenvolt } < n > |
| 11106 |
% \end{macrocode} |
| 11107 |
% \begin{macrocode} |
| 11108 |
{ Msp } [ Msp. ] { Messerspitze } [ Messerspitzen ] < f > |
| 11109 |
{ pn } [ Prise ] { Prise } [ Prisen ] < f > |
| 11110 |
{ EL } [ EL ] { Essl{\"o}ffel } |
| 11111 |
{ TL } [ TL ] { Teel{\"o}ffel } |
| 11112 |
{ csp } [ KL ] { Mokkal{\"o}ffel } |
| 11113 |
% \end{macrocode} |
| 11114 |
% \begin{macrocode} |
| 11115 |
{ decimal-mark } { , } |
| 11116 |
{ one (m) } { ein } |
| 11117 |
{ one (f) } { eine } |
| 11118 |
{ one (n) } { ein } |
| 11119 |
} |
| 11120 |
% \end{macrocode} |
| 11121 |
% |
| 11122 |
% |
| 11123 |
% \begin{macrocode} |
| 11124 |
\cudefinename { English } |
| 11125 |
{ |
| 11126 |
{ kg } { kilogramme } |
| 11127 |
{ dag } { decagramme } |
| 11128 |
{ g } { gramme } |
| 11129 |
{ oz } { ounce } |
| 11130 |
{ lb } { pound } [ pounds ] |
| 11131 |
{ stick } { stick } [ sticks ] |
| 11132 |
% \end{macrocode} |
| 11133 |
% \begin{macrocode} |
| 11134 |
{ d } { day } [ days ] |
| 11135 |
{ h } { hour } [ hours ] |
| 11136 |
{ min } { minute } [ minutes ] |
| 11137 |
{ s } { second } [ seconds ] |
| 11138 |
% \end{macrocode} |
| 11139 |
% \begin{macrocode} |
| 11140 |
{ C } { degree \space Celsius } [ degrees \space Celsius ] |
| 11141 |
{ F } { degree \space Fahrenheit } [ degrees \space Fahrenheit ] |
| 11142 |
{ K } { kelvin } |
| 11143 |
{ Re } { degree \space R\'{e}aumur } [ degrees \space R\'{e}aumur ] |
| 11144 |
% \end{macrocode} |
| 11145 |
% \begin{macrocode} |
| 11146 |
{ m } { metre } [ metres ] |
| 11147 |
{ dm } { decimetre } [ decimetres ] |
| 11148 |
{ cm } { centimetre } [ centimetres ] |
| 11149 |
{ mm } { millimitre } [ millimitres ] |
| 11150 |
{ in } { inch } [ inches ] |
| 11151 |
% \end{macrocode} |
| 11152 |
% \begin{macrocode} |
| 11153 |
{ l } [ \ensuremath { \ell } ] { litre } [ litres ] |
| 11154 |
{ dl } { decilitre } [ decilitres ] |
| 11155 |
{ cl } { centilitre } [ centilitres ] |
| 11156 |
{ ml } { millilitre } [ millilitres ] |
| 11157 |
% \end{macrocode} |
| 11158 |
% \begin{macrocode} |
| 11159 |
{ cal } { calorie } [ calories ] |
| 11160 |
{ kcal } { kilocalorie } [ kilocalories ] |
| 11161 |
{ J } { joule } [ joules ] |
| 11162 |
{ kJ } { kilojoule } [ kilojoules ] |
| 11163 |
{ eV } { electron \space volt } |
| 11164 |
% \end{macrocode} |
| 11165 |
% \begin{macrocode} |
| 11166 |
% { Msp } [ pinch ] { pinch } [ pinches ] |
| 11167 |
% { Msp } { Messerspitze } [ Messerspitzen ] <f> |
| 11168 |
{ pn } [ pinch ] { pinch } [ pinches ] |
| 11169 |
{ EL } [ tbsp. ] { tablespoon } [ tablespoons ] |
| 11170 |
{ TL } [ tsp. ] { teaspoon } [ teaspoons ] |
| 11171 |
{ dsp } { dessertspoonful } |
| 11172 |
{ csp } { coffeespoonful } |
| 11173 |
{ ssp } { saltspoonful } |
| 11174 |
% \end{macrocode} |
| 11175 |
% \begin{macrocode} |
| 11176 |
{ decimal-mark } { . } |
| 11177 |
{ one (m) } { one } |
| 11178 |
{ one (f) } { one } |
| 11179 |
{ one (n) } { one } |
| 11180 |
} |
| 11181 |
% \end{macrocode} |
| 11182 |
% |
| 11183 |
% \begin{macrocode} |
| 11184 |
\cudefinename { AmericanEnglish } |
| 11185 |
{ |
| 11186 |
{ kg } { kilogram } |
| 11187 |
{ dag } { decagram } |
| 11188 |
{ g } { gram } |
| 11189 |
{ oz } { ounce } |
| 11190 |
% \end{macrocode} |
| 11191 |
% \begin{macrocode} |
| 11192 |
{ m } { meter } [ meters ] |
| 11193 |
{ dm } { decimeter } [ decimeters ] |
| 11194 |
{ cm } { centimeter } [ centimeters ] |
| 11195 |
{ mm } { millimiter } [ millimiters ] |
| 11196 |
{ in } { inch } [ inches ] |
| 11197 |
% \end{macrocode} |
| 11198 |
% \begin{macrocode} |
| 11199 |
{ l } [ \ensuremath { \ell } ] { liter } [ liters ] |
| 11200 |
{ dl } { deciliter } [ deciliters ] |
| 11201 |
{ cl } { centiliter } [ centiliters ] |
| 11202 |
{ ml } { milliliter } [ milliliters ] |
| 11203 |
% \end{macrocode} |
| 11204 |
% \begin{macrocode} |
| 11205 |
% { Msp } { Messerspitze } [ Messerspitzen ] <f> |
| 11206 |
{ pn } [ pn. ] { pinch } [ pinches ] |
| 11207 |
} |
| 11208 |
% \end{macrocode} |
| 11209 |
% |
| 11210 |
% |
| 11211 |
% \begin{macrocode} |
| 11212 |
\cudefinename { French } |
| 11213 |
{ |
| 11214 |
{ kg } { kilogramme } [ kilogrammes ] |
| 11215 |
{ dag } { d\'{e}cagramme } [ d\'{e}cagrammes] |
| 11216 |
{ g } { gramme } [ grammes ] |
| 11217 |
{ oz } { once } [ onces ] < f > |
| 11218 |
{ lb } { livre } [ livres ] < f > |
| 11219 |
% \end{macrocode} |
| 11220 |
% \begin{macrocode} |
| 11221 |
{ d } { jour } [ jours ] |
| 11222 |
{ h } { heure } [ heures ] < f > |
| 11223 |
{ min } { minute } [ minutes ] < f > |
| 11224 |
{ s } { seconde } [ secondes ] < f > |
| 11225 |
% \end{macrocode} |
| 11226 |
% \begin{macrocode} |
| 11227 |
{ C } { degr\'{e} \space Celsius } [ degr\'{e}s \space Celsius ] |
| 11228 |
{ K } { degr\'{e} \space Fahrenheit } [ degr\'{e}s \space Fahrenheit ] |
| 11229 |
{ F } { kelvin } [ kelvins ] |
| 11230 |
{ Re } { \'{e}chelle \space R\'{e}aumur } [ degr\'{e}s \space R\'{e}aumur ] |
| 11231 |
% \end{macrocode} |
| 11232 |
% \begin{macrocode} |
| 11233 |
{ m } { m\`{e}tre } [ m\`{e}tres ] |
| 11234 |
{ dm } { d\'{e}cim\`{e}tre } [ d\'{e}cim\`{e}tres ] |
| 11235 |
{ cm } { centim\`{e}tre } [ centim\`{e}tres ] |
| 11236 |
{ mm } { millim\`{e}tre } [ millim\`{e}tres ] |
| 11237 |
{ in } [ po ] { pouce } [ pouces ] |
| 11238 |
% \end{macrocode} |
| 11239 |
% \begin{macrocode} |
| 11240 |
{ l } [ L ] { litre } [ litres ] |
| 11241 |
{ dl } [ dL ] { d\'{e}cilitre } [ d\'{e}cilitres ] |
| 11242 |
{ cl } [ cL ] { centilitre } [ centilitres ] |
| 11243 |
{ ml } [ mL ] { millilitre } [ millilitres ] |
| 11244 |
% \end{macrocode} |
| 11245 |
% \begin{macrocode} |
| 11246 |
{ cal } { calorie } [ calories ] < f > |
| 11247 |
{ kcal } { kilocalorie } [ kilocalories ] < f > |
| 11248 |
{ J } { joule } [ joules ] |
| 11249 |
{ kJ } { kilojoule } [ kilojoules ] |
| 11250 |
{ eV } { \'{e}lectron-volt } [ \'{e}lectron-volts ] |
| 11251 |
% \end{macrocode} |
| 11252 |
% \begin{macrocode} |
| 11253 |
{ pn } [ pinc\'{e}e ] { pinc\'{e}e } [ pinc\'{e}es ] < f > |
| 11254 |
{ EL } [c.\`{a}.s.] { cuill\`{e}re \space \`{a} \space soupe } [ cuill\`{e}res \space \`{a} \space soupe ] < f > |
| 11255 |
{ TL } [c.\`{a}.c.] { cuill\`{e}re \space \`{a} \space caf\'{e} } [ cuill\`{e}res \space \`{a} \space caf\'{e} ] < f > |
| 11256 |
% \end{macrocode} |
| 11257 |
% \begin{macrocode} |
| 11258 |
{ decimal-mark } { , } |
| 11259 |
{ one (m) } { un } |
| 11260 |
{ one (f) } { une } |
| 11261 |
{ one (n) } { un } |
| 11262 |
} |
| 11263 |
% \end{macrocode} |
| 11264 |
% |
| 11265 |
% |
| 11266 |
% |
| 11267 |
% \begin{macrocode} |
| 11268 |
\cudefinekeychain |
| 11269 |
{ |
| 11270 |
{ kg } { 1 } |
| 11271 |
{ dag }{ 100 } |
| 11272 |
{ g } { 1000 } |
| 11273 |
{ lb } { 1/0.45359237 } |
| 11274 |
{ oz } { 16/0.45359237 } |
| 11275 |
{ stick } { 4/0.45359237 } |
| 11276 |
{ eVc-2 } { 560958865.0e+27 } %% (560958865.0 +- 3.5) e+27 |
| 11277 |
} |
| 11278 |
%\cudefinekeys { kg } |
| 11279 |
% { |
| 11280 |
% { dag }{ 100 } |
| 11281 |
% { g } { 1000 } |
| 11282 |
% { lb } { 1/0.45359237 } |
| 11283 |
% { oz } { 16/0.45359237 } |
| 11284 |
% { stick } { 4/0.45359237 } |
| 11285 |
% { eVc-2 } { 560958865.0e+27 } %% (560958865.0 +- 3.5) e+27 |
| 11286 |
% } |
| 11287 |
% \end{macrocode} |
| 11288 |
% \begin{macrocode} |
| 11289 |
\cudefinekeys { d } |
| 11290 |
{ |
| 11291 |
{ h } { 24 } |
| 11292 |
{ min }{ 1440 } |
| 11293 |
{ s } { 86400 } |
| 11294 |
{ hbareV-1 } { 151926746.1e+7 * 86400 } %% (151926746.1 +- 2.1) e+7 |
| 11295 |
} |
| 11296 |
%\cuaddtokeys { s } { hbareV-1 } { 6.582119514e-16 } |
| 11297 |
% \end{macrocode} |
| 11298 |
% \begin{macrocode} |
| 11299 |
\cudefinekeys { m } |
| 11300 |
{ |
| 11301 |
{ dm } { 10 } |
| 11302 |
{ cm } { 100 } |
| 11303 |
{ mm } { 1000 } |
| 11304 |
{ in } { 36/0.9144 } |
| 11305 |
{ chbareV-1 } { 5067730.759 } %% 5067730.759 +- 0.070 |
| 11306 |
} |
| 11307 |
%\cuaddtokeys { m } { chbareV-1 } { 1.97326972e-7 } |
| 11308 |
% \end{macrocode} |
| 11309 |
% \begin{macrocode} |
| 11310 |
\cudefinekeys { l } |
| 11311 |
{ |
| 11312 |
{ dl } { 10 } |
| 11313 |
{ cl } { 100 } |
| 11314 |
{ ml }{ 1000 } |
| 11315 |
{ (chbareV-1)3 } { 130148929.5e+12 * 1e-3 } %% (130148929.5 +- 5.4 e+12)*1e-3 |
| 11316 |
} |
| 11317 |
% \end{macrocode} |
| 11318 |
% \begin{macrocode} |
| 11319 |
\cudefinekeys { J } |
| 11320 |
{ |
| 11321 |
{ kJ }{ 1e-3 } |
| 11322 |
{ cal }{ 0.2388459 } |
| 11323 |
{ kcal }{ 0.2388459e-3 } |
| 11324 |
{ eV }{ 624150912.6e+10 } %% (624150912.6 +- 3.9) e+10 |
| 11325 |
} |
| 11326 |
%\cuaddtokeys { J } { eV } { 1.6021766208e-19 } |
| 11327 |
% \end{macrocode} |
| 11328 |
% \begin{macrocode} |
| 11329 |
\fp_const:Nn \c_@@_kb_eV_fp { 8.617 330 3 e-5 } |
| 11330 |
\cudefinesinglekey { C } |
| 11331 |
{ |
| 11332 |
{ K } { #1 + 273.15 } |
| 11333 |
{ F } { #1 * 1.8 + 32 } |
| 11334 |
{ Re } { #1 * 0.8 } |
| 11335 |
{ eV } { ( #1 + 273.15 ) * \c_@@_kb_eV_fp } |
| 11336 |
} |
| 11337 |
\cudefinesinglekey { F } |
| 11338 |
{ |
| 11339 |
{ C } { ( #1 - 32 ) * 5/9 } |
| 11340 |
{ K } { ( #1 + 459.67 ) * 5/9 } |
| 11341 |
{ Re } { ( #1 - 32 ) * 4/9 } |
| 11342 |
{ eV } {( #1 + 459.67 ) * 5/9 * \c_@@_kb_eV_fp } |
| 11343 |
} |
| 11344 |
\cudefinesinglekey { K } |
| 11345 |
{ |
| 11346 |
{ C } { #1 - 273.15 } |
| 11347 |
{ F } { #1 * 1.8 - 459.67 } |
| 11348 |
{ Re } { ( #1 - 273.15 ) * 0.8 } |
| 11349 |
{ eV } { #1 * \c_@@_kb_eV_fp } |
| 11350 |
} |
| 11351 |
\cudefinesinglekey { Re } |
| 11352 |
{ |
| 11353 |
{ K } { #1 * 1.25 + 273.15 } |
| 11354 |
{ C } { #1 * 1.25 } |
| 11355 |
{ F } { #1 * 2.25 + 32 } |
| 11356 |
{ eV } { ( #1 * 1.25 + 273.15 ) * \c_@@_kb_eV_fp } |
| 11357 |
} |
| 11358 |
% \end{macrocode} |
| 11359 |
% |
| 11360 |
% |
| 11361 |
% \begin{macrocode} |
| 11362 |
\cudefinephrase { German } |
| 11363 |
{ |
| 11364 |
% { 6 } * { halbes \ Dutzend } < n > |
| 11365 |
% { 6 } { halbe \ Dutzend } < n > |
| 11366 |
{ 12 } { Dutzend } < n > |
| 11367 |
% { 60 } { Schock } < n > |
| 11368 |
% { 1728 } { Gro{\ss}gros } < n > |
| 11369 |
% { 144 } { Gros } < n > |
| 11370 |
} |
| 11371 |
% \end{macrocode} |
| 11372 |
% |
| 11373 |
% |
| 11374 |
% \subsection{Finish} |
| 11375 |
% |
| 11376 |
% \begin{macrocode} |
| 11377 |
\cudeclareunitgroup { weight } { kg , dag, g, oz, lb, stick } |
| 11378 |
\cudeclareunitgroup { length } { m , dm , cm , mm , in } |
| 11379 |
\cudeclareunitgroup { volume } { l , dl , cl , ml } |
| 11380 |
\cudeclareunitgroup { temperature } { C , F , K , Re } |
| 11381 |
\cudeclareunitgroup { energy } { cal, kcal , J , kJ , eV } |
| 11382 |
\cudeclareunitgroup { time } { d , h , min , s } |
| 11383 |
\cusetoptionfor { F , C , K , Re } { round-precision = 0 } |
| 11384 |
\cusetup |
| 11385 |
{ |
| 11386 |
curef-add-forbidden-unit = { F , C , K , Re } , |
| 11387 |
add-temperature-to-check = |
| 11388 |
{ |
| 11389 |
K = 0, |
| 11390 |
C = -273.15 , |
| 11391 |
F = -459.67 , |
| 11392 |
Re = -218.52 |
| 11393 |
} , |
| 11394 |
round-precision = 2 , |
| 11395 |
} |
| 11396 |
%\AtBeginDocument{ |
| 11397 |
%\keys_define:nn { cooking-units } |
| 11398 |
% { |
| 11399 |
% unknown .code:n = { \tl_show:N {\l_keys_key_str} } |
| 11400 |
% } |
| 11401 |
% \keys_set:nn { cooking-units } {#2} |
| 11402 |
% |
| 11403 |
%} |
| 11404 |
% \end{macrocode} |
| 11405 |
% |
| 11406 |
% |
| 11407 |
% |
| 11408 |
% |
| 11409 |
% |
| 11410 |
% |
| 11411 |
% |
| 11412 |
% |
| 11413 |
% |
| 11414 |
% |
| 11415 |
% \begin{macrocode} |
| 11416 |
%</package> |
| 11417 |
% \end{macrocode} |
| 11418 |
% |
| 11419 |
% \end{implementation} |
| 11420 |
% |
| 11421 |
% |
| 11422 |
% |
| 11423 |
% \begin{thebibliography}{} |
| 11424 |
% \bibitem{Gattopardo} |
| 11425 |
% Guiseppe Tomasi di Lampedusa, \emph{Der Gattopardo}, |
| 11426 |
% Piper, Volume~8 (2018), ISBN~978-3-492-24586-9 |
| 11427 |
% |
| 11428 |
% \bibitem{Sh:3} |
| 11429 |
% Sir Arthur Conan Doyle, \emph{Sherlock Holmes The Complete Novels and Stories Volume~II}, |
| 11430 |
% Bantam Books |
| 11431 |
% |
| 11432 |
% \bibitem{Nist2008} \emph{Guide for the Use of the International System of Units (SI)}, |
| 11433 |
% NIST Special Publication 811, 2008 Edition, Ambler Thompson and Barry N. Taylor |
| 11434 |
% |
| 11435 |
% \bibitem{Nist2006} \emph{The International System of Units (SI) – Conversion Factors |
| 11436 |
% for General Use}, NIST Special Publication 1038, May 2006, |
| 11437 |
% Kenneth Butcher, Linda Crown and Elizabeth J. Gentry |
| 11438 |
% |
| 11439 |
% \bibitem{WM1985} \emph{Weights and Measures Act 1985}, |
| 11440 |
% \url{https://www.legislation.gov.uk/ukpga/1985/72} |
| 11441 |
% |
| 11442 |
% \bibitem{StickSource} \url{https://cooking.stackexchange.com/questions/784/translating-cooking-terms-between-us-uk-au-ca-nz} |
| 11443 |
% |
| 11444 |
% \bibitem{Plural-French-Academia} |
| 11445 |
% Dictionnaire de l’Académie française. |
| 11446 |
% \url{https://www.dictionnaire-academie.fr/article/A9P2979} |
| 11447 |
% [Last checked: 2022-05-29] |
| 11448 |
% |
| 11449 |
% \bibitem{Plural-French-absolute-1} |
| 11450 |
% \url{https://www.antidote.info/fr/blogue/enquetes/15-gramme-ou-15-grammes} |
| 11451 |
% [Last checked: 2022-05-29] |
| 11452 |
% |
| 11453 |
% \bibitem{Plural-French-absolute-2} |
| 11454 |
% \url{https://french.stackexchange.com/q/1975} |
| 11455 |
% [Last checked: 2022-05-29] |
| 11456 |
% |
| 11457 |
% |
| 11458 |
% \end{thebibliography} |
| 11459 |
% |
| 11460 |
% |
| 11461 |
% |
| 11462 |
% \endinput |
| 11463 |
% |
| 11464 |
% |
| 11465 |
% |
| 11466 |
% |
| 11467 |
% Local Variables: |
| 11468 |
% mode: doctex |
| 11469 |
% TeX-master: t |
| 11470 |
% End: |