0

It seems that there are vertical blank spaces before and after the center enviroment, as shown in the attached picture.

My question is: how to adjust these vertical blank spaces?

Code:

\documentclass{article}
\parindent0pt
\begin{document}
\rule{\textwidth}{1pt}
  \begin{center}
    aaa\\bbb\\ccc
  \end{center}
\rule[\baselineskip]{\textwidth}{1pt}
\end{document}

enter image description here

10
  • Instead of \begin{center}...\end{center}, use {\centering...\par} to eliminate the added space. May 21 at 1:35
  • Thank you @Steven. As \centering may lead to some odd and uncontrolable behavior, center enviroment seems to be better, except that how to adjust the extra vertical spaces before/after it.
    – lyl
    May 21 at 1:41
  • 1
    I am not sure why you think "odd and uncontrollable behavior" may result. The use of braces { } before and after the \centering...\par is intended to limit the effect of \centering to the scope within the braces. May 21 at 1:44
  • For your particular use case, I would also add a \strut before the \par. May 21 at 1:46
  • 1
    Also, if you show the \meaning of \center (the environment), you will discover that it is just \centering inside of a \trivlist. May 21 at 1:49

1 Answer 1

1

I added a \vspace{} command inside the center environment at the top and buttom, which seems to have worked. You can make the space smaller by using negative values and make the space larger by using positive values.

\documentclass{article}
\parindent0pt
\begin{document}
\rule{\textwidth}{1pt}
  \begin{center}
  \vspace{-4mm}
    aaa\\bbb\\ccc
    \vspace{-2mm}
  \end{center}
\rule[\baselineskip]{\textwidth}{1pt}
\end{document}

This code produces:

enter image description here

Using positive values 5mm and 7mm:

enter image description here

5
  • Thank you for your solution. I'd like to know if there are default values for these vertical spaces in the center enviroment and where can I find them.
    – lyl
    May 21 at 14:09
  • 1
    mirror.math.princeton.edu/pub/CTAN/macros/latex/base/… Page 621: \def\center{\trivlist \centering\item\relax} \def\endcenter{\endtrivlist} Centering invokes the trivlist environment to handle vertical spacing before and after. This is found on page 648. Beofre: \parskip (which is dependent on the documentclass) After: \vskip \lastskip -\@outerparskip + \parskip.
    – Vebjorn
    May 21 at 16:18
  • 1
    To find the documentation go to latex-project.org -> help -> documentation -> scroll down to "Source documentation" -> click on "The LaTeX2e Sources (1000+ pages)".
    – Vebjorn
    May 21 at 16:22
  • Thank you so much!! And what does \item do in the defination of \center?
    – lyl
    May 22 at 0:02
  • I guess it is the same as item in enumerate and itemize, but without any point/ number. The item probably refers specificually (in this case) to eighter the text in the center environment or nothing (an empty list is after all a trivial list).
    – Vebjorn
    May 22 at 7:59

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.