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
add state to the class
state' = T(state)
multiplicity = 1
while state' != state:
add state' to the class
multiplicity++
state' = T(state')
representative = min(class)
\end{Verbatim}
which looks as I want
apart from that I am not able to correctly create a way to number this block, even after studying the great answer Steven B. Segletes in the question How can I have numbered verbatim environments? . I guess it should be easy to do, but I've not come up with any working solution, since in Steven's answer the numblock package is used and it gives my problems when mixing it with Verbatim.
Any advice? Thank you very much in advance!
listingsare more useful for this, especially they allow for line-numbering – Aug 19 '17 at 21:43\href. – Aug 20 '17 at 08:41