# vertical space after algorithm

I am using the usual algorithm package for a paper. However, LaTeX puts too much vspace below algorithms. I have already reduced \floatsep, \textfloatsep and \intextsep but it does not seem to help. For figures, I can use negative \vspaces after the figure to get less space after it. However, this does not work for algorithms as there is a line displayed below the algorithm. If I use a negative vspace in the algorithm environment, the line gets pulled into the pseudocode.

Thus, both answers which were posted for this question:

How to remove/change the vertical spacing before and after an \algorithm environment?

do not work.

How to fix this?

-
You should provide a minimal working example (MWE) that illustrates your problem. That's the best way for community members to assess your situation and provide solutions. – Werner Jul 9 '12 at 14:28
I took the liberty to format your post a little. See this link for more details on available formatting. – yo' Jul 9 '12 at 15:14

The layouts documentation (section 6.2 Detailed float layout, p 25) describes the possible lengths influencing the vertical space between floats and text body elements:

• \textfloatsep - between top and bottom-aligned float and text body (default is 20\p@ \@plus 2\p@ \@minus 4\p@); and
• \intextsep - between float and text for other floats (default is 12\p@ \@plus 2\p@ \@minus 2\p@).

The defaults for these are set in latex.ltx. Both these lengths have glue (meaning they can stretch/shrink). Here's a graphic from layouts showing the lengths involved.

Here's an incidental view on a change in \textfloatsep from the default to 0pt with an example from the algorithmicx package:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\begin{document}
\lipsum[1-2]
\begin{algorithm}[t]
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\caption{Euclid’s algorithm}\label{euclid}
\end{algorithm}
\lipsum[3-6]
\setlength{\textfloatsep}{0pt}% Remove \textfloatsep
\begin{algorithm}[t]
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\caption{Euclid’s algorithm}\label{euclid}
\end{algorithm}
\end{document}


Note the visible difference in the vertical space below algorithm.

-