|
15 | 15 |
|
16 | 16 | \NeedsTeXFormat{LaTeX2e} |
17 | 17 |
|
18 | | -\RequirePackage{xparse}[2018/05/09] |
19 | | -\ProvidesExplPackage{derivative}{2021/05/28}{1.01}{Nice and easy derivatives and differentials for LaTeX} |
| 18 | +\RequirePackage{expl3,xparse}[2018/05/09] |
| 19 | +\RequirePackage{l3keys2e} |
| 20 | +\ProvidesExplPackage{derivative}{2021/06/03}{1.1}{Nice and easy derivatives and differentials for LaTeX} |
| 21 | + |
| 22 | +\bool_new:N \l__deriv_pkg_italic_bool |
| 23 | +\bool_new:N \l__deriv_pkg_upright_bool |
| 24 | + |
| 25 | +\keys_define:nn { deriv/pkg } |
| 26 | +{ |
| 27 | + italic .choice:, |
| 28 | + italic .default:n = { true }, |
| 29 | + italic / true .code:n = |
| 30 | + { |
| 31 | + \bool_set_true:N \l__deriv_pkg_italic_bool |
| 32 | + \bool_set_false:N \l__deriv_pkg_upright_bool |
| 33 | + }, |
| 34 | + italic / false .code:n = |
| 35 | + { |
| 36 | + \bool_set_false:N \l__deriv_pkg_italic_bool |
| 37 | + \bool_set_true:N \l__deriv_pkg_upright_bool |
| 38 | + }, |
| 39 | + italic / unknown .code:n = |
| 40 | + { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str }, |
| 41 | + |
| 42 | + upright .choice:, |
| 43 | + upright .default:n = { true }, |
| 44 | + upright / true .code:n = |
| 45 | + { |
| 46 | + \bool_set_true:N \l__deriv_pkg_upright_bool |
| 47 | + \bool_set_false:N \l__deriv_pkg_italic_bool |
| 48 | + }, |
| 49 | + upright / false .code:n = |
| 50 | + { |
| 51 | + \bool_set_false:N \l__deriv_pkg_upright_bool |
| 52 | + \bool_set_true:N \l__deriv_pkg_italic_bool |
| 53 | + }, |
| 54 | + upright / unknown .code:n = |
| 55 | + { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str }, |
| 56 | + upright .initial:n = true, |
| 57 | +} |
| 58 | + |
| 59 | +\ProcessKeysPackageOptions{ deriv/pkg } |
20 | 60 |
|
21 | 61 | %%%%% Useful conditionals %%%%% |
22 | 62 |
|
| 63 | +\prg_new_conditional:Npnn \__deriv_if_pkg:n #1 { p, TF } |
| 64 | +{ |
| 65 | + \@ifpackageloaded{unicode-math} |
| 66 | + { \prg_return_true: } |
| 67 | + { \prg_return_false: } |
| 68 | +} |
| 69 | + |
23 | 70 | \prg_new_conditional:Npnn \__deriv_if_novalue:n #1 { T , F , TF } |
24 | 71 | { |
25 | 72 | \tl_if_novalue:nTF {#1} |
|
86 | 133 | \seq_new:N \l__deriv_tmp_keys_seq |
87 | 134 | \tl_new:N \l__deriv_tmp_keys_tl |
88 | 135 |
|
89 | | -%%%%% Variables: infinisimal %%%%% |
| 136 | +%%%%% Variables: differential %%%%% |
90 | 137 |
|
91 | 138 | \seq_new:N \l__deriv_i_var_seq |
92 | 139 | \seq_new:N \l__deriv_i_orders_seq |
|
213 | 260 |
|
214 | 261 | %%%%%% Key-val for all %%%%%% |
215 | 262 |
|
| 263 | +\prop_new:N \l__deriv_all_all_user_keys_prop |
216 | 264 | \prop_const_from_keyval:Nn \c__deriv_all_pkg_keys_prop |
217 | 265 | { scale-auto = leftright } |
218 | 266 |
|
|
228 | 276 | { |
229 | 277 | \cs_set_nopar:Npn \__deriv_auto_left:n { \mleft } |
230 | 278 | \cs_set_nopar:Npn \__deriv_auto_right:n { \mright } |
231 | | - }, |
232 | | - scale-auto .default:n = { leftright } |
| 279 | + } |
233 | 280 | } |
234 | 281 |
|
235 | 282 | %%%%%% Key-val: derivatives %%%%%% |
|
275 | 322 | fun .bool_set:c = { l__deriv_dv_#1_misc_fun_bool }, |
276 | 323 | frac .bool_set:c = { l__deriv_dv_#1_misc_frac_bool }, |
277 | 324 | var .clist_set:c = { l__deriv_dv_#1_misc_var_clist }, |
278 | | - %fun .default:n = {true}, |
279 | | - %frac .default:n = {true}, |
280 | 325 | var .default:n = {all}, |
281 | 326 |
|
282 | 327 | order .clist_set:c = { l__deriv_dv_#1_misc_order_clist }, |
|
1271 | 1316 | \deriv_dv_define:NVn \RenewDocumentCommand \l__deriv_cs_name_tl {#1} |
1272 | 1317 | } |
1273 | 1318 | { |
1274 | | - \msg_error:nnxx { deriv } { command-already-defined } |
| 1319 | + \msg_error:nnxx { deriv } { command-not-defined } |
1275 | 1320 | { \token_to_str:N #1 } |
1276 | 1321 | { \token_to_str:N \RenewDerivative } |
1277 | 1322 | } |
|
1415 | 1460 |
|
1416 | 1461 | \msg_new:nnnn { deriv } { command-not-defined } |
1417 | 1462 | { Command~'#1'~not~yet~defined! } |
1418 | | -{ You~have~used~#2~with~a~derivative~that~was~never~defined. } |
| 1463 | +{ You~have~used~#2~with~a~command~that~was~never~defined. } |
| 1464 | + |
| 1465 | +\msg_new:nnnn { deriv } { boolean-values-only } |
| 1466 | +{ The~key~'#1'~accepts~boolean~values~only. } |
| 1467 | +{ The~key~'#1'~only~accepts~the~values~'true'~and~'false'. } |
| 1468 | + |
| 1469 | +\msg_new:nnnn { deriv } { derivative-option-not-defined } |
| 1470 | +{ Derivative option~'#1'~not~yet~defined! } |
| 1471 | +{ You~have~used~#2~with~a~derivative~option~that~was~never~defined. } |
| 1472 | + |
| 1473 | +\msg_new:nnnn { deriv } { differential-option-not-defined } |
| 1474 | +{ Differential option~'#1'~not~yet~defined! } |
| 1475 | +{ You~have~used~#2~with~a~differential~option~that~was~never~defined. } |
1419 | 1476 |
|
1420 | 1477 | %%%%% Declaring derivatives %%%%% |
1421 | 1478 |
|
1422 | | -\derivset{all} |
1423 | | -\bool_lazy_or:nnTF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: } |
| 1479 | +\@ifpackageloaded{mleftright} |
| 1480 | +{ \derivset{all}[scale-auto = mleftmright] } |
| 1481 | +{ \derivset{all}[scale-auto = leftright] } |
| 1482 | + |
| 1483 | +\cs_new_protected:Npn \deriv_define_legacy_italic_cs: |
1424 | 1484 | { |
1425 | | - \DeclareDerivative{\odv}{\symup{d}} |
1426 | | - \DeclareDerivative{\mdv}{\symup{D}} |
1427 | | - \DeclareDerivative{\fdv}{\delta} |
1428 | | - \DeclareDerivative{\adv}{\Delta} |
1429 | | - \DeclareDerivative{\jdv}{\partial}[fun=true, var=1] |
1430 | | - \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()] |
1431 | | - |
1432 | | - \DeclareDifferential{\odif}{\symup{d}} |
1433 | | - \DeclareDifferential{\mdif}{\symup{D}}[style-notation=single, style-notation-*=mixed] |
1434 | | - \DeclareDifferential{\fdif}{\delta} |
1435 | | - \DeclareDifferential{\adif}{\Delta} |
1436 | | - \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] |
| 1485 | + \DeclareDerivative{\odv}{\mathnormal{d}} |
| 1486 | + \DeclareDerivative{\mdv}{\mathnormal{D}} |
| 1487 | + \DeclareDifferential{\odif}{\mathnormal{d}} |
| 1488 | + \DeclareDifferential{\mdif}{\mathnormal{D}}[style-notation=single, style-notation-*=mixed] |
1437 | 1489 | } |
| 1490 | + |
| 1491 | +\cs_new_protected:Npn \deriv_define_legacy_upright_cs: |
1438 | 1492 | { |
1439 | 1493 | \DeclareDerivative{\odv}{\mathrm{d}} |
1440 | 1494 | \DeclareDerivative{\mdv}{\mathrm{D}} |
1441 | | - \DeclareDerivative{\fdv}{\delta} |
1442 | | - \DeclareDerivative{\adv}{\Delta} |
1443 | | - \DeclareDerivative{\jdv}{\partial}[fun=true, var=1] |
1444 | | - \DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()] |
1445 | | - |
1446 | 1495 | \DeclareDifferential{\odif}{\mathrm{d}} |
1447 | 1496 | \DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single, style-notation-*=mixed] |
1448 | | - \DeclareDifferential{\fdif}{\delta} |
1449 | | - \DeclareDifferential{\adif}{\Delta} |
1450 | | - \DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] |
1451 | 1497 | } |
1452 | 1498 |
|
| 1499 | +\__deriv_case:n |
| 1500 | +{ |
| 1501 | + { \l__deriv_pkg_italic_bool } { \deriv_define_legacy_italic_cs: } |
| 1502 | + { \l__deriv_pkg_upright_bool } { \deriv_define_legacy_upright_cs: } |
| 1503 | +} |
| 1504 | + |
| 1505 | +\DeclareDerivative{\fdv}{\delta} |
| 1506 | +\DeclareDerivative{\adv}{\Delta} |
| 1507 | +\DeclareDerivative{\jdv}{\partial}[fun=true, var=1] |
| 1508 | +\DeclareDerivative{\pdv}{\partial}[style-var=multiple, sep-inf-ord=1, delims-eval=(), delims-eval-/=()] |
| 1509 | + |
| 1510 | +\DeclareDifferential{\fdif}{\delta} |
| 1511 | +\DeclareDifferential{\adif}{\Delta} |
| 1512 | +\DeclareDifferential{\pdif}{\partial}[style-notation=single, style-notation-*=mixed] |
| 1513 | + |
1453 | 1514 | \endinput |
1454 | 1515 |
|
0 commit comments