Font unwantedly changes while typing math equations

Hi. I originally posted this issue in the Help category:

But after some conversation with those who gave me replies, I decided to post this as a bug report.

Terminology

There are two font styles involved. For convenience, let me define their names, as below:

  • Math font (colored monospace in italics)
    image
  • Normal text font
    image

Steps to reproduce

  1. Enter the editing mode in the sandbox vault. (This bug happens both in the source mode and in the live preview.)
  2. Type $$ and move the cursor between these two dollar signs.
  3. Type some equation in it, separating symbols with white spaces, e.g., $S_n = \sum_{i=1}^n a_i$.

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

Yes

Expected result

The editor should keep displaying the math font while I’m typing the equation.

Actual result

Every time you insert a white space, you will see the font changes from the math font to the normal text font, like this:
ezgif-3-51a56226f1

Environment

SYSTEM INFO:
	Obsidian version: v1.3.5
	Installer version: v1.3.5
	Operating system: Darwin Kernel Version 22.3.0: Thu Jan  5 20:53:49 PST 2023; root:xnu-8792.81.2~2/RELEASE_X86_64 22.3.0
	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

See the original post that I mentioned at the beginning for some discussions.

In particular, it has been confirmed that this phenomenon seems to be caused by the white space right before the closing dollar sign, so a simple dirty workaround such as $(type the equation here) \hspace{0em}$ works.

Thank you.

1 Like

Not a bug. There needs to be no space before the final $ to be inline math, hence the observed behavior.

I suggest you open a FR, as this sound more like an UX issue and I am not even sure we should do it.

Thank you for the reply.

There needs to be no space before the final $ to be inline math

I see, so this behavior is by the design of Obsidian.

But I don’t see why Obsidian adopts this design because, in other markdown editors such as MarkText, VSCode, etc., it is common to allow white spaces before closing dollar signs.

And personally, I feel this behavior is user-unfriendly.

So I’m going to open a FR as you suggested. Thank you.

2 Likes

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