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 have the following code in algorithm2e with boxruled, vlined, and linesnumbered options. pdflatex gives me an empty line at the end of both the for loops inside the ifs. Can someone please suggest a way to get rid of the extra lines? Thanks.

\If {$\lfloor c\ (\log (n+1) - \log n) \rfloor > 1$}
{
    $u \leftarrow {\tt SampleControl}$\;
    $U \leftarrow \{ u \} \cup U_m$\;
}
${\tt ConnectState}(z, S_{n+1}, U, P_n, Q_n, \delta_n)$\;
\eIf{$\min_{u \in U} \Delta t_{n+1} (z_{n+1}, u) \leq \delta_n$}
{   $\delta_{n+1} = \delta_n/2$\;
    \For{$z \in S_{n+1}$}{
        ${\tt ConnectState}(z, S_{n+1}, U, P_{n+1}, Q_{n+1}, \delta_{n+1})$\;
}}{ $\delta_{n+1} \leftarrow \delta_n$\;
    \For{$z' \in Z_\mathrm{near}(z_{n+1})$}{
        ${\tt ConnectState}(z', S_{n+1}, U, P_{n+1}, Q_{n+1}, \delta_{n+1})$\;
}}
share|improve this question
    
Welcome to TeX.SX! Please, add a minimal preamble to your code so that it becomes a complete example that can be run through LaTeX. –  egreg Sep 16 '12 at 11:08
add comment

1 Answer 1

Perhaps you mean the additional vertical space at the end of the if and for blocks. It can be configured by \SetVlineSkip:

\documentclass{article}
\usepackage[boxruled,vlined,linesnumbered]{algorithm2e}

\SetVlineSkip{0pt}      

\begin{document}

\begin{algorithm}
\caption{Caption of algorithm}
\If {$\lfloor c\ (\log (n+1) - \log n) \rfloor > 1$}
{
    $u \leftarrow {\tt SampleControl}$\;
    $U \leftarrow \{ u \} \cup U_m$\;
}
${\tt ConnectState}(z, S_{n+1}, U, P_n, Q_n, \delta_n)$\;
\eIf{$\min_{u \in U} \Delta t_{n+1} (z_{n+1}, u) \leq \delta_n$}
{   $\delta_{n+1} = \delta_n/2$\;
    \For{$z \in S_{n+1}$}{
        ${\tt ConnectState}(z, S_{n+1}, U, P_{n+1}, Q_{n+1},
\delta_{n+1})$\;
}}{ $\delta_{n+1} \leftarrow \delta_n$\;
    \For{$z' \in Z_\mathrm{near}(z_{n+1})$}{
        ${\tt ConnectState}(z', S_{n+1}, U, P_{n+1}, Q_{n+1},
\delta_{n+1})$\;
}}
\end{algorithm}

\end{document}

Result

BTW, \SetVlineSkip is defined as:

\newcommand{\SetVlineSkip}[1]{\skiphlne=#1}%

A better definition for \SetVlineSkip would be (terminating of the assignment, support of package calc):

\renewcommand*{\SetVlineSkip}{\setlength{\skiphlne}}
share|improve this answer
    
Thanks a lot for your answer. I however just realised that the extra vspace shows up if I use \IncMargin{} in ieeeconf.cls. It does not show up in the article class. Any suggestions to get incmargin and still remove the white space? :) –  Pratik C Sep 17 '12 at 1:08
    
The class file is IEEEconf.cls. In twocolumn mode the line width is too small and you get overfull \hbox warnings. Fix them and then also the additional white space should disappear. –  Heiko Oberdiek Sep 17 '12 at 1:26
    
I solved this problem by reducing the font in the algorithm environment, saves more space for my paper and looks better as well! –  Pratik C Sep 29 '12 at 22:48
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.