sobjornstad / TiddlyRemember

Embed Anki notes in your TiddlyWiki
https://sobjornstad.github.io/TiddlyRemember/
MIT License
66 stars 7 forks source link

Support for mathjax `\(\)` and `\[\]` #9

Closed sandersantema closed 4 years ago

sandersantema commented 4 years ago

I was wondering whether mathjax is supported or might be trivially implemented by for instance simply installing a mathjax tiddlywiki plugin. I couldn't find anything about this in the documentation.

sobjornstad commented 4 years ago

I'm not aware of a TiddlyWiki 5 plugin for MathJax. Anki uses a different syntax ([$][/$]) to call out LaTeX snippets, but if you could get the rendering going in TiddlyWiki, it wouldn't be too hard to do that replacement for the Anki sync side of things.

sandersantema commented 4 years ago

I'm not aware of a TiddlyWiki 5 plugin for MathJax.

Given that I'm not familiar with TiddlyWiki I wouldn't know for sure if this would work but it seems fine: https://gist.github.com/kpe/cc0547b318e6f8d4ddaa

Anki uses a different syntax ([$][/$]) to call out LaTeX snippets, but if you could get the rendering going in TiddlyWiki, it wouldn't be too hard to do that replacement for the Anki sync side of things.

Anki does indeed use a different syntax for latex, but for mathjax it doesn't. For mathjax \( \) works for inline and \[ \] works for displayed formulas. The latex stuff actually gets rendered and put inside the anki card I believe while the mathjax stuff is displayed like it is on stackexchange as far as I understood.

sobjornstad commented 4 years ago

Ooh, I forgot about that. I used to be the primary support person for Anki, but it's been a couple years, so sometimes I forget about features that have been added in the meantime. :-)

I can give it a shot and see what happens. I'm not sure how it's going to interact with the macro rendering, but it's conceivable it might work. I'm extremely busy right now though, so it may be a few days before I get a chance.

On Wed, Jun 3, 2020, at 03:43, sandersantema wrote:

I'm not aware of a TiddlyWiki 5 plugin for MathJax.

Given that I'm not familiar with TiddlyWiki I wouldn't know for sure if this would work but it seems fine: https://gist.github.com/kpe/cc0547b318e6f8d4ddaa

Anki uses a different syntax ([$][/$]) to call out LaTeX snippets, but if you could get the rendering going in TiddlyWiki, it wouldn't be too hard to do that replacement for the Anki sync side of things.

Anki does indeed use a different syntax for latex, but for mathjax it doesn't. For mathjax \( \) works for inline and \[ \] works for displayed formulas. The latex stuff actually gets rendered and put inside the anki card I believe while the mathjax stuff is displayed like it is on stackexchange as far as I understood.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sobjornstad/TiddlyRemember/issues/9#issuecomment-638052793, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARUZRVLT5HIWZIOLSTVC2TRUYEKRANCNFSM4NQ5JO2Q.

linonetwo commented 4 years ago

In tiddlywiki we write mathjax like $$P_{max} = \frac{V_{TH}^2}{4\times R_{TH}}$$

Maybe just use regex to replace leading $$ with \( and tailing $$ with \)

sobjornstad commented 4 years ago

@sandersantema: I tried installing the MathJax plugin mentioned in your gist and at http://mathjax-tw5.kantorsite.net/, but I get an error:

Screenshot from 2020-07-10 14-35-09

At least one person in the gist thread also mentioned this error.

Do you all use something different, or did you have to make some kind of configuration change to get it to work? I'm willing to take a look at what would be required to get this to display in both TiddlyWiki and Anki, but am not keen on debugging someone else's plugin when I don't personally have any use for it.

sobjornstad commented 4 years ago

I gave it another shot but still have not been able to get any MathJax plugin to work in TiddlyWiki, even without pulling Anki or macros or anything like that into the picture. However, I have confirmed that the \( \) syntax syncs across fine into Anki and renders correctly there, so I'm going to close this issue, as I don't think there's anything else to be done in TiddlyRemember to make this work.

Let me know if you think there's something else that should be implemented or documented in TR. If you find a rendering plugin that works in TW, I'd be happy to include a note in the docs about how to use it.

sobjornstad commented 3 years ago

For anyone who might still be subscribed to this, I have a change out that works with the official KaTeX plugin in TiddlyWiki -- see https://github.com/sobjornstad/TiddlyRemember/issues/28. If you want to test and give me feedback, feel free to hop over there.