# how to change the type of vertical line in algorithm environment while minimizing the vertical spacing

I am trying to have a straight vertical line after if and for statements to remove the redundant space in algorithm environment.

I use informs3 class that can be found in this website where you should click INFORMS Journal on Computing Style Files.

Here is a MWE.

\documentclass[ijoc,nonblindrev]{informs3}
\OneAndAHalfSpacedXII % current default line spacing
\TheoremsNumberedThrough
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\For{$i \in V$} {
\For{} {
\If{}{
\uIf{}{
$statement$
}\Else{
$statement$
}
}
}
}
\Return{x}
\caption{{\sc My Algorithm}}
\end{algorithm}
\end{document}

Also, I'd like to remove the spaces between the lines. None of the recommendations presented in this post Vertical spacing in the algorithm environment works.I would appreciate if someone could help me out.

• Could you provide a compilable code reproducing the output? I compiled your code by placing it in an informs3 class document loading the package algorithm2e, but I got a different output. – Vincent Dec 30 '19 at 17:05
• I updated the post and here how it looks imgur.com/JME7YCh – whitepanda Dec 30 '19 at 17:08
• @Vincent I solved the first issue. – whitepanda Dec 30 '19 at 17:15
• @whitepanda: You want to reduce the vertical or horizontal spacing between the lines? – Werner Dec 30 '19 at 17:16
• I want the minimize the vertical spacing. When I used lines, the spacing increased even more. – whitepanda Dec 30 '19 at 17:18

With the combination of the options lined and noend:

\documentclass[ijoc,nonblindrev]{informs3}
\OneAndAHalfSpacedXII % current default line spacing
\TheoremsNumberedThrough
\usepackage[linesnumbered,ruled,lined, noend]{algorithm2e}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\For{$i \in V$} {
\For{} {
\If{}{
\uIf{}{
$statement$
}\Else{
$statement$
}
}
}
}
\Return{x}
\caption{{\sc My Algorithm}}
\end{algorithm}
\end{document}

Or with vlined and \SetVlineSkip{0pt}:

\documentclass[ijoc,nonblindrev]{informs3}
\OneAndAHalfSpacedXII % current default line spacing
\TheoremsNumberedThrough
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\For{$i \in V$} {
\For{} {
\If{}{
\uIf{}{
$statement$
}\Else{
$statement$
}
}
}
}
\Return{x}
\caption{{\sc My Algorithm}}
\end{algorithm}
\end{document}

The vertical spacing between the rows of the algorithm is quite large, since you used \OneAndAHalfSpacedXII in the preamble. To locally decrease the linespacing in the algorithm, you can use \SingleSpacedXII inside of the algorithm environment as shown in teh following example:

\documentclass[ijoc,nonblindrev]{informs3}
\OneAndAHalfSpacedXII % current default line spacing
\TheoremsNumberedThrough
\usepackage[linesnumbered,ruled,lined, noend]{algorithm2e}
\begin{document}
\begin{algorithm}
\SingleSpacedXII
\DontPrintSemicolon
\For{$i \in V$} {
\For{} {
\If{}{
\uIf{}{statement}\Else{
$statement$
}
}
}
}
\Return{x}
\caption{{\sc My Algorithm}}
\end{algorithm}
\end{document}
• In the user manual, this is how the algorithms look imgur.com/a/CB3KTgd. I want mine to look like the same. When I run your code, there is still a huge gap between the lines. Please check imgur.com/IrzoY0L to see the output. – whitepanda Dec 30 '19 at 17:25
• @whitepanda: I have updated my answer accordingly. Hope this helps. – leandriis Dec 30 '19 at 17:36