6

When I need to place a tabular or figure inside a paragraph (usually in exams or class notes) I use {\par\centering <tabular>/<figure>\par} because center environment uses too much vertical space. But I don't like my solution because tabular or figure are too close to previous and following paragraphs. I would like that vertical space between figures and paragraphs was similar to the one between lines. How can I do it?

\documentclass{article}
\usepackage{booktabs}
\usepackage{mwe}
\usepackage{lipsum}
\begin{document}

\lipsum[2]

{\par\centering
\begin{tabular}{ccc}
\toprule
a & b & c\\
\midrule
1 & 2 & 3\\
4 & 5 & 6\\
\bottomrule
\end{tabular}\par}

\lipsum[2]

{\par\centering
\includegraphics[width=.75\linewidth]{example-image}\par}

\lipsum[2]

\end{document}

enter image description here

2 Answers 2

6

Define your own environment:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs}
\usepackage{mwe}
\usepackage{lipsum}

\newenvironment{rcenter}
 {\setlength{\topsep}{.5ex}\center}
 {\endcenter}

\begin{document}

\lipsum[2]
\begin{rcenter}
\begin{tabular}{ccc}
\toprule
a & b & c\\
\midrule
1 & 2 & 3\\
4 & 5 & 6\\
\bottomrule
\end{tabular}
\end{rcenter}
\lipsum[2]
\begin{center}
\begin{tabular}{ccc}
\toprule
a & b & c\\
\midrule
1 & 2 & 3\\
4 & 5 & 6\\
\bottomrule
\end{tabular}
\end{center}

\lipsum[2]
\begin{rcenter}
\includegraphics[width=.75\linewidth]{example-image}
\end{rcenter}

\lipsum[2]

\end{document}

enter image description here

1
  • I recommend adding 0.5\baselineskip (or \baselineskip) before and after the tabular. It makes the lines back each other up better on the recto and verso pages.
    – user10274
    May 2, 2013 at 11:06
1

The \addvbuffer command of the verbatimbox package provides a capability to add symmetric or asymmetric buffer space above and below an object (including adding space above and below tabular, images, "plain text" , etc.). Its syntax can be

\addvbuffer[space-above space-below]{object]

or

\addvbuffer[symmetric-space]{object}

or

\addvbuffer{object}

In this last case, it uses redefinable lengths associated with the package to set the buffer space. It can even use negative space, to shrink a pre-existing border.

Here is [roughly speaking] your code with some \addvbuffer applied. I use the first two syntaxes shown above.

\documentclass{article}
\usepackage{booktabs}
\usepackage{mwe}
\usepackage{lipsum}
\usepackage{verbatimbox}
\begin{document}

\lipsum[2]

{\par\centering
\addvbuffer[1ex]{
\begin{tabular}{ccc}
\toprule
a & b & c\\
\midrule
1 & 2 & 3\\
4 & 5 & 6\\
\bottomrule
\end{tabular}
}
\par}

\lipsum[2]

\scshape
The following figure is shown with asymmetric buffering on purpose, to
demonstrate the capability of the \verb|\addvbuffer| macro.  It also
shows the use of a negative buffer space.
\upshape
  \begin{center}
    \addvbuffer[3ex -2ex]{\rule{.75\linewidth}{.5in}}
  \end{center}
\lipsum[2]

\end{document}

enter image description here

3
  • oops! \centering didn't go away after the graphics insertion. (didn't try to test it to figure out why.) May 2, 2013 at 13:20
  • when i look at the output of your example on my browser screen, the final paragraph isn't justified -- all lines are centered. that shouldn't be. also, there's more space above than below the graphics insertion (black box), where those spaces should be equal. (or perhaps there is something wrong with my browser.) May 2, 2013 at 15:00
  • @barbarabeeton Got it. The centering was a misplaced }. The asymmetric spacing was intentional to demonstrate capability of \addvbuffer. I've edited to correct the first, and highlight the second. May 2, 2013 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .