marcel@cs.caltech.edu (Marcel van der Goot) (12/06/90)
In <DAVIS.90Dec5022859@pacific.mps.ohio-state.edu> John E. Davis (davis@pacific.mps.ohio-state.edu) defines > \def\dolines#1{\medskip\obeylines#1\medskip} which doesn't work. > [Apparently] TeX is converting the 'newlines' to spaces before > substitution into the macro. If this is the correct diagnosis, [...] No, it isn't. What TeX reads (chapter 7) are pairs (character code, category code). Of course, your file contains only charcodes, so when TeX reads a character it uses the current catcode of that character. When it reads the newlines before substitution in your macro, <return> has catcode 5, so the newlines are replaced by (<return>, 5). In your macro, \obeylines changes the current catcode of <return> to 13 (active), but then it is already too late, since the argument already consists of (charcode, catcode) pairs. The conversion of <return> to a space is only done when the text is actually typeset. You can check this by doing (with your definition of \dolines): {\catcode`\^^M=\active \dolines{...} % read argument with current catcode (13) of <return> } In other words, the solution is to do the \obeylines before you read the argument. Here are macros that do that: \def\dolines{\bgroup\obeylines\dothelines} \def\dothelines#1{\medskip#1\medskip\egroup} Usage: \dolines{ This is line 1. This is line 2. This is line 3. } Marcel van der Goot marcel@vlsi.cs.caltech.edu