1

I have the below MWE. The desired output is one tab indentation of lines. Do you see what is wrong?

\documentclass{article}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{geometry,nccmath}
\usepackage{booktabs,caption}
\usepackage{algpseudocode}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\algorithmic}
  {\ALG@tlm\z@}{\leftmargin\z@\ALG@tlm\z@}
  {}{}
\makeatother

\begin{document}

\begin{algorithm}[H]
\SetArgSty{textnormal}
\SetAlgoLined
\begin{algorithmic}
    \Function{Initialization}{$A$,$B$,$C$}
    
    \State{\For{$i \gets 1$ \KwTo $N$,}{\For{$i \gets 1$ \KwTo $nPop$,}{ $A \gets B$\;} \For{$j \gets{} 1$ \KwTo $M$,}{$C\gets 5$\;}}}
    \EndFunction
  \end{algorithmic}
 \caption{Initialization}
\end{algorithm}

\end{document}

enter image description here

2
  • 3
    You cannot use algorithm2e and algpseudocode together. Choose either.
    – egreg
    Commented Dec 16, 2022 at 10:02
  • Makes sense. I just like the vertical lines but also the function name style of algpseudocode.
    – tcokyasar
    Commented Dec 16, 2022 at 23:09

0

You must log in to answer this question.

Browse other questions tagged .