# Spacing around table and figure environments

I've got table and figure environments, some placed "here" with h and some arranged automatically. But all together I don't like the spacing above and below the figure and table environments.

I searched the internet and found tips to set abovecaptionskip and belowcaptionskip. Well since my tables and figures all have a caption below the actual table/figure belowcaptionskip allows me to set the \vspace between table/figure and the following text. But abovecaptionskip obviously just gives me \vspace between the table/figure and the caption, but not between the above text and the table/figure.

How to set the \vspace above and below table/figure correctly then?

You are probably looking for the length \intextsep (at least). This is the space that is inserted to separate floats from the surrounding text.

• How does one adjust this parameter? – Roly Dec 4 '19 at 21:00
• @Roly this is how: \setlength\intextsep{18pt} – yegor256 May 1 '20 at 9:53

One way would be to simply add the desired \vspace before and after:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}

\newenvironment{MyFigure}[1][]{\begin{figure}[#1]\vspace{1.0cm}}{\vspace{1.0cm}\end{figure}}
\begin{document}
\lipsum[1]
\begin{MyFigure}[h!]
\centering
\includegraphics[width=5cm,height=2cm]{foo}
\caption{Figure: foo}
\end{MyFigure}
\lipsum[2]
\end{document}

• Also works for a negative space, as I have just found out. – henry Oct 12 '14 at 21:06
• underrated answer! +1 – Georges Oct 21 '16 at 5:13

Try adjusting the parameter \intextsep.

• How does one adjust this parameter? – Roly Dec 4 '19 at 20:59
• @Roly --- something like \setlength\intextsep{10cm} or \addtolength\intextsep{1cm}. – Ian Thompson Dec 10 '19 at 16:13

etoolbox can be used to add content at the start/end of an environment automatically. The following minimal example adds (up to) 5mm to the top and bottom of the figure environment (via \addvspace{5mm}).

\documentclass{article}
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\begin{document}
\lipsum[1]
\begin{figure}[h!]
\centering\includegraphics{image}
\caption{This is a caption.}
\end{figure}
\begin{figure}[h!]
\centering\includegraphics{image}
\caption{This is a caption.}
\end{figure}
\lipsum[2]
\end{document}


The advantage with using \addvspace is that it only adds enough, making figures that end up on top of one another not add double the amount of space. See the \addvspace{<len>} documentation.

• Hm, I get "undefined control sequenc" when I add the etoolbox package and use the AtBeginEnvironment.. – Meinzlein Dec 15 '11 at 18:22
• @Meinzlein: You need to be a little more specific than that, since etoolbox recently added those patching commands. The most recent version of etoolbox on CTAN is v 2.1 2011/01/03. To see yours, add \listfiles before \documentclass and find the etoolbox entry after **File List** in your .log file. – Werner Dec 15 '11 at 18:33
• Not working here either, inside a beamer class, probably interference with some other stuff I have... – PatrickT Apr 16 '18 at 19:57
• @PatrickT: You can probably forego using figures inside a beamer presentation, as no-one would necessarily remember figures numbers associated with a \caption. Instead, name the figures or just use a center environment to place and caption them. – Werner Apr 16 '18 at 20:13
• @Werner. Thanks. The figure, table and center environments create too much space when they are immediately below the frametitle. I often use the caption (without numbers), typeset in smaller font, so it's more convenient than a center environment. My workaround is adding \vspace{-1em} but I was looking for a more general fix. Your approach looked very promising. I don't really have time to make a MWE and post a question, so I'll stay with negative vspace for now. Thanks! – PatrickT Apr 16 '18 at 20:35

Insert \vspace{} above \begin{table}

The example below adds 10mm of space above the table.

\vspace{10 mm} % add some space above the table

\begin{table}[ht]
\centering % used for centering table
\begin{tabular*}{0.7\textwidth}{ l r } % centered columns (2 columns)
\hline\hline %inserts double horizontal lines
Category & Score \\ [0.5ex] % inserts table heading
\hline % inserts single horizontal line
a & b \\ % inserting body of the table
c & d \\
e & f \\
g &  h \\ [1ex] % [1ex] adds vertical space
\hline %inserts single line
\end{tabular*}
% \caption{What a great table}
% \label{table:scores} % is used to refer this table in the text
\end{table}

• Welcome to TeX.SX! While this can work if the float can respect the h option, it will leave an unwanted vertical space if the float must be moved. – egreg Jul 1 '13 at 9:22