Extra newline between Latex equation blocks/a Latex equation block and a paragraph

I searched in the forum, seems that there is only one topic related. And it is about generating newlines with an empty $$ Latex equation call.

Steps to reproduce

- test case 1
    $$func1$$
    text here
- test case 2
    $$func2$$
    $func3$
-test case 3
    $$func4$$
    $$func5$$

Expected result

Text/equations right after a Latex equation block generated by $$sample equation$$, no extra space in between.

Actual result

There is a <br> below $$Latex equations$$. No such a problem with $Latex equation$`
(I’m using the mouse cursor to select all text so that newlines are easier to see)
image

code here :

Environment

  • Operating system: Windows 10
  • Obsidian version: v0.10.1

Additional information

Yea I also came across that Bug several times.
Just got used to add an emtpy line after my $$Latex equation$$. Oddly that extra line will get rid of the
in viewing mode.

Summary

When there is some text in a line immediately following a math block, it produces more space than if there was a blank line between the math block and the text.

Steps to reproduce

Case 1

$$1 + 1 = 2$$
Text

Case 2

$$1 + 1 = 2$$

Text

Expected result

Because case 2 has a blank line in between, one would expect that case 2 should produce equal or more space between the math block and the text compared to case 1.

Actual result

Case 1 produces more space between the math block and the text compared to case 2.


Additional information

Inspecting the HTML, I noticed that in case 1 there is a line break <br> between the math block and the text. I initially tried hiding the line break but this caused a problem:
Case 3

$$1 + 1 = 2$$ is true.
Text

If a math block was followed by some text in the same line, the subsequent “Text” appeared on the same line as the first part because of the missing line break.

Proposed solution

A solution would be to hide the line break when it immediately follows a math block. In case 3, " is true." appears between the math block and the line break, and in this case the line break should be present to separate " is true." and “Text”. However, in case 1 there is nothing between the math block and the line break, and in this case the line break takes up extra space before “Text” so it should be hidden.

This JavaScript code fixes it in preview mode. However, this is temporary and does not work for exporting to PDF.

for (a of document.querySelectorAll("span.math.math-block.is-loaded")) {
    if (a.nextSibling && a.nextSibling.nodeName === "BR") {
        a.nextSibling.style.setProperty("display", "none");
    }
}

will be fixed in 0.12.5

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