LaTeX: newline after closing $$

  • Context: LaTeX 
  • Thread starter Thread starter kiuhnm
  • Start date Start date
  • Tags Tags
    latex
Click For Summary
SUMMARY

The forum discussion addresses the issue of excessive vertical spacing in rendered LaTeX formulas when using MathJax, specifically when newlines are inserted after the closing \$$. Users report that this results in unwanted space both above and below the formulas. The consensus is that removing unnecessary newlines before and after the \$$ will mitigate this issue. The discussion emphasizes the limitations of the MathJax library in controlling spacing and suggests formatting adjustments for better readability.

PREREQUISITES
  • Understanding of LaTeX syntax and formatting
  • Familiarity with MathJax library functionality
  • Basic knowledge of HTML and web content formatting
  • Experience with editing and structuring text in forum posts
NEXT STEPS
  • Research best practices for formatting LaTeX in MathJax
  • Explore advanced MathJax configuration options
  • Learn about LaTeX spacing commands to control vertical space
  • Investigate alternative libraries for rendering mathematical expressions
USEFUL FOR

Content creators, web developers, and educators who utilize LaTeX for mathematical expressions in online platforms, particularly those using MathJax for rendering.

kiuhnm
Messages
66
Reaction score
1
The support for ##\LaTeX## is great, but there's just one thing I don't like: if I put a newline after the closing \$$ I get too much vertical space after the rendered part. For instance:
$$(x_1+\ldots+x_p)^n = \sum_{c_1+\ldots+c_p=n} \frac{n!}{c_1!\cdots c_p!}x_1^{c_1}\cdots x_p^{c_p}$$
As you can see, there's a space right above this line.
I think the correct thing to do would be to remove all the superfluous newlines before the opening and after the closing \$$.
Things are even worse if I want to separate ##\LaTeX## formulas from the rest of the text in the source code:

$$(x_1+\ldots+x_p)^n = \sum_{c_1+\ldots+c_p=n} \frac{n!}{c_1!\cdots c_p!}x_1^{c_1}\cdots x_p^{c_p}$$

Now I also have a space before the rendered formula.
 
Physics news on Phys.org
This is possibly because we do not use LaTeX but MathJax. Just don't insert extra empty lines! In any case the library we use is ready made, so that we have no influence on the source code.
 
  • Like
Likes   Reactions: Greg Bernhardt
fresh_42 said:
This is possibly because we do not use LaTeX but MathJax. Just don't insert extra empty lines! In any case the library we use is ready made, so that we have no influence on the source code.

I insert empty lines because it makes it easier for me to write and especially edit parts of my posts before posting them. Well, I'll live with that. I just wanted to make sure you were aware of this issue. Could you tell me the name of the library?
 
kiuhnm said:
I insert empty lines because it makes it easier for me to write and especially edit parts of my posts before posting them. Well, I'll live with that. I just wanted to make sure you were aware of this issue. Could you tell me the name of the library?
I do it this way:

<text>
$$
<formula>
$$ <text>

which doesn't produce extra lines and is equally easy to edit and read.

One line test for comparison:
<text>$$<formula>$$<text>
 
  • Like
Likes   Reactions: SammyS and kiuhnm

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
1K
  • · Replies 0 ·
Replies
0
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 45 ·
2
Replies
45
Views
6K
  • · Replies 61 ·
3
Replies
61
Views
13K
  • · Replies 3 ·
Replies
3
Views
1K
Replies
9
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K