I have tried a few ways I found here, including This, and This, there are more but I can't remember them.
The issue I'm having is I'd like "Fifth Instruction" to start on 5, I know "Third Instruction" has the correct number by accident, but none of my attempts seem to work. I'm happy with the indented sections being automatically renumbered, but even if it was one numbering the whole way down (1-13) but indented I'd be happy – I can't seem to manage that either.
Any help is really appreciated!
\usepackage{algorithm,algpseudocode}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\State First Instruction
\State Second Instruction
\begin{algorithmic}[1]
\State Instruction 2.1
\State Instruction 2.2
\end{algorithmic}\\
Third Instruction\\
Fourth Instruction
\begin{algorithmic}[1]
\State Instruction 4.1
\State Instruction 4.2
\State Instruction 4.3
\end{algorithmic}\\
Fifth Instruction
\begin{algorithmic}[1]
\State Instruction 5.1
\State Instruction 5.2
\end{algorithmic}\\
Instruction 6
\end{algorithmic}
\end{algorithm}
Best Answer
A simple way with continuous numbering is to use extra indents with
\hspace
. To be consistent with the default indentation ofalgorithmic
you can use\algorithmicindent
as the value for the extra indent (this is1.5em
by default).MWE (note that I removed
algorithm2e
because it was causing an error):Result: