summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/derivative/derivative.tex
blob: f9c693535e3e5af4d7077166ac04e56589157509 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
% derivative.tex
% Copyright 2019-2024 Simon Jensen
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% 
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Simon Jensen.
% Contributors: Romain Noel

\begin{filecontents*}{macro.mst}
headings_flag 1
heading_prefix "\\begingroup \\ttfamily \\color\{RoyalBlue\}"
heading_suffix "\\endgroup \\nopagebreak\n"
item_0 "\n \\item \\begingroup \\small \\ttfamily \\upshape "
delim_0 "\\endgroup, "
group_skip "\n\n\\par\\bigskip\n"
\end{filecontents*}

\begin{filecontents*}{option.mst}
item_0 "\n \\item \\begingroup \\color\{RoyalBlue\} "
item_x1 "\\endgroup \n \\subitem \\begingroup \\small \\ttfamily \\upshape "
item_1 "\n \\subitem \\begingroup \\small \\ttfamily \\upshape "
delim_1 "\\endgroup, "
group_skip "\n\n\\par\\bigskip\n"
\end{filecontents*}

\NeedsTeXFormat{LaTeX2e}

\documentclass[final,british,10pt]{scrartcl}
	\reversemarginpar
\RequirePackage[british]{babel}
\RequirePackage{fontspec}
%\RequirePackage{polyglossia}
%	\setmainlanguage[variant=british]{english}
\RequirePackage[style=english,english=british]{csquotes}
\RequirePackage[final,babel,auto]{microtype}
\RequirePackage{xcolor}
	\definecolor{RoyalGray}{RGB}{127, 144, 158}
	\definecolor{RoyalDarkGray}{RGB}{78, 93, 104}
	\definecolor{RoyalLightGray}{RGB}{250, 250, 250}
	\definecolor{RoyalRed}{RGB}{157, 16, 45}
	\definecolor{RoyalBlue}{RGB}{0, 35, 102}
	\definecolor{RoyalGreen}{RGB}{32, 77, 2}

%	\definecolor{RoyalGray}{RGB}{75, 75, 75}
%	\definecolor{RoyalDarkGray}{RGB}{225, 225, 225}
%	\definecolor{RoyalLightGray}{RGB}{30, 30, 30}
%	\definecolor{RoyalRed}{RGB}{255, 177, 151} % 207, 102, 121
%	\definecolor{RoyalBlue}{RGB}{187, 134, 252} % 55, 185, 255
%	\definecolor{RoyalGreen}{RGB}{3, 218, 198} % 52, 177, 20
%	\definecolor{RoyalPageCoulor}{RGB}{18, 18, 18} % 30, 30, 30
%	\definecolor{RoyalTextCoulor}{RGB}{225, 225, 225}
%	\pagecolor{RoyalPageCoulor}
%	\color{RoyalTextCoulor}

\RequirePackage{amsmath, amsthm}
	\allowdisplaybreaks
	\theoremstyle{remark}
	\newtheorem*{note}{Note}
\RequirePackage{unicode-math}

\RequirePackage{booktabs}
\RequirePackage{tabularx}
\RequirePackage{ragged2e}
\RequirePackage{siunitx}
	\sisetup{locale = UK}
\RequirePackage{hologo}
\RequirePackage{enumitem}
\RequirePackage{listings}
\RequirePackage{imakeidx}
\RequirePackage{calc}

\RequirePackage{mleftright}
\RequirePackage{xfrac}

\RequirePackage[unicode]{hyperref}
\RequirePackage[nameinlink]{cleveref}

\makeatletter
\ExplSyntaxOn

\tl_new:N \pakkenavn
\tl_new:N \titel
\tl_new:N \email
\tl_new:N \forfatter
\tl_new:N \dato
\tl_new:N \version

\NewDocumentCommand{\Pakkenavn}{ m }{ \tl_gset:Nf \pakkenavn { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Titel}    { m }{ \tl_gset:Nf \titel     { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Forfatter}{ m }{ \tl_gset:Nf \forfatter { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Email}    { m }{ \tl_gset:Nf \email { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Dato}     { m }{ \tl_gset:Nf \dato  { \tl_trim_spaces:n { #1 } } }
\NewDocumentCommand{\Version}  { m }{ \tl_gset:Nf \version  { \tl_trim_spaces:n { #1 } } }

\NewDocumentCommand{\mypackage}{ } {  \pkg{\pakkenavn}  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\forside}{ m }
{
	\thispagestyle{empty}
	
	\null\vspace{15mm}\noindent
	
	\begin{minipage}[t]{\textwidth}
		\centering
		\rule{\textwidth}{.4pt} \par \bigskip
		{ \Huge \bfseries \tl_use:N \titel \par } \bigskip
		\rule{\textwidth}{.4pt}
	\end{minipage} \par \vspace{6mm} \noindent
	
	\begin{minipage}[t]{0.5\textwidth}
		\centering
		\textsl{Written~by:} \par
		{ \color{RoyalRed} \forfatter \par }
		{ \color{RoyalRed} \email \par }
	\end{minipage}
	\hfill
	\begin{minipage}[t]{0.5\textwidth}
		\centering
		\textsl{Released:} \par
		{ \color{RoyalRed} v\version \par }
		{ \color{RoyalRed}  \dato \par }
	\end{minipage}
	
	\par \vspace{20mm} \noindent
	
	\begin{abstract}
		\noindent \ignorespaces
		#1
	\end{abstract}
	
	\vfill
	\clearpage
}

\lstdefinestyle{inlinestyle}
{
	columns = fullflexible,
	basicstyle = \ttfamily\upshape\small,
	alsoletter =  {\\,-,*,/,!},
	keywords = [0]{style-inf, style-inf-num, style-inf-den, style-var, style-var-/, style-var-!, style-var-/!, style-frac, style-frac-/, style-notation, style-notation-*, scale-eval, scale-eval-/, scale-fun, scale-var, scale-var-!, scale-var-*, scale-frac, scale-frac-/, delims-eval, delims-eval-/, delims-fun, delims-var, delims-var-!, delims-var-*, delims-frac, delims-frac-/, sep-inf-ord, sep-inf-fun, sep-ord-fun, sep-frac-fun, sep-inf-var, sep-var-ord, sep-var-inf, sep-ord-inf, sep-ord-ord, sep-ord-var, sep-var-var, sep-eval-sb, sep-eval-sp, sep-begin, sep-end, switch-*, switch-/, switch-!, switch-sort, sort-method, sort-numerical, sort-abs-reverse, sort-lexical-reverse, sort-number-reverse, sort-sign-reverse, sort-symbol-reverse, fun, frac, var, order, ord, mixed-order, mixord, scale-auto},
	keywordstyle = [0]\__mydoc_option_font:,
	keywords = [1]{\\odv, \\pdv, \\mdv, \\fdv, \\adv, \\jdv, \\odif, \\pdif, \\mdif, \\fdif, \\adif, \\NewDerivative, \\RenewDerivative, \\ProvideDerivative, \\DeclareDerivative, \\NewDifferential, \\RenewDifferential, \\ProvideDifferential, \\DeclareDifferential, \\slashfrac, \\derivset},
	keywordstyle = [1]\__mydoc_function_font:,
}

\lstdefinestyle{definitionstyle}
{
	style = inlinestyle,
	tabsize = 1,
	escapechar = \%,
	commentstyle = \footnotesize,
	frame = single,
	xleftmargin=3.4pt,
	xrightmargin=3.4pt,
	rulesep = 0pt,
	backgroundcolor = \color{RoyalLightGray},
	rulecolor = \color{RoyalGray},
}

\lstnewenvironment{definition}{\lstset{style=definitionstyle}\normalmarginpar}{\reversemarginpar}

\newlist{todo}{enumerate}{1}
\setlist[todo]{label=(\roman{todoi}), ref=\thesubsection(\roman{todoi})}
\crefname{todoi}{todo}{todos}

\newlist{changes}{enumerate}{1}
\setlist[changes]{label=(\roman{changesi}), ref=\thesubsection(\roman{changesi})}
\crefname{changesi}{change}{changes}

\newlist{consideration}{enumerate}{1}
\setlist[consideration]{label=(\roman{considerationi}), ref=\thesubsection(\roman{considerationi})}
\crefname{considerationi}{consideration}{considerations}

\AtEndPreamble
{
	%\meaning\@idxitem\\
	%\meaning\subitem\\
	%\meaning\indexspace\\
	%\meaning\hangindent
	%\meaning\indexspace
	\RenewDocumentCommand{\@idxitem}{}{\par \hangindent 0\p@ }
	\RenewDocumentCommand{\subitem}{}{\@idxitem \hspace *{0\p@ }}
	\RenewDocumentCommand{\indexspace}{}{\par \vskip 10\p@ \relax}
}

\NewDocumentCommand{\marginnote}{ m }
{
	\leavevmode
	\marginline{\leavevmode \ttfamily\upshape\small \color{RoyalDarkGray} \tl_trim_spaces:n {#1} }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\ket}{ m }
{
	\lvert #1 \rangle
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\pkg}{ m }
{
	\group_begin:
	\sffamily \upshape \small #1
	\group_end:
}

\NewDocumentCommand{\uni}{} % Kræver unicode
{ \textsuperscript{\texttt{U}} }

\NewDocumentCommand{\pdf}{} % Kræver pdflatex
{ \textsuperscript{\texttt{P}} }

\NewDocumentCommand{\req}{} % Kræver pakke
{ \textsuperscript{\texttt{R}} }

\NewDocumentCommand{\tex}{}{\texorpdfstring{\hologo{TeX}}{TeX}}
\NewDocumentCommand{\pdftex}{}{\texorpdfstring{\hologo{pdfTeX}}{pdfTeX}}
\NewDocumentCommand{\luatex}{}{\texorpdfstring{\hologo{LuaTeX}}{LuaTeX}}
\NewDocumentCommand{\xetex}{}{\texorpdfstring{\hologo{XeTeX}}{XeTeX}}
\NewDocumentCommand{\latex}{ t2 t3 }
{
	\bool_if:nTF {#1}
	{  \texorpdfstring{\hologo{LaTeX2e}}{LaTeX2e}  }
	{
		\bool_if:nTF {#2}
		{  \texorpdfstring{\hologo{LaTeX3}}{LaTeX3}  }
		{  \LaTeX  }
	}
}

\NewDocumentCommand{\xmark}{}
{
	\textcolor{red}{\ensuremath{\mathord{\mathpalette\bigcdot@{}}}}
}
\NewDocumentCommand{\cmark}{}
{
	\textcolor{green}{\ensuremath{\checkmark}}
}

\bool_new:N \l__mydoc_answer_bool
\keys_define:nn {mydoc/answer}
{
	done .bool_set:N = \l__mydoc_answer_bool,
	done .initial:n = false,
	done .default:n = true
}

\NewDocumentCommand{\answer}{ o m m }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn {answer} {#1} }
	
	\bool_if:NTF \l__mydoc_answer_bool
	{
		\fcolorbox{RoyalGray}{RoyalLightGray}
		{
			\parbox{\dimexpr\linewidth-2\fboxsep\relax}
			{
				\__mydoc_answer:nn {#2} {#3}
			}
		}
	}
	{
		\__mydoc_answer:nn {#2} {#3}
	}
	\group_end:
}

\cs_new_protected:Npn \__mydoc_answer:nn #1 #2
{
	#1
	\textbf{Conclusion:}
	\c_space_tl
	\group_begin:
	\slshape
	#2
	\group_end:
}

\newcommand*{\bigcdot@scalefactor}{1.25}
\newcommand*{\bigcdot@widthfactor}{1.15}
\newcommand*{\bigcdot@}[2]{
	% #1: math style
	% #2: unused
	\sbox0{$#1\vcenter{}$}% math axis
	\sbox2{$#1\vectimes\m@th$}
	\hbox to \bigcdot@widthfactor\wd2{
		\hfil
		\raise\ht0\hbox{
			\scalebox{\bigcdot@scalefactor}{
				\lower\ht0\hbox{$#1\vectimes\m@th$}
			}
		}
		\hfil
	}
}



\tl_new:N \l__mydoc_ch_version_tl
\tl_new:N \l__mydoc_ch_date_tl
\tl_new:N \l__mydoc_ch_change_tl

\bool_new:N \l__mydoc_ch_beta_bool
\bool_new:N \l__mydoc_ch_change_bool

\keys_define:nn { mydoc/changelog }
{
	version .tl_set:N = \l__mydoc_ch_version_tl,
	version .default:n = \c_novalue_tl,
	
	date .tl_set:N = \l__mydoc_ch_date_tl,
	date .default:n = \c_novalue_tl,
	
	beta .bool_set:N = \l__mydoc_ch_beta_bool,
	beta .default:n = {false}
}

\DeclareDocumentEnvironment{change}{ o }
{
	\IfNoValueTF{#1}
	{  \keys_set:nn { mydoc/changelog } { version, date, beta     }  }
	{  \keys_set:nn { mydoc/changelog } { version, date, beta, #1 }  }
	
	\mydoc_change_set:
	\mydoc_change_begin:
}
{
	\mydoc_change_end:
}

\cs_new_protected:Npn \mydoc_change_set:
{
	\bool_set_true:N \l__mydoc_ch_change_bool
	\tl_set:Nn \l__mydoc_ch_change_tl
	{
		\leavevmode
		\marginline
		{
			\upshape \scriptsize \ttfamily
			%\leavevmode
			\null\vspace{-3.5\baselineskip}\null
			\tabular[t]{ r }
			\toprule
			v\tl_use:N \l__mydoc_ch_version_tl
			\\
			\tl_use:N \l__mydoc_ch_date_tl
			\bool_if:NT \l__mydoc_ch_beta_bool
			{  \\ \color{RoyalRed} Beta  }
			\\ \bottomrule
			\endtabular
		}
		\ignorespaces
	}
}

\cs_new_protected:Npn \mydoc_change_begin:
{
	\let\mydoc_item:\item
	
	\DeclareDocumentCommand{\item}{ o }
	{
		\tl_if_novalue:nTF {##1}
		{ \mydoc_item: }
		{ \mydoc_item: [##1] }
		\bool_if:NT \l__mydoc_ch_change_bool
		{
			\tl_use:N \l__mydoc_ch_change_tl
			\bool_set_false:N \l__mydoc_ch_change_bool
		}
	}
	\itemize[itemsep=0pt]
}

\cs_new_protected:Npn \mydoc_change_end:
{
	\enditemize
	%\let\item\mydoc_item:
}

\NewDocumentEnvironment{changelog}{ }
{
	\mydoc_ch_begin:
}
{
	\mydoc_ch_end:
}

\cs_new_protected:Npn \mydoc_ch_begin:
{
}

\cs_new_protected:Npn \mydoc_ch_end:
{
}

\ExplSyntaxOff


\ExplSyntaxOn

\tl_new:N \l__mydoc_number_tl
\tl_new:N \l_mydoc_index_item_tl
\tl_new:N \l_mydoc_index_subitem_tl
\tl_new:N \l_mydoc_index_entry_tl

\seq_new:N \l__mydoc_macro_arg_seq

\seq_new:N \l__mydoc_group_seq
\seq_new:N \l__mydoc_type_seq
\seq_new:N \l__mydoc_function_seq
\seq_new:N \g__mydoc_syntax_seq
\seq_new:N \l__deriv_earg_seq

\int_new:N \l__mydoc_earg_int
\int_new:N \g__mydoc_function_int
\int_new:N \g__mydoc_option_int

\bool_new:N \l__mydoc_number_bool

\tl_set:Nn \l__mydoc_number_tl {0123456789}

\seq_new:N \l__mydoc_example_seq
\int_new:N \g__mydoc_example_int

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_vars_keys:nnnn #1 #2 #3 #4
{
	\seq_set_from_clist:Nn \l__mydoc_group_seq {#4}
	\seq_map_inline:Nn \l__mydoc_group_seq
	{
		\mydoc_define_var:nnnn {#1} {#2} {#3} {##1}
		\mydoc_define_key:nnnn {#1} {#2} {#3} {##1}
	}
}

\cs_new_protected:Npn \mydoc_define_var:nnnn #1 #2 #3 #4
{  \use:c { #3_new:c } { #2__mydoc_#1_#4_#3 }  }

\cs_new_protected:Npn \mydoc_define_key:nnnn #1 #2 #3 #4
{
	\str_if_eq:nnTF {#2} { g }
	{  \keys_define:nn { mydoc/#1 } { #4 .#3_#2set:c = { #2__mydoc_#1_#4_#3 } }  }
	{  \keys_define:nn { mydoc/#1 } { #4 .#3_set:c = { #2__mydoc_#1_#4_#3 } }  }
}

%\cs_new_protected:Npn \mydoc_define_inital:nnn #1 #2 #3
%{  \keys_define:nn { mydoc/#1 } { #3 .initial:n = {#2} }  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_set_keys:nn #1 #2
{
	\keys_set:nn { mydoc/#1 } {#2}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_font_i:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl } { colour, family, shape, size }
	
	\cs_new_protected:cpn { __mydoc_#1_font: }
	{
		\color    { \use:c { l__mydoc_#1_colour_tl } }
		\tl_use:c { l__mydoc_#1_family_tl }
		\tl_use:c { l__mydoc_#1_shape_tl  }
		\tl_use:c { l__mydoc_#1_size_tl   }
	}
}

\cs_new_protected:Npn \mydoc_define_font_ii:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl   } { family, shape, size }
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { familyb, shapeb, sizeb }
	
	\cs_new_protected:cpn { __mydoc_#1_font: }
	{
		\bool_if:cT { l__mydoc_#1_familyb_bool } {  \tl_use:c { l__mydoc_#1_family_tl }  }
		\bool_if:cT { l__mydoc_#1_shapeb_bool  } {  \tl_use:c { l__mydoc_#1_shape_tl  }  }
		\bool_if:cT { l__mydoc_#1_sizeb_bool   } {  \tl_use:c { l__mydoc_#1_size_tl   }  }
	}
}

\cs_new_protected:Npn \mydoc_define_index:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { index }
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { definition }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl   } { cat }
}

\cs_new_protected:Npn \mydoc_define_updated:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl } { new }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl } { updated }
}

\cs_new_protected:Npn \mydoc_define_default:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { g } { clist } { default }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepa    }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepb    }
	\mydoc_define_vars_keys:nnnn {#1} { l } { tl    } { sepc    }
}

\cs_new_protected:Npn \mydoc_define_tabular:n #1
{
	\mydoc_define_vars_keys:nnnn {#1} { l } { bool } { result   }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_define_type:nn #1 #2
{
	\seq_set_from_clist:Nn \l__mydoc_type_seq {#2}
	\seq_map_inline:Nn \l__mydoc_type_seq
	{
		\str_case:nn {##1}
		{
			{ font_i  } { \mydoc_define_font_i:n  {#1} }
			{ font_ii } { \mydoc_define_font_ii:n {#1} }
			{ index   } { \mydoc_define_index:n   {#1} }
			{ default } { \mydoc_define_default:n {#1} }
			{ tabular } { \mydoc_define_tabular:n {#1} }
			{ updated } { \mydoc_define_updated:n {#1} }
		}
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mydoc_define_type:nn { function } { font_i, index, updated }
\mydoc_define_type:nn { macro    } { font_ii, index   }
\mydoc_define_type:nn { syntax   } { font_ii          }
\mydoc_define_type:nn { argument } { font_i, updated  }
\mydoc_define_type:nn { arg      } { font_ii,         }
\mydoc_define_type:nn { option   } { font_i, index, updated }
\mydoc_define_type:nn { key      } { font_ii, index   }
\mydoc_define_type:nn { values   } { font_ii, default }
\mydoc_define_type:nn { val      } { font_ii          }
\mydoc_define_type:nn { example  } { font_ii, tabular }
\mydoc_define_type:nn { marg     } { font_ii          }
\mydoc_define_type:nn { narg     } { font_ii          }
\mydoc_define_type:nn { oarg     } { font_ii          }
\mydoc_define_type:nn { targ     } { font_ii          }
\mydoc_define_type:nn { meta     } { font_ii          }
\mydoc_define_type:nn { cs       } { font_ii          }

\mydoc_set_keys:nn { function } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalRed, index=true, definition=true, cat=\c_novalue_tl }
\mydoc_set_keys:nn { macro    } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl }
\mydoc_set_keys:nn { syntax   } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { argument } { family=\rmfamily, shape=\upshape, size=\small, colour=RoyalBlue }
\mydoc_set_keys:nn { arg      } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { option   } { family=\ttfamily, shape=\upshape, size=\small, colour=RoyalGreen, index=true, definition=true, cat=\c_novalue_tl }
\mydoc_set_keys:nn { key      } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, index=true, definition=false, cat=\c_novalue_tl }
\mydoc_set_keys:nn { values   } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, default=\c_novalue_tl, sepa={ ,~}, sepb={ ,~}, sepc={ ,~} }
\mydoc_set_keys:nn { val      } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { example  } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true, result=true }
\mydoc_set_keys:nn { marg     } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { narg     } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { oarg     } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { targ     } { family=\ttfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { meta     } { family=\rmfamily, shape=\slshape, size=\small, familyb=true, shapeb=true, sizeb=true }
\mydoc_set_keys:nn { cs       } { family=\rmfamily, shape=\upshape, size=\small, familyb=true, shapeb=true, sizeb=true }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\prg_new_protected_conditional:Npnn \mydoc_if_int:n #1 { T, F, TF }
{
	\tl_map_inline:Nn {#1}
	{
		\tl_if_in:NnTF \l__mydoc_number_tl {##1}
		{ \bool_set_true:N \l__mydoc_number_bool }
		{ \tl_map_break:n { \bool_set_false:N \l__mydoc_number_bool } }
	}
	\bool_if:NTF \l__mydoc_number_bool
	{ \prg_return_true:  }
	{ \prg_return_false: }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_vspace:n #1
{
	\vspace{#1\baselineskip}
}

\cs_new_protected:Npn \mydoc_margin:n #1
{
	\leavevmode
	\marginline
	{
		\leavevmode
		#1
	}
	\ignorespaces
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_function_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_function_end:
{
	\seq_gclear:N \g__mydoc_syntax_seq
	\par \noindent \ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_function_margin:n #1
{
	\seq_set_from_clist:Nn \l__mydoc_function_seq {#1}
	\int_gzero:N \g__mydoc_function_int
	
	\mydoc_margin:n
	{
		\tabular[t]{ @{} r @{} }
		%\group_begin:
		\seq_map_inline:Nn \l__mydoc_function_seq
		{
			\__mydoc_function_font:
			\int_gincr:N \g__mydoc_function_int
			\mydoc_cs_to_str:N ##1
			\mydoc_index_cs:Nnn ##1 { function } { macro }
			\int_compare:nNnF { \g__mydoc_function_int } = { \seq_count:N \l__mydoc_function_seq }
			{  \\  }
		}
		%\group_end:
		\deriv_new_updated:NN \l__mydoc_function_new_tl \l__mydoc_function_updated_tl
		\endtabular
	}
}

\cs_new_protected:Npn \deriv_new_updated:NN #1 #2
{
	\tl_if_empty:NTF #1
	{
		\tl_if_empty:NF #2
		{
			\\ \midrule
			\deriv_add_updated:N #2
		}
	}
	{
		\\ \midrule 
		\deriv_add_new:N #1
		\tl_if_empty:NF #2
		{
			\\ 
			\deriv_add_updated:N #2
		}
	}
}

\cs_new_protected:Npn \deriv_add_new:N #1
{
	\group_begin:
	\small \ttfamily
	New: \tl_use:N \c_space_tl
	
	\tl_if_head_eq_charcode:fNTF {#1} v
	{ \tl_use:N #1 }
	{ v\tl_use:N #1 }
	\group_end:
}

\cs_new_protected:Npn \deriv_add_updated:N #1
{
	\group_begin:
	\small \ttfamily
	Updated: \tl_use:N \c_space_tl
	
	\tl_if_head_eq_charcode:fNTF {#1} v
	{ \tl_use:N #1 }
	{ v\tl_use:N #1 }
	\group_end:
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_syntax_begin:
{  \ignorespaces  }

\cs_new_protected:Npn \mydoc_syntax:n #1
{
	\seq_gset_from_clist:Nn \g__mydoc_syntax_seq {#1}
	
	\__mydoc_syntax_font:
	\seq_use:Nn \g__mydoc_syntax_seq { }
}

\cs_new_protected:Npn \__mydoc_syntax_end:
{  \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_argument_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_argument_end:
{
	\par\noindent\ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_argument_margin:n #1
{
	\mydoc_margin:n
	{
		\tabular[t]{ @{} r @{} }
		\mydoc_set_keys:nn { marg     } { familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { narg     } { familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { oarg     } { familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { targ     } { familyb = false, shapeb = false, sizeb = false }
		\mydoc_set_keys:nn { meta     } { familyb = true,  shapeb = true,  sizeb = false }
		\mydoc_set_keys:nn { cs       } { familyb = false, shapeb = false, sizeb = false }
		\__mydoc_argument_font:
		\mydoc_if_int:nTF {#1}
		{  \seq_item:Nn \g__mydoc_syntax_seq {#1}  }
		{  #1                                      }
		\deriv_new_updated:NN \l__mydoc_argument_new_tl \l__mydoc_argument_updated_tl
		\endtabular
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_option_begin:n #1
{
	\par
	\bool_if:NF {#1} {  \mydoc_vspace:n { 0.3 }  }
	\@afterindentfalse \@afterheading
}

\cs_new_protected:Npn \__mydoc_option_end:
{
	\seq_clear:N \l__mydoc_option_seq
	\clist_gclear:c { g__mydoc_values_default_clist }
	\par \noindent \ignorespacesafterend
}

\cs_new_protected:Npn \__mydoc_option_margin:n #1
{
	\seq_set_from_clist:Nn \l__mydoc_option_seq {#1}
	\int_gzero:N \g__mydoc_option_int
	
	\mydoc_margin:n
	{
		\tabular[t]{ @{} r @{} }
		\seq_map_inline:Nn \l__mydoc_option_seq
		{
			\int_gincr:N \g__mydoc_option_int
			\__mydoc_option_font:
			##1
			\mydoc_index_key:nnn {##1} { option } { option }
			\int_compare:nNnF { \g__mydoc_option_int } = { \seq_count:N \l__mydoc_option_seq }
			{ \\ }
		}
		\deriv_new_updated:NN \l__mydoc_option_new_tl \l__mydoc_option_updated_tl
		\endtabular
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \__mydoc_values_begin:
{  \ignorespaces  }

\cs_new_protected:Npn \mydoc_values:n #1
{
	\seq_gset_from_clist:Nn \g__mydoc_values_seq  {#1}
	
	\__mydoc_values_font:
	\seq_use:Nn \g__mydoc_values_seq { ,~}
	
	\exp_args:Nf \tl_if_novalue:nF { \clist_item:Nn \g__mydoc_values_default_clist { 1 } }
	{
		\hfill
		\mydoc_clist_use:n { values }
	}
}

\cs_new_protected:Npn \mydoc_clist_use:n #1
{
	\clist_use:cnnn { g__mydoc_#1_default_clist }
	{ \tl_use:c { l__mydoc_#1_sepa_tl } }
	{ \tl_use:c { l__mydoc_#1_sepb_tl } }
	{ \tl_use:c { l__mydoc_#1_sepc_tl } }
}

\cs_new_protected:Npn \__mydoc_values_end:
{  \par \mydoc_vspace:n { 0.2 } \noindent \ignorespacesafterend  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentEnvironment{example}{ s o b }
{
	\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { example } {#2} }
	\__mydoc_example_begin:nn {#1} {#3}
}
{
	\__mydoc_example_end:
}

\cs_new_protected:Npn \__mydoc_example_end:
{
	\endtabular
	\endcenter
}

\cs_new_protected:Npn \__mydoc_example_begin:nn #1 #2
{
	\seq_set_split:Nnn \l__deriv_example_seq { \\ } {#2}
	\bool_if:NTF \l__mydoc_example_result_bool
	{
		\bool_if:nTF {#1}
		{
			\center \tabular{ @{} c @{} }
			\__mydoc_example_content_star:N \l__deriv_example_seq
		}
		{
			\center \tabular{ @{} r c l @{} }
			\__mydoc_example_content:N \l__deriv_example_seq
		}
	}
	{
		\renewcommand{\arraystretch}{0}
		\center \tabular{ @{} >{\arraybackslash}l @{} }
		\__mydoc_example_content_nores:N \l__deriv_example_seq
	}
}

\cs_new_protected:Npn \__mydoc_example_content:N #1
{
	\int_gzero:N \g__mydoc_example_int
	\seq_map_inline:Nn #1
	{
		\int_gincr:N \g__mydoc_example_int
		\__mydoc_example_font:
		\__mydoc_print:n {##1}
		&
		$\Longrightarrow$
		&
		$\displaystyle ##1$
		\int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
		{  \\ \addlinespace[0.5em]  }
	}
}

\cs_new_protected:Npn \__mydoc_example_content_star:N #1
{
	\int_gzero:N \g__mydoc_example_int
	\seq_map_inline:Nn #1
	{
		\int_gincr:N \g__mydoc_example_int
		\__mydoc_example_font:
		\__mydoc_print:n {##1}
		\\[0.5em]
		$\Longrightarrow \qquad \displaystyle ##1$
		\int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
		{  \\ \addlinespace[0.5em]  }
	}
}

\cs_new_protected:Npn \__mydoc_example_content_nores:N #1
{
	\int_gzero:N \g__mydoc_example_int
	\seq_map_inline:Nn #1
	{
		\int_gincr:N \g__mydoc_example_int
		\__mydoc_example_font:
		\__mydoc_print:n {##1}
		\int_compare:nNnF { \g__mydoc_example_int } = { \seq_count:N #1 }
		{  \\ \addlinespace[0.4em] }
	}
}

\tl_new:N \l__mydoc_print_tmp_tl
\seq_new:N \l__deriv_print_seq
\str_new:N \l__deriv_print_str

\cs_new_protected:Npn \__mydoc_print:n #1
{
	\tl_set:Nn \l__mydoc_print_tmp_tl {#1}
	\regex_replace_all:nnN { . } { \c{string} \0 } \l__mydoc_print_tmp_tl
	\str_set:Nx \l__deriv_print_str \l__mydoc_print_tmp_tl
	
	\__deriv_split_at_star:NN \l__deriv_print_seq \l__deriv_print_str
}

\cs_new_protected:Npn \__mydoc_inlinecode:n #1
{
	\lstinline[style=inlinestyle]$#1$
}

\cs_new_protected:Npn \__deriv_split_at_star:NN #1 #2
{
	\seq_set_split:NnV \l_tmpa_seq {*} #2
	\bool_set_false:N \l__mydoc_star_bool
	\seq_clear:N \l__deriv_print_seq
	\seq_indexed_map_inline:Nn \l_tmpa_seq
	{
		\str_if_eq:eeTF { \tl_item:nn {##2} {-1} } { - }
		{
			\bool_set_true:N \l__mydoc_star_bool
			\__mydoc_inlinecode:n {##2*}
		}
		{
			\int_compare:nNnTF {##1} = { 1 }
			{ \__mydoc_inlinecode:n {##2} }
			{
				\bool_if:NTF \l__mydoc_star_bool
				{
					\bool_set_false:N \l__mydoc_star_bool
					\__mydoc_inlinecode:n {##2}
				}
				{ \hspace{0.7pt}\__mydoc_inlinecode:n {*##2} }
			}
		}
	}
}

%\bool_if:NTF \l__mydoc_star_bool
%{
%	\seq_put_right:Nn #1 {*##2}
%	\bool_set_false:N \l__mydoc_star_bool
%}
%{ \seq_put_right:Nn #1 {##2} }

\NewDocumentCommand{\inlinecode}{ m }
{
	\group_begin:
	\__mydoc_print:n {#1}
	\group_end:
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentEnvironment{function}{ s m o }
{
	\tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { function } {#3} }
	\__mydoc_function_begin:n  {#1}
	\__mydoc_function_margin:n {#2}
}
{
	\__mydoc_function_end:
}

\DeclareDocumentEnvironment{syntax}{ o b }
{
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { syntax } {#1} }
	\__mydoc_syntax_begin:
	\mydoc_syntax:n {#2}
}
{
	\__mydoc_syntax_end:
}

\DeclareDocumentEnvironment{argument}{ s m o }
{
	\tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { argument } {#3} }
	\__mydoc_argument_begin:n  {#1}
	\__mydoc_argument_margin:n {#2}
}
{
	\__mydoc_argument_end:
}

\DeclareDocumentEnvironment{option}{ s m o }
{
	\tl_if_novalue:nF {#3} { \mydoc_set_keys:nn { option } {#3} }
	\__mydoc_option_begin:n  {#1}
	\__mydoc_option_margin:n {#2}
}
{
	\__mydoc_option_end:
}

\DeclareDocumentEnvironment{values}{ o b }
{
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { values } {#1} }
	\__mydoc_values_begin:
	\mydoc_values:n {#2}
}
{
	\__mydoc_values_end:
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\default}{ s O{values} }
{
	\group_begin:
	\mydoc_default:nn {#1} {#2}
	\group_end:
}

\cs_new_protected:Npn \mydoc_default:nn #1 #2
{
	\bool_if:nTF {#1}
	{  \clist_use:cnnn { g__mydoc_#2_default_clist } {~and~} { ,~} {~and~}  }
	{  \clist_use:cn   { g__mydoc_#2_default_clist } { ,~}                  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\macro}{ o m o }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { macro } { #1 } }
	\mydoc_macro:nn {#2} {#3}
	\group_end:
}

\cs_new_protected:Npn \mydoc_macro:nn #1 #2
{
	\__mydoc_macro_font:
	\mydoc_if_int:nTF {#1}
	{
		\tl_set:Nx \l__mydoc_marg_tl { \seq_item:Nn \l__mydoc_function_seq {#1}  }
		\mydoc_cs_to_str:x { \seq_item:Nn \l__mydoc_function_seq {#1} }
		\exp_args:NV \mydoc_index_cs:Nnn \l__mydoc_marg_tl { macro } { macro }
	}
	{
		\mydoc_cs_to_str:N #1
		\mydoc_index_cs:Nnn #1 { macro } { macro }
	}
	\tl_if_novalue:nF {#2}
	{
		\seq_set_from_clist:Nn \l__mydoc_macro_arg_seq {#2}
		\seq_map_function:NN \l__mydoc_macro_arg_seq \mydoc_arg:n
	}
}

\DeclareDocumentCommand{\arg}{ o m }
{
	\group_begin:
	\mydoc_arg:n {#2}
	\group_end:
}

\cs_new_protected:Npn \mydoc_arg:n #1
{
	\__mydoc_arg_font:
	\mydoc_if_int:nTF {#1}
	{  \seq_item:Nn \g__mydoc_syntax_seq {#1}  }
	{  #1                                      }
}

\DeclareDocumentCommand{\key}{ O{index=false} m }
{
	\group_begin:
	\tl_if_novalue:nF {#1} { \mydoc_set_keys:nn { key } {#1} }
	\mydoc_key:n {#2}
	\group_end:
}

\AfterEndPreamble{
	\DeclareDocumentCommand{\val}{ s o m }
	{
		\group_begin:
		\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { val } {#2} }
		\bool_if:nTF {#1}
		{ \mydoc_val_star:n {#3} }
		{ \mydoc_val:n {#3} }
		\group_end:
	}
}
\DeclareDocumentCommand{\keyval}{ s o m m }
{
	\group_begin:
	\tl_if_novalue:nF {#2} { \mydoc_set_keys:nn { key } {#2} }
	\bool_if:nTF {#1}
	{ \mydoc_keyval_star:nn {#3} {#4} }
	{ \mydoc_keyval:nn {#3} {#4} }
	\group_end:
}

\cs_new_protected:Npn \mydoc_key:n #1
{
	\__mydoc_key_font:
	#1
	\mydoc_index_key:nnn {#1} { key } { option }
}

\cs_new_protected:Npn \mydoc_val:n #1
{
	\__mydoc_key_font:
	#1
}
\cs_new_protected:Npn \mydoc_val_star:n #1
{
	\__mydoc_key_font:
	\{ #1 \}
}

\cs_new_protected:Npn \mydoc_keyval:nn #1 #2
{
	\group_begin:
	\mydoc_key:n {#1}
	=
	\mydoc_val:n {#2}
	\group_end:
}
\cs_new_protected:Npn \mydoc_keyval_star:nn #1 #2
{
	\group_begin:
	\mydoc_key:n {#1}
	=
	\mydoc_val_star:n {#2}
	\group_end:
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cs_new_protected:Npn \mydoc_index_cs:Nnn #1 #2 #3
{
	\tl_set:Nf \l_mydoc_index_item_tl { \cs_to_str:N #1 }
	\tl_set:Nx \l_mydoc_index_entry_tl { \cstostr{#1} }
	
	\tl_set:Nf \l_mydoc_index_item_tl { \str_uppercase:f { \tl_head:N \l_mydoc_index_item_tl } }
	
	\bool_if:cT  { l__mydoc_#2_index_bool }
	{
		\bool_if:cTF { l__mydoc_#2_definition_bool }
		{  \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textbf     }  }
		{  \mydoc_index:VVnn \l_mydoc_index_item_tl \l_mydoc_index_entry_tl {#3} { textnormal }  }
	}
}

\cs_new_protected:Npn \mydoc_index_key:nnn #1 #2 #3
{
	\seq_set_split:Nnn \l__mydoc_index_seq { - } {#1}
	\mydoc_if_novalue:vTF { l__mydoc_#2_cat_tl } 
	{ \tl_set:Nx \l_mydoc_index_item_tl { \seq_item:Nn \l__mydoc_index_seq {1} } }
	{ \tl_set_eq:Nc \l_mydoc_index_item_tl { l__mydoc_#2_cat_tl } }
	
	\tl_set:Nx \l_mydoc_index_subitem_tl {#1}
	\tl_set:Nx \l_mydoc_index_entry_tl   {#1}
	
	\tl_replace_all:Nnn \l_mydoc_index_subitem_tl { ! } { "! }
	\tl_replace_all:Nnn \l_mydoc_index_entry_tl   { ! } { "! }
	
	\bool_if:cT  { l__mydoc_#2_index_bool }
	{
		\bool_if:cTF { l__mydoc_#2_definition_bool }
		{  \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textbf     }  }
		{  \mydoc_index:VVVnn \l_mydoc_index_item_tl \l_mydoc_index_subitem_tl \l_mydoc_index_entry_tl {#3} { textnormal }  }
	}
}
\prg_new_conditional:Npnn \mydoc_if_novalue:n #1 { TF }
{
	\token_if_macro:NTF {#1}
	{
		\exp_args:NV \tl_if_novalue:nTF {#1}
		{ \prg_return_true:  }
		{ \prg_return_false: }
	}
	{
		\tl_if_novalue:nTF {#1}
		{ \prg_return_true:  }
		{ \prg_return_false: }
	}
}
\prg_generate_conditional_variant:Nnn \mydoc_if_novalue:n { v } { TF }

\cs_new_protected:Npn \mydoc_index:nnnn #1 #2 #3 #4
{
	\index[#3]{#1@\protect{#2}|#4}
}

\cs_new_protected:Npn \mydoc_index:nnnnn #1 #2 #3 #4 #5
{
	\index[#4]{#1!#2@#3|#5}
}
\cs_generate_variant:Nn \mydoc_index:nnnnn { VVV }
\cs_generate_variant:Nn \mydoc_index:nnnn  { VV  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareDocumentCommand{\tsb}{ m }{ \textsubscript{#1} }

\DeclareDocumentCommand{\meta}{ m }
{
	\ensuremath{\langle}
	\group_begin:
	\__mydoc_meta_font:
	#1
	\group_end:
	\ensuremath{\rangle}
}

\DeclareDocumentCommand{\marg}{ m }
{
	\group_begin:
	\mydoc_marg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\narg}{ m }
{
	\group_begin:
	\mydoc_narg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\oarg}{ s m }
{
	\group_begin:
	\bool_if:nTF {#1}
	{ \mydoc_oarg_star:n {#2} }
	{ \mydoc_oarg:n      {#2} }
	\group_end:
}
\DeclareDocumentCommand{\earg}{ m }
{
	\group_begin:
	\mydoc_earg:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\targ}{ m }
{
	\group_begin:
	\mydoc_targ:n {#1}
	\group_end:
}
\DeclareDocumentCommand{\sarg}{ }
{
	\group_begin:
	\mydoc_sarg:
	\group_end:
}
\DeclareDocumentCommand{\cs}{ m }
{
	\group_begin:
	\mydoc_cs:n {#1}
	\group_end:
}

\DeclareDocumentCommand{\csverb}{ v }
{
	\group_begin:
	\mydoc_csverb:n {#1}
	\group_end:
}

\cs_new:Npn \mydoc_marg:n #1
{
	\__mydoc_marg_font:
	\mydoc_arg_delim_format:n { \{ }
	\meta{#1}
	\mydoc_arg_delim_format:n { \} }
}

\cs_new:Npn \mydoc_narg:n #1
{
	\__mydoc_narg_font:
	\mydoc_arg_delim_format:n { \{ }
	#1
	\mydoc_arg_delim_format:n { \} }
}

\cs_new:Npn \mydoc_oarg:n #1
{
	\__mydoc_oarg_font:
	\mydoc_arg_delim_format:n { [ }
	\meta{#1}
	\mydoc_arg_delim_format:n { ] }
}

\cs_new:Npn \mydoc_oarg_star:n #1
{
	\__mydoc_oarg_font:
	\mydoc_arg_delim_format:n { [ }
	#1
	\mydoc_arg_delim_format:n { ] }
}

\cs_new:Npn \mydoc_earg:n #1
{
	\seq_set_from_clist:Nn \l__deriv_earg_seq {#1}
	
	\int_zero:N \l__mydoc_earg_int
	\seq_map_inline:Nn \l__deriv_earg_seq
	{
		\int_incr:N \l__mydoc_earg_int
		\int_if_odd:nTF \l__mydoc_earg_int
		{  \mydoc_arg_delim_format:n {##1}  }
		{  \mydoc_marg:n {##1}              }
	}
}

\cs_new:Npn \mydoc_targ:n #1
{
	\__mydoc_targ_font:
	\mydoc_arg_delim_format:n {#1}
}

\cs_new:Npn \mydoc_sarg:
{  \mydoc_targ:n { * }  }

\cs_new:Npn \mydoc_cs:n #1
{
	\__mydoc_cs_font:
	\mydoc_arg_delim_format:n { \\#1 }
}

\cs_new:Npn \mydoc_csverb:n #1
{
	\__mydoc_cs_font:
	\group_begin:
	\ttfamily #1
	\group_end:
}

\cs_new:Npn \mydoc_arg_delim_format:n #1
{
	\group_begin:
	\ttfamily \char` #1
	\group_end:
}

\DeclareDocumentCommand{\low}{ O{0,0} m m }
{
	\seq_set_from_clist:Nn \l__low_seq {#1}
	
	\mskip -\seq_item:Nn \l__low_seq {1} mu
	\underbracket
	{
		\mskip \seq_item:Nn \l__low_seq {1} mu
		\vphantom{f}
		#2
		\mskip \seq_item:Nn \l__low_seq {2} mu
	}
	\sb{\text{#3}}
	\mskip -\seq_item:Nn \l__low_seq {2} mu
}

\DeclareDocumentCommand{\ms}{ m }
{
	{\scriptstyle\langle\texttt{#1}\rangle}
}

\DeclareDocumentCommand{\here}{}
{
	{\scriptstyle\langle\texttt{here}\rangle}
}

\cs_new_protected:Npn \mydoc_cs_to_str:N #1
{  \char` \\ \cs_to_str:N #1  }

\cs_new_protected:Npn \mydoc_cs_to_str:n #1
{  \char` \\ \cs_to_str:N #1  }
\cs_generate_variant:Nn \mydoc_cs_to_str:n { x }

\DeclareDocumentCommand{\cstostr}{ m }
{  \mydoc_cs_to_str:N #1 }

\ExplSyntaxOff
\makeatother

\Pakkenavn{derivative}
\Titel{The \pakkenavn{} package}
\Forfatter{Simon Jensen}
\Email{sjelatex@gmail.com}
\Dato{2024/02/08}
\Version{1.4}

\RequirePackage{derivative}[\dato]

\hypersetup
{
	final = true,
	bookmarksnumbered = true,
	colorlinks = true,
	linkcolor = RoyalRed,
	urlcolor = RoyalBlue,
	pdfauthor = \forfatter,
	pdftitle = \titel,
	pdfencoding = unicode
}

\listfiles

\setlength{\marginparwidth}{126pt} % 74.68849pt
\setlength{\marginparpush}{0pt} % 5.39996pt

\makeindex[name=option, title=Index of Options,  intoc=true]
\makeindex[name=macro,  title=Index of Commands, intoc=true]

\indexsetup{level=\subsection*, noclearpage=false, toclevel=subsection}

\directlua{
	pdf.setmajorversion(2)
	pdf.setminorversion(0)
}

\begin{document}
	
	\forside{The \mypackage{} package provides a set of commands which makes writing ordinary and partial derivatives of arbitrary order in a straight forward manner. Additionally, this package provides a set of commands to define variants of the aforementioned derivatives. A set of optional arguments along with lots of package options allow for easy and great flexibility over the derivative's format, such as where the function is positioned, point of evaluation, and switching between fraction styles. Moreover, the mixed order of the partial derivative and variants hereof is automatically computed. This package is written in the \pkg{expl3} language and requires therefore the \LaTeX3 package bundles \pkg{l3kernel} and \pkg{l3package}. Additionally, the \pkg{mleftright} package is optional and provides the improved automatically scaling \cs{mleft} and \cs{mright}.}
	
	\clearpage
	\tableofcontents
	
	\clearpage
	\section{Introduction}
This package originated as a personal package I developed several years ago for various projects. Initially written in \tex{} and \latex{}, it encountered numerous errors as its complexity grew, eventually becoming a convoluted code. Consequently, I rewrote the code using the \latex3 language, allowing for easier maintenance. Originally, I created this package due to the lack of robust derivative packages available. However, I later discovered the \pkg{diffcoeff} package, which served the purpose well. Unfortunately, by that time, I had already written a most of the code, undocumented. To address this, I decided to document the code and transform it into a publicly available package.

\bigskip

Regarding terminology, I use the abbreviation \texttt{inf} to represent the operator symbols $d, \partial, \delta$, etc., commonly used in derivatives (e.g., $\odv{y}{x}, \pdv{y}{x}, \fdv{y}{x}$) and differentials (e.g., $\odif{x}, \pdif{x}, \fdif{x}$). In the description of macros and options, I often use the notation \emph{cs-\meta{placeholder}} to indicate a comma-separated list of \meta{placeholder}. For instance, \oarg{cs-numbers} is used in the option section to denote a comma-separated list of numbers for math space keys. It is important to note that whenever an argument specifies \meta{keyvalue list}, it refers to a comma-separated list of key-value pairs.

\bigskip

\noindent The GitHub repository for this package can be accessed at:\\ \href{https://github.com/sjelatex/derivative}{www.github.com/sjelatex/derivative}.


	
	\clearpage
	\section{Derivative}\label{sec:derivative}

\begin{function}*{\pdv}[updated=v1.3]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \targ{!}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	The partial derivative is defined using the \macro{1} command, which has both mandatory and optional arguments. These arguments allow for the customization of specific parts and the style of the derivative.
	\begin{definition}
		\DeclareDerivative{\pdv}{\partial}[style-var=multiple, style-var-/=multiple,
		style-var-!=mixed, style-var-/!=multiple, delims-eval=(), delims-eval-/=(),
		delims-eval-!=()]
	\end{definition}
	
	\begin{argument}*{1}
		The optional first argument of \macro{1} controls the placement of the function in relation to the fraction. By setting \keyval{switch-*}{false}, the function is typeset in the numerator when the star is absent, and next to the fraction when the star is present. Here is an example:
		\begin{example}
			\pdv{f}{x,y} \\
			\pdv*{f}{x,y}
		\end{example}
		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.
	\end{argument}
	
	\begin{argument}{2}[updated = v1.4]
		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:
		\begin{example}
			\pdv[order={2,3}]{f}{x,y,z} \\
			\pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\
			\pdv[sep-var-inf=0]{f}{x,y,z} \\
			\pdv[order={3/2-n/3,n/2,1/3}]{f}{x,y,z}
		\end{example}
		To ease the cumbersome order key, implicit orders can now be given:
		\begin{example}
			\pdv[n+2, \alpha]{f}{x,y,z}
		\end{example}
		For a comprehensive list of available options that can be applied to derivatives, please refer to \cref{ssec:options_dv}.
		%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}
	\end{argument}
	
	\begin{argument}{3}
		The first mandatory argument of \macro{1} is used to typeset the function that will be differentiated. Here are some examples:
		\begin{example}
			\pdv{f(x,y,z)}{x,y,z} \\
			\pdv{e^x\sin(y)\ln(z)}{x,y,z}
		\end{example}
		The function is displayed either in the numerator or to the right of the derivative, depending on the presence or absence of the star argument.
	\end{argument}
	
	\begin{argument}{4}[updated = v1.3]
		The fourth argument of \macro{1} is an optional slash that appears between the function and the variable arguments, indicating an alternative style. Its behaviour depends on the presence or absence of the exclamation mark argument.
		
		When the exclamation mark is absent, the slash determines the fraction style in which the derivative is typeset. By default, when the slash is absent, the derivative is typeset with \cs{frac}, and when the slash is present, it is typeset with \cs{slashfrac}\footnote{Note that \cs{slashfrac} is a macro defined by the package, please refer to \cref{ssec:slashfrac} for more details.\label{foot:sfrac}}, as shown in the following example:
		\begin{example}
			\pdv{f}{x,y} \\
			\pdv{f}/{x,y}
		\end{example}
		However, when the exclamation mark argument is present, the slash argument switches between shorthand styles rather than fraction styles.
		
		Similar to the star argument, the effect of the slash's presence can be reversed by setting \keyval{switch-/}{true}. In other words, the equations in the previous example will be interchanged.
	\end{argument}
	
	\begin{argument}{5}[new = v1.3]
		The fifth argument of \macro{1} is an optional exclamation mark that appears between the function and the variable arguments. It allows switching the derivative into shorthand style, as described in \cref{ssec:options_dv}.
		
		When \keyval{switch-!}{false} is used, along with the \macro{1}'s default shorthand styles, the derivative is typeset as shown in the example below:
		\begin{example}
			\pdv{f}!{x,y} \\
			\pdv{f}/!{x,y}
		\end{example}
		The effect of the exclamation mark's presence can be reversed by setting \keyval{switch-!}{true}. In other words, the equations in the previous example will be interchanged.
		\begin{note}
			The order of the slash and exclamation mark is important. For example, \cs{pdv}\narg{f}\targ{!}\targ{/}\narg{x,y} will give $\pdv{f}!/{x,y}$ and not the indented output $\pdv{f}/!{x,y}$.
		\end{note}
	\end{argument}
	
	\begin{argument}{6}
		This is the second and final mandatory argument is used to typeset the variable in which the function is differentiated with respect to. The variables should be provided as a comma-separated list
		\begin{example}
			\pdv{f}{x} \\
			\pdv{f}{x,y}
		\end{example}
	\end{argument}
	
	\clearpage
	\begin{argument}{7}
		The last optional argument specifies the point(s) of evaluation or variables held constant. It is an \emph{e-type} argument from the \pkg{xparse} package, denoted as \verb|e{_^}|. This means that the subscript \verb|_| and superscript \verb|^| accepts an argument given within braces. The order of the subscript and superscript is independent, as shown in the following examples:
		\begin{example}
			\pdv{f}{x,y}_{(x_1,y_1)} \\
			\pdv{f}{x,y}^{(x_2,y_2)} \\
			\pdv{f}{x,y}_{(x_1,y_1)}^{(x_2,y_2)} \\
			\pdv{f}{x,y}^{(x_2,y_2)}_{(x_1,y_1)}
		\end{example}
		The subscript argument is commonly used to indicate the point of evaluation or the variables held constant. If needed, the superscript argument can be used to denote a second point of evaluation.
	\end{argument}
\end{function}

\subsection{Other derivatives}
In addition to the partial derivative, the package also provides five other derivative commands:
\begin{itemize}
	\item Ordinary derivative: \macro{\odv} - Used to represent the rate of change of a single-variable function with respect to its independent variable.
	\item Material derivative: \macro{\mdv} - Applied in fluid mechanics and continuum mechanics to describe the rate of change of a quantity attached to a moving fluid particle.
	\item Functional derivative: \macro{\fdv} - Used in functional analysis, calculus of variations, and quantum mechanics to express the derivative of a functional.
	\item Average rate of change: \macro{\adv} - Used to denote the average rate of change of a quantity over a given interval.
	\item Jacobian: \macro{\jdv} - Significant in multivariable calculus and linear algebra for representing the derivative of a vector-valued function.
\end{itemize}
A unique feature of this package is that it allows you to define your own derivatives, as described in \cref{ssec:defvar_dv}. This means you can create custom derivative commands tailored to your specific needs.

If you require more information on the usage and customization of these derivative commands, please refer to the documentation in \cref{ssec:defvar_dv}.

\clearpage
\begin{function}{\odv}[updated=v1.1]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	In this package, the ordinary derivative is defined with an upright lowercase d if the package option \keyval[cat=misc]{upright}{true} is used. Otherwise, it is defined with an italic lowercase \textit{d}. This choice was made to align with the convention used in many modern books.
	\begin{definition}
		\DeclareDerivative{\odv}{\mathrm{d}}%\marginnote{\keyval[cat=misc]{upright}{true}}%
		\DeclareDerivative{\odv}{\mathnormal{d}}%\marginnote{\keyval[cat=misc]{italic}{true}}%
	\end{definition}

	\noindent The ordinary derivative can then be typeset as:
	\begin{equation*}
		\odv{f}{x} = \lim_{h\to 0} \mleft( \frac{ f(x+h) - f(x) }{ h } \mright)
	\end{equation*}
	By adjusting the \key{style-inf} or \key{style-inf-num} and \key{style-inf-den} keys, the operator d can be customized to personal preference or specific formatting requirements.
\end{function}

\begin{function}{\mdv}[updated=v1.1]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	The material derivative is defined with an upright uppercase D when the package option \keyval[cat=misc]{upright}{true}. Otherwise, it is defined with an italic uppercase D.
	\begin{definition}
		\DeclareDerivative{\mdv}{\mathrm{D}}%\marginnote{\keyval[cat=misc]{upright}{true}}%
		\DeclareDerivative{\mdv}{\mathnormal{D}}%\marginnote{\keyval[cat=misc]{italic}{true}}%
	\end{definition}
	
	\noindent In physics, the material derivative is defined by
	\begin{equation*}
		\mdv{ \varphi(\symbf{r}, t) }{ t } \coloneq \pdv{ \varphi(\symbf{r}, t) }{ t } + \dot{\symbf{r}} \cdot \nabla \varphi(\symbf{r}, t)
	\end{equation*}
	By adjusting the \key{style-inf} or \key{style-inf-num} and \key{style-inf-den} keys, the operator D can be customized to personal preference or specific formatting requirements.
\end{function}

\begin{function}{\fdv}
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	In this package, the functional derivative is defined with a lowercase delta. By default, it is represented in italic form. The functional derivative can be defined as follows:
	\begin{definition}
		\DeclareDerivative{\fdv}{\delta}
	\end{definition}
	
	\noindent In physics, the functional derivative is commonly employed in various equations, such as the Lagrange equation and the derivation of the Hartree-Fock equation. Examples of its usage include:
	\begin{equation*}
		\fdv{I}{q_{\alpha}} = \pdv{L}{q_{\alpha}} - \odv*{ \pdv{L}{ \dot{q}_{\alpha} } } { t } = 0, \qquad \fdv{ \symcal{L} }{ \psi_{n}^* } = \hat{F} \ket{\psi_{n}} - \epsilon_{n} \ket{\psi_{n}} = 0
		,
	\end{equation*}
\end{function}

\begin{function}{\adv}
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	The average rate of change is defined to use an upright uppercase delta with the default settings. In this package, the average rate of change is defined as
	\begin{definition}
		\DeclareDerivative{\adv}{\Delta}
	\end{definition}
	
	\noindent The average rate of change can be expressed as
	\begin{equation*}
		\adv{ y }{ x } = \frac{y_2- y_1}{x_2 - x_1}
	\end{equation*}
\end{function}

\begin{function}{\jdv}[updated = v1.0]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{function}, \targ{/}, \marg{variables}, \earg{\_, point\tsb{1}, \^, point\tsb{2}}
	\end{syntax}
	In this package, the Jacobian is defined with an italic partial differential by default. Additionally, a pair of parentheses is automatically inserted around the function and variable.
	\begin{definition}
		\DeclareDerivative{\jdv}{\partial}[fun=true, var=1]
	\end{definition}
	
	\noindent which gives
	\begin{equation*}
		\jdv{f,g,h}{x,y,z}
	\end{equation*}
\end{function}


	
	\clearpage
	\section{Differentials}\label{sec:differential}

\begin{function}*{\odif}[new = v1.0, updated=v1.1]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{variables}
	\end{syntax}
	The differential \macro{1} is defined with both mandatory and optional arguments that allow for customizing its typesetting and style. It is defined with an upright lowercase d when \keyval[cat=misc]{upright}{true} is used. Otherwise, it will be defined with an italic lowercase d.
	\begin{definition}
		\DeclareDifferential{\odif}{\mathrm{d}}%\marginnote{\keyval[cat=misc]{upright}{true}}%
		\DeclareDifferential{\odif}{\mathnormal{d}}%\marginnote{\keyval[cat=misc]{italic}{true}}%
	\end{definition}
	
	\begin{argument}*{1}
		The first argument of \macro{1} is an optional star that determines the notation style of the differential. With the \keyval{switch-*}{false} option, the variables and orders are typeset as subscript and superscript, respectively, when the star is present. When the star is absent, the infinitesimal is placed in front of each variable, as illustrated below:
		\begin{example}
			\odif{x,y,z} \\
			\odif*{x,y,z}
		\end{example}
		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.
	\end{argument}
	
	\begin{argument}{2}[updated = v1.4]
		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:
		\begin{example}
			\odif[order={n,3}]{x,y,z} \\
			\odif[sep-var-inf=0]{x,y,z} \\
			\odif*[sep-var-var=0]{x,y,z}
		\end{example}
		To ease the cumbersome order key, implicit orders can now be given:
		\begin{example}
			\odif[n+2, \alpha]{x,y,z}
		\end{example}
		For a comprehensive list of available options that can be applied to differentials, please refer to \cref{ssec:options_inf}
	\end{argument}
	
	\begin{argument}{3}
		The mandatory argument is used to typeset the variables in the differential. Here are some examples:
		\begin{example}
			\odif{x} \\
			\odif{s_1,s_2...,s_n}
		\end{example}
	\end{argument}
\end{function}

\subsection{Other differentials}
In addition to the regular differential, the package also provides four other differential commands:
\begin{itemize}
	\item Partial differential: \macro{\pdif} - This command is used to typeset partial differentials.
	\item Uppercase D: \macro{\mdif} - It is used to typeset differentials with an uppercase "D".
	\item Lowercase delta: \macro{\fdif} - This command is used to typeset differentials with a lowercase delta symbol.
	\item Uppercase delta: \macro{\adif} - It is used to typeset differentials with an uppercase Delta symbol.
\end{itemize}
A unique feature of this package is that it allows you to define your own differentials, as described in \cref{ssec:defvar_inf}. This means you can create custom differential commands tailored to your specific needs.

If you require more information on the usage and customization of these differential commands, please refer to the documentation in \cref{ssec:defvar_inf}.

%This package offers four other differentials: partial differential \macro{\pdif}, uppercase D \macro{\mdif}, delta \macro{\fdif} and Delta \macro{\adif}. A unique feature of this package, is that you can define your own differential as described in \cref{ssec:defvar_inf}.

\begin{function}{\pdif}
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{variables}
	\end{syntax}
	The partial differential \macro{1} is commonly used as a shorthand notation for the partial derivative. In this package, it is defined as follows:
	\begin{definition}
		\DeclareDifferential{\pdif}{\partial}[style-notation=single,
		style-notation-*=mixed]
	\end{definition}

	\noindent The non-star and star versions are represented on the left side as:
	\begin{align*}
		\pdif[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z} \\
		\pdif*[order={i,j,k}]{x,y,z} &\coloneq \pdv[order={i,j,k}]{}{x,y,z}
	\end{align*}
	respectively.
\end{function}

\begin{function}{\mdif}[updated=v1.1]
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{variables}
	\end{syntax}
	Another commonly used shorthand notation for derivatives is the differential with an uppercase D. In this package it is defined with a upright D when \keyval[cat=misc]{upright}{true}. Otherwise, it is defined with an italic D.
	\begin{definition}
		\DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single,
		style-notation-*=mixed]%\marginnote{\keyval[cat=misc]{upright}{true}}%
		\DeclareDifferential{\mdif}{\mathnormal{D}}[style-notation=single,
		style-notation-*=mixed%\marginnote{\keyval[cat=misc]{italic}{true}}%
	\end{definition}
	
	\noindent The non-star and star version gives
	\begin{align*}
		\mdif[order={i,j,k}]{x,y,z} \\
		\mdif*[order={i,j,k}]{x,y,z}
	\end{align*}
	respectively.
\end{function}

\begin{function}{\fdif}
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{variables}
	\end{syntax}
	When working with functional derivatives, another commonly used differential is one that uses a delta symbol. It is defined as follows:
	\begin{definition}
		\DeclareDifferential{\fdif}{\delta}
	\end{definition}
	
	\noindent For example, in expression like:
	\begin{align*}
		\fdif{J} = \int_{a}^{b} \pdv{L}{f} \fdif{f(x)} + \pdv{L}{f'} \odv*{ \fdif{f(x)} }{x} \odif{x}
	\end{align*}
	this differential is frequently encountered.
\end{function}

\begin{function}{\adif}
	\begin{syntax}
		\sarg, \oarg{keyval list}, \marg{variables}
	\end{syntax}
	A differential for differences that uses a uppercase delta is defined as
	\begin{definition}
		\DeclareDifferential{\adif}{\Delta}
	\end{definition}
	
	\noindent For example, the difference between two energy levels can be written as:
	\begin{align*}
		\adif{E} = E_2 - E_1
	\end{align*}
\end{function}
	
	\clearpage
	\section{Options}
This package accepts its options using the familiar \emph{key=value} syntax. The keys are divided into categories, with each key having its associated category as a prefix.

\begin{function}{\derivset}[updated = v1.0]
	\begin{syntax}
		\marg{command}, \oarg{keyval list}
	\end{syntax}
	The \macro{1} command is used to set default values for derivative and differential options in the preamble. While it can be used within the document, the new \oarg{keyval list} arguments in the derivative and differential commands allow for more flexibility in specifying options on a per-use basis.
	
	\begin{argument}{1}
		The mandatory argument determines which command the \emph{key=value} pairs are assigned to. The allowed \meta{commands} are the derivatives and differentials defined by the package, as well as any additional derivatives and differentials you have defined (see \cref{ssec:defvar_dv,ssec:defvar_inf} for more information). Additionally, the special value \texttt{all} is allowed, which provides access to the options that apply to all derivatives and differentials.
		\begin{example}
			\derivset{\odv}[switch-*=true] \odv{y}{x} \\
			\derivset{\odif}[switch-*=true] \odif{y}{x}
		\end{example}
	\end{argument}
	
	\begin{argument}{2}
		The optional argument accepts input as a comma-separated list of \emph{key=value} pairs. If \arg{2} is omitted, the options will be set to the package's default settings for the chosen \arg{1}. For example, using the \macro{\derivset}[\narg{\macro{\odv}}] command will set the options for the ordinary derivative to the default settings defined by the package.
		\begin{example}
			\derivset{\odv}[switch-*=false] \odv{y}{x} \odv*{y}{x} \\
			\derivset{\odv}[switch-*=true] \odv{y}{x} \odv*{y}{x} \\
			\derivset{\odv} \odv{y}{x} \odv*{y}{x}
		\end{example}
	\end{argument}
\end{function}

\subsection{Categories}
This section seeks to give a detailed description of each category.

\begin{itemize}
	\item The \key[index=false]{style-\meta{\dots}} keys allow you to customize the style of derivatives or differentials by specifying options such as the fraction command, infinitesimal notation (e.g., $d$, $\partial$) and its font, and variable treatment.
	\item The \key[index=false]{delims-\meta{\dots}} keys sets the delimiters used around the \meta{\dots}. The Rule of Two applies: \enquote{Always two there are, no more, no less. A left and a right delimiter}. Only delimiters that can be scaled with commands like \cs{left}, \cs{big}, etc., are allowed.
	\item The \key[index=false]{scale-\meta{\dots}} keys sets the size of the \meta{\dots}'s delimiters. The values \val{big}, \val{Big}, \val{bigg}, and \val{Bigg} are self-explanatory. The value \val{none} leaves the delimiters unscaled (except for periods, which are removed). The value \val{auto} automatically scales the delimiters using \cs{left} and \cs{right}.
	\item The \key[index=false]{sep-\meta{\dots}-\meta{\dots}} keys inserts their value between \meta{\dots} and \meta{\dots}. If the value is a comma-separated list of up to three numbers (e.g. \texttt{\{1,2,3\}}) it is converted into the syntax \texttt{\cs{muskip} 1 mu plus 2 mu minus 3 mu} and used accordingly. For other values, they are used as given without any conversion.
	\item The \key[index=false]{switch-\meta{\dots}} keys allow you to change the behaviour of an argument by swapping the effect of the presence or absence of an optional character argument.
	\item The \key[index=false]{sort-\meta{\dots}} keys handle the sorting algorithm used for the mixed order. These keys allow you to choose the sorting method that best suits your preferences.
	\item The miscellaneous keys do not fall into any of the previously mentioned categories and does not have a prefix.
\end{itemize}

\begin{note}
	A value with a superscripted \texttt{R} indicates that it requires a specific package to be loaded. Additionally, some keys have multiple versions, denoted by \texttt{-/}, \texttt{-!}, and \texttt{-/!} at the end. These keys are specifically related to the slash and exclamation mark arguments. 
\end{note}

\subsection{Package options}
The package options can be used with the following syntax when loading the package in the preamble:
\begin{center}
	\ttfamily\small
	\cs{usepackage}\oarg{keyval list}\narg{derivative}
\end{center}

\begin{option}*{italic}[cat=misc, new = v1.1]
	\begin{values}[default = false]
		true, false
	\end{values}
	Sets the font style of the infinitesimals $d$ and $D$ used in \cs{odv}, \cs{mdv}, \cs{odif} and \cs{mdif} to italic using \cs{mathnormal}. The \key[cat=misc,index=false]{italic} and \key[cat=misc,index=false]{upright} options are mutually exclusive.
\end{option}

\begin{option}{upright}[cat=misc, new = v1.1]
	\begin{values}[default = true]
		true, false
	\end{values}
	Sets the font style of the infinitesimals $d$ and $D$ used in \cs{odv}, \cs{mdv}, \cs{odif} and \cs{mdif} to upright using \cs{mathrm}. The \key[cat=misc,index=false]{italic} and \key[cat=misc,index=false]{upright} options are mutually exclusive.
\end{option}

\subsection{Derivative options} \label{ssec:options_dv}
The options in this subsection are available fo  customizing the behaviour of derivatives defined by the package and you.% using the commands described in \cref{ssec:defvar_dv}.

\subsubsection*{Style}

\begin{option}*{style-inf}[updated = {v1.0, v1.3}]
	\begin{values}[default = ]
		\meta{math-font-style}\meta{infinitesimal}
	\end{values}
	Sets the infinitesimal used in the derivative. This is a meta key, which means it sets the value of both \key{style-inf-num} and \key{style-inf-den} at the same time.
	\begin{example}
		\odv[style-inf=\symbf{d}]{f}{x}
	\end{example}
\end{option}

\begin{option}{style-inf-num}[new = v1.3]
	\begin{values}[default = d]
		\meta{math-font-style}\meta{infinitesimal}
	\end{values}
	Sets the infinitesimal used in the numerator of the derivative. This option is also used in the shorthand versions, i.e., when the exclamation mark argument is used. The default infinitesimal is a plain \default.
	\begin{example}
		\odv[style-inf-num=\mathbf{d}]{f}{x} \\
		\odv[style-inf-num=\mathbf{d}]{f}!{x}
	\end{example}
\end{option}

\begin{option}{style-inf-den}[new = v1.3]
	\begin{values}[default = d]
		\meta{math-font-style}\meta{infinitesimal}
	\end{values}
	Sets the infinitesimal used in the denominator of the derivative. The default infinitesimal is a plain \default.
	\begin{example}
		\odv[style-inf-den=\mathbf{d}]{f}{x}
	\end{example}
\end{option}

\begin{option}{style-frac}
	\begin{values}[default = \cs{frac}]
		\meta{fraction}
	\end{values}
	The derivative uses the fraction set by this key when the slash argument is absent. If \keyval{switch-/}{true}, the derivative uses this fraction when the slash argument is present. The key's default value is the usual fraction \cs{frac}.
	\begin{example}
		\odv[style-frac=\tfrac]{f}{x} \\
		\odv[switch-/=true, style-frac=\tfrac]{f}/{x}
	\end{example}
\end{option}

\begin{option}{style-frac-/}
	\begin{values}[default = \cs{slashfrac}]
		\meta{fraction}
	\end{values}
	The derivative uses the fraction set by this key when the slash argument is present. If \keyval{switch-/}{true}, the derivative uses this fraction when the slash argument is absent. The key's default value is a text-styled fraction \val{\default}\footref{foot:sfrac} on the form $\odv[style-frac-/=\slashfrac, switch-/=false]{f}/{x}$.
	\begin{example}
		\odv[style-frac-/=\sfrac]{f}/{x}
	\end{example}
\end{option}

\begin{option}{style-var}[new = v1.0]
	\begin{values}[default = single]
		single, multiple
	\end{values}
	This option determines how the derivative treats its variables and orders when both the slash argument and the exclamation mark are absent assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}
	\begin{itemize}[widest = {\val{multiple}}, leftmargin =*]
		\item[\val{single}] The derivative behaves like a ordinary derivative, treating the variable argument and order as single entities.
		\item[\val{multiple}] The derivative behaves like a partial derivative, treating the variable argument as a list of comma-separated variables. The mixed order is automatically calculated and sorted based on the \keyval[cat=misc]{order}{\meta{cs-orders}} key. See \cref{ssec:overall_order} for limitations on the automatic calculation.
	\end{itemize}
	%This option determines how the derivative treats its variables. The variable argument is treated as a single variable and the order is treated as a single order when \val{single} is used. The variable argument is treated as a comma separated list of variables with \val{multiple} similarly to a partial derivative. Moreover the mixed order is automatically calculated from the list of orders given in \keyval[cat=misc]{order}{\meta{order}}.
	\begin{example}
		\pdv[style-var=single, order={1,2,3}]{f}{x,y,z} \\
		\pdv[style-var=multiple]{f}{x,y,z}
	\end{example}
\end{option}

\begin{option}{style-var-/}[new = v1.3]
	\begin{values}[default = single]
		single, multiple
	\end{values}
	This option behaves identically to \key{style-var}, however it is used when the slash argument is present and the exclamation mark is absent assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}.
	\begin{example}
		\pdv[style-var-/=single, order={1,2,3}]{f}/{x,y,z} \\
		\pdv[style-var-/=multiple]{f}/{x,y,z}
	\end{example}
\end{option}

\begin{option}{style-var-!}[new = v1.3]
	\begin{values}[default = multiple]
		single, multiple, mixed
	\end{values}
	This options determines the shorthand notation of the derivative when the slash argument is absent and the exclamation mark is present assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}.
	\begin{itemize}[widest = {\val{multiple}}, leftmargin =*]
		\item[\val{single}] Creates a single differential with variables as subscripts and orders as superscripts.
		\item[\val{multiple}] Creates a separate differential for each variable.
		\item[\val{mixed}] Creates a separate differential for each variable but with variables as subscripts and orders as superscripts.
	\end{itemize}
	%When \val{single} is used, a single differential is created with the variables and orders in a subscript and superscript, respectively. The value \val{multiple} creates a differential for each variable. While the value \val{mixed} creates differentials their variable and order in a subscript and superscript, respectively.
	\begin{example}
		\pdv[style-var-!=single]{f}!{x,y,z} \\
		\pdv[style-var-!=multiple]{f}!{x,y,z} \\
		\pdv[style-var-!=mixed]{f}!{x,y,z}
	\end{example}
\end{option}

\begin{option}{style-var-/!}[new = v1.3]
	\begin{values}[default = single]
		single, multiple, mixed
	\end{values}
	This option behaves identical to \key{style-var-!}, however it is used when both the exclamation mark and slash arguments are present assuming \keyval{switch-/}{false} and \keyval{switch-!}{false}.
	\begin{example}
		\pdv[style-var-/!=single]{f}/!{x,y,z} \\
		\pdv[style-var-/!=multiple]{f}/!{x,y,z} \\
		\pdv[style-var-/!=mixed]{f}/!{x,y,z}
	\end{example}
\end{option}

\subsubsection*{Scaling}

\begin{option}*{scale-eval}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used for the point of evaluation. It is applied when the slash argument is absent, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-eval=auto]{f}{x,y}_{(x_0,y_0)}\\
		\pdv[scale-eval=auto]{f}!{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{scale-eval-/}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used for the point of evaluation. It is applied when the slash argument is present, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-eval-/=none]{f}/{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{scale-eval-!}[new = v1.3]
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used for the point of evaluation. It is applied when the exclamation mark argument is present, assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters. This option takes priority over \key{scale-eval-/} when the slash argument is also present.
	\begin{example}
		\pdv[scale-eval-!=Big]{f}!{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{scale-fun}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used around the function. It is applied when \keyval[cat=misc]{fun}{true}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-fun=big, fun]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{scale-var}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is absent assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-var=Big, var]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{scale-var-!}[new = v1.3]
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is present assuming \keyval{switch-!}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-var-!=big, var]{f}!{x,y}
	\end{example}
\end{option}

\begin{option}{scale-frac}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used for around the fraction. It is applied when the slash argument is absent and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-frac=bigg, frac]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{scale-frac-/}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used for around the fraction. It is applied when the slash argument is present and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\pdv[scale-frac-/=Bigg, frac]{f}/{x,y}
	\end{example}
\end{option}

\subsubsection*{Delimiters}

\begin{option}*{delims-eval}
	\begin{values}[default = .~\cs{rvert}]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is absent, assuming \keyval{switch-/}{false}. The key's default delimiters are a period and a vertical line.
	\begin{example}
		\pdv[delims-eval=.|]{f}{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{delims-eval-/}
	\begin{values}[default = .~\cs{rvert}]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is present, assuming \keyval{switch-/}{false}. The key's default delimiters are a period and a vertical line.
	\begin{example}
		\pdv[delims-eval-/=[]]{f}/{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{delims-eval-!}[new = v1.3]
	\begin{values}[default = .~\cs{rvert}]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used to indicate the point of evaluation. These delimiters are used when the slash argument is present, assuming \keyval{switch-!}{false}. The key's default delimiters are a period and a vertical line. This option takes priority over \key{delims-eval-/} when the slash argument is also present.
	\begin{example}
		\pdv[delims-eval-!=[]]{f}!{x,y}_{(x_0,y_0)}
	\end{example}
\end{option}

\begin{option}{delims-fun}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used around the function. These delimiters are used when \keyval[cat=misc]{fun}{true}. The key's default delimiters are parentheses.
	\begin{example}
		\pdv[delims-fun=\langle\rangle, fun]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{delims-var}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is absent assuming \keyval{switch-!}{false}. The key's default delimiters are parentheses.
	\begin{example}
		\pdv[delims-var=\{\}, var]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{delims-var-!}[new = v1.3]
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the exclamation mark argument is present assuming \keyval{switch-!}{false}. The key's default delimiters are parentheses.
	\begin{example}
		\pdv[delims-var-!=\lceil\rceil, var]{f}!{x,y}
	\end{example}
\end{option}

\begin{option}{delims-frac}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets delimiters used around the fraction in the derivative. These delimiters are used when the slash argument is absent and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The key's default delimiters are parentheses.
	\begin{example}
		\pdv[delims-frac=||, frac]{f}{x,y} \\
		\pdv*[delims-frac=||, frac=true]{y}{x}
	\end{example}
\end{option}

\begin{option}{delims-frac-/}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets delimiters used around the fraction in the derivative. These delimiters are used when the slash argument is present and \keyval[cat=misc]{frac}{true}, assuming \keyval{switch-/}{false}. The key's default delimiters are parentheses.
	\begin{example}
		\pdv[delims-frac-/=\|\|, frac]{f}/{x,y} \\
		\pdv*[delims-frac-/=\|\|, frac]{f}/{x,y}
	\end{example}
\end{option}

\subsubsection*{Math spacing and separators}
%The options in this subsection insert additional horizontal math space or separators in specific positions. The equations below illustrates where the space is inserted for each option:%TODO - math space should probably be seperator instead
%\begin{align*}
%	\begin{gathered}
%		\frac{ \partial }{ \partial x } \ms{frac-fun} f \\
%		\frac{ \partial^{ \ms{inf-ord} 2 } f }{ \partial x^{ \ms{var-ord} 2 } }
%	\end{gathered}
%	&&
%	\begin{gathered}
%		\frac{ \partial \ms{inf-fun} f }{ \partial \ms{inf-var} x } \\
%		\frac{ \partial^3 \ms{ord-fun} f }{ \partial x^2 \ms{ord-inf} \partial y }
%	\end{gathered}
%	&&
%	\begin{gathered}
%		\frac{ \partial^2 f }{ \partial x \ms{var-inf} \partial y }   \\
%		\mleft( \frac{ \partial f}{ \partial x } \mright)_{ \ms{eval-sb} x_1}^{ \ms{eval-sp} x_2}
%	\end{gathered}
%\end{align*}
%where it have been split into six to give a better overview. Here $\ms{\dots}$ means the value given to the option \key[index=false]{sep-\meta{\dots}}. Some of the math spaces shown above are only used when \keyval[index=false]{style-var}{multiple}. Additionally, when the option \keyval[index=false]{style-var}{single} is used then the following math space is used in the denominator
%%Please note that some of the math spaces shown above are only used when \key[index=false]{style-var} is set to \val{multiple}. Additionally, when \key[index=false]{style-var} is set to \val{single}, the following math space is used in the denominator:
%\begin{equation*}
%	\frac{\partial(f, g)}{\partial(x \ms{var-var} y)}
%\end{equation*}
%where the Jacobian is used as an example.

\begin{option}{sep-inf-ord}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted to the left of the infinitesimal's power when the (mixed) order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-inf-ord=\here]{f}{x,y} \\
		\pdv[sep-inf-ord=\here, order=2]{f}!{x,y} \\
		\pdv[sep-inf-ord=\here, order=2]{f}/!{x,y}
	\end{example}
\end{option}

\begin{option}{sep-inf-fun}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between the infinitesimal and the function when the (mixed) order \emph{is equal} to \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-inf-fun=\here]{f}{x}
	\end{example}
\end{option}

\begin{option}{sep-ord-fun}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between the function and the infinitesimal's order when the order \emph{is different} from \num{1}. The space is only inserted when a non-blank function is printed \emph{in the numerator}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-ord-fun=\here]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{sep-frac-fun}[new = v1.0]
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between the fractional part of the derivative and the function when a non-blank function is printed \emph{next to the derivative}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv*[sep-frac-fun=\here]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{sep-inf-var}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between the infinitesimal and the following non-blank variable. In shorthand mode, the order must also \emph{be different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-inf-var=\here, order=2]{f}{x,y} \\
		\pdv[sep-inf-var=\here, order=2]{f}!{x,y} \\
		\pdv[sep-inf-var=\here, order=2]{f}/!{x,y}
	\end{example}
\end{option}

\begin{option}{sep-var-ord}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted to the left of the variable's power when its order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}.
	%This key sets the separator that is inserted in a variable's power left to the order. The space is only inserted when the order \emph{is different} from \num{1}. The key's default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-var-ord=\here, order=n]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{sep-var-inf}
	\begin{values}[default = \cs{mathop}\{\}\cs{!}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between a variable and the following infinitesimal when more than one \emph{non-blank} variables are given. In fraction mode, it is also required that the variable's order \emph{is equal} to \num{1}. The default value is \val{\default}.
	\begin{example}
		\pdv[sep-var-inf=\here, order=n]{f}{x,y,z}\\
		\pdv[sep-var-inf=\here, order=n]{f}!{x,y,z}\\
		\pdv[sep-var-inf=\here, order=n]{f}/!{x,y,z}
	\end{example}
\end{option}

\begin{option}{sep-ord-inf}
	\begin{values}[default = \cs{mathop}\{\}\cs{!}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between an order and the following infinitesimal when more than one \emph{non-blank} variables are given. In fraction mode, it is also required that the variable's order \emph{is different} from \num{1}. The default value is \val{\default}.
	\begin{example}
		\pdv[sep-ord-inf=\here, order=n]{f}{x,y,z}
	\end{example}
\end{option}

\begin{option}{sep-ord-ord}[new = v1.3]
	\begin{values}[default = {{,}}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between two orders when more than one \emph{non-blank} variables are given in shorthand notation when it is set to \val{single}. The default value is a comma.
	\begin{example}
		\odv[sep-ord-ord=\here, order={n,2}]{f}/!{x,y}
	\end{example}
\end{option}

\begin{option}{sep-ord-var}[new = v1.3]
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between an order and the following variable in shorthand notation when it is set to \val{multiple}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\odv[sep-ord-var=\here, order=n]{f}!{x,y}
	\end{example}
\end{option}

\begin{option}{sep-var-var}[new = v1.0]
	\begin{values}[default = {{,}}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between two variables when more than one \emph{non-blank} variables are given in shorthand notation when it is set to \val{single}. The default value is a comma.
	\begin{example}
		\odv[sep-var-var=\here]{f}{x,y} \\
		\odv[sep-var-var=\here]{f}/!{x,y}
	\end{example}
\end{option}

\begin{option}{sep-eval-sb}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted in the evaluation subscript left to the point of evaluation when a \emph{non-blank} subscript is given. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-eval-sb=\here]{f}{x,y}_{(x_1,y_1)}
	\end{example}
\end{option}

\begin{option}{sep-eval-sp}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted in the evaluation superscript left to the point of evaluation when a \emph{non-blank} superscript is given. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\pdv[sep-eval-sp=\here]{f}{x,y}^{(x_2,y_2)}
	\end{example}
\end{option}

\subsubsection*{Switches}

\begin{option}*{switch-*}
	\begin{values}[default = false]
		true, false
	\end{values}
	The effect of the star argument can be toggled with the value \val{true}.
	%That is, the function is typeset next to the fraction when the star is absent and in the numerator when the star is present. 
	For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}.
	\begin{example}
		\pdv[switch-*=false]{f}{x,y} \\
		\pdv[switch-*=true]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{switch-/}
	\begin{values}[default = false]
		true, false
	\end{values}
	The effect of the slash argument can be toggled with the value \val{true}.
	%That is, the derivative is typeset with the fraction set by \key{style-frac-/} when the slash is absent and with the fraction set by \key{style-frac} when the slash is present.
	For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}).	The default value is \val{\default}.
	\begin{example}
		\pdv[switch-/=false]{f}{x,y} \\
		\pdv[switch-/=true]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{switch-!}[new = 1.3]
	\begin{values}[default = false]
		true, false
	\end{values}
	The effect of the exclamation mark argument can be toggled with the value \val{true}.
	%That is, the derivative is in shorthand mode the exclamation mark is absent and in fraction mode when the exclamation is present. 
	For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}.
	\begin{example}
		\pdv[switch-!=false]{f}{x,y} \\
		\pdv[switch-!=true]{f}{x,y}
	\end{example}
\end{option}

\begin{option}{switch-sort}[new = 1.2]
	\begin{values}[default = true]
		true, false
	\end{values}
	This options disables (\val{false}) and enables (\val{true}) the sorting algorithm behind the mixed order. The sorting algorithm is only used/available in fraction mode when it is \val{multiple}. When disabled, the terms in the mixed order are arranged according to their first appearance in \keyval*[cat=misc,index=false]{order}{\dots}. Compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}.
	%When the value \val{true} is given, the mixed order sorting algorithm is activated, applying the methods specified in \keyval*{sort-method}{\dots}. Conversely, when the value \val{false} is given, the sorting algorithm is deactivated, and the terms in the mixed order are arranged according to their first appearance in \keyval*{order}{\dots}. Here's a comparison example with the option enabled (\val{true}) and disabled (\val{false}).
	\begin{example}
		\pdv[switch-sort=false, order={a+b,2kn-d,2-2b}]{f}{x,y,z} \\
		\pdv[switch-sort=true, order={a+b,2kn-d,2-2b}]{f}{x,y,z}
	\end{example}
\end{option}

\subsubsection*{Sort}
The keys mentioned in this subsection will be briefly described here, with a more detailed explanation provided in \cref{ssec:overall_order}.

\begin{option}{sort-method}[updated = v1.2]
	\begin{values}[default = {sign, symbol, abs}]
		abs, lexical, number, sign, symbol
	\end{values}
	Sets the sorting method for the mixed order using build-in algorithms.
	\begin{itemize}[widest = {\val{lexical}}, leftmargin =*]
		\item[\val{abs}] Sorts terms in descending order based on their absolute value.
		\item[\val{lexical}] Sorts terms alphabetically in lexicographical ascending order.
		\item[\val{number}] Sorts terms in descending order based on their numerical value.
		\item[\val{sign}] Sorts terms by their sign, placing positive terms before the negative terms.
		\item[\val{symbol}] Sorts terms in descending order based on their symbolic length.
	\end{itemize}
	This option accepts a comma-separated list of values, allowing up to three values. For example:
	\begin{example}
		\pdv[sort-method=abs, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method=lexical, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method=number, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method=symbol, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method=sign, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method={sign,abs}, order={kn-c,2a-3b}]{f}{x,y} \\
		\pdv[sort-method={sign,symbol,abs}, order={kn-c,2a-3b}]{f}{x,y}
	\end{example}
	Notice the different term ordering achieved with each method. For a more detailed explanation of this key, see \cref{ssec:sort-method} for more information. The default value uses the three algorithms \val{\default}.
\end{option}

\begin{option}{sort-numerical}[updated = v1.0]
	\begin{values}[default = auto]
		auto, first, last, symbolic
	\end{values}
	Determines the placement of the numerical term\footnote{The numerical term refers to the sum of all orders that consist solely of numbers and do not include any symbols.\label{foot:numerical-term}} in the mixed order. The placement options are as follows:
	\begin{itemize}[widest=\val{symbolic}, leftmargin=*]
		\item[\val{first}] Always places the numerical term as the first term in the mixed order.
		\item[\val{last}] Always places the numerical term as the last term in the mixed order.
		\item[\val{auto}] After sorting, the numerical term is automatically positioned based on the sign of the first symbolic term. If positive, the numerical term is placed last. If negative, the numerical term is placed first.
		\item[\val{symbolic}] Treats the numerical term as a symbolic term with a symbolic length of zero and sorts it alongside all other terms.
	\end{itemize}
	Here are some examples to illustrate the different placements of the numerical term:
	\begin{example}
		\pdv[sort-numerical=first, order={n,2}]{f}{x,y} \\
		\pdv[sort-numerical=last, order={-n,2}]{f}{x,y} \\
		\pdv[sort-numerical=auto, order={n,2}]{f}{x,y} \\
		\pdv[sort-numerical=auto, order={-n,2}]{f}{x,y} \\
		\pdv[sort-numerical=symbolic, order={2+n,-a}]{f}{x,y}
	\end{example}
	This key is further described in \cref{ssec:sort-numerical}. The default value is \val{\default}.
\end{option}

\begin{option}{sort-abs-reverse}
	\begin{values}[default = false]
		true, false
	\end{values}
	When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information.
	\begin{example}
		\pdv[sort-abs-reverse=false, sort-method=abs, order=2a-3b]{f}{x} \\
		\pdv[sort-abs-reverse=true, sort-method=abs, order=2a-3b]{f}{x}
	\end{example}
\end{option}

\begin{option}{sort-lexical-reverse}[new = v1.2]
	\begin{values}[default = false]
		true, false
	\end{values}
	When the value \val{true} is used with this option, the sorting order is reversed to lexicographical descending order. See \cref{ssec:sort-reverse} for more information.
	\begin{example}
		\pdv[sort-lexical-reverse=false, sort-method=lexical, order=a+b]{f}{x} \\
		\pdv[sort-lexical-reverse=true, sort-method=lexical, order=a+b]{f}{x}
	\end{example}
\end{option}

\begin{option}{sort-number-reverse}[new = v1.0]
	\begin{values}[default = false]
		true, false
	\end{values}
	When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information.
	\begin{example}
		\pdv[sort-number-reverse=false, sort-method=number, order=2a-3b]{f}{x} \\
		\pdv[sort-number-reverse=true, sort-method=number, order=2a-3b]{f}{x}
	\end{example}
\end{option}

\begin{option}{sort-sign-reverse}
	\begin{values}[default = false]
		true, false
	\end{values}
	When the value \val{true} is used with this option, the sorting order is reversed, placing negative terms before the positive terms. See \cref{ssec:sort-reverse} for more information.
	\begin{example}
		\pdv[sort-sign-reverse=false, sort-method=sign, order=a-b]{f}{x} \\
		\pdv[sort-sign-reverse=true, sort-method=sign, order=a-b]{f}{x}
	\end{example}
\end{option}

\begin{option}{sort-symbol-reverse}
	\begin{values}[default = false]
		true, false
	\end{values}
	When the value \val{true} is used with this option, the sorting order is reversed to ascending order. See \cref{ssec:sort-reverse} for more information.
	\begin{example}
		\pdv[sort-symbol-reverse=false, sort-method=symbol, order=ab+c]{f}{x} \\
		\pdv[sort-symbol-reverse=true, sort-method=symbol, order=ab+c]{f}{x}
	\end{example}
\end{option}

\subsubsection*{Miscellaneous}

\begin{option}*{fun}[cat=misc, new = v1.0]
	\begin{values}[default = false]
		true, false
	\end{values}
	This option allows you to add (\val{true}) or remove (\val{false}) delimiters around the function. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{fun}{true}. By default, the value is \val{\default}.
	\begin{example}
		\pdv[fun=false]{f}{x} \\
		\pdv[fun=true]{f}{x} \\
		\pdv[fun]{f}{x}
	\end{example}
	%Without setting the option to a value is equivalent to setting it to \val{true} as seen above.
\end{option}

\begin{option}{frac}[cat=misc, new = v1.0]
	\begin{values}[default = false]
		true, false
	\end{values}
	This option allows you to add (\val{true}) or remove (\val{false}) delimiters around the fractional part of the derivative. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{frac}{true}. By default, the value is \val{\default}.
	\begin{example}
		\pdv[frac=false]{f}{x} \\
		\pdv[frac=true]{f}{x} \\
		\pdv*[frac=true]{f}{x} \\
		\pdv[frac]{f}{x}
	\end{example}
\end{option}

\begin{option}{var}[cat=misc, new = v1.0]
	\begin{values}[default=none]
		none, all, \meta{cs-numbers}
	\end{values}
	This option allows you to add or remove delimiters around the variables. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. If only specific variables require delimiters, you can use \meta{cs-numbers}. For example, \keyval*[cat=misc,index=false]{var}{1,3} adds delimiters around the first and third variables. Note that if the option is not explicitly set, it is considered equivalent to \keyval[cat=misc,index=false]{var}{all}. By default, the value is \val{\default}.
	\begin{example}
		\pdv[var=none]{f}{x,y,z,t} \\
		\pdv[var={1,3}]{f}{x,y,z,t} \\
		\pdv[var=all]{f}{x,y,z,t} \\
		\pdv[var]{f}{x,y,z,t}
	\end{example}
\end{option}

\begin{option}{order, ord}[cat=misc, new = v1.0]
	\begin{values}[default = 1]
		\marg{cs-orders}
	\end{values}
	Sets the order of differentiation for each variable as a comma separated list of values.
	\begin{example}
		\pdv[order={2,3}]{f}{x,y,z} \\
		\pdv[order={\beta,a,n+2a}]{f}{x,y,z} \\
		\pdv[order={2,n^2,n^2-1}]{f}{x,y,z} \\
		\pdv[order={3/2-n/3,n/2,1/3}]{f}{x,y,z}
	\end{example}
\end{option}

\begin{option}{mixed-order, mixord}[cat=misc, new = v1.0]
	\begin{values}[default = 1]
		\marg{mixed order}
	\end{values}
	This option allows you to manually specify the mixed order of differentiation, overriding the automatically calculated value based on the orders set by \keyval[cat=misc]{order}{\marg{orders}}. In cases where the automatic calculation fails or when a different form is preferred, you can use this option to set the desired mixed order.
	\begin{example}
		\pdv[order={n+3k, n-k}]{f}{x,y} \\
		\pdv[order={n+3k, n-k}, mixed-order={2(n+k)}]{f}{x,y}
	\end{example}
\end{option}

\subsection{Differential options} \label{ssec:options_inf}
The options in this subsection are available for customizing the behaviour of differentials defined by the package and you.

\subsubsection*{Style}

\begin{option}*{style-inf}
	\begin{values}[default = d]
		\meta{math-font-style}\meta{infinitesimal}
	\end{values}
	Sets the infinitesimal used in the differential. The default infinitesimal is a plain \default.
	\begin{example}
		\odif[style-inf=\mathbf{d}]{x_1,x_2,x_3}
	\end{example}
\end{option}

\begin{option}{style-var}[updated=1.3]
	\begin{values}[default = multiple]
		single, multiple, mixed
	\end{values}
	This options determines the shorthand notation of the differential when the star argument is absent assuming \keyval{switch-*}{false}.
	\begin{itemize}[widest = {\val{multiple}}, leftmargin =*]
		\item[\val{single}] Creates a single differential with variables as subscripts and orders as superscripts.
		\item[\val{multiple}] Creates a separate differential for each variable.
		\item[\val{mixed}] Creates a separate differential for each variable but with variables as subscripts and orders as superscripts.
	\end{itemize}
	\begin{example}
		\odif[style-var=multiple, order={n,1,2}]{x,y,z,t} \\
		\odif[style-var=single, order={n,1,2}]{x,y,z,t} \\
		\odif[style-var=mixed, order={n,1,2}]{x,y,z,t}
	\end{example}
\end{option}

\begin{option}{style-var-*}[updated=1.3]
	\begin{values}[default = single]
		single, multiple, mixed
	\end{values}
	This option behaves identically to \key{style-var}, however it is used when the star argument is present assuming \keyval{switch-*}{false}.
\end{option}

\subsubsection*{Scaling}

\begin{option}{scale-var}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is absent assuming \keyval{switch-*}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\odif[scale-var=none, var]{r,\theta,\varphi}\\
		\odif[scale-var=Big, var]{r,\theta,\varphi}
	\end{example}
\end{option}

\begin{option}{scale-var-*}
	\begin{values}[default = auto]
		auto, none, big, Big, bigg, Bigg
	\end{values}
	Sets the size of the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is present assuming \keyval{switch-*}{false}. The default behaviour is to automatically scale the delimiters.
	\begin{example}
		\odif*[scale-var-*=auto, var]{r,\theta,\varphi}\\
		\odif*[scale-var-*=big, var]{r,\theta,\varphi}
	\end{example}
\end{option}

\subsubsection*{Delimiters}

\begin{option}{delims-var}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is absent assuming \keyval{switch-*}{false}. The default delimiters are parentheses.
	\begin{example}
		\odif[delims-var=\{\}, var]{x,y}\\
		\odif[delims-var=[], var]{x,y}
	\end{example}
\end{option}

\begin{option}{delims-var-*}
	\begin{values}[default = (~)]
		\meta{left delimiter}\meta{right delimiter}
	\end{values}
	Sets the delimiters used around the variables specified by the \keyval*[cat=misc,index=false]{var}{\dots} option when the star argument is present assuming \keyval{switch-*}{false}. The default delimiters are parentheses.
	\begin{example}
		\odif*[delims-var-*=\|\|, var]{x,y}\\
		\odif*[delims-var-*=\langle\rangle, var]{x,y}
	\end{example}
\end{option}

\subsubsection*{Math spacing and separators}
%The options in this subsection inserts additional horizontal math space in specific positions. The equations below illustrates where the space is inserted for each option:%TODO - math space should probably be seperator instead
%\begin{align*}
%	\begin{gathered}
%		\partial \ms{inf-var} x \ms{var-inf} \partial y \\
%		\partial^{ \ms{inf-ord} 2 } \ms{ord-var} x
%	\end{gathered}
%	&&
%	\begin{gathered}
%		\ms{begin} \partial x \ms{end} \\
%		\partial^{ 2\ms{ord-ord} 2 }_{ x \ms{var-var} y }
%	\end{gathered}
%\end{align*}

\begin{option}{sep-begin}
	\begin{values}[default = \cs{mathop}\{\}\cs{!}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted at the beginning of the expression. The default value is \val{\default}.
	\begin{example}
		\odif[sep-begin=\here]{x,y,z}
	\end{example}
\end{option}

\begin{option}{sep-inf-ord}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted to the left of the infinitesimal's power when the order \emph{is different} from \num{1}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\odif[sep-inf-ord=\here, order=2]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-inf-var}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between the infinitesimal and the following non-blank variable when the associated order \emph{is equal} to \num{1}. The key's default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\odif[sep-inf-var=\here, order=2]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-ord-var}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between an order and the following non-blank variable when the order \emph{is different} from \num{1}. This option is only available when the style is set to \val{multiple}. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\odif[sep-ord-var=\here, order=2]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-var-inf}
	\begin{values}[default = \cs{mathop}\{\}\cs{!}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between a non-blank variable and the following infinitesimal when more than one non-blank variables are given. The default value is \val{\default}.
	\begin{example}
		\odif[sep-var-inf=\here]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-var-var}
	\begin{values}[default = {{,}}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between two variables when more than one non-blank variables are given. This option is only available when the style is set to \val{single}. The default value is a comma.
	\begin{example}
		\odif*[sep-var-var=\here]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-ord-ord}
	\begin{values}[default = {{,}}]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted between two orders that are both not equal to \num{1}. This option is only available when the style is set to \val{single}. The default value is a comma.
	\begin{example}
		\odif*[sep-ord-ord=\here, order={2,n}]{x,y}
	\end{example}
\end{option}

\begin{option}{sep-end}
	\begin{values}[default = 0]
		\meta{cs-number}, \marg{mspace}, \marg{delimiter}
	\end{values}
	Sets the separator that is inserted at the end of the expression. The default value corresponds to \val{\default} \texttt{mu}.
	\begin{example}
		\odif[sep-end=\here]{x,y}
	\end{example}
\end{option}

\subsubsection*{Switches}

\begin{option}*{switch-*}
	\begin{values}[default = false]
		true, false
	\end{values}
	The effect of the star argument can be toggled with the value \val{true}. For example, compare below where the option is disabled (\val{false}) and enabled (\val{true}). The default value is \val{\default}.
	\begin{example}
		\odif[switch-*=false]{x,y,z,t} \\
		\odif[switch-*=true]{x,y,z,t}
	\end{example}
\end{option}

\subsubsection*{Miscellaneous}

\begin{option}*{var}[cat=misc]
	\begin{values}[default=none]
		none, all, \meta{cs-numbers}
	\end{values}
	This option allows you to add or remove delimiters around the variables. The value \val{all} adds delimiters around all variables and \val{none} removed all delimiters. If only specific variables require delimiters, you can use \meta{cs-numbers}. For example, \keyval*[cat=misc,index=false]{var}{1,3} adds delimiters around the first and third variables. Note that if the option is not explicitly set, it is considered equivalent to \val{all}. By default, the value is \val{\default}.
	\begin{example}
		\odif[var=none]{x,y,z,t} \\
		\odif[var={1,3}]{x,y,z,t} \\
		\odif[var=all]{x,y,z,t} \\
		\odif[var]{x,y,z,t}
	\end{example}
\end{option}

\begin{option}{order, ord}[cat=misc]
	\begin{values}[default = 1]
		\marg{cs-orders}
	\end{values}
	Sets the order of differentiation for each variable as a comma separated list of values.
	\begin{example}
		\odif[order={2,3}]{x,y,z} \\
		\odif[order={\beta,a,n+2a}]{x,y,z}
	\end{example}
\end{option}

\subsection{All derivatives and differentials} \label{ssec:both_options}
The options in this subsection are applied to all derivatives and differentials because they define settings that should be consistent regardless of the specific derivative or differential. These options can be accessed using the command \macro{\derivset}[\narg{all},\oarg{key=value}].

The options in this subsection are applied to all derivatives and differential because some options should be consisting regardless of the derivative and differential. The options are accessed using \macro{\derivset}[\narg{all},\oarg{key=value}].
\begin{example}[result=false]
	\derivset{all}[key=value]
\end{example}

\begin{option}{scale-auto}[updated = v1.1]
	\begin{values}[default = {leftright or mleftmright\req}]
		leftright, mleftmright\req
	\end{values}
	Sets the automatic delimiter scaling commands. The value \val{leftright} sets them as \cs{left} and \cs{right} while \val{mleftmright} sets them as \cs{mleft} and \cs{mright} from the \pkg{mleftrigth} package. The default value is \val{leftright} unless \pkg{mleftright} is loaded, in which case it is \val{mleftmright}.
	\begin{example}
		\derivset{all}[scale-auto=leftright] a \pdv[frac]{f}{x} a\\
		\derivset{all}[scale-auto=mleftmright] a \pdv[frac]{f}{x} a
	\end{example}
	Notice the space difference between the a's and the parentheses in the two equations.
\end{option}

	
	\clearpage
	\section{Defining variants} \label{sec:defvar}
This section goes into detail on how to define derivative and differential variants based on the package's internal commands. The \mypackage{} package provides a \latex2-based approach to defining derivatives and differentials.

\subsection{Derivative variant} \label{ssec:defvar_dv}

\begin{function}*{\NewDerivative, \RenewDerivative, \ProvideDerivative, \DeclareDerivative}
	\begin{syntax}
		\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
	\end{syntax}
	This family of commands is used to define a derivative variant with the macro name \arg{1}. %The new derivative will use the infinitesimal \arg{2} and inherit the package's default settings given in \cref{ssec:options_dv}, which can be overwritten with \arg{3}. The difference between the commands is as follows:
	\begin{itemize}
		\item \macro{1} will issue an error if \arg{1} has already been defined.
		\item \macro{2} will issue an error if \arg{1} has not previously been defined.
		\item \macro{3} will define \arg{1} if it does not have an existing definition. It will not issue any errors.
		\item \macro{4} will always define the \arg{1} with the new definition regardless of whether it already exists.
	\end{itemize}
	Examples of their use can be found in \cref{sec:derivative}.
	
	\begin{argument}{1}
		The first argument specifies the macro name of the derivative being defined.
	\end{argument}
	
	\begin{argument}{2}
		The second argument sets the infinitesimal of the derivative \arg{1}. It is equivalent to setting \keyval{style-inf}{\arg{2}}.
	\end{argument}
	
	\begin{argument}{3}
		The optional argument accepts a comma-separated list of \emph{key=value} pairs, allowing you to override the package's default values for the keys given. If the optional argument is omitted, the derivative will use the package's default settings.
	\end{argument}
\end{function}

\subsection{Differential variant} \label{ssec:defvar_inf}

\begin{function}*{\NewDifferential, \RenewDifferential, \ProvideDifferential, \DeclareDifferential}
	\begin{syntax}
		\meta{control-sequence}, \marg{infinitesimal}, \oarg{key=value}
	\end{syntax}
	This family of commands is used to define a differential variant with the macro name \arg{1}. %The new differential will use the infinitesimal \arg{2} and inherit the package's default settings given in \cref{ssec:options_inf}, which can be overwritten with \arg{3}. The difference between the commands is as follows:
	
	\begin{itemize}
		\item \macro{1} will issue an error if \arg{1} has already been defined.
		\item \macro{2} will issue an error if \arg{1} has not previously been defined.
		\item \macro{3} will define \arg{1} if it does not have an existing definition. It will not issue any errors.
		\item \macro{4} will always define the \arg{1} with the new definition regardless of whether it already exists.
	\end{itemize}
	Examples of their use can be found in \cref{sec:differential}.
	
	\begin{argument}{1}
		The first argument specifies the macro name of the differential being defined.
	\end{argument}
	
	\begin{argument}{2}
		The second argument sets the infinitesimal of the differential \arg{1}. It is equivalent to setting \keyval{style-inf}{\arg{2}}.
	\end{argument}
	
	\begin{argument}{3}
		The optional argument accepts a comma-separated list of \narg{key=value} pairs, allowing you to override the package's default values for the keys given. If the optional argument is omitted, the derivative will use the package's default settings.
	\end{argument}
\end{function}


	
	\clearpage
	\section{The mixed order} \label{ssec:overall_order}
The algorithm used to calculate the mixed order is advanced and can handle a wide range of inputs, including numbers, symbols and fractions. It accurately parses the orders to generate the appropriate mixed order. Let's consider some examples to illustrate its capabilities:
\begin{example}
	\pdv[order={n+1,2}]{f}{x,y}\\
	\pdv[order={n+1,2n}]{f}{x,y}\\
	\pdv[order={n^2,n^2}]{f}{x,y}\\
	\pdv[order={2/n-1/2, 3/n+m/3}]{f}{x,y,z}
\end{example}
The algorithm handles these cases and calculates the mixed order correctly. However, there are certain limitations when dealing with parentheses, except for a specific case where there is a single term in the denominator. 
\begin{example}
	\pdv[order={2/n-1/2, 3/(2n)+m/3}]{f}{x,y}\\
	\pdv[order={(2n+m)/3, 3n+m/3}]{f}{x,y}\\
	\pdv[order={2/(2n+m), 1/(2(2n+m))}]{f}{x,y}
\end{example}
In the third equation, the mixed order doesn't make sense because the algorithm splits up the orders at $+$ and $-$ within parentheses without evaluating them correctly. For example, $2/(2n+m), 1/(2(2n+m))$ is incorrectly split into $2/(2n, m), 1/(2(2n, m))$. The same happens in the second equation. To address this limitation, the package provides the \key[cat=misc]{mixed-order} option, which overrides the incorrect output. You can specify the desired mixed order manually.
\begin{example}
	\pdv[order={(2n+m)/3, 3n+m/3}, mixord=8n/3+2m/3]{f}{x,y}\\
	\pdv[order={2/(2n+m), 1/(2(2n+m))}, mixord=5/(2(2n+m))]{f}{x,y}
\end{example}
By using the \key[cat=misc]{mixed-order} option, you can ensure that the mixed order is displayed correctly, even when the algorithm's output may be incorrect or when a different form is preferred.

\subsection{Sorting algorithms} \label{ssec:sort-method}
A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms. These algorithms are designed to offer variety of ways to sort the mixed order according to ones preferences.
\begin{itemize}[widest = {\val{lexical}}, leftmargin =*]
	\item[\val{abs}] Sorts terms based on their absolute value in descending order. By setting \keyval{sort-abs-reverse}{true}, terms are sorted in ascending order instead.
	\item[\val{lexical}] Sorts the terms alphabetically in lexicographical order. By setting \keyval{sort-lexical-reverse}{true}, terms are sorted in reverse lexicographical order.
	\item[\val{number}] Sorts terms based on their numerical value in descending order. By setting \keyval{sort-number-reverse}{true}, terms are sorted in ascending order instead.
	\item[\val{sign}] Sorts terms by their sign, placing positive terms before negative terms. By setting, \keyval{sort-sign-reverse}{true}, places negative terms before positive terms.
	\item[\val{symbol}] Sorts terms in descending order based on their symbolic length. By setting \keyval{sort-symbol-reverse}{true}, terms are sorted in ascending order instead.
\end{itemize}

The sorting method allows up to three algorithms given by \keyval*{sort-method}{algorithm1, algorithm2, algorithm3}. The list of orders is primarily sorted based on algorithm 1's condition. In case of ties, algorithm 2 is used for further sorting, and so on.

Consider the list \texttt{\{a,-c,-b,d\}} and the sorting method \keyval*{sort-method}{sign,lexical}. Initially, the \val{sign} algorithm sorts the list as \texttt{\{a,d,-c,-b\}}. However, due to ties, other valid orderings exist like \texttt{\{d,a,-c,-b\}}, \texttt{\{a,d,-b,-c\}} and \texttt{\{d,a,-b,-c\}}. Subsequently, the \val{lexical} algorithm sorts the tied values alphabetically as \texttt{\{a,d,-b,-c\}}.

\subsubsection{Examples}
The examples below use partial derivatives with \keyval*[cat=misc]{order}{3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}, along with a close-up view of the mixed order. Square brackets indicate how the terms was sorted by the applied algorithm. `Positive' and `negative', `long' and `short', and `big' and `low' refer to the \val{sign}, \val{symbol}, and \val{abs} algorithms, respectively.

The default sorting method is \keyval*{sort-method}{sign,symbol,abs} which is used below. The \val{sign} algorithm separate the positive and negative terms. Within each group, the \val{symbol} algorithm sorts the terms based on symbolic length. Finally, In the resulting four groups, the \val{abs} algorithm sorts the terms based on absolute value.
\begin{gather*}
	\pdv[sort-method = {sign,symbol,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\
	\low{
		\low{
			\low{4gg}{big} +
			\low[2,2]{2ff}{low}
		}{long} +
		\low{ 
			\low[1,2]{4c}{big} +
			\low[1,1]{3a}{low}
		}{short}
	}{positive} -
	\low{
		\low{
			\low[3,3]{5ee}{big} -
			\low[2,2]{3hh}{low}
		}{long} -
		\low{
			\low[1,1]{5d}{big} -
			\low[2,2]{2b}{low}
		}{short}
	}{negative}
\end{gather*}
By interchanging the \val{sign} and \val{symbol} algorithm in the previous example, then the \val{symbol} algorithm will be applied first and the \val{sign} algorithm handles the symbolic ties.
\begin{gather*}
	\pdv[sort-method = {symbol,sign,abs}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\
	\low{
		\low{
			\low{4gg}{big} +
			\low[2,2]{2ff}{low}
		}{positive} -
		\low{
			\low[3,3]{5ee}{big} -
			\low[2,2]{3hh}{low}
		}{negative}
	}{long} +
	\low{
		\low{
			\low[1,2]{4c}{big} +
			\low[1,1]{3a}{low}
		}{positive} -
		\low{
			\low[1,1]{5d}{big} -
			\low[2,2]{2b}{low}
		}{negative}
	}{short}
\end{gather*}

In contrast to the previous two examples with three algorithms, this example uses a sorting method with two algorithms: \keyval*{sort-method}{sign,symbol}. The terms are first sorted by sign and then by symbolic length.
\begin{gather*}
	\pdv[sort-method = {sign,symbol}, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\
	\low{
		\low{ 4gg + 2ff }{long} +
		\low{ 3a  + 4c  }{short}
	}{positive} -
	\low{
		\low{ 3hh - 5ee }{long} -
		\low{ 2b  - 5d  }{short}
	}{negative}
\end{gather*}
In the last example, a sorting method with a single algorithm, \keyval{sort-method}{symbol}, is used.
\begin{gather*}
	\pdv[sort-method = symbol, order={3a-3hh-2b, 4c+4gg+2ff, -5d-5ee}]{f}{x,y,z} \\
	\low{ - 3hh + 4gg + 2ff - 5ee }{long} +
	\low{   3a  - 2b  + 4c  - 5d  }{short}
\end{gather*}

\subsection{Treating the numerical term} \label{ssec:sort-numerical}
After handling the symbolic part of the mixed order, we now turn our attention to the numerical term\footref{foot:numerical-term}, which has a symbolic length of zero. For this reason it is treated differently than the symbolic terms. It can be placed either at the beginning or at the end of the mixed order by \val{first} and \val{last}, respectively. Alternatively, it is automatically positioned in the mixed order using \val{auto}. Setting \keyval{sort-numerical}{symbolic}, treats the numerical term as a symbolic term. Its behaviour is determined by the chosen algorithms in \keyval*{sort-method}{\dots}. In this example the sort method is the default value of the package.
\begin{align*}
	\text{\inlinecode{sort-numerical=auto:}}  && 
	\pdv[order={\beta, 2}, sort-numerical=auto]{f}{x,y}   &&
	\pdv[order={\beta, -2}, sort-numerical=auto]{f}{x,y}  &&
	\pdv[order={-\beta, 2}, sort-numerical=auto]{f}{x,y}  &&
	\pdv[order={-\beta, -2}, sort-numerical=auto]{f}{x,y} \\
	\text{\inlinecode{sort-numerical=first:}} &&
	\pdv[order={\beta, 2}, sort-numerical=first]{f}{x,y}   &&   \pdv[order={\beta, -2}, sort-numerical=first]{f}{x,y}  &&   \pdv[order={-\beta, 2}, sort-numerical=first]{f}{x,y}  &&   \pdv[order={-\beta, -2}, sort-numerical=first]{f}{x,y} \\
	\text{\inlinecode{sort-numerical=last:}}  &&
	\pdv[order={\beta, 2}, sort-numerical=last]{f}{x,y}   &&   \pdv[order={\beta, -2}, sort-numerical=last]{f}{x,y}  &&   \pdv[order={-\beta, 2}, sort-numerical=last]{f}{x,y}  &&   \pdv[order={-\beta, -2}, sort-numerical=last]{f}{x,y} \\
	\text{\inlinecode{sort-numerical=symbolic:}}  && 
	\pdv[order={\beta, 2}, sort-numerical=symbolic]{f}{x,y}   &&   \pdv[order={\beta, -2}, sort-numerical=symbolic]{f}{x,y}  &&   \pdv[order={-\beta, 2}, sort-numerical=symbolic]{f}{x,y}  &&   \pdv[order={-\beta, -2}, sort-numerical=symbolic]{f}{x,y}
\end{align*}

\subsection{Reversing the sort algorithm} \label{ssec:sort-reverse}
The reverse keys serves to reverse the sorting algorithms' ordering, providing more flexibility over the sorting method. If the default ordering of an algorithm is not preferred it may be reversed with the corresponding reverse key. The examples below showcase the reverse functionality. Note that \keyval*[index=false]{sort-method}{1 algorithm only} is also used to better demonstrate the reverse feature, where the algorithm is the one used in the reverse key.
\begin{align*}
	\text{\inlinecode{sort-abs-reverse=false:}}     && \pdv[sort-method={abs}, sort-abs-reverse=false, order={2a, -3b}]{f}{x,y}       &&
	\text{\inlinecode{sort-abs-reverse=true:}}      && \pdv[sort-method={abs}, sort-abs-reverse=true, order={2a, -3b}]{f}{x,y}        \\
	\text{\inlinecode{sort-number-reverse=false:}}  && \pdv[sort-method={number}, sort-number-reverse=false, order={2a, -3b}]{f}{x,y} &&
	\text{\inlinecode{sort-number-reverse=true:}}   && \pdv[sort-method={number}, sort-number-reverse=true, order={2a, -3b}]{f}{x,y}  \\
	\text{\inlinecode{sort-sign-reverse=false:}}    && \pdv[sort-method={sign}, sort-sign-reverse=false, order={a, -b}]{f}{x,y}       &&
	\text{\inlinecode{sort-sign-reverse=true:}}     && \pdv[sort-method={sign}, sort-sign-reverse=true, order={a, -b}]{f}{x,y}        \\
	\text{\inlinecode{sort-symbol-reverse=false:}}  && \pdv[sort-method={symbol}, sort-symbol-reverse=false, order={ab, c}]{f}{x,y}   &&
	\text{\inlinecode{sort-symbol-reverse=true:}}   && \pdv[sort-method={symbol}, sort-symbol-reverse=true, order={ab, c}]{f}{x,y}    \\
	\text{\inlinecode{sort-lexical-reverse=false:}} && \pdv[sort-method={lexical}, sort-lexical-reverse=false, order={a, c, b}]{f}{x,y,z}  &&
	\text{\inlinecode{sort-lexical-reverse=true:}}  && \pdv[sort-method={lexical}, sort-lexical-reverse=true, order={a, c, b}]{f}{x,y,z}   \\
\end{align*}

%\subsection{Mixed order override}
%In cases where the mixed order fails to be calculated or another form is preferred, then the mixed order override can be used
%\begin{example}
%	\pdv[order={n+3k, n-k}]{f}{x,y} \\
%	\pdv[order={n+3k, n-k}, mixed-order={2(n+k)}]{f}{x,y}
%\end{example}


	
	\clearpage
	\section{Miscellaneous} 

\subsection{Slashfrac}\label{ssec:slashfrac}
\begin{function}*{\slashfrac}
	\begin{syntax}
		\oarg{scale}, \marg{numerator}, \marg{denominator}
	\end{syntax}
	The text-styled fraction, $\slashfrac{a}{b}$, is commonly used in text-mode. While \macro{\slashfrac}[\narg{a},\narg{b}] requires more keystrokes to write than \texttt{a/b}, a macro is needed for implementing text-styled derivatives.
	
	\begin{argument}{1}
		The optional argument serves as the scaling parameter for the solidus and accepts the following inputs:
		\begin{example}
			\slashfrac{y_f}{x} \\
			\slashfrac[auto]{y_f}{x} \\
			\slashfrac[none]{y_f}{x} \\
			\slashfrac[big]{y_f}{x}  \\
			\slashfrac[Big]{y_f}{x}  \\
			\slashfrac[bigg]{y_f}{x} \\
			\slashfrac[Bigg]{y_f}{x}
		\end{example}
		Omitting \arg{1} sets the scaling parameter to \val{auto}.
		%This argument is subject to change, see \cref{consid:slashfrac_opt} for more information.
	\end{argument}
	
	\begin{argument}{2}
		Typesets the fraction's numerator.
	\end{argument}
	
	\begin{argument}{3}
		Typesets the fraction's denominator.
	\end{argument}
\end{function}

	
	\clearpage
	\addsec{Index}
Numbers in bold refer to the page where the entry is defined.

\printindex[option]

\clearpage

\printindex[macro]
	
	\clearpage
	\addsec{Change history}

\setlength{\marginparwidth}{75pt}

\begin{changelog}
	\begin{change}[version=0.9,  date=2019-07-21, beta=true]
		\item First release of the package. The package is currently in a beta version.
	\end{change}
	\bigskip
	\begin{change}[version=0.95, date=2019-09-18, beta=true]
		\item \emph{Please ignore this version, since it contained the wrong \pkg{.sty} and \pkg{.pdf} files} \texttt{:(}.
		%\item Second beta release of the package.
		\item Removed the single token restriction on the infinitesimal since it was unnecessary.
		\item Fixed documentation errors and typos.
		\item Made minor fixes to the code.
	\end{change}
	\begin{change}[version=0.95b, date=2019-09-21, beta=true]
		\item Contains the correct \pkg{.sty} and \pkg{.pdf} files \texttt{:)}.
		\item Made one minor code fix.
	\end{change}
	\smallskip
	\begin{change}[version=0.96, date=2019-12-22, beta=true]
		\item Fixed the issue with double superscript for higher-order derivatives when the variable contained a superscript.
	\end{change}
	\smallskip
	\begin{change}[version=0.97, date=2020-02-03, beta=true]
		\item Fixed the argument specifier of \csverb{\__deriv_scale_big:nnnn} when it was used (it was used with \texttt{:nnnm}).
	\end{change}
	\smallskip
	\begin{change}[version=0.98, date=2020-07-20, beta=true]
		\item Fixed a bug related to the subscript argument caused by recent changes to the \pkg{xparse} package dated 2020-05-14 (the fix also works with earlier versions of \pkg{xparse}).
	\end{change}
	\smallskip
	\begin{change}[version=1.0, date=2021-05-25, beta=false]
		\item Added new options for derivatives.
		\item Added new values for existing options.
		\item Added new commands for writing differentials.
		\item Changed the usage of \key[index=false]{style-inf}.
		\item Changed the order argument to an option argument.
		\item Adjusted default values for certain options.
		\item Expanded math space keys to accept more general inputs.
		\item Changed \cs{derivset} to define default options.
		\item Merged the codes for ordinary and partial derivatives.
		\item Removed the mixed order argument.
		\item Removed the options \key[index=false]{misc-add-delims} and \key[index=false]{misc-remove-delims}.
		\item Replaced the commands in \cref{sec:defvar} with new ones, as the old ones are deprecated.
		\item Code clean-up and optimization.
		\item Fixed code errors.
		\item Fixed documentation errors.
		\item Improved support for preventing options affecting nested derivatives/differentials.
	\end{change}
	\begin{change}[version=1.01, date=2021-05-28, beta=false]
		\item Changed the default value of the option \key[index=false]{sep-end} due to issues.
		\item Fixed code errors due to changes introduced in version 1.0 to the option \key[index=false]{style-inf}.
		\item Fixed documentation errors.
	\end{change}
	\begin{change}[version=1.1, date=2021-06-03, beta=false]
		\item Added package options to be used with \cs{usepackage}\oarg{options}\narg{derivative}.
		\item Removed the hidden dependency on \pkg{unicode-math} when using \xetex{} or \luatex.
		\item Replaced \cs{symup} with \cs{mathrm} for simplicity.
		\item If \pkg{mleftright} is loaded, the default value of \key[index=false]{scale-auto} is set to \val{mleftmright}.
	\end{change}
	\begin{change}[version=1.2, date=2022-07-09, beta=false]
		\item Code clean-up and optimisation that significantly speeds up usage of the package.
		\item Added new a sorting algorithm \keyval[index=false]{sort-method}{lexical}, which sorts terms alphabetically.
		\item Added the option \key[index=false]{sort-lexical-reverse} to reverse the alphabetical sorting order.
		\item Added the option \key[index=false]{switch-sort} to enable/disable the sorting algorithm for the mixed order.
		\item Fixed a bug related to \keyval[index=false]{scale-\meta{\dots}}{none} when the corresponding delimiter option contained a period.
		\item Fixed documentation errors.
	\end{change}
	\begin{change}[version=1.3, date=2023-07-26, beta=false]
		\item Code clean-up and minor optimisation.
		\item Fixed documentation errors.
		\item Updated documentation to include more examples.
		\item Enhanced the algorithm that automatically calculates the mixed order to support fractional calculus.
		\item Introduced a new argument, \targ{!}, for derivatives to enable shorthand notation.
		\item Added new options \key[index=false]{style-inf-den}.
		and \key[index=false]{style-inf-num} to set the infinitesimals in the denominator and numerator, respectively.
		\item Added new options \key{style-var-/}, \key{style-var-!} and \key{style-var-/!} to set the style of the derivatives.
		\item Added new options \key{scale-var-!} and \key{delims-var-!} for variable delimiters in shorthand mode.
		\item Added new options \key{scale-eval-!} and \key{delims-eval-!} for evaluation delimiters in shorthand mode.
	\end{change}
	\begin{change}[version=1.31, date=2023-11-04, beta=false]
		\item Fixed issue relating to the order when nesting derivatives (issues \#14).
	\end{change}
	\bigskip
	\begin{change}[version=1.4, date=2024-02-08, beta=false]
		\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).
	\end{change}
\end{changelog}

	
\end{document}