diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/moremath/moremath.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/moremath/moremath.sty | 1245 |
1 files changed, 1245 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/moremath/moremath.sty b/Master/texmf-dist/tex/latex/moremath/moremath.sty new file mode 100644 index 00000000000..cc63871489b --- /dev/null +++ b/Master/texmf-dist/tex/latex/moremath/moremath.sty @@ -0,0 +1,1245 @@ +%% +%% This is file `moremath.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% moremath.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% +%% Copyright (C) 2024 Marcel Ilg +%% +%% 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 +%% +%% https://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 Marcel Ilg. +%% +%% This work consists of the files listed in MANIFEST.md. +%% + +\NeedsTeXFormat{LaTeX2e}[2022-11-01] +\DeclareCurrentRelease{v0}{2024-07-15} +\ProvidesExplPackage{moremath} + {2024-08-20}{v0.5.0}{More Math Macros} +\msg_new:nnn { moremath } {load / bm} +{ + Option~'bm'~given.\\ + Loading~the~bm~package~\msg_line_context:. +} +\msg_new:nnn {moremath} { load / disabling } +{ + Option~'#1'~given.\\ + Disabling~#2~\msg_line_context:. +} +\bool_new:N \l__moremath_predef_vector_op_bool +\bool_new:N \l__moremath_predef_operators_bool +\bool_new:N \l__moremath_predef_crvector_bool +\bool_new:N \l__moremath_predef_matrix_bool +\bool_new:N \l__moremath_predef_abs_bool +\keys_define:nn { moremath / load } +{ + bm .code:n = { + \msg_info:nn {moremath} {load / bm} + \RequirePackage{bm} + }, + bm .value_forbidden:n = true, + bm. usage:n = load, + no-vector .bool_set_inverse:N = \l__moremath_predef_vector_op_bool, + no-vector .default:n = true, + no-vector .initial:n = false, + no-vector .usage:n = load, + no-operators .bool_set_inverse:N = \l__moremath_predef_operators_bool, + no-operators .default:n = true, + no-operators .initial:n = false, + no-operators .usage:n = load, + no-abs-shorthands .bool_set_inverse:N = \l__moremath_predef_abs_bool, + no-abs-shorthands .default:n = true, + no-abs-shorthands .initial:n = false, + no-abs-shorthands .usage:n = load, + no-matrix .bool_set_inverse:N = \l__moremath_predef_matrix_bool, + no-matrix .initial:n = false, + no-matrix .default:n = true, + no-matrix .usage:n =load, + no-crvector .bool_set_inverse:N = \l__moremath_predef_crvector_bool, + no-crvector .default:n = true, + no-crvector .initial:n = false, + no-crvector .usage:n = load, + nopredef .multichoice:, + nopredef / operators .meta:nn = { moremath / load } + { + no-operators = true + }, + nopredef / vector .meta:nn = { moremath / load } + { + no-vector = true + }, + nopredef / abs .meta:nn = { moremath / load } + { + no-abs-shorthands = true, + }, + noperdef / matrix .meta:nn = { moremath / load } + { + no-matrix = true, + }, + nopredef / crvector .meta:nn = {moremath / load} + { + no-crvector = true, + }, + nopredef / all .meta:nn = { moremath / load } + { + no-operators = true, + no-vector = true, + no-abs-shorthands = true + }, + nopredef .usage:n = load, + unknown .code:n = {\PassOptionsToPackage{\CurrentOption}{mathtools}}, + unknown .usage:n = load, +} +\tl_new:N \l__moremath_nabla_tl +\bool_new:N \l__moremath_nabla_arrow_bool +\bool_new:N \l__moremath_nabla_arrow_bold_bool +\tl_new:N \l__moremath_grad_op_tl +\tl_new:N \l__moremath_laplacian_symb_tl +\bool_new:N \l__moremath_laplacian_delta_bool +\bool_new:N \l__moremath_laplacian_arrow_bool +\tl_new:N \l__moremath_laplacian_tl +\tl_new:N \l__moremath_dalembert_symb_tl +\bool_new:N \l__moremath_vcenter_bool +\keys_define:nn { moremath } +{ + % Symbol to use for the nabla + nabla .tl_set:N = \l__moremath_nabla_tl, + nabla .initial:n = {\nabla}, + nabla .value_required:n = true, + % shall the nabla have an arrow over it + arrownabla .bool_set:N = \l__moremath_nabla_arrow_bool, + arrownabla .default:n = {true}, + arrownabla .initial:n = {false}, + % shall the nabla be bold + boldnabla .bool_set:N = \l__moremath_nabla_bold_bool, + boldnabla .default:n = {true}, + boldnabla .initial:n = {false}, + % Symbol to use for the gradient operator + grad-op .tl_set:N = \l__moremath_grad_op_tl, + grad-op .value_required:n = true, + % Symbol to use for the laplacian + laplacian-symb .tl_set:N = \l__moremath_laplacian_symb_tl, + laplacian-symb .initial:n = {\l__moremath_nabla_tl}, + % shall the Laplace operator be a delta + delta-laplace .bool_set:N = \l__moremath_laplacian_delta_bool, + delta-laplace .initial:n = {false}, + % shall the laplace operator have an arrow over itself + arrowlaplace .bool_set:N = \l__moremath_laplacian_arrow_bool, + arrowlaplace .default:n = {true}, + arrowlaplace .initial:n = {false}, + % overwrite the laplace operator + laplacian .tl_set:N = \l__moremath_laplacian_tl, + laplacian .value_required:n = true, + dalembert-symb .tl_set:N = \l__moremath_dalembert_symb_tl, + dalembert-symb .initial:n = {\square}, + vcenter .bool_set:N = \l__moremath_vcenter_bool, + vcenter .initial:n = true, + vcenter .value_required:n = true, +}% \keys_define:nn +\keys_define:nn { moremath / matrix } +{ + delimiter .tl_set:N = \l__moremath_matrix_delim_tl, + delimiter .initial:n = {}, + fill .tl_set:N = \l__moremath_matrix_fill_tl, + fill .initial:n = {}, + align .tl_set:N = \l__moremath_matrix_align_tl, + align .initial:n = {c}, + align .value_required:n = true, +} +\cs_new_protected:Nn \moremath_setup:n +{ + \keys_set:nn {moremath} {#1} +} +\NewDocumentCommand \moremathsetup {m} +{ + \moremath_setup:n {#1} +} +\cs_new_protected:Nn \__moremath_load_time_setup: +{ + \ProcessKeyOptions[ moremath / load ] +} +\__moremath_load_time_setup: +\msg_new:nnn { moremath } { load / loading-amssymb } +{ + Vector~calculus~commands~enabled.\\ + Loading~amssymb~package~\msg_line_context:. +} +\bool_if:NT \l__moremath_predef_vector_op_bool +{ + \msg_info:nn { moremath } { load / loading-amssymb } + \RequirePackage{amssymb} +} +\RequirePackage{mathtools}[2004/06/05] +\cs_new_protected:Nn \__moremath_tex_vcenter:n +{ + \tex_vcenter:D {#1} +} +\cs_new_protected:Nn \__moremath_tex_mathpalette:Nn +{ + \mathpalette #1 {#2} +} +\cs_new_protected_nopar:Nn \__moremath_tex_mathsurround:n +{ + \tex_mathsurround:D = #1 +} +\cs_new_protected_nopar:Nn \__moremath_tex_mathop:n +{ + \tex_mathop:D {#1} +} +\cs_new_nopar:Nn \__moremath_matrix_star_begin:nn +{ + \begin{ #1 matrix* } [ #2 ] +} +\cs_generate_variant:Nn \__moremath_matrix_star_begin:nn { nV, Vn, VV } +\cs_new_nopar:Nn \__moremath_matrix_star_end:n +{ + \end{ #1 matrix* } +} +\cs_generate_variant:Nn \__moremath_matrix_star_end:n {V} +\cs_new_protected_nopar:Nn \moremath_vcenter:n +{ + \__moremath_tex_mathpalette:Nn \__moremath_vcenter:Nn {#1} +} +\cs_new_protected_nopar:Nn \__moremath_vcenter:Nn +{ + \__moremath_tex_vcenter:n + { + \hbox:n + { + $ + \__moremath_tex_mathsurround:n {0pt} + #1 {#2} + $ + } + } +} +\msg_new:nnn { moremath } { csname-already-defined } +{ + Control~sequence~' #1 '~is~already~ defined.\\ + Skipping~definition~\msg_line_context: +} +\msg_new:nnnn { moremath } { vcenter / only-in-math-mode } +{ + Command~#1~used~outside~math~mode~\msg_line_context:. +} +{ + The~command~#1~may~only~be~used~inside~math~mode. +} +\cs_if_free:NTF \VCenterMath +{ + \NewDocumentCommand \VCenterMath { m } + { + \mode_if_math:TF + { + \moremath_vcenter:n {#1} + }{% \mode_if_math:TF FALSE BRANCH + \msg_error:nnn { moremath } { vcenter / only-in-math-mode } {\VCenterMath} + } + } +}{% \cs_if_free:NTF \VCenterMath FALSE BRANCH + \msg_warning:nnn { moremath } { csname-already-defined } {\VCenterMath} +} +\DeclarePairedDelimiter{\__moremath_inparent:w}{\lparen}{\rparen} +\DeclarePairedDelimiter{\__moremath_inbrack:w}{\lbrack}{\rbrack} +\DeclarePairedDelimiter{\__moremath_inbrace:w}{\lbrace}{\rbrace} +\DeclarePairedDelimiter{\__moremath_in_vert:w}{\lvert}{\rvert} +\DeclarePairedDelimiter{\__moremath_in_Vert:w}{\lVert}{\rVert} +\cs_new_protected:Nn \__moremath_operator:Nnn +{ + #1 + % add superscript if present + \tl_if_empty:nF {#2} {^{#2}} + % add subscript if present + \tl_if_empty:nF {#3} { \c_math_subscript_token {#3} } +} +\cs_new_protected_nopar:Nn \moremath_delim_op_noscale:NNnnn +{ + \__moremath_operator:Nnn #1 {#3} {#4} + % #2 is the paired delimiter + #2 {#5} +} + +\cs_new_protected_nopar:Nn \moremath_delim_op_autoscale:NNnnn +{ + \__moremath_operator:Nnn #1 {#3} {#4} + % #2 is the paired delimiter + #2 * {#5} +} +\cs_new_protected_nopar:Nn \moremath_delim_op_manuscale:NNnnnn +{ + \__moremath_operator:Nnn #1 {#4} {#5} + % #2 is the paired delimiter + #2 [ #3 ] {#6} +} +\cs_generate_variant:Nn \moremath_delim_op_manuscale:NNnnnn {NNVnnn} +\msg_new:nnn { moremath } { delimop / already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~of~delimited~operator~'#1'~\msg_line_context:. +} +\msg_new:nnn { moremath } { delimop / auto-manu-scale-conflict } +{ + Both~star~and~scale~cmd~given~to~'#1'.\\ + Automatic~scaling~will~be~preferred,~the~size~command~will~be~ + ignored~\msg_line_context:. +} +\cs_new_protected:Nn \moremath_new_delim_op_command:NNN +{ + \cs_if_free:NTF #1 + { + \exp_args:NNe \NewDocumentCommand #1 + { s o E{ ^ \char_generate:nn {`_} {8} }{{}{}} m } + { + \tl_if_novalue:nTF {##2} + { + % second argument empty + \bool_if:nTF {##1} + { + % star given + \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5} + }{ + % star not given + \moremath_delim_op_noscale:NNnnn #2 #3 {##3} {##4} {##5} + } + }{ + % second argument present + % star given? + \bool_if:nTF {##1} + { + % Warn if both star and scaling factor are present + \msg_warning:nnn { moremath } { delimop / auto-manu-scale-conflict } + {#1} + \moremath_delim_op_autoscale:NNnnn #2 #3 {##3} {##4} {##5} + }{ % FALSE BRANCH + \moremath_delim_op_manuscale:NNnnnn #2 #3 {##2} {##3} {##4} {##5} + } + } + } + }{ % \cs_if_free:nTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { delimop / already-defined-skip } + {#1} + } +} + +\cs_generate_variant:Nn \moremath_new_delim_op_command:NNN {cNN} +\NewDocumentCommand\DeclareDelimitedOperator { m m m } +{ + \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } { error } + \moremath_new_delim_op_command:NNN #1 #2 #3 + \msg_redirect_name:nnn { moremath } { delimop / already-defined-skip } {} +} +\cs_new_protected:Nn \__moremath_new_delim_op_cmds:nN +{ + \moremath_new_delim_op_command:cNN {p #1} #2 \__moremath_inparent:w + \moremath_new_delim_op_command:cNN {b #1} #2 \__moremath_inbrack:w + \moremath_new_delim_op_command:cNN {B #1} #2 \__moremath_inbrace:w + \moremath_new_delim_op_command:cNN {v #1} #2 \__moremath_in_vert:w + \moremath_new_delim_op_command:cNN {V #1} #2 \__moremath_in_Vert:w +} +\bool_if:NTF \l__moremath_predef_operators_bool +{ +\__moremath_new_delim_op_cmds:nN {arccos} \arccos +\__moremath_new_delim_op_cmds:nN {arcsin} \arcsin +\__moremath_new_delim_op_cmds:nN {arctan} \arctan +\__moremath_new_delim_op_cmds:nN {arg} \arg +\__moremath_new_delim_op_cmds:nN {cos} \cos +\__moremath_new_delim_op_cmds:nN {cosh} \cosh +\__moremath_new_delim_op_cmds:nN {cot} \cot +\__moremath_new_delim_op_cmds:nN {coth} \coth +\__moremath_new_delim_op_cmds:nN {csc} \csc +\__moremath_new_delim_op_cmds:nN {deg} \deg +\__moremath_new_delim_op_cmds:nN {det} \det +\__moremath_new_delim_op_cmds:nN {dim} \dim +\__moremath_new_delim_op_cmds:nN {exp} \exp +\__moremath_new_delim_op_cmds:nN {gcd} \gcd +\__moremath_new_delim_op_cmds:nN {hom} \hom +\__moremath_new_delim_op_cmds:nN {inf} \inf +\__moremath_new_delim_op_cmds:nN {injlim} \injlim +\__moremath_new_delim_op_cmds:nN {ker} \ker +\__moremath_new_delim_op_cmds:nN {lg} \lg +\__moremath_new_delim_op_cmds:nN {lim} \lim +\__moremath_new_delim_op_cmds:nN {liminf} \liminf +\__moremath_new_delim_op_cmds:nN {limsup} \limsup +\__moremath_new_delim_op_cmds:nN {ln} \ln +\__moremath_new_delim_op_cmds:nN {log} \log +\__moremath_new_delim_op_cmds:nN {max} \max +\__moremath_new_delim_op_cmds:nN {min} \min +\__moremath_new_delim_op_cmds:nN {Pr} \Pr +\__moremath_new_delim_op_cmds:nN {projlim} \projlim +\__moremath_new_delim_op_cmds:nN {sec} \sec +\__moremath_new_delim_op_cmds:nN {sin} \sin +\__moremath_new_delim_op_cmds:nN {sinh} \sinh +\__moremath_new_delim_op_cmds:nN {sup} \sup +\__moremath_new_delim_op_cmds:nN {tan} \tan +\__moremath_new_delim_op_cmds:nN {tanh} \tanh +\__moremath_new_delim_op_cmds:nN {varinjlim} \varinjlim +\__moremath_new_delim_op_cmds:nN {varprojlim} \varprojlim +\__moremath_new_delim_op_cmds:nN {varliminf} \varliminf +\__moremath_new_delim_op_cmds:nN {varlimsup} \varlimsup +}{ + \msg_info:nnnn {moremath} {load /disabling} {no-operators} + { + predefined~delimited~operator~macros + } +} % End of the conditional +\cs_new_protected_nopar:Nn \__moremath_maybe_vcenter:n +{ + \bool_if:NTF \l__moremath_vcenter_bool + { + \moremath_vcenter:n {#1} + }{ + #1 + } +} +\cs_new_protected:Nn \__moremath_gradient_operator_get: +{ + \tl_if_empty:NTF \l__moremath_grad_op_tl + { + \__moremath_tex_mathop:n + { + \bool_if:NTF \l__moremath_nabla_arrow_bool + { + \vec + { + \__moremath_maybe_vcenter:n + { + \bool_if:NT \l__moremath_nabla_bold_bool + { + \boldsymbol + } + \l__moremath_nabla_tl + } + } + }{ + \bool_if:NTF \l__moremath_nabla_bold_bool + { + \__moremath_maybe_vcenter:n + { + \boldsymbol + \l__moremath_nabla_tl + } + }{ + \l__moremath_nabla_tl + } + } + }% \__moremath_tex_mathop:n + \nolimits + }{ + \l__moremath_grad_op_tl + } +} +\cs_new_protected:Nn \__moremath_laplace_operator_get: +{ + \tl_if_empty:NTF \l__moremath_laplacian_tl + { + \__moremath_tex_mathop:n + { + \bool_if:NTF \l__moremath_laplacian_delta_bool + { + \Delta + }{ + \bool_if:NTF \l__moremath_laplacian_arrow_bool + { + \vec{ + \__moremath_maybe_vcenter:n + { + \bool_if:NT \l__moremath_nabla_bold_bool {\boldsymbol} + \l__moremath_laplacian_symb_tl + } + } + }{ + \bool_if:NTF \l__moremath_nabla_bold_bool + { + \__moremath_maybe_vcenter:n + { + \boldsymbol + \l__moremath_laplacian_symb_tl + } + }{ + \l__moremath_laplacian_symb_tl + } + } + } + }\nolimits + \bool_if:NF \l__moremath_laplacian_delta_bool + { + \c_math_superscript_token + { + 2 + } + } + }{ + \l__moremath_laplacian_tl + } +} +\cs_new_protected:Nn \__moremath_dalembert_operator_get: +{ + \__moremath_tex_mathop:n + { + \l__moremath_dalembert_symb_tl + }% \__moremath_tex_mathop:n + \nolimits +} +\cs_new_protected_nopar:Nn \moremath_gradient_operator:n +{ + \__moremath_gradient_operator_get: + \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}} +} +\cs_new_protected_nopar:Nn \moremath_laplace_operator:n +{ + \__moremath_laplace_operator_get: + \tl_if_empty:nF {#1} {\c_math_subscript_token {#1}} +} +\cs_new_protected_nopar:Nn \moremath_divergence_operator:n +{ + { + \moremath_gradient_operator:n {#1} + } + \cdot +} + +\cs_new_protected_nopar:Nn \moremath_curl_operator:n +{ + { + \moremath_gradient_operator:n {#1} + } + \times +} +\cs_new_protected:Nn \moremath_dalembert_operator:n +{ + \__moremath_dalembert_operator_get: + \tl_if_empty:nF {#1} + { + \c_math_subscript_token {#1} + } +} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_noscale:NNnn +{ + #1 {#3} #2{#4} +} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_autoscale:NNnn +{ + #1 {#3} #2 * {#4} +} +\cs_new_protected_nopar:Nn \moremath_delim_nabla_op_manuscale:NNnnn +{ + #1 {#4} #2 [#3] {#5} +} +\cs_generate_variant:Nn \moremath_delim_nabla_op_manuscale:NNnnn {NNVnn} +\cs_new_protected:Nn \__moremath_parse_kv_args:nN +{ + \prop_set_from_keyval:Nn \l_tmpa_prop {#1} + + \prop_pop:NnNT \l_tmpa_prop {scale} #2 {} + + \keys_set:ne {moremath} {\prop_to_keyval:N \l_tmpa_prop} +} +\msg_new:nnn { moremath } { vector-calc / scale-star-conflict } +{ + Both~star~and~scaling~factor~given~to~'#1'.\\ + Automatic~scaling~will~be~preferred,~the~size~command~'#2'~will~be~ + ignored~\msg_line_context:. +} +\cs_new_protected:Nn \__moremath_new_delim_nabla_doc_cmd:NNN +{ + \cs_if_free:NTF #1 + { + \exp_args:NNe \NewDocumentCommand #1 + { + s ={scale} o E{ \char_generate:nn {`_}{8} }{ {} } m + } + { % command code + \group_begin: + % optional arguments given? + \tl_if_novalue:nF {##2} + { + \__moremath_parse_kv_args:nN {##2} \l_tmpa_tl + } + % star given? + \bool_if:nTF {##1} + { + % scale factor given? + \tl_if_empty:NF \l_tmpa_tl + { + \msg_warning:nnnV { moremath } { vector-calc / scale-star-conflict } + {#1} \l_tmpa_tl + } + \moremath_delim_nabla_op_autoscale:NNnn #2 #3 {##3} {##4} + }{ % \bool_if:nTF {##1} FALSE BRANCH + % scale factor given? + \tl_if_empty:NTF \l_tmpa_tl + { + \moremath_delim_nabla_op_noscale:NNnn #2 #3 {##3} {##4} + }{ % FALSE BRANCH + \moremath_delim_nabla_op_manuscale:NNVnn #2 #3 \l_tmpa_tl {##3} {##4} + } + } % \bool_if:nTF {##1} + \group_end: + } + }{ % \cs_if_free:NTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { vector-calc / already-defined-skip } {#1} + } % \cs_if_free:NTF #1 +} +\cs_generate_variant:Nn \__moremath_new_delim_nabla_doc_cmd:NNN {cNN} +\cs_new_protected:Nn \__moremath_new_nabla_doc_cmds:nN +{ + \__moremath_new_delim_nabla_doc_cmd:cNN { p #1 } #2 \__moremath_inparent:w + \__moremath_new_delim_nabla_doc_cmd:cNN { b #1 } #2 \__moremath_inbrack:w + \__moremath_new_delim_nabla_doc_cmd:cNN { B #1 } #2 \__moremath_inbrace:w + \__moremath_new_delim_nabla_doc_cmd:cNN { v #1 } #2 \__moremath_in_vert:w + \__moremath_new_delim_nabla_doc_cmd:cNN { V #1 } #2 \__moremath_in_Vert:w +} +\bool_if:NTF \l__moremath_predef_vector_op_bool +{ +\msg_new:nnn { moremath } { vector-calc / already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~\msg_line_context:. +} +\cs_if_free:NTF \grad +{ + \exp_args:NNe \NewDocumentCommand \grad { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_gradient_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\grad} +} + +\cs_if_free:NTF \divergence +{ + \exp_args:NNe \NewDocumentCommand \divergence + { !o E{ \char_generate:nn {`_} {8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_divergence_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } {\divergence} +} + +\cs_if_free:NTF \curl +{ + \exp_args:NNe \NewDocumentCommand \curl + { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_curl_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} {vector-calc / already-defined-skip} {\curl} +} + +\cs_if_free:NTF \laplacian +{ + \exp_args:NNe \NewDocumentCommand \laplacian + { !o E{ \char_generate:nn {`_}{8} }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath} {#1} + } + \moremath_laplace_operator:n {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} { vector-calc / already-defined-skip } + {\laplacian} +} +\cs_if_free:NTF \quabla +{ + \exp_args:NNe \NewDocumentCommand \quabla + { !o E{ \char_generate:nn {`_} { 8 } }{{}} } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath } {#1} + } + \moremath_dalembert_operator:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \quabla FALSE BRANCH + \msg_warning:nnn { moremath } { vector-calc / already-defined-skip } + {\quabla} +} +\__moremath_new_nabla_doc_cmds:nN {grad} \moremath_gradient_operator:n +\__moremath_new_nabla_doc_cmds:nN {div} \moremath_divergence_operator:n +\__moremath_new_nabla_doc_cmds:nN {curl} \moremath_curl_operator:n +\__moremath_new_nabla_doc_cmds:nN {laplacian} \moremath_laplace_operator:n +\__moremath_new_nabla_doc_cmds:nN {quabla} \moremath_dalembert_operator:n +}{ % IF NOT \l__moremath_predef_vector_op_bool + \msg_info:nnnn {moremath} { load /disabling } {no-vector} + { + predefined~vector~calculus~macros + } +} % END \l__moremath_predef_vector_op_bool +\seq_new:N \l__moremath_vector_entries_seq +\cs_new_protected_nopar:Nn \__moremath_seq_to_column_vector:N +{ + \seq_use:Nn #1 {\\} +} +\cs_new_protected_nopar:Nn \__moremath_seq_to_row_vector:N +{ + \seq_use:Nn #1 {&} +} +\cs_new_protected_nopar:Nn \moremath_column_vector:nn +{ + \seq_clear:N \l__moremath_vector_entries_seq + \seq_set_from_clist:Nn \l__moremath_vector_entries_seq {#2} + + \__moremath_matrix_star_begin:nV {#1} \l__moremath_matrix_align_tl + \__moremath_seq_to_column_vector:N \l__moremath_vector_entries_seq + \__moremath_matrix_star_end:n {#1} +} +\cs_new_protected_nopar:Nn \moremath_row_vector:nn +{ + \seq_clear:N \l__moremath_vector_entries_seq + \seq_set_from_clist:Nn \l__moremath_vector_entries_seq {#2} + + \__moremath_matrix_star_begin:nV {#1} \l__moremath_matrix_align_tl + \__moremath_seq_to_row_vector:N \l__moremath_vector_entries_seq + \__moremath_matrix_star_end:n {#1} +} +\cs_generate_variant:Nn \moremath_column_vector:nn { Vn } +\cs_generate_variant:Nn \moremath_row_vector:nn { Vn } +\cs_new_protected_nopar:Nn \moremath_column_smallvector:nn +{ + \moremath_column_vector:nn {#1 small} {#2} +} + +\cs_new_protected_nopar:Nn \moremath_row_smallvector:nn +{ + \moremath_row_vector:nn {#1 small} {#2} +} +\cs_generate_variant:Nn \moremath_column_smallvector:nn { Vn } +\cs_generate_variant:Nn \moremath_row_smallvector:nn { Vn } +\seq_clear_new:N \l__moremath_mat_diag_entries_seq +\seq_clear_new:N \l__moremath_mat_row_entries_seq +\cs_new_protected:Nn \__moremath_constr_diagmat_row:n +{ + \seq_clear:N \l__moremath_mat_row_entries_seq + \int_step_inline:nn {\seq_count:N \l__moremath_mat_diag_entries_seq} + { + \int_compare:nTF { #1 == ##1 } + { + \seq_put_right:Nx \l__moremath_mat_row_entries_seq + { + \seq_item:Nn \l__moremath_mat_diag_entries_seq { #1 } + } + }{ % false branch + \seq_put_right:NV \l__moremath_mat_row_entries_seq \l__moremath_matrix_fill_tl + } % \int_compare:nTF { #1 == ##1 } + } + \seq_use:Nn \l__moremath_mat_row_entries_seq { & } \\ +} + +\cs_new_protected:Nn \__moremath_constr_antidiagmat_row:n +{ + \seq_clear:N \l__moremath_mat_row_entries_seq + \int_step_inline:nn {\seq_count:N \l__moremath_mat_diag_entries_seq} + { + \int_compare:nTF { #1 == ##1 } + { + % as this is a anti diagonal matrix we put in the elements from the + % left so that the first entry is the right most entry + \seq_put_left:Nx \l__moremath_mat_row_entries_seq + { + \seq_item:Nn \l__moremath_mat_diag_entries_seq { #1 } + } + }{ % false branch + \seq_put_left:NV \l__moremath_mat_row_entries_seq \l__moremath_matrix_fill_tl + } % \int_compare:nTF { #1 == ##1 } + } + \seq_use:Nn \l__moremath_mat_row_entries_seq { & } \\ +} +\cs_new_protected:Nn \moremath_diagonal_matrix:nn +{ + \seq_set_from_clist:Nn \l__moremath_mat_diag_entries_seq { #2 } + \__moremath_matrix_star_begin:nV { #1 } \l__moremath_matrix_align_tl + \int_step_function:nN { \seq_count:N \l__moremath_mat_diag_entries_seq } + \__moremath_constr_diagmat_row:n + \__moremath_matrix_star_end:n { #1 } +} +\cs_new_protected:Nn \moremath_antidiagonal_matrix:nn +{ + \seq_set_from_clist:Nn \l__moremath_mat_diag_entries_seq { #2 } + \__moremath_matrix_star_begin:nV { #1 } \l__moremath_matrix_align_tl + \int_step_function:nN { \seq_count:N \l__moremath_mat_diag_entries_seq } + \__moremath_constr_antidiagmat_row:n + \__moremath_matrix_star_end:n { #1 } +} + +\cs_new_protected:Nn \moremath_diagonal_smallmatrix:nn +{ + \moremath_diagonal_matrix:nn {#1 small} {#2} +} + +\cs_new_protected:Nn \moremath_antidiagonal_smallmatrix:nn +{ + \moremath_antidiagonal_matrix:nn {#1 small} {#2} +} +\cs_generate_variant:Nn \moremath_diagonal_matrix:nn { nV, Vn, VV } +\cs_generate_variant:Nn \moremath_antidiagonal_matrix:nn { nV, Vn, VV } +\cs_generate_variant:Nn \moremath_diagonal_smallmatrix:nn { nV, Vn, VV} +\cs_generate_variant:Nn \moremath_antidiagonal_smallmatrix:nn { nV, Vn, VV } +\cs_new_protected_nopar:Nn \__moremath_generate_one_filled_clist:Nn +{ + \seq_clear:N \l_tmpa_seq + \int_step_inline:nn {#2} + { + \seq_put_right:NV \l_tmpa_seq \c_one_int + } + \clist_set_from_seq:NN #1 \l_tmpa_seq +} +\cs_generate_variant:Nn \__moremath_generate_one_filled_clist:Nn { N V } +\clist_new:N \l__moremath_id_entries_clist +\cs_new_protected_nopar:Nn \moremath_id_matrix:n +{ + \clist_clear:N \l__moremath_id_entries_clist + \__moremath_generate_one_filled_clist:Nn \l__moremath_id_entries_clist {#1} + \moremath_diagonal_matrix:VV \l__moremath_matrix_delim_tl \l__moremath_id_entries_clist +} +\cs_new_protected_nopar:Nn \moremath_id_smallmatrix:n +{ + \clist_clear:N \l__moremath_id_entries_clist + \__moremath_generate_one_filled_clist:Nn \l__moremath_id_entries_clist {#1} + \moremath_diagonal_smallmatrix:VV \l__moremath_matrix_delim_tl \l__moremath_id_entries_clist +} +\cs_generate_variant:Nn \moremath_id_matrix:n { V } +\cs_generate_variant:Nn \moremath_id_smallmatrix:n { V } +\msg_new:nnnn { moremath } { matrix / already-defined-doc-cmd-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~definition~\msg_line_context:. +} +{ + The~control~sequence~'#1'~has~already\\ + been~defined~by~some~other~package.\\ + And~I~am~refusing~to~overwrite~the~existing~definition,\\ + therefore~I~am~skipping~the~definition~of~this~command. +} +\bool_if:nTF \l__moremath_predef_crvector_bool +{ +\cs_if_free:NTF \cvector +{ + \NewDocumentCommand \cvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_column_vector:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + % issue a warning message if the csname is already taken. + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \cvector + } +} % \cs_if_free:NTF \cvector +\cs_if_free:NTF \rvector +{ + \NewDocumentCommand \rvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_row_vector:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + % warn if csname is already taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip} + { + \rvector + } +} % \cs_if_free:NTF \rvector +\cs_if_free:NTF \smallcvector +{ + \NewDocumentCommand \smallcvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn {moremath / matrix} {#1} + } + \moremath_column_smallvector:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + % Issue a warning message if the csname is already taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallcvector + } +} % \cs_if_free:NTF \smallcvector + +\cs_if_free:NTF \smallrvector +{ + \NewDocumentCommand \smallrvector { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_row_smallvector:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + % warn if csname is taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallrvector + } +} +\cs_new_protected:Nn \__moremath_new_vector_shorth_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + % set the delimiter key pre-set for this function + \keys_set:nn {moremath / matrix } {delimiter = #3} + \tl_if_novalue:nF {##1} + { + \keys_set:nn {moremath / matrix } {##1} + } + #2 \l__moremath_matrix_delim_tl {##2} + \group_end: + } + }{ + % warn if csname is taken + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + #1 + } + } +} +\__moremath_new_vector_shorth_doc_cmd:NNn \pcvector \moremath_column_vector:Vn {p} +\__moremath_new_vector_shorth_doc_cmd:NNn \bcvector \moremath_column_vector:Vn {b} +\__moremath_new_vector_shorth_doc_cmd:NNn \Bcvector \moremath_column_vector:Vn {B} +\__moremath_new_vector_shorth_doc_cmd:NNn \vcvector \moremath_column_vector:Vn {v} +\__moremath_new_vector_shorth_doc_cmd:NNn \Vcvector \moremath_column_vector:Vn {V} +\__moremath_new_vector_shorth_doc_cmd:NNn \prvector \moremath_row_vector:Vn {p} +\__moremath_new_vector_shorth_doc_cmd:NNn \brvector \moremath_row_vector:Vn {b} +\__moremath_new_vector_shorth_doc_cmd:NNn \Brvector \moremath_row_vector:Vn {B} +\__moremath_new_vector_shorth_doc_cmd:NNn \vrvector \moremath_row_vector:Vn {v} +\__moremath_new_vector_shorth_doc_cmd:NNn \Vrvector \moremath_row_vector:Vn {V} +\__moremath_new_vector_shorth_doc_cmd:NNn \psmallcvector \moremath_column_smallvector:Vn + {p} +\__moremath_new_vector_shorth_doc_cmd:NNn \bsmallcvector \moremath_column_smallvector:Vn + {b} +\__moremath_new_vector_shorth_doc_cmd:NNn \Bsmallcvector \moremath_column_smallvector:Vn + {B} +\__moremath_new_vector_shorth_doc_cmd:NNn \vsmallcvector \moremath_column_smallvector:Vn + {v} +\__moremath_new_vector_shorth_doc_cmd:NNn \Vsmallcvector \moremath_column_smallvector:Vn + {V} +\__moremath_new_vector_shorth_doc_cmd:NNn \psmallrvector \moremath_row_smallvector:Vn {p} +\__moremath_new_vector_shorth_doc_cmd:NNn \bsmallrvector \moremath_row_smallvector:Vn {b} +\__moremath_new_vector_shorth_doc_cmd:NNn \Bsmallrvector \moremath_row_smallvector:Vn {B} +\__moremath_new_vector_shorth_doc_cmd:NNn \vsmallrvector \moremath_row_smallvector:Vn {v} +\__moremath_new_vector_shorth_doc_cmd:NNn \Vsmallrvector \moremath_row_smallvector:Vn {V} + +}{ % \bool_if:nTF \l__moremath_predef_crvector_bool FALSE PATH + \msg_info:nnnn {moremath} {load / disabling} {no-crvector} + { + commands~producing~row~and~column~vectors + } +} % \bool_if:nTF \l__moremath_predef_crvector_bool +\bool_if:nTF \l__moremath_predef_matrix_bool +{ +\cs_if_free:NTF \diagmat +{ + \NewDocumentCommand \diagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_diagonal_matrix:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn {moremath} {matrix / already-defined-doc-cmd-skip} + { + \diagmat + } +} % \cs_if_free:nTF \diagmat + +\cs_if_free:NTF \antidiagmat +{ + \NewDocumentCommand \antidiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_antidiagonal_matrix:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \antidiagmat + } +} % \cs_if_free:nTF \antidiagmat + +\cs_if_free:NTF \smalldiagmat +{ + \NewDocumentCommand \smalldiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_diagonal_smallmatrix:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smalldiagmat + } +} + +\cs_if_free:NTF \smallantidiagmat +{ + \NewDocumentCommand \smallantidiagmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_antidiagonal_smallmatrix:Vn \l__moremath_matrix_delim_tl {#2} + \group_end: + } +}{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + \smallantidiagmat + } +} +\cs_new_protected:Nn \__moremath_new_matrix_shorth_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + \tl_if_empty:nF {#3} + { + \keys_set:nn { moremath / matrix } + { + delimiter = #3 + } + } % \tl_if_empty:nF {#3} + \tl_if_novalue:nF {##1} + { + \keys_set:nn { moremath / matrix } {##1} + } + #2 \l__moremath_matrix_delim_tl {##2} + \group_end: + } + }{ + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + { + #1 + } + } +} +\__moremath_new_matrix_shorth_doc_cmd:NNn \pdiagmat \moremath_diagonal_matrix:Vn {p} +\__moremath_new_matrix_shorth_doc_cmd:NNn \bdiagmat \moremath_diagonal_matrix:Vn {b} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Bdiagmat \moremath_diagonal_matrix:Vn {B} +\__moremath_new_matrix_shorth_doc_cmd:NNn \vdiagmat \moremath_diagonal_matrix:Vn {v} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Vdiagmat \moremath_diagonal_matrix:Vn {V} +\__moremath_new_matrix_shorth_doc_cmd:NNn \pantidiagmat + \moremath_antidiagonal_matrix:Vn {p} +\__moremath_new_matrix_shorth_doc_cmd:NNn \bantidiagmat + \moremath_antidiagonal_matrix:Vn {b} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Bantidiagmat + \moremath_antidiagonal_matrix:Vn {B} +\__moremath_new_matrix_shorth_doc_cmd:NNn \vantidiagmat + \moremath_antidiagonal_matrix:Vn {v} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Vantidiagmat + \moremath_antidiagonal_matrix:Vn {V} +\__moremath_new_matrix_shorth_doc_cmd:NNn \psmalldiagmat + \moremath_diagonal_smallmatrix:Vn {p} +\__moremath_new_matrix_shorth_doc_cmd:NNn \bsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {b} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Bsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {B} +\__moremath_new_matrix_shorth_doc_cmd:NNn \vsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {v} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Vsmalldiagmat + \moremath_diagonal_smallmatrix:Vn {V} +\__moremath_new_matrix_shorth_doc_cmd:NNn \psmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {p} +\__moremath_new_matrix_shorth_doc_cmd:NNn \bsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {b} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Bsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {B} +\__moremath_new_matrix_shorth_doc_cmd:NNn \vsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {v} +\__moremath_new_matrix_shorth_doc_cmd:NNn \Vsmallantidiagmat + \moremath_antidiagonal_smallmatrix:Vn {V} +\cs_if_free:NTF \idmat +{ + \NewDocumentCommand \idmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_id_matrix:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \idmat FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {\idmat} +} +\cs_if_free:NTF \smallidmat +{ + \NewDocumentCommand \smallidmat { o m } + { + \group_begin: + \tl_if_novalue:nF {#1} + { + \keys_set:nn { moremath / matrix } {#1} + } + \moremath_id_smallmatrix:n {#2} + \group_end: + } +}{ % \cs_if_free:NTF \smallidmat FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {\smallidmat} +} +\cs_new_protected:Nn \__moremath_new_id_matrix_doc_cmd:NNn +{ + \cs_if_free:NTF #1 + { + \NewDocumentCommand #1 { o m } + { + \group_begin: + \tl_if_empty:nF {#3} + { + \keys_set:nn { moremath / matrix } {#3} + } + \tl_if_novalue:nF {##1} + { + \keys_set:nn { moremath / matrix } {##1} + } + #2 {##2} + \group_end: + } + }{ % \cs_if_free:NTF #1 FALSE BRANCH + \msg_warning:nnn { moremath } { matrix / already-defined-doc-cmd-skip } + {#1} + } +} +\__moremath_new_id_matrix_doc_cmd:NNn \pidmat \moremath_id_matrix:n { delimiter = p } +\__moremath_new_id_matrix_doc_cmd:NNn \bidmat \moremath_id_matrix:n { delimiter = b } +\__moremath_new_id_matrix_doc_cmd:NNn \Bidmat \moremath_id_matrix:n { delimiter = B } +\__moremath_new_id_matrix_doc_cmd:NNn \vidmat \moremath_id_matrix:n { delimiter = v } +\__moremath_new_id_matrix_doc_cmd:NNn \Vidmat \moremath_id_matrix:n { delimiter = V } +\__moremath_new_id_matrix_doc_cmd:NNn \psmallidmat \moremath_id_smallmatrix:n + { delimiter = p } +\__moremath_new_id_matrix_doc_cmd:NNn \bsmallidmat \moremath_id_smallmatrix:n + { delimiter = b } +\__moremath_new_id_matrix_doc_cmd:NNn \Bsmallidmat \moremath_id_smallmatrix:n + { delimiter = B } +\__moremath_new_id_matrix_doc_cmd:NNn \vsmallidmat \moremath_id_smallmatrix:n + { delimiter = v } +\__moremath_new_id_matrix_doc_cmd:NNn \Vsmallidmat \moremath_id_smallmatrix:n + { delimiter = V } +}{ % \bool_if:nTF \l__moremath_predef_matrix_bool FALSE BRANCH + \msg_info:nnnn {moremath} { load / disabling } { no-matrix } + { + (anti-)diagonal~matrix~commands + } +} % \bool_if:nTF \l__moremath_predef_matrix_bool +\msg_new:nnnn { moremath } { abs-shorth / csname-already-defined-skip } +{ + Control~sequence~'#1'~is~already~defined.\\ + Skipping~declaration~of~paired~delimiter~\msg_line_context:.\\ + Use~package~option~'no-abs-shorthands'~to~disable~the~paired\\ + delimiter~shorthands. +}{ + The~control~sequence~'#1'~has~already~been\\ + defined~by~something~else.\\ + I~am~refusing~to~overwrite~its~existing~definition~and~instead~avoid\\ + declaring~a~paired~delimiter.\\ +} +\bool_if:NTF \l__moremath_predef_abs_bool +{ +\cs_if_free:NTF \abs +{ + \DeclarePairedDelimiter \abs {\lvert} {\rvert} +}{ + % warn if the csname is taken + \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip } + {\abs} +} % \cs_if_free:NTF \abs + +\cs_if_free:NTF \norm +{ + \DeclarePairedDelimiter \norm {\lVert} {\rVert} +}{ + % warn if csname is already taken + \msg_warning:nnn { moremath } { abs-shorth / csname-already-defined-skip } + {\norm} +} % \cs_if_free:NTF +}{ + \msg_info:nnnn {moremath} {load / disabling} {no-abs-shorthands} + { + '\abs'~and~'\norm'~macros + } +} % End of the conditional +\endinput +%% +%% End of file `moremath.sty'. |