I would like to suppress the line numbering for specific lines in listings package by identifying the specific lines using some kind of command.


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.

  • 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? – user2478 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
  • 1
    @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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