Path: utzoo!attcan!uunet!peregrine!elroy.jpl.nasa.gov!jarthur!nntp-server.caltech.edu!news From: marcel@cs.caltech.edu (Marcel van der Goot) Newsgroups: comp.text.tex Subject: obeylines (Re: easy macro for novice) Summary: catcodes are assigned when a character is first read Keywords: category codes, \obeylines Message-ID: <1990Dec6.001129.10115@nntp-server.caltech.edu> Date: 6 Dec 90 00:11:29 GMT References: Sender: news@nntp-server.caltech.edu Reply-To: marcel@cs.caltech.edu Distribution: comp Organization: California Institute of Technology (CS dept) Lines: 38 Nntp-Posting-Host: stun4d.caltech.edu In 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, has catcode 5, so the newlines are replaced by (, 5). In your macro, \obeylines changes the current catcode of to 13 (active), but then it is already too late, since the argument already consists of (charcode, catcode) pairs. The conversion of 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 } 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