I saw a question that tells me how to change the spacing in an algorithm environment, but I don't know how to do remove/change the space before and after an algorithm environment like:
% remove the space here
\begin{algorithm}
\begin{algorithmic}
[...]
\end{algorithmic}
\end{algorithm}
% remove the space here
Best Answer
LaTeX has three length variables to control (i) the distance between two adjacent floating objects (such as figure, table, or algorithm objects), (ii) the distance between a float at the top (bottom) of a page and the text below (above) it, and (iii) the distance between an in-text float and the text above and below it; they are called
\floatsep
,\textfloatsep
, and\intextsep
, respectively. (LaTeX also has three more such variables to control the spacing above and/or below floats on floats-only pages; these are\@fptop
,\@fpbot
, and\@fpsep
, respectively.)To completely suppress the in-text separation of a float (not recommended, by the way!!), you'd type (in the preamble)
i.e., you'd set
\intextsep
to a fixed length of 0 points. A better solution, if you're pressed for space (pun intended), would be to setHere's a MWE that uses the algorithm2e package: