Spacing – How to Change the Whitespace Above and Below Center

environmentshorizontal alignmentspacing

Is it possible to control the space above and below center, e.g. the way it can be controlled above and below math display? In other words, is there an equivalent to, say,

\setlength\abovedisplayskip{3pt plus 2pt minus 2pt}
\setlength\belowdisplayskip{3pt plus 2pt minus 2pt}

Best Answer

You can define your mycenter environment and pass a length (optionally) to modify the top/bottom gap:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\newenvironment{mycenter}[1][\topsep]
  {\setlength{\topsep}{#1}\par\kern\topsep\centering}% \begin{mycenter}[<len>]
  {\par\kern\topsep}% \end{mycenter}
\setlength{\parindent}{0pt}% Just for this MWE
\begin{document}
1: \lipsum[2]
\begin{center}
  2: \lipsum[2]
\end{center}
3: \lipsum[2]
\begin{mycenter}
  4: \lipsum[2]
\end{mycenter}
5: \lipsum[2]
\begin{mycenter}[0pt]
  6: \lipsum[2]
\end{mycenter}
7: \lipsum[2]
\end{document}

geometry and lipsum were loaded specifically for this MWE, and may not be needed in your final document.

Related Question