vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Support MathJax in addition to KaTeX

Open yzhang-gh opened this issue 6 years ago • 17 comments

Any chance to add MathJaX support in addition to KaTeX? Like letting the user to select the Math Rendering Engine?

MathJaX is almost fully compliant with LaTeX while KaTeX misses few abilities.

Originally posted by @RoyiAvital in https://github.com/yzhang-gh/vscode-markdown/issues/106#issuecomment-468934680

yzhang-gh avatar Oct 11 '19 02:10 yzhang-gh

Hi @RoyiAvital, thanks for the feedback.

There is a workaround now (use MathJax scripts and export it to HTML). For example,

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

\\(\alpha\\)

Remember to use \\( and \\[ rather than $ and $$.

The only disadvantage is you cannot see the preview inside VSCode as it disables scripts for security concerns. I suggest using markdown.extension.print.onFileSave option and Live Server extension.

mathjax

yzhang-gh avatar Oct 11 '19 02:10 yzhang-gh

As I wrote in the other issue, I really think this feature will make this extension perfect for students as alternative to LaTeX. Yet in that case KaTeX won't cut it. it has too many limitations and missing features.

It will be great to have MathJaX support in addition to KaTeX. As the other features in this package are amazing (I like specifically all the flexibility with TOC).

RoyiAvital avatar Oct 11 '19 08:10 RoyiAvital

Just out of curiosity, what are the missing features of KaTeX ?

You could also ask them to add them, I mean the advantage of KaTeX is that it is really fast, which may be convenient while taking notes.

PierreMarchand20 avatar Oct 11 '19 08:10 PierreMarchand20

On modern Chrome the speed difference isn't an issue. MathJaX has support for all environments of LaTeX while KaTeX doesn't. It also doesn't have the reference and labeling system of MathJaX.

We have written many times about features of KaTeX but they are not easy to implement in KaTeX. I guess due to the design choices made there.

If you want to have a true replacement for LaTeX in MarkDown, you need MathJaX.

RoyiAvital avatar Oct 11 '19 09:10 RoyiAvital

@RoyiAvital I agree it might be a good addition. It is just because I don't much time for it. BTW, we haven't got a new version of this extension for near 3 months 😅.

yzhang-gh avatar Oct 11 '19 15:10 yzhang-gh

@yzhang-gh , I see new features in the extension (Great!). Any chance to give this another thought?

It is the only blocker for me to use it as my daily MarkDown driver for University.

Thank You.

RoyiAvital avatar Feb 21 '20 06:02 RoyiAvital

Actually, most of those features come from PRs (or only require a few tweaks to the source code).

MathJax support is not a "small" feature. It requires extra dependency and needs testing. For comparison, supporting \(\) and \[\] delimiters seems to be a more popular feature (#552) and easier to implement. (However, no ETA too. 😑)

I would suggest using Markdown+Math plugin which is more dedicated to math support. I'm not sure whether it is compatible with this extension. But I can add an option to disable math support of this one. It is much easier.

yzhang-gh avatar Feb 23 '20 02:02 yzhang-gh

Markdown+Math use KaTeX as well instead of MathJaX.

Can't the MathJaX functionality be borrowed from other Extensions? MarkDown Preview Enhanced is using MathJaX. Could their code be borrowed?

RoyiAvital avatar Feb 23 '20 07:02 RoyiAvital

Markdown Preview Enhanced is using MathJaX. Could their code be borrowed?

It goes for an entirely different direction, providing a standalone preview, rather than contribute to the VSCode's default one.

Since you have mentioned it, why not just use it 😳? It is compatible with this extension (it has its own preview window and supports exporting to PDF/HTML)

yzhang-gh avatar Feb 23 '20 11:02 yzhang-gh

I am using it. But your extension has many features I'd like to have.

RoyiAvital avatar Feb 23 '20 17:02 RoyiAvital

Yep, I have seen many people using the two extensions together. This extension provides the general features and the MPE enables many useful Markdown dialects.

yzhang-gh avatar Feb 24 '20 01:02 yzhang-gh

I'm not sure I'm following. Which one will render the output, this one or MPE? MPE uses MathJaX (Can be configured) while this uses the limited KaTeX. When both implement the same feature, which one will be the effective one?

RoyiAvital avatar Feb 24 '20 07:02 RoyiAvital

https://shd101wyy.github.io/markdown-preview-enhanced/#/usages image

For this extension, it is ctrl+shift+v/ctrl+k v.

yzhang-gh avatar Feb 24 '20 07:02 yzhang-gh

I can guarantee you that Ctrl + k, v is what's used to enable the preview for MPE on Visual Studio Code:

image

RoyiAvital avatar Feb 24 '20 07:02 RoyiAvital

Alright, you may not be very familiar with VSCode (and the MPE's docs are not clear) so I tried it out for you.

You need to invoke the toggle-preview command from the command palette because the assigned keybindings are conflicted.

image

image

You can reassign those keybindings as you wish (see https://code.visualstudio.com/docs/getstarted/keybindings).

yzhang-gh avatar Feb 24 '20 08:02 yzhang-gh

Any update about this function?

PeterWang-dev avatar Jun 27 '22 01:06 PeterWang-dev

Adding to this request. MathJax has full accessibility support, KaTeX has none.

mathematicsformisfits avatar Aug 01 '23 15:08 mathematicsformisfits