The \obeylines command tells TeX to preserve line endings, which is useful for poetry and various other things. I can limit the effect of \obeylines by wrapping it in a scope, like so:

    We obey, and end up on separate lines.
    We obey.
We disobey, and end up on the same line.
We disobey.

This is practically always the way to go, or newlines breaking up formatting code will break up more than that. But, out of curiosity: is there also a command that resets TeX's handling of line endings? Googling for \disobeylines turned up some roll-your-own implementations, but I'm curious whether Donald Knuth wrote an antidote into Plain TeX itself, too.

  • 1
    No, there's no "official" one. Knuth recommends to use it in a group. – egreg May 25 '12 at 14:41

The definition of \obeylines is

\def\obeylines{\catcode`\^^M\active \let ^^M\par }

So you can try:

\def\disobeylines{\catcode`\^^M=5 }

The example:

\def\disobeylines{\catcode`\^^M=5 }

    We obey, and end up on separate lines.
    We obey.
We disobey, and end up on the same line.
We disobey.



As egreg pointed out in his comment, Donald Knuth doesn't provide any \disobeylines. In the TeXBook at page 94 the command \obeylines is introduced with the following paragraph:

You may have several consecutive lines of input for which you want the output to appear line-for-line in the same way. One solution is to type \par at the end of each input line; but that’s somewhat of a nuisance, so plain TeX provides the abbreviation \obeylines, which causes each end-of-line in the input to be like \par. After you say \obeylines you will get one line of output per line of input, unless an input line ends with % or unless it is so long that it must be broken. For example, you probably want to use \obeylines if you are typesetting a poem. Be sure to enclose \obeylines in a group, unless you want this "poetry mode" to continue to the end of your document.

  • or better \def\disobeylines{\catcode ‘\^^M=5 } – David Carlisle May 25 '12 at 14:33
  • @DavidCarlisle: Do you mean the space? – Marco Daniel May 25 '12 at 14:35
  • 3
    yes otherwise \disobeylines 1 is a good number... doesn't do what you want – David Carlisle May 25 '12 at 14:43
  • @DavidCarlisle: Indeed -- every time I forget this case. – Marco Daniel May 25 '12 at 14:44

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.