# Numbering correctly indented Verbatim code blocks

I have been looking through the tex.stackechange community answers and questions and I've not managed to find an answer to my problem. I want to be able to write blocks of code in a verbatim-like environment in LaTeX and have them also numbered in a way reminiscent of how equations are numbered but with a different label.

Thanks to the question How to indent code in \begin{verbatim} and the documentation of the fancyvrb package I have so far the following in my tex file:

\begin{Verbatim}[obeytabs,frame=single,rulecolor=\color{red}]
for state in basis_with_fixed_M:
if state is not in any class yet:
create new class
state' = T(state)
multiplicity = 1
while state' != state:

• You are trying to typeset an algorithm apparently. I think, some of the algorithm based packages or listings are more useful for this, especially they allow for line-numbering – user31729 Aug 19 '17 at 21:43
• No, I don't meant anything with \href. – user31729 Aug 20 '17 at 8:41