LaTeX forum ⇒ Math & ScienceWhat is the default value of \abovedisplayskip?

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

What is the default value of \abovedisplayskip?

Postby Cham » Thu Dec 05, 2019 11:40 pm

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \newcommand*{\topless}{\setlength{\abovedisplayskip}{0pt}}
  2. \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?

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

Postby Cham » Fri Dec 06, 2019 3:28 am

I've found this solution, using \begingroup ... \endgroup, instead of using the macros defined above:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begingroup\abovedisplayskip=0pt
  2. \begin{equation}
  3. y = x
  4. \end{equation}
  5. \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: 266
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Fri Dec 06, 2019 9:15 am

You should avoid changing the vertical spacing often. But if you really want, you could define own environment:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \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.

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

Postby Cham » Fri Dec 06, 2019 1:20 pm

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \setlength{\abovedisplayskip}{11pt}
  2. \setlength{\abovedisplayshortskip}{0pt}
  3. \setlength{\belowdisplayskip}{11pt}
  4. \setlength{\belowdisplayshortskip}{11pt}

I'll try to make a MWE but it's getting pretty complicated...

User avatar
Ijon Tichy
Posts: 266
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Fri Dec 06, 2019 1:33 pm

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.

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

Postby Cham » Fri Dec 06, 2019 2:04 pm

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[11pt,letterpaper,twoside]{book}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[french]{babel}
  5. \usepackage{lmodern}
  6. \usepackage{textcomp}
  7. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  8. \usepackage[nodisplayskipstretch]{setspace}
  9. \setstretch{1.1}
  10. \raggedbottom
  11. \usepackage{microtype}
  12. \usepackage{nccmath,amsmath}
  13. \usepackage{mathtools}
  14. \usepackage{tensor}
  15. % Parenthesis macro:
  16. \newcommand*{\bigs}[1]{\vcenter{\hbox{\scalebox{1.25}{\ensuremath#1}}}}
  17. \setlength{\abovedisplayskip}{11pt}
  18. \setlength{\abovedisplayshortskip}{0pt}
  19. \setlength{\belowdisplayskip}{11pt}
  20. \setlength{\belowdisplayshortskip}{11pt}
  21.  
  22. \begin{document}
  23.  
  24. \noindent
  25. Blabla bla :
  26. \begin{equation}
  27. y(x) = a \, x^2.
  28. \end{equation}
  29. Blabla bla blabla bla bla :
  30. \begin{equation}
  31. y(x) = a \, x^2.
  32. \end{equation}
  33. Blabla bla blabla bla blabla blabla:
  34. \begin{equation}
  35. y(x) = a \, x^2.
  36. \end{equation}
  37. Blabla bla blabla bla blabla blabla bla bla blabla :
  38. \begin{equation}
  39. y(x) = a \, x^2.
  40. \end{equation}
  41. Blablabla bla bla bla bla blabla bla blabla blabla bla.
  42.  
  43. \end{document}


Here's a preview:
preview.jpg
preview.jpg (33.05 KiB) Viewed 1053 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: 266
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Sat Dec 07, 2019 11:42 am

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.

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

Postby Cham » Tue Dec 17, 2019 10:21 pm

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: 266
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Wed Dec 18, 2019 8:53 am

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.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 3 guests