Inline math boundary should not be a word boundary

Steps to reproduce

Open a sandbox vault. Type " $somemath$." Notice there is a space in the beginning and a full stop without space right after the inline math. Move the cursor back to the beginning of the line and type random words, until the inline math block just typed reaches the line end and the line is broken.

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

Y

Expected result

The full block “$somemath$.” should move to the next line.

Actual result

Only the “.” moves to the next line; after adding more content to the first line, then also “$somemath$” moves to the next line.

Environment


Additional information

This behavior is incorrect because it’s common to have math symbols or punctuation as integral parts of non-breakable text. For instance, “The $n$th occurrence of this event” should keep “$n$th” as a full word. Another example: “Solve for the variable $x$.” should never get a line break separating the full stop and $x$.

This is a known issue in MathJax. See two related resources.

In your example
The $n$th occurrence of this event
write
The $n\text{th}$ occurrence of this event

You can also use \textsf or \texttt which make typeface sans-serif or monospace.

1 Like

This is a limitation specific of live preview and not limited to math.

thanks for the workaround. nonetheless, this seems cumbersome and something that should be fixed upstream. actually, the last blog post you linked looks more like a proper solution – could that script possibly be used by default inside obsidian?

hi, actually i think not. i was able to make a full stop appear on its own on the beginning of the next line after inline math, in reading mode as well.

so the preview line break issue appears to be a separate issue.