# Vertical spacing in the algorithm environment

I'm using the algorithm/algorithmic packages and want to condense some of the vertical space between an algorithm's line numbers in order to save space. Ideally, I would like to remove 1 to 2mm of space between each line. Is there a way to do this with the algorithm package without editing the .sty file?

-

You can do this either by using the spacing environment from the setspace package or by using the second argument of the \fontsize command to change the value of \baselineskip; an example:

\documentclass{article}
\usepackage{algorithmic}
\usepackage{setspace}

\begin{document}

{\fontsize{10}{10}\selectfont
\begin{algorithmic}
\IF{$n$ is odd}
\RETURN \TRUE
\ELSE
\RETURN \FALSE
\ENDIF
\end{algorithmic}
}

\begin{spacing}{0.8}
\begin{algorithmic}
\IF{$n$ is odd}
\RETURN \TRUE
\ELSE
\RETURN \FALSE
\ENDIF
\end{algorithmic}
\end{spacing}

\end{document}
-
Couldn't get the spacing command to work (neither outside or inside of the enclosing \begin{algorithm} and \end{algorithm} tags), but the \fontsize command worked perfectly - thanks Gonzalo! –  ralphey Apr 18 '11 at 12:36
I used the spacing environment for a start and worked nicely. If the text gets too cluttered then use the fontsize command, as well. –  g24l Aug 13 '11 at 19:36
@g24l: Since your answer is supporting the very similar ealier solution give by Gonzalo, I converted it to a comment to this answer. –  Stefan Kottwitz Aug 14 '11 at 11:04