dendron
dendron copied to clipboard
Enable setting Katex options from dendron
Please Select if your Request is Either something new or an Enhancement
- [ ] Enhancement of an existing Feature.
- [x] Request of a new feature.
Please select the area your request applies to. (Multiple selections are Possible)
- [ ] Onboard. Initial vault setup and import/export pods
- [x] Create. Note creation, lookup, snippets and templates
- [ ] Retrieve. Backlinks, references, graph view
- [ ] Structure. Refactoring, multi-vault and schemas
- [ ] Publish. Sharing your repo with the world
- [ ] Misc (Choose this if your not sure)
Is your feature request related to a problem? Please describe
Among other things I take notes on the math books that I read. I prefer markdown based solutions over latex for various reasons. One thing that latex still does better than all the markdown note taking applications that I used(they all use the Katex engine) is the ability to define new commands with macros. This is useful because when one reads a new book new notation is introduced and used throughout the book and when I'm taking notes it would be great to define new shorter commands for this.
Describe the solution you'd like
It would be great if you could expose the Katex settings via the "dendron.yml" or some other mechanism. I was browsing through the source and found that dendron is using rehype-katex as the API for Katex. This library supports passing options to Katex. The options that Katex accepts are documented here.
My problem would be solved by exposing the "globalGroup" option which I could turn to true and then macros would persist between the math blocks. Note that inside one math block I can already use the "\newcommand" and similar macros(documented here) and in that block I can call it. For example "$$\newcommand\powmacro[2]{#1^#2} \powmacro{1}{2}$$" displays the expected result.
Describe alternatives you've considered
One can add commands to VS Code and let it do the snippet expansion. One issue I see with this is that you can't call a snippet from another snippet which makes it less flexible than latex macros.
Another solution which I currently use is a clipboard which supports fuzzy search on the clipboard history. My current choice is greenclip. This is fine but it has the same issues as the VS code snippet based approach. Also my my history is cluttered with irrelevant things so again not really my preference.
Additional context
N/A
Thanks for the request. Adding this as a CROP candidate
I started working on this. I managed to put together a rudimentary version. Given that Dendron is using KaTeX and KaTeX has some issues like not supporting default arguments for newcommand and similar macros it might makes sense to expose MathJax as a math renderer option given that the same remark-math github project exposes MathJax as well(see here). I care more about robustness than speed. Also I have larger documents in Obsidian which is probably rendering with MathJax given it supports default values for macros and there are basically these 2 options for rendering math in the browser and they are rendering just fine. For backward compatibility the default renderer can stay KaTeX, but I think this option will benefit a lot of people who do math in Dendron.
In addition a place to define global macros or load third party modules would be nice!
+1 for this, macros are incredibly useful for typesetting maths
I found Markdown-Preview-Enhanced already have Katex macros config. I am not sure we need to port the same functionality to Dendron or able to integrate with Markdown-Preview-Enhanced.
@s1913388 As dendron already replaced the MPE extension view I doubt that relying on it again is a good option.
Are there news about this query. I think that using macro for typesetting equation is a must have for all academics working with equation and writing papers in TeX
This issue is featured in this week's round of CROP voting on Dendron's Discord server.
Is there a chance that this feature be added in a future release ?
I just wanna add that VSCode's built-in preview already supports this feature from settings.json
.
You just have to set your macros in markdown.extension.katex.macros
. The syntax is almost the same as in MD-Preview-enhanced
Dendron does not seem to currently interact with it, though.