1

I read in official documentation of algorithm2e that \SetAlgoLined is used to draw vertical lines between begin and end markers.

But without it also, there are vertical lines drawn, though there are no begin and end markers.

So, what exactly is the use of \SetAlgoLined?

Below is a sample code:

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{algo_issue}
\date{July 2022}

\usepackage{subcaption} %a
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}  %a
\usepackage{amsmath} % a
\usepackage{amsfonts} % a
\usepackage{amssymb} % a
\usepackage{amsthm} % a 2
\usepackage{multicol} % a
\usepackage{multirow} % a


% \SetKwInput{KwGlobal}{Global}              % Set the Global variables
\SetKwProg{myproc}{procedure}{}{end}  

\begin{document}

% \maketitle

\section{Introduction}
this is sample

\begin{algorithm*}[!htb]  % replaced [t] temporarliy [!htb]
    \DontPrintSemicolon
    \caption{ this is my caption }
    \label{algo:algo1}
    \begin{multicols}{2}
    % \fontsize{8pt}{6pt}\selectfont
    \footnotesize
    %\small
    \SetAlgoLined
    

\myproc{$\mathtt{p1}${ ($a$, $b$, $c$)}} 
{
    hello
    hello 2
}

\end{multicols}
\end{algorithm*}
\end{document}

Thanks.

4
  • Welcome. Can you please show a minimal example of code?
    – egreg
    Jul 26, 2022 at 16:44
  • @egreg Provided above; please help. You can comment \SetAlgoLined and observe the difference. Also the official document of algorithm2e says this:- \SetAlgoLined prints vertical lines between bloc start-end keywords as begin, end. The link to official doc is here: ``` tug.ctan.org/macros/latex/contrib/algorithm2e/doc/… ```
    – akhil
    Jul 26, 2022 at 16:49
  • You have the option vlined, don't you?
    – egreg
    Jul 26, 2022 at 16:52
  • @egreg Yes, I have that option. If I remove both vlined and \SetAlgoLined still there are vertical lines. I am trying to understand the use of \SetAlgoLined and vlined.
    – akhil
    Jul 26, 2022 at 16:59

1 Answer 1

1

The documentation of algorithm2e is not up-to-date. In the intentions of the authors, the default option should be noline, but it apparently isn't.

Use it explicitly. Of course you should remove vlined as well. You can then use \SetAlgoLined in the body of an algorithm environment where you want the rules.

\documentclass{article}

\usepackage[noline,ruled,linesnumbered]{algorithm2e}


\SetKwProg{myproc}{procedure}{}{end}  

\begin{document}

\begin{algorithm*}[!htbp]
  \DontPrintSemicolon
  \caption{this is my caption}
  \label{algo:algo1}
  \myproc{$\mathtt{p1}(a,b,c)$}
   {
    hello
    hello 2
   }
\end{algorithm*}

\begin{algorithm*}[!htbp]
  \DontPrintSemicolon
  \SetAlgoLined
  \caption{this is my caption}
  \label{algo:algo2}
  \myproc{$\mathtt{p1}(a,b,c)$}
   {
    hello
    hello 2
   }
\end{algorithm*}

\end{document}

enter image description here

Or go to a different package, such as the combination algorithm and algpseudocode.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .