I'd like to decrease the space between an algorithm environment and the text beneath it in my document. Looking at similar questions (How to remove/change the vertical spacing before and after an \algorithm environment? and vertical space after algorithm) I tried:
- Negative vspace
- Changing the textfloatsep (either for the entire document, or just before the algorithm environment)
- Changing the intextsep (seemed unlikely, since my algorithm is at the top of a page, but I tried it anyway)
None of those worked. Here is a MWE based on an answer to the second question:
\documentclass[twocolumn]{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\begin{document}
\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[10-20]
\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*}
\lipsum[20-30]
\end{document}