0

I am using \documentclass[5p]{elsarticle} and packages \usepackage{algorithmic} \usepackage[ruled, vlined, longend, linesnumbered]{algorithm2e}

There is no error but did not get the vertical lines in loops and if conditions. Following is sample:

\documentclass[5p]{elsarticle}

\usepackage{algorithmic}
\usepackage[ruled, vlined, longend, linesnumbered]{algorithm2e}


\begin{document}

\section{Intro}
Text here
\begin{algorithm} 
\caption{title of algo} 
\label{alg:algo1}
  \begin{quote} 
  {\bf Input:} Input 1, Input 3
  {\bf Output:} Output here  
  \begin{algorithmic} `[`1`]`
  \STATE Initialize variable 
    \FORALL{1st for loop }
      \FORALL{2st for loop } 
        \FORALL{3rd for loop} 
          \IF {1st IF condition}
              \STATE statements
          \ELSIF{elseif condition}
            \STATE statements
          \ENDIF       
          \STATE statements
          \IF {if condition}
              \STATE statement
          \ENDIF
        \ENDFOR 
      \ENDFOR
    \ENDFOR
  \STATE Update the list  
  \end{algorithmic}   
 \end{quote}    
\end{algorithm} 

\end{document}

Thanks in advance for the help!

The output file is as shown below:

enter image description here

1

The vertical lines between the start and end of blocks is a feature of the algorithm2e package. You've used the algorithmic environment and syntax from the algorithmic package, so you cannot expect the lines to appear as the algorithmic does not have such a feature.

I don't think you should be loading both packages - both define the the algorithm environment and I can find no evidence to indicate that the two are compatible (with regards to how you have tried to mix them).

Seen as you want the vertical lines, my advice would be to remove \usepackage{algorithmic} and re-write your algorithm using the algorithm2e package.

A good comparison on the different packages for writing algorithms can be found on the Wikibooks: LaTeX/Algorithms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.