2

First confusion I have is that space generated between center environments is always 10pt regardless of global font size. Because interline spacing should depend on the font size but in this case it doesn't.

Second is that negative vspace must be -20pt to remove that generated space between center environments. Why can't it be -10pt? (which results in no change for some reason).

You explanations are very welcome (I need to solve this to move forward with my document typesetting).

\documentclass[varwidth]{standalone}
\begin{document}
  \LARGE % comment/uncomment this line and still get same space (for different font-size)
  \begin{center}
    \hrule height 0.01pt
      hello world
    \hrule height 0.01pt
  \end{center}
  \vspace{-20pt} % space here is 10pt but requires -20pt to remove (why?)
  \begin{center}
    \hrule height 0.01pt
      hello world
    \hrule height 0.01pt
  \end{center}
\end{document}

ADDENDUM (similar case with math display-mode, aside from not being required to negate twice as much space as appears in previous example with center environment; why additional 1pt is generated and is 10pt added for same reason as in example above or does it come from somewhere else [not as part of a list spacing]?; this time, \LARGE affects the spacing and makes it greater than [10pt+1pt]):

\documentclass[varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
  hello world
  \hrule height 0.01pt
    $$\boxed{\begin{gathered}2+2=4\end{gathered}}$$
    % remove following line to get generated space
    \vspace{-\dimexpr(10pt+1pt)}
  \hrule height 0.01pt
  hello world
\end{document}
2

The center environment is implemented as a trivlist so gets list spacing, Both the lists here start in vertical mode so get a vertical space of \partopsep + \topsep.

In the standard styles and standalone with the default 10pt option, this is

(2pt plus 1pt minus 1pt) + (8pt plus 2pt minus 4pt)

so

10pt plus 3pt minus 5pt

So has a natural length of 10pt as you say.

In the standard classes \topsep and \partopsep are not changed by the size change commands so are unaffected by the \LARGE in your example.

6
  • Thank you. But why -20pt to remove 10pt?
    – bp2017
    May 2 '19 at 20:05
  • 1
    you get the list spacing at the end of the first center and the start of the second. (Any) negative space between them stops latex combining these two so you get both in full so need -20pt, or better -20pt plus -6pt minus -10pt to cancel them out. @bp2017 May 2 '19 at 20:08
  • And why \LARGE affects the spacing this time.
    – bp2017
    May 2 '19 at 20:27
  • 1
    @bp2017 you should never have $$ in latex of course, but display math is similar to list but has \abovedisplayskip space rather than \topsep also you should never have display math starting in vertical mode. However there below the display you get 6.0 plus 3.0 minus 3.0 from \belowdisplayskip and 5.1pt from \baselineskip so more or less 11pt May 2 '19 at 20:27
  • 1
    @bp2017 \LARGE affects baselineskip (this is really unrelated to the original question) May 2 '19 at 20:28
2

The problem can be avoided by not using a center environment and thus not inserting the additional vertical space associated with it

\documentclass[varwidth]{standalone}
\begin{document}
%  \LARGE % comment/uncomment this line and still get same space (for different font-size)
%  \begin{center}
{
\centering
    \hrule height 0.01pt
      hello world
    \hrule height 0.01pt
%  \end{center}
}
%  \vspace{-20pt} % space here is 10pt but requires -20pt to remove (why?)
{
\centering
%  \begin{center}
    \hrule height 0.01pt
      hello world
    \hrule height 0.01pt
%  \end{center}
}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.