TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 would like to suppress the line numbering for specific lines in listings package by identifying the specific lines using some kind of command.

share|improve this question
Please accept answers. In your previous question there are 2 answers without any response: tex.stackexchange.com/questions/33999/… – Marco Daniel Nov 8 '11 at 12:15
up vote 11 down vote accepted

It isn't such simple as it sounds. You have to hook every line. Here a small solution which needs more testing:

enter image description here





First line.
Second line.|\Suppressnumber|
Third line.
Next line.|\Reactivatenumber|
Next Line

Next time please provide an example. I took this one from you previous question.

share|improve this answer
Sorry for not providing an example; I felt my question was simple. Anyhow, thank you very much for the answer. I tried it and got the following result: – user9131 Nov 8 '11 at 17:32
I suppose that you do not need the \global and why do you have all the \relax after the let statement? – Herbert Nov 8 '11 at 17:41
@Herbert: The \relax is obsolete. I know this. I don't know why I haven't changed it. -- I tested without global and it works. – Marco Daniel Nov 8 '11 at 17:48
Everything worked, except the line numbers were not suppressed, but the line number was just repeated so I saw 1 xxx 2 xxx 2 xxx 3 xxx. – user9131 Nov 8 '11 at 17:58
@user9131: Marco's example works fine, showing that there's no line number printed after |\Suppressnumber|. What did you do differently? Did you receive any warnings in your .log? Perhaps you have an older version of listings - currently at 1.4. To see whether this is the case, add \listfiles before \documentclass and check your .log file after *File List*. – Werner Nov 8 '11 at 18:33

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.