There are four parameters that define this space and you can look at the values for them for example via
\showthe\abovedisplayskip
\showthe\belowdisplayskip
\showthe\abovedisplayshortskip
\showthe\belowdisplayshortskip
The "..short.." are used if the previous text line has less material than the width of the formula. In case of displaymath
(or \[...\]
for short) standard LaTeX behaves a bit strangely in that it adds an explicit empty box with a width of .6\linewidth
in front of such a display if it starts out in vertical mode. As a result you see an empty line in front of the display and in addition \abovedisplayskip
is used. This is not done for the equation
environment (here low-level TeX is adding the empty line but it will only consists of an \indent
box) so this is a strange historical "feature".
The values for these parameters depend on the font size and in the default classes (e.g., article
) LaTeX sets them as part of executing \normalsize
, \small
, or \footnotesize
. The other font size command do not chamge them, probably because Leslie thought that in something like \huge
one doesn't typeset any displays.
So changing them then to your taste can be done with \setlength
, e.g.
\setlength\abovedisplayskip{5pt plus 2pt minus 2pt}
or whatever you think fits your design (the plus and minus part define how much the space can stretch or shrink if necessary). But that definition then has to replace the one inside the font size command or at least have to be added to the end of it so that it overwrites whatever is being set up earlier. A simple way to do that would be
\makeatletter
\g@addto@macro \normalsize {%
\setlength\abovedisplayskip{5pt plus 2pt minus 2pt}%
\setlength\belowdisplayskip{5pt plus 2pt minus 2pt}%
}
\makeatother
As long as you do not typeset displays in \small
or \footnotesize
there is no need to append values to those commands, but if so the same approach could be used.
(thanks to egreg for pointing out my blunder about not remembering that this is size dependent)
The issue is that in v3 I work harder to use 'real' text mode symbols, but they of course don't space correctly in 'math like' situations. I've logged and issue and will creat a release shortly. For the present, you can use
\ExplSyntaxOn
\makeatletter
\cs_gset_protected:Npn \__siunitx_print_text_replace:n #1
{
\group_begin:
\tl_if_head_eq_meaning:nNTF {#1} \mathchoice
{ \__siunitx_print_text_replace:Nnnnn #1 }
{
\tl_set:Nn \l__siunitx_print_tmp_tl {#1}
\tl_if_empty:NF \l_siunitx_unit_font_tl
{ \exp_after:wN \cs_set_eq:NN \l_siunitx_unit_font_tl \use:n }
\cs_set:Npn \mathord ##1
{
\str_case:nnF {##1}
{
{ \cdot } { \exp_not:N \textperiodcentered }
{ \pm } { \exp_not:N \textpm }
{ \times } { \exp_not:N \texttimes }
}
{ ##1 }
}
\cs_set:Npn \pm { \: \exp_not:N \textpm \: }
\tl_map_inline:nn
{ \mp \ge \le \gg \ll }
{ \cs_set:Npn ##1 { \exp_not:N \ensuremath { \exp_not:N ##1 } } }
\cs_set:Npn \cdot { \: \exp_not:N \textperiodcentered \: }
\cs_set:Npn \times { \: \exp_not:N \texttimes \: }
\protected@edef \l__siunitx_print_tmp_tl { \l__siunitx_print_tmp_tl }
\__siunitx_print_text_replace:N \l__siunitx_print_tmp_tl
\__siunitx_print_text_replace_aux:n { \tl_use:N \l__siunitx_print_tmp_tl }
}
\group_end:
}
\makeatother
\ExplSyntaxOff
The idea here is that if \mathord
applies, we filter out \cdot
/\pm
/\times
and just replace with the text mode version. Without the \mathord
, the definitions are adjusted such that spaces are added explicitly to maintain the spacing.
Best Answer
You can define your
mycenter
environment and pass a length (optionally) to modify the top/bottom gap:geometry
andlipsum
were loaded specifically for this MWE, and may not be needed in your final document.