Math & ScienceWhat is the default value of \abovedisplayskip?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What is the default value of \abovedisplayskip?

Post by Cham »

The following problem is pretty simple (if not straightforward), and I don't think it needs a MWE.

In a document, I defined two macros like this:

Code: Select all

\newcommand*{\topless}{\setlength{\abovedisplayskip}{0pt}}
\newcommand*{\topmore}{\setlength{\abovedisplayskip}{11pt}}
The first macro is used to reduce the vertical space after some text and before an equation. The second macro is just a reset to the default value.

The document is written with a standard 11pt font, so this is why I used that value in the second macro. However, I suspect it's not the proper thing to do (since I may need to change the font size one of these days). What command should I use in that second macro instead of 11pt?

Recommended reading 2024:

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

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

User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What is the default value of \abovedisplayskip?

Post by Cham »

I've found this solution, using \begingroup ... \endgroup, instead of using the macros defined above:

Code: Select all

\begingroup\abovedisplayskip=0pt
	\begin{equation}
		y = x
	\end{equation}
\endgroup
But then, how can I create a simple macro to simplify this solution, instead of typing all the extra code each time I need it?
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

What is the default value of \abovedisplayskip?

Post by Ijon Tichy »

You should avoid changing the vertical spacing often. But if you really want, you could define own environment:

Code: Select all

\newenvironmen{noabovedisplayskip}{\setlength{\abovedisplayskip}{0pt}}{}
Note 1: There is not only \abovedisplayskip but also \abovedisplayshortskip. So it could be necessary to change this value too, but only, if you do not use amsmath.

Note 2: amsmath uses \abovedisplayskip also for \intertext inside displayed math. So it could be necessary to store the original value in a length and restore it inside the equation.

Note 3: Another suggestion could be to patch the math environments to make it possible to temporary use a different value before the initial and the final $$. But this also depends on using a math package like amsmath or not. So again it was not a good idea to show us only a code snippet instead of a real Infominimal working example. And for only some places of changes the effort in doing all the patches could be larger than doing the change manually like you've done.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What is the default value of \abovedisplayskip?

Post by Cham »

I do use the amsmath package (and about a dozen of other maths packages as well). I don't understand the uses of \abovedisplayshortskip. What does it do?

I need all my equations to have a fixed constant space between the text above and under them. I hate variable spaces around equations. In my preamble, I used the following for a 11pt font document, but I'm not sure this is a right thing to do:

Code: Select all

\setlength{\abovedisplayskip}{11pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{11pt}
\setlength{\belowdisplayshortskip}{11pt}
I'll try to make a MWE but it's getting pretty complicated...
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

What is the default value of \abovedisplayskip?

Post by Ijon Tichy »

Please read an introduction into LaTeX that explains things like \abovedisplayskip.

If you don't like variable spaces, you should not change spaces at the time you use an environment but only in the document preamble. So your change in the document preamble should be enough. And with that change you already know the value of \abovedisplayskip, because it is the value you've used in the second argument of \setlength.

If you just want to remove the glue from the default value of \abovedisplayskip you can use:
\setlength{\abovedisplayskip}{\dimexpr\abovedisplayskip\relax} in the document preamble.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What is the default value of \abovedisplayskip?

Post by Cham »

Here's a not so MWE to show my problem and why I use the macros defined above to solve it after a first compilation:

Code: Select all

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\raggedbottom
\usepackage{microtype}
\usepackage{nccmath,amsmath}
\usepackage{mathtools}
\usepackage{tensor}
% Parenthesis macro:
\newcommand*{\bigs}[1]{\vcenter{\hbox{\scalebox{1.25}{\ensuremath#1}}}}
\setlength{\abovedisplayskip}{11pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{11pt}
\setlength{\belowdisplayshortskip}{11pt}

\begin{document}

\noindent
Blabla bla :
\begin{equation}
    y(x) = a \, x^2.
\end{equation}
Blabla bla blabla bla bla :
\begin{equation}
    y(x) = a \, x^2.
\end{equation}
Blabla bla blabla bla blabla blabla:
\begin{equation}
    y(x) = a \, x^2.
\end{equation}
Blabla bla blabla bla blabla blabla bla bla blabla :
\begin{equation}
    y(x) = a \, x^2.
\end{equation}
Blablabla bla bla bla bla blabla bla blabla blabla bla.

\end{document}
Here's a preview:
preview.jpg
preview.jpg (33.05 KiB) Viewed 11533 times
As you can see, all spacings appear to be fine, except above equation (3). It looks "goofy"! I have to reduce it by hand, after compilation (it cannot be predicted).
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

What is the default value of \abovedisplayskip?

Post by Ijon Tichy »

The shown result is correct. You cannot wait to add the vertical distance of \abovedisplayskip until the displayed math moves under the end of the previous line. Optical effects almost always differ from simple mathematical semblance. TeX takes respect for this and adds \abovedisplayskip if the end of the previous line is near to the beginning of the displayed math. This results in much better typography. You should not invest your time in worsing the good result of TeX.

BTW: letterpaper and twoside are defaults of book.
Really letterpaper for a French book? Canada? If so: There is also an option acadian for babel. Currently it does the same like french, but this may change and so it could be better to use this, if this should be a book in Canadian French.

Since LaTeX 2018-04-01 \usepackage[utf8]{inputenc} is not needed any longer. See LaTeX News 28 for more information.

nccmath already loads amsmath, so you do not need to load amsmath explicitly.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What is the default value of \abovedisplayskip?

Post by Cham »

Thanks Ijon for the info.

Yes, it's a French Canadian book. We do use letter paper as in the USA here.

I prefer to keep the amsmath in there, in case I decide to deactivate nccmath (I use it only for its mfrac command!)

What is the standard for a French book in Europe?
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

What is the default value of \abovedisplayskip?

Post by Ijon Tichy »

The standard paper size in Europe is A4. The standard size for scientific books is 170mm:240mm (sometimes before cutting, sometimes after cutting), but there are several other book formats depending on the publisher.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply