15

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:

{\obeylines
    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.

Esteis
  • 2,917

1 Answers1

16

The definition of \obeylines is

% In \obeylines, we say `\let^^M=\par' instead of `\def^^M{\par}'
% since this allows, for example, `\let\par=\cr \obeylines \halign{...'
{\catcode`\^^M=\active % these lines must end with %
  \gdef\obeylines{\catcode`\^^M\active \let^^M\par}%
  \global\let^^M\par} % this is in case ^^M appears in a \write

So you can try:

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

The example:

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

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

\bye


EDIT

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.

David Carlisle
  • 757,742
Marco Daniel
  • 95,681