Math & ScienceVertical spacing of math environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
woltan
Posts: 19
Joined: Mon Mar 09, 2009 2:08 pm

Vertical spacing of math environment

Post by woltan »

Hey folks,
I ran into a "problem" regarding the spacing of math environments. I'd like to have the same vertical spacing above and below the equation, so that the equation fits nice in the text around it. Something like this:

text text text text text text text text text

equation

text text text text text text text text text

The only way I can achieve this is by not having a paragraph in front of the equation like this:

Code: Select all

text text text text text text text text text 
\begin{equation}
a = b
\end{equation}
text text text text text text text text text 
The spacing of this approach is rather narrow, which is why I would like it to increase it a little like this:

Code: Select all

text text text text text text text text text 

\begin{equation}
a = b
\end{equation}

text text text text text text text text text 
With the second approach the spacing increases but with that fact that there is more space above the equation than below.

My question is: How can I increase the space above an below the equation to a certain degree? I am using the amsmath package and did not find any command in it that does the trick.

Any help, hint, link is appreciated!!
cherio Woltan

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Vertical spacing of math environment

Post by Stefan Kottwitz »

Hi Woltan,

don't use paragraph breaks/ empty lines before or after displayed equations. Modify certain lengths instead: \abovedisplayskip, \belowdisplayskip, \abovedisplayshortskip, \belowdisplayshortskip, have a look at Mathmode.pdf.

Stefan
LaTeX.org admin
woltan
Posts: 19
Joined: Mon Mar 09, 2009 2:08 pm

Vertical spacing of math environment

Post by woltan »

Hey Stefan,
thx for the posting those lengths realy did the trick. The only thing I couldn't handle was the strange behavior of the align environment. This example should show what I mean:

Code: Select all

\begin{document}
\abovedisplayskip=0.7cm
\abovedisplayshortskip=-0.3cm
\belowdisplayskip=0.7cm
\belowdisplayshortskip=0.4cm

----------------------------------------------------
\begin{equation}
a = \sqrt{\kappa RT}
\end{equation}
----------------------------------------------------

----------------------------------------------------

\begin{equation}
a = \sqrt{\kappa RT}
\end{equation}

----------------------------------------------------
\newpage
----------------------------------------------------
\begin{align}
a = \sqrt{\kappa RT}
\end{align}
----------------------------------------------------

----------------------------------------------------

\begin{align}
a = \sqrt{\kappa RT}
\end{align}

----------------------------------------------------


\end{document}
What I am trying to do is simply not being forced to write my equations right after the text, but anywhere (with any number of empty lines in front) in my document and still have the same offset above and below the equations to the text itself.
Maybe there is a much simpler command or length that would do the trick, but until now I haven't found it.
Cherio Woltan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Vertical spacing of math environment

Post by Stefan Kottwitz »

Hi Woltan,
woltan wrote: What I am trying to do is simply not being forced to write my equations right after the text, but anywhere (with any number of empty lines in front) in my document and still have the same offset above and below the equations to the text itself.
again, don't use empty lines before or after equations. Why do you want to insert unnecessary paragraph breaks? If you want to have empty lines in your source code just insert percent signs to comment out the paragraph effect.

You wouldn't expect text to behave equally whether an empty line comes before or not.

Just avoid paragraph breaks before formulas, using those lengths will give you equal skips. Further have a look at this post explaining more about setting those lengths.

Stefan
LaTeX.org admin
woltan
Posts: 19
Joined: Mon Mar 09, 2009 2:08 pm

Re: Vertical spacing of math environment

Post by woltan »

Hey Stefan,
of course you are right. It is the wrong approach putting paragraphs and empty lines infront of an equation. The trick with the comments is nice and I havent thought about it myself. It works and I can rid of my ugly environments.
Thanks for your postings!
cherio Woltan
Post Reply