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'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?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

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

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.