Links From Within Math Blocks

Currently links do not work within text inside maths blocks. For example, the following


$$
\begin{align*}
    A_{i} \in \mathcal{F}, \ \forall i \in \mathbb{N} &\implies A_{i}^{c} \in \mathcal{F}, \ \forall i \in \mathbb{N} \\
    &\implies \bigcup_{i=0}^{\infty} A_{i}^{c} \in \mathcal{F} \\
    &\implies \left(\bigcup_{i=0}^{\infty} A_{i}^{c} \right)^{c} \in \mathcal{F} \\
    &\implies \bigcap_{i=0}^{\infty} A_{i} \in \mathcal{F} & \text{[[De Morgan's Laws]]} \\
\end{align*}
$$

renders as

This would be a really valuable feature for people writing complex mathematics proofs in Obsidian, as it allows the links to related results to be right next to their usage.

I am aware that this is likely a very difficult thing to implement, given that Obsidian is currently using MathJax, however I believe that moving away from MathJax would have benefits with respect to other feature requests, such as this one. Namely, using MathJax is a bottleneck in being able to have equations be aware of context beyond themselves, and vice versa.

5 Likes

I DEFINITELY FEEL YOU. If this feature comes true, Obsidian will be a paradise for math people.

2 Likes

I found a reddit post suggesting using \href to insert a link in an equation. Not sure if this can be used to link between notes

https://www.reddit.com/r/ObsidianMD/comments/17d0fgm/add_links_inside_math_writing/

OK, after some investigation I found a promising direction.

By default, the protocols that we are allowed to use in \href are the following.

  1. file:
  2. http:
  3. https:

(You can check it by MathJax.config.options.safeOptions.safeProtocols)

So we can’t use obsidian: or javascript: to open a note in the vault. However, we can change this setting afterward. For example, running the following in the dev console (or as a Templater/QuickAdd startup script) will enable us to use Obsidian URI inside \href.

MathJax.config.options.safeOptions.safeProtocols.obsidian = true;
MathJax.startup.getComponents();

For example: $\href{obsidian://open?vault=my%20vault&file=my%20note}{link}$

This way we can insert a link to another note inside an equation. Also it will be possible to create a plugin that renders [[internal link|display text]] as if it were \href{obsidian://...}{display text}.

Find more information at:

Remark

There are some important concerns regarding using [[internal links]] or \href with Obsidian URIs:

  • It will make our notes more Obsidian-dependent and less future-proof.
  • They will not appear in the graph view or backlink view (this is the biggest drawback for me). So it would be best if it could be implemented as a core feature of Obsidian (not as a plugin)
2 Likes

This is a really nice workaround! Thank you.

For me the other big drawback though is the fact that links won’t be automatically updated if notes have their names changed.

2 Likes