# How to have sub-numbering in an algorithm

Below is a Dummy Algorithm code. I am not getting the desired output with this code. The code is as follows:

\documentclass{article}

longend]{algorithm2e} \usepackage{xcolor}

\begin{document}

\newcommand\mycommfont[1]{\small\ttfamily\textcolor{blue}{#1}}

\begin{algorithm}
\SetKwFunction{isOddNumber}{isOddNumber}
% \SetKwInput{Input}{Input}
% \SetKwInput{Output}{Output}
\SetKwInOut{KwIn}{Input}
\SetKwInOut{KwOut}{Output}

\KwIn{A list where each element is an integer.}

\KwOut{Processed list.}

First List is follows
\begin{itemize}
\item One
\item Two
\item Three
\end{itemize}
Second List is follows
\begin{itemize}
\item Four
\item Five
\item Six
\end{itemize}
\caption{A plain algorithm} \end{algorithm} \end{document}


I want output as:

  1. First List is as follows

i.   One
ii.  Two
iii. Three

2. Second List is as follows
i.   Four
ii.  Five
iii. Six


The above latex code can't retain its numbering sequence i.e., 2. is not printed in the output. Also, bullet points are in dot form and I want alphabetic and there is a space between each sub-numbering that I don't as my actual algorithm is quite long.

• Your MWE is not minimal. Remove the unnecessary packages. MWE should actually be minimal. Commented Jan 28, 2020 at 4:15
• You're not really utilising algorithm2e notation/functionality. How about this instead (code)?
– Werner
Commented Jan 28, 2020 at 4:45
• Thanks a lot, Werner. The code is working as desired. The only thing left is the indent of sub-numbers. Commented Jan 28, 2020 at 5:45
• @TriptiAgrawal: Line numbers in an algorithm is meant to be flush left, regardless of the indentation of the code. At least, you'll find that in all algorithm packages.
– Werner
Commented Jan 28, 2020 at 5:54
• In the algorithm, I have everything inside for loop. It is a big algorithm and it is a part of unpublished research work, so I can't post the actual algorithm. In my algorithm, due to for loop, sub-numbering is appearing very far and it is looking odd. Commented Jan 29, 2020 at 3:31

Probably you want something like this -

\documentclass{article}
\makeatletter
\let\@alph\@roman
\makeatother

\begin{document}
\begin{enumerate}
\item First List as follows
\begin{enumerate}
\item One
\item Two
\item Three
\end{enumerate}
\item Second List is follows
\begin{enumerate}
\item Four
\item Five
\item Six
\end{enumerate}
\end{enumerate}
\end{document}

• There is one problem that your code is not changing the sequence number of line "Second List is as follows" Commented Jan 28, 2020 at 5:48
• Tripti see the edit. Commented Jan 28, 2020 at 5:50