TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have post a question several weeks ago: Print programs with its proper syntax, and I choose to use tabbing package at the moment.

Now I really need to keep the tabbing and print a line number before each line. It will be great if this line number is automatically generated. Does anyone know how to do it?

I guess one fundamental approach is to define my own highlighting and tabbing rules based on the syntax of my language. (I have seen an example somewhere, but I could not find it anymore...) Could anyone help?

share|improve this question
It would be helpful to compose a MWE including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Nov 19 '11 at 15:54
IMHO you made the wrong choice to use tabbing and now want automatic line number and syntax highlighting that other packages like algorithmicx and listings can perform by default. Why do you "really need to keep [..] tabbing"? – Werner Nov 19 '11 at 15:57
I'm with Werner. This sounds to me like the ideal use case for listings. – qubyte Nov 19 '11 at 16:33

There is a package ntabbing on CTAN which provides the ntabbing environment which numbers lines. It's not present on TeX Live, but it's simple to put it in the same directory as the main file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.