Currently, Obsidian recognizes $...$ as inline math only if there is no whitespace before the closing dollar sign. For example,
$S_n$ is inline math
editing mode:
reading mode:
but $S_n $ is not.
editing mode:
reading mode:
This causes user-UNfriendly behavior when we type inline math equations.
That is, every time we type a whitespace, the font changes from the math font (colored monospace in italics) to the normal text font, like this:
I personally feel this behavior is problematic because it distracts me a little and prevents me from focusing on typing.
Moreover, other markdown editors (MarkText, VSCode, etc.) allow us to use white spaces before closing dollar signs with no problem. In other words, we don’t see the flickering problem in other editors.
In summary, we can avoid this flickering problem and improve our math typing experience by allowing white spaces before closing dollar signs.
Proposed solution
I’m sorry that I don’t have any specific implementation ideas, but it seems that we have to modify the current mechanism of how Obsidian’s markdown parser works.
Current workaround (optional)
It’s rather a dirty workaround, but we can avoid the font change white typing inline math by using $(...) \hspace{0em}$.
Related feature requests (optional)
I couldn’t find related FRs, but this FR was originally motivated by discussions in two posts in this forum:
The default math delimiters are $...$ and \[...\] for displayed mathematics, and \(...\) for in-line mathematics. Note in particular that the $...$ in-line delimiters are not used by default. That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly. For example, with single-dollar delimiters, “… the cost is $2.50 for the first one, and $2.00 for each additional one …” would cause the phrase “2.50 for the first one, and” to be treated as mathematics since it falls between dollar signs. See the section on TeX and LaTeX Math Delimiters for more information on using dollar signs as delimiters.
Given this fact, it would be difficult to simulate ${}$ by $$ without causing any unexpected behavior. I personally recommend using the Latex Suite plugin to enter ${ }$ quickly. See the linked post below for the details:
P.S.
Alternatively, you can easily implement a similar feature if you make your own plugin; just paste the following code inside the onload() method of your plugin.
So what you think about adopting \( \) for inline math? I personally find that more elegant given that \( has no any meaning in natural language. What comes to typing efficiency, one has to deal that problem separately. But typing efficiency is not only limited to how to write \( quickly and conveniently, it’s much broader topic of interest.
Typing efficiency will not be a big problem if we use some appropriate tools.
However, I think \( )\ has other limitations too.
First of all, Obsidian doesn’t support it out of the box.
Moreover, using \( )\ instead of $ $ will cause compatibility issues for several community plugins that assume $ $ only, such as MathLinks (+ maybe Latex Suite, Quick Latex, and so on).
If Obsidian officially supports \( )\ in the future, that would be a different story.