Welcome to our community

Be a part of something great, join today!

[SOLVED] Remove superfluous newline after double-dollar latex?

  • Thread starter
  • Admin
  • #1

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,884
I would yet again want to request an improvement in $\LaTeX$ formatting.

I'm pretty happy with the \$\$ method of automatically indenting $\LaTeX$with displaystyle.
However, it's a bit of a problem that we always get a superfluous new line after it.
Often, when I write a formula, I explain the symbols immediately after.
But the extra newline completely separates the explanation from the formula.


To illustrate, if I use \$\$ in the following text, I get:
[HR][/HR]
The modulus of elasticity λ is a property of a material.
To use it, you need the area of a cross section of the material.
So you need to use that
$$\lambda = \frac{\text{stress}}{\text{strain}} = \frac{F/A}{x_E/l}$$
where F is the force of gravity and A is the area of a cross section.

Note that this can be rewritten as
$$F=\frac{\lambda A}{l} x_E = k x_E$$
which is the usual form of Hooke's law, meaning that the extension of a spring is linear with the applied force.​


I'd like to see it more like the following (using [MATH]\qquad):
[HR][/HR]
The modulus of elasticity λ is a property of a material.
To use it, you need the area of a cross section of the material.
So you need to use that
$\\[5pt]$
\(\displaystyle \qquad \displaystyle \lambda = \frac{\text{stress}}{\text{strain}} = \frac{F/A}{x_E/l}\)
$\\[3pt]$
where F is the force of gravity and A is the area of a cross section.

Note that this can be rewritten as
$\\[5pt]$
\(\displaystyle \qquad F=\frac{\lambda A}{l} x_E = k x_E\)
$\\[3pt]$
which is the usual form of Hooke's law, meaning that the extension of a spring is linear with the applied force.​


Edited: I added a little vertical spacing in the last form as Bacterius suggested.
 
Last edited:

Bacterius

Well-known member
MHB Math Helper
Jan 26, 2012
644
Indeed, it annoys me too and I have to add a newline before the LaTeX to make it look nice, as such:

Code:
This is an equation:

$$\frac{4x + 2}{a} - 1$$
Where $a$ represents..
This is an equation:

$$\frac{4x + 2}{a} - 1$$
Where $a$ represents..
Which is still too big. That said I don't like \qquad, the equation and text are far too squashed together. How about:

Code:
This is an equation:
$\\[5pt]$
$\displaystyle \frac{4x + 2}{a} - 1$
$\\[5pt]$
Where $a$ represents..
This is an equation:
$\\[5pt]$
$\displaystyle \frac{4x + 2}{a} - 1$
$\\[5pt]$
Where $a$ represents..
[JUSTIFY]Of course this is horrible to type out but I'm hoping there is some way to automate this - as well as \displaystyle and the indent (which I don't know how to add cleanly in single-dollar mode) as expected - when using double dollar signs. Here you can also easily adjust the desired spacing as well.[/JUSTIFY]

In any case, I agree with the change in general, the newline been tormenting my OCD for a while now :p
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,052
Great observation, I like Serena, and thank you for the helpful suggestion Bacterius. This is something that occurs in all Latex environments from what I've noticed. When I write out assignments in Texworks on my Mac, the double dollar sign centers the equation and adds a good amount of vertical spacing below it. The indentation can be changed but not the vertical spacing, as far as I know. I will ask Mathjax support though if it's possible to change this slightly. If not, the issue is we can't keep fundamentally editing what certain delimiters do on MHB so the only other option I see is to add another Latex button that indents and has less vertical space somehow. I will let you all know what Mathjax support says.
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,052
This question has been answered by Mathjax support and it's not something I wanted to hear. Basically what is happening is vBulletin is adding an extra line break after last line of the Latex-rendered web font (we use fonts aparently, not images). I was corrected of this mistake by support and it's an important distinction. Anyway here was the response I got:
The forum software is adding <br> elements before and after the math code which is causing the additional space -- not MathJax.

I'd suggest to first check if something can be done about that.

[Name redacted]

PS MathJax does not produce images in your configuration but HTML+CSS using regular (web)fonts.
So while I am not giving up on this it will not be a quick fix and the next step is to ask vB support about what I can do.
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,052
How's the spacing now? :D Notice any general problems at all? I got a great response to our question that seems to have fixed the problem as the person also claims to have removed an unnecessary part of our configuration that should speed things up overall.
 
Last edited:
  • Thread starter
  • Admin
  • #6

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,884
How's the spacing now? :D Notice any general problems at all? I got a great response to our question that seems to have fixed the problem as the person also claims to have removed an unnecessary part of our configuration that should speed things up overall.
The vertical spacing does look better now!
But... it seems that now it's centered again instead of indented?
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,052
The vertical spacing does look better now!
But... it seems that now it's centered again instead of indented?
It was for a moment. Fixed once more! :)
 
  • Thread starter
  • Admin
  • #8

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,884

Ackbach

Indicium Physicus
Staff member
Jan 26, 2012
4,197
Testing before:
$$\int_{- \infty}^{ \infty}e^{-x^{2}} \, dx= \sqrt{ \pi}.$$
Testing after. Very nice!