Obsidian inserts unwarrented blank line before display math

Obsidian doesn’t treat a\nb as two paragraphs, so why is 'a\n$$x+1$$` treated as separate paragraphs?

With text:

x
y

renders
as

x
y

With display math

a $$x+1$$

renders as

a
     x+1

while

a 
$$x+1$$

renders as

a 

     x+1

I think this is wrong. Also, when the display math expression is long, it’s often useful to edit it in a new line.

My notes end up full of useless unintended blank lines, which disconnect text from the display math they refer to.

My notes end up full of unintended blank lines, which I have to manually correct.

1 Like

Hi.

Is this what you want?

a  
$x+1$

i don’t see any extra spacing between the two.

hmmm. Thanks. I checked again and I think my repro instructions were just wrong. It’s triggered differently than I thought.

This source

x
$$ x+1 $$ x

renders as

and there’s definitely an extra blank row after the first x. Do you also see this?

yeah, i see that also. not sure why it happens. in any case, the extra line doesn’t appear if there is a line break after the closing $$, and i think that syntax is better anyway.

Thank you for confirming.

@WhiteNoise , please consider moving back to bug reports.

This is the standard expected behaviour, insn’t?

I mean, in LaTeX, the double dollar delimiter ($$math$$) means that you want to have “displayed math”, which is by definition typeset in a separate paragraph, with vertical space around.

If you want inline math, use a single dollar ($math$).

Note however that inline math and displayed math can present also small differences. Inline math is meant to be part of a line in a paragraph of text, so it minimises the vertical space needed by the math, by using smaller sum signs, integral signs or fractions.

See here an example:

This is displayed math: $$\sum_{x=1}^\infty\frac{1}{x}$$

This is inline: $\sum_{x=1}^\infty\frac{1}{x}$ and typesets 
the sum and the fraction accordingly.

which results in:

In case you want “big” symbols inline, you can force the displayed style, without triggering the vertical spacing, by inserting \displaystyle in the equation. Eg:

This is inline: $\displaystyle\sum_{x=1}^\infty\frac{1}{x}$ 
but uses "big" sum and fractions.

which gives
image

1 Like

No. The issue that, based on where you place the next character after the display math, an extra blank line appears before the display math. That’s not expected behavior.

The only officially supported display math syntax is

text
$$ x+1 $$
text

or

text
$$ 
x+1 
$$
text

The rest is unsupported and partially undermined at the moment.

… and those two produce different results, another bug.

I think it’s against the spirit of markdown to expect users to be just-so with things like this.

Sometimes I copy markdown from sources I have no control over. You expect me to rewrite them manually each time, simply because they were not especially written in Obsidian ? that’s not what markdown is all about.

Also noticed that this quirk doesn’t occur in reading mode (didn’t someone else point this out earlier? can’t see it now)

So preview mode shows something different from reading-mode. That’s another legit issue IMO.

they are identical for me in both live preview and reading mode. what are you seeing? could a snippet/theme/plugin be causing the issue?

No, I use stock appimage and see this even when disabling all plugins.

Note that if you type it in, preview mode silently inserts a new line, which is probably why you don’t see it. Try pasting it in.

It’s still easy to reach this state though, and somehow I often do. See screenshot and confirmation above as proof I’m not imagining things.

you are referring to these, correct? they are both faithfully copy-pasted and they render in exactly the same way for me, on Windows. if for some reason these are not copy-pasting faithfully for you, perhaps instead of manually correcting them you can use a markdown linter to fix it.

as i mentioned before, i do see the extra line when using the unsupported syntax. however it essentially never comes up for me in my usage of obsidian.

You want separate lines, without an empty line between them? Like this?

This is line 1   
$x+1$  
And this is line 3

Elostinbase - You’re right. My point is that subtle changes in whitespace cause surprising changes in the output.

Go back up a line and add a single “space” after the closing dollar sign. For me, that creates an extra blank line between the display math and the lower text line - and there’s no logic to it. Maybe I just added this extra space by force of habit, and it’s not-visible.

I expect a markdown renderer to generally ignore meaningless whitespace.

And when I type, it’s quite common for an extra space to appear after I add a display math fragment. I don’t like having to constantly tidy up whitespace. It’s pointless.

wow, really? there are markdown linters? that’s… kind of sad.

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