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.

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?

share|improve this question

5 Answers 5

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

share|improve this answer

Try adjusting the parameter \intextsep.

share|improve this answer

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

enter image description here

\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}
share|improve this answer
    
Also works for a negative space, as I have just found out. –  henry Oct 12 at 21:06

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}).

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\AtBeginEnvironment{figure}{\addvspace{5mm}}\AtEndEnvironment{figure}{\addvspace{5mm}}
\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.

share|improve this answer
    
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

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}
share|improve this answer
4  
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

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.