Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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

share|improve this answer
    
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. –  Marc van Dongen May 2 '13 at 11:06
add comment

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

share|improve this answer
    
oops! \centering didn't go away after the graphics insertion. (didn't try to test it to figure out why.) –  barbara beeton May 2 '13 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.) –  barbara beeton May 2 '13 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. –  Steven B. Segletes May 2 '13 at 15:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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