New Plugin: MathJax extended + preamble

Coming Soon :tm:! I have a hacky local version “working” right now.

3 Likes

Thank you for the great work, I love this!

Is it possible to add different packages in the preamble somehow? It is straightforward to edit the plugin to load the packages, e.g. in main.ts I could load the tensor package:

        o.loader = { load: ['[tex]/mhchem', '[tex]/bussproofs', '[tex]/tensor'] };
        o.tex.packages = { '[+]': ['mhchem', 'bussproofs', 'tensor']};

But then I would need to fork it, create my own plug in, and then pull from upstream every time you update. And presumably every user would need to do the same depending on what packages they need, which would be a bit of a mess. I’d love for a way to add MathJax extensions within this plugin!

1 Like

Have you tried using \require? For example I can load the braket package quite easily like this:

$\require{braket}\bra{x + y}$

I’ve enabled email notifications to be more responsive here.

Hi, this plugin is really wonderful! However, it stops working in my Obsidian note since last update (v0.11.3). Does anyone encounter similar problem?

Hello @shenghan, you’re not the first person to report this though each time the issue seems to be transitory. Can you confirm that you are on Windows (10)? Are you able to reproduce this in a fresh vault?

I’m going to take a deeper look into this during the weekend, see if maybe something changed in initialization of obsidian plugins?

Does this plug-in allow one to number equations? Currently $$ x^2 $$ shows as an equation but doesn’t have an equation number. Thanks.

Related forum topics: here, here

1 Like

Hi @xldenis , thanks for your reply. I am using Windows 10.
I follow your suggestion to try a new vault, and the problem disappear. In the current vault, I reinstall the plugin, and the problem also disappear. Thanks!

Hey, I’m having the same problem. I’m in version 0.11.5, also on Windows 10. When I made a new vault for testing it worked as you said. So I tried copying my old vault’s folder to another location, deleting the .obsidian folder, and opening the copied folder as a new vault. This worked, so the next step was deleting the .obsidian folder from my original vault, removing it from Obsidian, and opening the folder as a new vault. This worked too, but then I tried editing the preamble. Since nothing changed, and I wasn’t able to refresh Obsidian (Ctrl+R doesn’t seem to do anything [anymore?]) I closed and re-opened the program, but now the plugin doesn’t seem to work anymore. Some comments:

  • Reinstalling doesn’t work for me like it does for @shenghan, apparently.

  • Some times when testing MathJax would break completely, and the equations would display as plain text.

By the way, thanks for making this much needed package.

Thanks for the report, I’ll investigate this over the weekend, I wonder if there have been changes to plug-in loading or file access… I’m curious why it only happens on windows 10 though.

Hey. Just wanted to tell that your plugin is great. It is exactly what I was looking for, just thought of something like this and here it is! The open-source community at its best.

1 Like

To load the package “physics” you can use \require{physics} in the preamble. For example, when I use \require{physics} in the preamble, I see $\op{a}{b}$ rendered globally and it is not rendered globally otherwise.

Also trying to find out why $\ip{a}{b}$ from physics does not work, while $\innerproduct{a}{b}$ does. In physics readme \ip is said to be the shorthand version of \innerproduct.

2 Likes

Could it be a library version issue?

I didn’t get the chance to debug the windows issue yet, but it’s high on my todo list

I need to have a common latex preamble to my notes, but I noticed the banner on the Github readme:

Looking for someone to take this plugin over!

Anyone knows if there is another plugin out there replacing this one?

Hi,
maybe not exactly what you are looking for, but…

You can define some commands on for example your first note that you load in obsidian, your HomePage. There you can define things like this:

$$
\newcommand{func}[3]{\overset{#1}{\mathbb{Z}}{}^{(#2)}_{\text{#3}}}
$$

and in another note you can use it like this:

$$
\func{a}{b}{c}
$$

That renders like this:
image

1 Like

What do you mean by “HomePage”? If there is a setting for the “first note that Obsidian loads” on startup, I’m sorry but I can’t find it. Could you clarify this point?

Thanks!

I use a community plugin called “Homepage”. There you can define a default page that you want to open on startup of Obsidian. On that page you can have links to other important notes etc.

And you can also add these kind of Mathjax definitions. Because it is the first page you load, you inject these things in Mathjax before you open any other note. So you have one place to define the definitions you can use in other notes.

1 Like

Hey everyone, I recently took over this plugin from @xldenis and will be publishing future releases at GitHub - wei2912/obsidian-latex. It’ll take a while for me to go through the existing issues and plan out what to work on, but feel free to let me know if you have any suggestions/feedback, either on this forum or through GitHub Issues. Thanks!

3 Likes

@wei2912 Thanks for your efforts! I just want to say I find this plugin very useful, so I’m grateful someone is watching over it.

In addition to a global preamble, I would suggest that we consider also local preambles, that is, the functionality which enables each markdown file to optionally specify, say via its properties, a .sty file to be loaded, or a documentclass to be inherited. For the notes in Obsidian could very well differ drastically in their topics and consequently depend on different commands.

It would be even more flexible if options can be fed to a specification of the local preamble.

From my understanding, this is unofrtunately extremely hard due to how MathJax is loaded in obsidian.