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:

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
      state' = T(state')
    representative = min(class)

which looks as I want block of code correctly indented 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!

  • 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
  • Thanks for your anwer! I guess you have something like this tex.stackexchange.com/questions/163768/… in mind? Although it's not what I wanted, it could work. Should I leave this still as unanswered since my original question, not yet solved, may be what other person needs? – Hector248 Aug 20 '17 at 8:38
  • No, I don't meant anything with \href. – user31729 Aug 20 '17 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.