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

How can I make TeX/LaTeX insert the token \special{lb} into the generated DVI command stream whenever a linebreak occurs?

The listings package with its prebreak/postbreak option seems already close to the effect I want, however I need this \special to show up always, not only in case of a particular listing and I need this as a separate modification not as part of a package which might have side-effects.

The DVI commands are read as part of a postprocessing so I really need to see when TeX does a linebreak.

share|improve this question
LuaTeX might help. – Leo Liu Jun 16 '13 at 16:09
Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. – karlkoeller Jun 16 '13 at 16:12
LuaTeX is not an option for non-technical reasons. – user1162623 Jun 16 '13 at 20:13
up vote 4 down vote accepted

This is simply impossible. One should hook in the paragraph making algorithm, and this is not available to the user.

The only way is to use LuaTeX, that opens all the algorithms and procedures to user intervention.

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.