【已解决】如何在obsidian中使用actuarialangle、actuarialsymbol宏包?

rt,我希望在记笔记时使用 actuarialangle、actuarialsymbol 这两个宏包,但是网上似乎没有类似的导入宏包的教程,并且参考 如何在 Obsidian 中使用 physics 宏包? - 疑问解答 - Obsidian 中文论坛 中的方法也无法生效,如果各位大神有方法的话,麻烦教教小弟。

physics 能识别, 可能因为 Ob MathJax 直接就带了 physics

// 在 app://obsidian.md/lib/mathjax/tex-chtml-full.js
// 这里能搜到 physics 
// 但搜不到 actuarialxxx

"undefined" != typeof MathJax && MathJax.loader && MathJax.loader.preLoad("[tex]/action", "[tex]/ams", "[tex]/amscd", "[tex]/bbox", "[tex]/boldsymbol", "[tex]/braket", "[tex]/bussproofs", "[tex]/cancel", "[tex]/cases", "[tex]/centernot", "[tex]/color", "[tex]/colorv2", "[tex]/colortbl", "[tex]/empheq", "[tex]/enclose", "[tex]/extpfeil", "[tex]/gensymb", "[tex]/html", "[tex]/mathtools", "[tex]/mhchem", "[tex]/newcommand", "[tex]/noerrors", "[tex]/noundefined", "[tex]/physics", "[tex]/upgreek", "[tex]/unicode", "[tex]/verb", "[tex]/configmacros", "[tex]/tagformat", "[tex]/textcomp", "[tex]/textmacros", "[tex]/setoptions"),
            e.AllPackages = ["base", "action", "ams", "amscd", "bbox", "boldsymbol", "braket", "bussproofs", "cancel", "cases", "centernot", "color", "colortbl", "empheq", "enclose", "extpfeil", "gensymb", "html", "mathtools", "mhchem", "newcommand", "noerrors", "noundefined", "upgreek", "unicode", "verb", "configmacros", "tagformat", "textcomp", "textmacros"]
        },

这些知识我不太懂, 感觉宏包和 \newcommand 似乎也没太大区别?

比如在笔记里执行一遍

$\newcommand{\angl}[1]{\require{enclose} \enclose{actuarial}{#1}}$

$a_{\angl{n}}$ 会由原先的 image 变为 image

其中 \angl 定义我是从这里找到的 actuarialsymbol-MathJax/actuarialsymbol.js at main · MADEV34/actuarialsymbol-MathJax

看上去把常用的都拿 \newcommand 定义一遍就行, 缺点也明显: 这一大堆 \newcommand 需要每次进入该笔记都执行一遍

应该有更简单的办法做这事, 目前我还不会


此外还搜到个 wei2912/obsidian-latex 插件, 在 Ob 根目录造个 preamble.sty 文件来定义 \newcommand 实现同样效果, 这插件我没测试, 不知道有啥坑

非常感谢你的帮助。因为我还没有学习过任何计算机语言,所以不会阅读代码并进行修改。但在阅读你的示例后,我利用ds对 actuarialsymbol 的代码进行了修改,使其符合 Extended MathJax 的要求,并经测试能够正常显示。现修改后代码如下所示,希望能帮助到有需要的朋友。另外,如果想拥有更流畅的输入体验,建议配合Latex Suite自定义后再使用。
[collapse]

% 精算符号定义(基于 \newcommand)
\newcommand{\endow}[2]{\require{enclose} {#1:\enclose{actuarial}{#2}}}
\newcommand{\endowxn}{\require{enclose} {x:\enclose{actuarial}{n}}}

\newcommand{\pureendow}[2]{\require{enclose} {#1:\overset{1}{\enclose{actuarial}{#2}}}}
\newcommand{\pureendowxn}{\require{enclose} {x:\overset{1}{\enclose{actuarial}{n}}}}

\newcommand{\term}[2]{\require{enclose} {\overset{1}{#1}:\enclose{actuarial}{#2}}}
\newcommand{\termxn}{\require{enclose} {\overset{1}{x}:\enclose{actuarial}{n}}}

\newcommand{\angl}[1]{\require{enclose} \enclose{actuarial}{#1}}
\newcommand{\angln}{\require{enclose} \enclose{actuarial}{n}}

\newcommand{\nthtop}[2]{\overset{#1}{#2}}

\newcommand{\joint}[1]{\overline{#1}}

\newcommand{\itop}[1]{\overset{1}{#1}}
\newcommand{\iitop}[1]{\overset{2}{#1}}
\newcommand{\iiitop}[1]{\overset{3}{#1}}

\newcommand{\ibottom}[1]{\underset{1}{#1}}
\newcommand{\iibottom}[1]{\underset{2}{#1}}
\newcommand{\iiibottom}[1]{\underset{3}{#1}}

% 带参数的保险符号
\newcommand{\Ax}[2]{A^{#1}_{#2}}
\newcommand{\bAx}[2]{\bar{A}^{#1}_{#2}}
\newcommand{\dAx}[2]{\ddot{A}^{#1}_{#2}}
\newcommand{\tAx}[2]{\tilde{A}^{#1}_{#2}}

\newcommand{\ax}[2]{a^{#1}_{#2}}
\newcommand{\bax}[2]{\bar{a}^{#1}_{#2}}
\newcommand{\dax}[2]{\ddot{a}^{#1}_{#2}}
\newcommand{\tax}[2]{\tilde{a}^{#1}_{#2}}

\newcommand{\Aringx}[2]{\mathring{A}^{#1}_{#2}}
\newcommand{\aringx}[2]{\mathring{a}^{#1}_{#2}}

\newcommand{\Eringx}[2]{\mathring{E}^{#1}_{#2}}
\newcommand{\eringx}[2]{\mathring{e}^{#1}_{#2}}

\newcommand{\Sringx}[2]{\mathring{S}^{#1}_{#2}}
\newcommand{\sringx}[2]{\mathring{s}^{#1}_{#2}}

\newcommand{\dx}[2]{d^{#1}_{#2}}
\newcommand{\Dx}[2]{\mathscr{D}^{#1}_{#2}}

% 特殊保险符号(无参数)
\newcommand{\IA}{(IA)}
\newcommand{\IbA}{(I\bar{A})}
\newcommand{\bIbA}{(\bar{I}\bar{A})}
\newcommand{\ImA}{(I^{(m)}A)}
\newcommand{\ImbA}{(I^{(m)}\bar{A})}
\newcommand{\bImbA}{(\bar{I}^{(m)}\bar{A})}
\newcommand{\Is}{(Is)}
\newcommand{\Ibs}{(I\bar{s})}
\newcommand{\Ids}{(I\ddot{s})}

% 其他符号
\newcommand{\Ex}[2]{E^{#1}_{#2}}

\newcommand{\DA}{(DA)}
\newcommand{\DbA}{(D\bar{A})}
\newcommand{\bDbA}{(\bar{D}\bar{A})}
\newcommand{\DmA}{(D^{(m)}A)}
\newcommand{\DmbA}{(D^{(m)}\bar{A})}
\newcommand{\bDmbA}{(\bar{D}^{(m)}\bar{A})}
\newcommand{\Ds}{(Ds)}
\newcommand{\Dbs}{(D\bar{s})}
\newcommand{\Dds}{(D\ddot{s})}

\newcommand{\lx}[2]{\ell^{#1}_{#2}}
\newcommand{\Lx}[2]{\mathscr{L}^{#1}_{#2}}

\newcommand{\px}[2]{p^{#1}_{#2}}
\newcommand{\Px}[2]{P^{#1}_{#2}}

\newcommand{\premium}[2]{P^{#1}\ \left({#2}\right)}
\newcommand{\bpremium}[2]{\bar{P}^{#1}\left({#2}\right)}
\newcommand{\tpremium}[2]{\tilde{P}^{#1}\left({#2}\right)}

\newcommand{\paidup}[2]{W^{#1}\ \left({#2}\right)}
\newcommand{\bpaidup}[2]{\bar{W}^{#1}\left({#2}\right)}
\newcommand{\tpaidup}[2]{\tilde{W}^{#1}\left({#2}\right)}

\newcommand{\reserve}[2]{V^{#1}\ \left({#2}\right)}
\newcommand{\breserve}[2]{\bar{V}^{#1}\left({#2}\right)}
\newcommand{\treserve}[2]{\tilde{V}^{#1}\left({#2}\right)}

\newcommand{\qx}[2]{q^{#1}_{#2}}
\newcommand{\Qx}[2]{Q^{#1}_{#2}}

\newcommand{\sx}[2]{s^{#1}_{#2}}
\newcommand{\bsx}[2]{\bar{s}^{#1}_{#2}}
\newcommand{\dsx}[2]{\ddot{s}^{#1}_{#2}}

\newcommand{\Vx}[2]{V^{#1}_{#2}}
\newcommand{\Wx}[2]{W^{#1}_{#2}}

\newcommand{\actsymb}[5]{{_{#1}^{#2}{#3}_{#4}^{#5}}}

[/collapse]

1 个赞