Skip to content

Commit f79685d

Browse files
authored
Merge pull request #15 from sjelatex/Version-1.4
Version 1.4
2 parents 390790d + 287321c commit f79685d

File tree

4 files changed

+93
-53
lines changed

4 files changed

+93
-53
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## README for derivative package v1.31 dated 2023-11-04
1+
## README for derivative package v1.4 dated 2024-02-08
22

33
The package provides a set of commands `\NewDerivative`, `\NewDifferential` etc. that can be used to define a derivative or a differential operator, respectively. The package have already defined several derivatives and differentials:
44

@@ -16,7 +16,7 @@ The package provides a set of commands `\NewDerivative`, `\NewDifferential` etc.
1616

1717
### Copyright and license
1818

19-
Copyright 2019-2023 Simon Jensen
19+
Copyright 2019-2024 Simon Jensen
2020

2121
This work may be distributed and/or modified under the
2222
conditions of the LaTeX Project Public License, either version 1.3

derivative.pdf

-2.54 KB
Binary file not shown.

derivative.sty

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
% derivative.sty
2-
% Copyright 2019-2023 Simon Jensen
2+
% Copyright 2019-2024 Simon Jensen
33
%
44
% This work may be distributed and/or modified under the
55
% conditions of the LaTeX Project Public License, either version 1.3
@@ -16,10 +16,9 @@
1616

1717
\NeedsTeXFormat{LaTeX2e}
1818

19-
\RequirePackage{expl3}[2021/11/07]
20-
\RequirePackage{xparse}[2021/11/07]
19+
\RequirePackage{expl3}[2023/12/08]
2120
\RequirePackage{l3keys2e}
22-
\ProvidesExplPackage{derivative}{2023/11/04}{1.31}{Nice and easy derivatives and differentials for LaTeX}
21+
\ProvidesExplPackage{derivative}{2024/02/08}{1.4}{Nice and easy derivatives and differentials for LaTeX}
2322

2423
\bool_new:N \l__deriv_pkg_italic_bool
2524
\bool_new:N \l__deriv_pkg_upright_bool
@@ -118,6 +117,7 @@
118117

119118
\tl_new:N \l__deriv_cs_name_tl
120119
\tl_new:N \l__deriv_derivset_tl
120+
\bool_new:N \l__deriv_first_unknown_key_bool
121121

122122
\tl_new:N \l__deriv_gcd_result_tl
123123
\tl_new:N \l__deriv_gcd_remain_tl
@@ -290,14 +290,14 @@
290290
scale-frac .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { frac } },
291291
scale-frac-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { frac_slash } },
292292

293-
delims-eval .tl_set:c = { l__deriv_dv_#1_delims_eval_tl },
294-
delims-eval-/ .tl_set:c = { l__deriv_dv_#1_delims_eval_slash_tl },
295-
delims-eval-! .tl_set:c = { l__deriv_dv_#1_delims_eval_compact_tl },
296-
delims-fun .tl_set:c = { l__deriv_dv_#1_delims_fun_tl },
297-
delims-var .tl_set:c = { l__deriv_dv_#1_delims_var_tl },
298-
delims-var-! .tl_set:c = { l__deriv_dv_#1_delims_var_compact_tl },
299-
delims-frac .tl_set:c = { l__deriv_dv_#1_delims_frac_tl },
300-
delims-frac-/ .tl_set:c = { l__deriv_dv_#1_delims_frac_slash_tl },
293+
delims-eval .tl_set:c = { l__deriv_dv_#1_delims_eval_tl },
294+
delims-eval-/ .tl_set:c = { l__deriv_dv_#1_delims_eval_slash_tl },
295+
delims-eval-! .tl_set:c = { l__deriv_dv_#1_delims_eval_compact_tl },
296+
delims-fun .tl_set:c = { l__deriv_dv_#1_delims_fun_tl },
297+
delims-var .tl_set:c = { l__deriv_dv_#1_delims_var_tl },
298+
delims-var-! .tl_set:c = { l__deriv_dv_#1_delims_var_compact_tl },
299+
delims-frac .tl_set:c = { l__deriv_dv_#1_delims_frac_tl },
300+
delims-frac-/ .tl_set:c = { l__deriv_dv_#1_delims_frac_slash_tl },
301301

302302
sep-inf-ord .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_ord_tl } {##1} },
303303
sep-inf-fun .code:n = { \__deriv_set_rubber_length:cn { l__deriv_dv_#1_sep_inf_fun_tl } {##1} },
@@ -329,12 +329,23 @@
329329
fun .bool_set:c = { l__deriv_dv_#1_misc_fun_bool },
330330
frac .bool_set:c = { l__deriv_dv_#1_misc_frac_bool },
331331
var .clist_set:c = { l__deriv_dv_#1_misc_var_clist },
332-
var .default:n = {all},
332+
var .default:n = { all },
333333

334334
order .clist_set:c = { l__deriv_dv_#1_misc_order_clist },
335335
ord .meta:n = { order={##1} },
336336
mixed-order .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl },
337337
mixord .meta:n = { mixed-order={##1} },
338+
339+
unknown .code:n =
340+
{
341+
\bool_if:NT \l__deriv_first_unknown_key_bool
342+
{
343+
\clist_clear:c { l__deriv_dv_#1_misc_order_clist }
344+
\bool_set_false:N \l__deriv_first_unknown_key_bool
345+
}
346+
\exp_args:NnnV \tl_set_rescan:Nnn \l__deriv_tmpa_tl { } \l_keys_key_str
347+
\clist_put_right:cV { l__deriv_dv_#1_misc_order_clist } \l__deriv_tmpa_tl
348+
}
338349
}
339350
}
340351

@@ -345,7 +356,7 @@
345356
{
346357
\keys_define:nn { deriv/i/#1 }
347358
{
348-
style-inf .tl_set:c = { l__deriv_i_#1_style_inf_tl },
359+
style-inf .tl_set:c = { l__deriv_i_#1_style_inf_tl },
349360
style-var .choices:nn = { single, multiple, mixed } { \__deriv_i_set_style_var:nnn {i_#1} {##1} { } },
350361
style-var-* .choices:nn = { single, multiple, mixed } { \__deriv_i_set_style_var:nnn {i_#1} {##1} { _star } },
351362

@@ -370,7 +381,18 @@
370381
var .default:n = {all},
371382

372383
order .clist_set:c = { l__deriv_i_#1_misc_order_clist },
373-
ord .clist_set:c = { l__deriv_i_#1_misc_order_clist },
384+
ord .meta:n = { order={##1} },
385+
386+
unknown .code:n =
387+
{
388+
\bool_if:NT \l__deriv_first_unknown_key_bool
389+
{
390+
\clist_clear:c { l__deriv_i_#1_misc_order_clist }
391+
\bool_set_false:N \l__deriv_first_unknown_key_bool
392+
}
393+
\exp_args:NnnV \tl_set_rescan:Nnn \l__deriv_tmpa_tl { } \l_keys_key_str
394+
\clist_put_right:cV { l__deriv_i_#1_misc_order_clist } \l__deriv_tmpa_tl
395+
}
374396
}
375397
}
376398

@@ -462,6 +484,7 @@
462484
% keyval, dv/i, variant
463485
\cs_new_protected:Npn \deriv_local_keys:nnn #1 #2 #3
464486
{
487+
\bool_set_true:N \l__deriv_first_unknown_key_bool
465488
\tl_if_novalue:nTF {#1}
466489
{
467490
\bool_if:cT { l__deriv_#2_#3_local_keys_bool }
@@ -759,7 +782,7 @@
759782

760783
% Temporary store the order argument
761784
\tl_set:Nf \l__deriv_tmpb_tl { \seq_use:Nn #2 { \__deriv_insert_mskip:nn {#4} { ord_ord } } }
762-
785+
763786
\seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpc_tl
764787
\tl_put_right:Nx #3
765788
{
@@ -769,7 +792,6 @@
769792
\__deriv_show_order:NT \l__deriv_tmpb_tl
770793
{ \__deriv_insert_ord:Nnn \l__deriv_tmpb_tl {#4} { var_ord } }
771794
}
772-
773795
\str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1
774796
{ \tl_set_eq:cN { l__deriv_#4_misc_mixed_order_tl } \l__deriv_tmpb_tl }
775797
}
@@ -1553,10 +1575,10 @@
15531575
\bool_while_do:nn { \deriv_binary_if_even_p:N #2 }
15541576
{ \deriv_binary_shift_right:N #2 }
15551577

1556-
\__deriv_gcd_swap_helper:NNff #1 #2 { \int_from_bin:V #1 } { \int_from_bin:V #2 }
1578+
\__deriv_gcd_swap_helper:NNff #1 #2 { \exp_args:NV \int_from_bin:n {#1} } { \exp_args:NV \int_from_bin:n {#2} }
15571579
}
15581580
\deriv_binary_shift_left:NV #1 \l__deriv_gcd_counter_int
1559-
\tl_set:Nx #1 { \int_from_bin:V #1 }
1581+
\tl_set:Nx #1 { \exp_args:NV \int_from_bin:n {#1} }
15601582
}
15611583
\cs_new:Npn \__deriv_gcd_swap_helper:NNnn #1 #2 #3 #4
15621584
{
@@ -1659,7 +1681,7 @@
16591681

16601682
\DeclareDocumentCommand{\slashfrac}{ o m m }
16611683
{
1662-
\group_begin:
1684+
\group_begin:
16631685
\tl_if_novalue:nTF {#1}
16641686
{ \__deriv_slashfrac_auto:nn {#2} {#3} }
16651687
{
@@ -1670,7 +1692,7 @@
16701692
}
16711693
{ \__deriv_slashfrac_scale:nnn {#1} {#2} {#3} }
16721694
}
1673-
\group_end:
1695+
\group_end:
16741696
}
16751697
% numerator, denominator
16761698
\cs_new_protected:Npn \__deriv_slashfrac_auto:nn #1 #2
@@ -1695,7 +1717,6 @@
16951717
%%%%% Generate variants %%%%%
16961718

16971719
\prg_generate_conditional_variant:Nnn \__deriv_show_order:N { c } { T, TF }
1698-
\prg_generate_conditional_variant:Nnn \tl_if_head_eq_charcode:nN { V } { T, F, TF }
16991720

17001721
\cs_generate_variant:Nn \__deriv_set_rubber_length:Nn { c }
17011722
\cs_generate_variant:Nn \deriv_dv_define:Nnn { NV }
@@ -1726,9 +1747,6 @@
17261747
\cs_generate_variant:Nn \__deriv_update_seq:NNNNn { NNNNV }
17271748
\cs_generate_variant:Nn \__deriv_addfrac:NNnnnnn { NNVVxx }
17281749

1729-
\cs_generate_variant:Nn \int_to_bin:n { V }
1730-
\cs_generate_variant:Nn \int_from_bin:n { V }
1731-
17321750
%%%%% Messages %%%%%
17331751

17341752
\msg_new:nnnn { deriv } { command-already-defined }

derivative.tex

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
% derivative.tex
2-
% Copyright 2019-2023 Simon Jensen
2+
% Copyright 2019-2024 Simon Jensen
33
%
44
% This work may be distributed and/or modified under the
55
% conditions of the LaTeX Project Public License, either version 1.3
@@ -42,23 +42,23 @@
4242
\RequirePackage[style=english,english=british]{csquotes}
4343
\RequirePackage[final,babel,auto]{microtype}
4444
\RequirePackage{xcolor}
45-
% \definecolor{RoyalGray}{RGB}{127, 144, 158}
46-
% \definecolor{RoyalDarkGray}{RGB}{78, 93, 104}
47-
% \definecolor{RoyalLightGray}{RGB}{250, 250, 250}
48-
% \definecolor{RoyalRed}{RGB}{157, 16, 45}
49-
% \definecolor{RoyalBlue}{RGB}{0, 35, 102}
50-
% \definecolor{RoyalGreen}{RGB}{32, 77, 2}
51-
52-
\definecolor{RoyalGray}{RGB}{75, 75, 75}
53-
\definecolor{RoyalDarkGray}{RGB}{225, 225, 225}
54-
\definecolor{RoyalLightGray}{RGB}{30, 30, 30}
55-
\definecolor{RoyalRed}{RGB}{255, 177, 151} % 207, 102, 121
56-
\definecolor{RoyalBlue}{RGB}{187, 134, 252} % 55, 185, 255
57-
\definecolor{RoyalGreen}{RGB}{3, 218, 198} % 52, 177, 20
58-
\definecolor{RoyalPageCoulor}{RGB}{18, 18, 18} % 30, 30, 30
59-
\definecolor{RoyalTextCoulor}{RGB}{225, 225, 225}
60-
\pagecolor{RoyalPageCoulor}
61-
\color{RoyalTextCoulor}
45+
\definecolor{RoyalGray}{RGB}{127, 144, 158}
46+
\definecolor{RoyalDarkGray}{RGB}{78, 93, 104}
47+
\definecolor{RoyalLightGray}{RGB}{250, 250, 250}
48+
\definecolor{RoyalRed}{RGB}{157, 16, 45}
49+
\definecolor{RoyalBlue}{RGB}{0, 35, 102}
50+
\definecolor{RoyalGreen}{RGB}{32, 77, 2}
51+
52+
% \definecolor{RoyalGray}{RGB}{75, 75, 75}
53+
% \definecolor{RoyalDarkGray}{RGB}{225, 225, 225}
54+
% \definecolor{RoyalLightGray}{RGB}{30, 30, 30}
55+
% \definecolor{RoyalRed}{RGB}{255, 177, 151} % 207, 102, 121
56+
% \definecolor{RoyalBlue}{RGB}{187, 134, 252} % 55, 185, 255
57+
% \definecolor{RoyalGreen}{RGB}{3, 218, 198} % 52, 177, 20
58+
% \definecolor{RoyalPageCoulor}{RGB}{18, 18, 18} % 30, 30, 30
59+
% \definecolor{RoyalTextCoulor}{RGB}{225, 225, 225}
60+
% \pagecolor{RoyalPageCoulor}
61+
% \color{RoyalTextCoulor}
6262

6363
\RequirePackage{amsmath, amsthm}
6464
\allowdisplaybreaks
@@ -1220,10 +1220,12 @@
12201220
\mydoc_narg:n {#1}
12211221
\group_end:
12221222
}
1223-
\DeclareDocumentCommand{\oarg}{ m }
1223+
\DeclareDocumentCommand{\oarg}{ s m }
12241224
{
12251225
\group_begin:
1226-
\mydoc_oarg:n {#1}
1226+
\bool_if:nTF {#1}
1227+
{ \mydoc_oarg_star:n {#2} }
1228+
{ \mydoc_oarg:n {#2} }
12271229
\group_end:
12281230
}
12291231
\DeclareDocumentCommand{\earg}{ m }
@@ -1282,6 +1284,14 @@
12821284
\mydoc_arg_delim_format:n { ] }
12831285
}
12841286

1287+
\cs_new:Npn \mydoc_oarg_star:n #1
1288+
{
1289+
\__mydoc_oarg_font:
1290+
\mydoc_arg_delim_format:n { [ }
1291+
#1
1292+
\mydoc_arg_delim_format:n { ] }
1293+
}
1294+
12851295
\cs_new:Npn \mydoc_earg:n #1
12861296
{
12871297
\seq_set_from_clist:Nn \l__deriv_earg_seq {#1}
@@ -1369,8 +1379,8 @@
13691379
\Titel{The \pakkenavn{} package}
13701380
\Forfatter{Simon Jensen}
13711381
1372-
\Dato{2023/11/04}
1373-
\Version{1.31}
1382+
\Dato{2024/02/08}
1383+
\Version{1.4}
13741384

13751385
\RequirePackage{derivative}[\dato]
13761386

@@ -1445,14 +1455,18 @@
14451455
The behavior of the star can be reversed by setting \keyval{switch-*}{true}. In other words, the equations in the previous example will be interchanged.
14461456
\end{argument}
14471457

1448-
\begin{argument}{2}[updated = v1.0]
1458+
\begin{argument}{2}[updated = v1.4]
14491459
The second argument of \macro{1}, enclosed in square brackets, is optional and used to specify options for the derivative using a \keyval[index=false]{key}{value} syntax. For instance, the order of differentiation can be set using the \key[cat=misc]{order} option. Here is an example:
14501460
\begin{example}
14511461
\pdv[order={2,3}]{f}{x,y,z} \\
14521462
\pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\
1453-
\pdv[order={2,n^2,n^2-1}]{f}{x,y,z} \\
1463+
\pdv[sep-var-inf=0]{f}{x,y,z} \\
14541464
\pdv[order={3/2-n/3,n/2,1/3}]{f}{x,y,z}
14551465
\end{example}
1466+
To ease the cumbersome order key, implicit orders can now be given:
1467+
\begin{example}
1468+
\pdv[n+2, \alpha]{f}{x,y,z}
1469+
\end{example}
14561470
For a comprehensive list of available options that can be applied to derivatives, please refer to \cref{ssec:options_dv}.
14571471
%The order may be a number, a symbol and a combination hereof. Note that the total order of differentiation (i.e $\odif[order=n+2]{}$) is automatically calculated and sorted. This is particularly useful when dealing with mixed partial derivatives which is further described in \cref{ssec:DV_pdv,ssec:overall_order}
14581472
\end{argument}
@@ -1632,14 +1646,18 @@ \subsection{Other derivatives}
16321646
The behavior of the star can be reversed by setting \keyval{switch-*}{true}. In other words, the equations in the previous example will be interchanged.
16331647
\end{argument}
16341648

1635-
\begin{argument}{2}
1649+
\begin{argument}{2}[updated = v1.4]
16361650
The second argument, enclosed in square brackets, is optional and is used to specify options for the differential using the \keyval[index=false]{key}{value} syntax. Here are some examples:
16371651
\begin{example}
16381652
\odif[order={n,3}]{x,y,z} \\
16391653
\odif[sep-var-inf=0]{x,y,z} \\
16401654
\odif*[sep-var-var=0]{x,y,z}
16411655
\end{example}
1642-
The available options for the differential can be found in \cref{ssec:options_inf}
1656+
To ease the cumbersome order key, implicit orders can now be given:
1657+
\begin{example}
1658+
\odif[n+2, \alpha]{x,y,z}
1659+
\end{example}
1660+
For a comprehensive list of available options that can be applied to differentials, please refer to \cref{ssec:options_inf}
16431661
\end{argument}
16441662

16451663
\begin{argument}{3}
@@ -3049,6 +3067,10 @@ \subsection{Slashfrac}\label{ssec:slashfrac}
30493067
\begin{change}[version=1.31, date=2023-11-04, beta=false]
30503068
\item Fixed issue relating to the order when nesting derivatives (issues \#14).
30513069
\end{change}
3070+
\bigskip
3071+
\begin{change}[version=1.4, date=2024-02-08, beta=false]
3072+
\item Introduced implicit order parameter to simplify specifying the order of differentiation, for example: \cs{pdv}\oarg*{n,2}\narg{f}\narg{x,y} (issues \#2 and \#10).
3073+
\end{change}
30523074
\end{changelog}
30533075

30543076

0 commit comments

Comments
 (0)