shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.48k stars 173 forks source link

Katex 应该如何添加宏?| How to add Katex macros? #519

Closed pilgrimlyieu closed 3 years ago

pilgrimlyieu commented 3 years ago

已解决 Solved

我通过禁用插件确定了是MPE的问题我的问题。 I confirm it's the question of MPE me through forbidening plugins.

我尝试在C:\Users\Administrator\.mume\katex_config.js添加宏的设置,但是并不成功。 I've tried to add macros setting in C:\Users\Administrator\.mume\katex_config.js, but it didn't work.

如下,应该没有问题 As follow, it should be right.

2021-08-06_14-43-44

不过有个点我并不确定,宏的设置格式是"\\macroname": "{\\command}"吗?我并不确定是否要加{},但是似乎加不加都没能成功。 But I have one point none confirmed: Is the format of macros setting like "\\macroname": "{\\command}"? I'm not sure whether {} should be added. Though, it seems to influence nothing.

显示结果 Show Result

2021-08-06_14-42-35

请修复这个问题/帮助我! Please fix this bug/help me find the problems lie in!

非常感谢! Thanks very much!

pilgrimlyieu commented 3 years ago

大家好,我已经解决了问题,我会将我的方法贴在下面。不过我仍然弄不清楚一些细节。 Hey guys, I've solved the problem. I'll post the procedure as follows. Though I'm confused about some of details.

以下右边预览窗口的代码为$$\d$$。 The follows code is $$\d$$.

这是通过禁用宏试验出的两个问题所在。 I disabled two macros and found out where the question lay in.

2021-08-07_10-07-02

通过一些小的修改,我解决了它,但是我弄不清楚原理。发生错误的两个宏为\sdx\ddx,但是类似的\sdy\ddy却并没有出现问题,我非常困惑。 I overcame it through a small modify. But I don't know why. The error lies in two macros \sdx and \ddx. But \sdy and \ddy works great. I'm confused about it.

2021-08-07_10-10-41

宏代码(已修改) macros codes(modified)

module.exports = {
    macros: {
        "\\d": "\\mathrm{d}​​​​",
        "\\lims": "\\lim\\limits",
        "\\i": "\\mathrm{i}",
        "\\rt": "\\rightarrow",
        "\\Rt": "\\Rightarrow",
        "\\Lrt": "\\Leftrightarrow",
        "\\as": "\\bigg|",
        "\\f": "f(x)",
        "\\sums": "\\displaystyle\\sum",
        "\\pros": "\\displaystyle\\prod",
        "\\c": "\\mathrm{C}",
        "\\dyx": "\\dfrac{\\d y}{\\d x}",
        "\\ddy": "\\dfrac{\\d}{\\d y}​",
        "\\ddx": "\\dfrac{\\d\ }{\\d x}​​",//​
        "\\dy": "\\d y",
        "\\dx": "\\d x",
        "\\sdy": "\\d^2 y",
        "\\sdx": "\\d^{2} x",​//
        "\\sdyx": "\\dfrac{\\d^2y}{\\d x^2}",
    }
}

如果你知道为什么,请告诉我,非常感谢! If you know the reason, please make a comment here. I'll really appreciate it!