Latex globals don't apply to previously created nodes in canvas. Sometimes breaks on load too

Steps to reproduce

  1. Create a new canvas
  2. Create a first node with $$\a$$ (this should show up in red, because \a is undefined)
  3. Create a second node with $$\def \a{w}$$ (this defines a latex macro, replacing \a with w)
  4. Copy the first node, and paste it, so that there are now three nodes total
  5. Bug #1: only the pasted node will now show w, meaning the first node didn’t update its latex after creating the macro
  6. Save and close obsidian
  7. Open the canvas in obsidian again
  8. Bug #2: even on document reload, the macro \a is still not applied to both the first and the third node, even though it is defined in the document

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

I expect nodes with formerly invalid macros, to become valid when you create a macro, ie: it should refresh any latex using a custom macro, when a macro is created.

In general, latex macros seem pretty flaky in obsidian, sometimes requiring a restart, because latex globals are global per-session, if they’ve been loaded once (also mentioned in Custom LaTeX commands (global)), which, is very unintuitive. I would expect latex macros to be per-document. I would love for there to be a dedicated place to define latex macros in every document, rather than doing it in-place. I’m guessing a lot of the issues just come from how MathJax works, and the order they are loaded in

Actual result

Some nodes show up as invalid, even though a valid global macro is defined

Environment

SYSTEM INFO:
Obsidian version: v1.3.5
Installer version: v1.3.5
Operating system: Windows 10 Home 10.0.19045
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

image

yes

You can open a FR for this.

Ultimately, this boil down to how obsidian and mathjax work. Mathjax doesn’t lend itself to being embedded easily per document but is active on the whole app. This is the reason why equation numbering doesn’t work well either.

I think there is plugin that help you preload a set of macro at obsidian startup. They will applied globally.

alright! should I open a FR for having mathjax work on a per-document basis? feels more like a bug to me

Neverminded, I’ll write it.

oh lol I just finished my writeup and was about to link here ;-;

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.