[texhax] question about newlines

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Sat Oct 23 19:24:35 CEST 2004



Philip G. Ratcliffe wrote:
 >>I don't have much experience writing advanced macros, but
 >>I always wanted to write a macro that has a newline as delimiter.
 >>So I could say something like
 >>
 >>----
 >>\mymacro argument
 >>
 >>rest of the document
 >>---
 >>
 >>Do you know any way of doing this?
 >
 >
 > Try this
 >
 > \def\mymacro#1\par{blah blah #1 blah blah}

But a newline isn't a par; it's much closer to
a space than anything else.  If Carlos is really
going to succeed in taking #1 to be everything
up to (but not including) end of line, he'll
need some catcode trickery along the lines of :

	\def \activeeol {\catcode `\^^M = \active}
	\def \passiveeol {\catcode `\^^M = 5 }

	\def \mymacro
		{\activeeol
		 \Mymacro
		}

	\begingroup
	\activeeol %
	\gdef \Mymacro #1
		{\passiveeol %
		 <do something with #1>%
		}%
	\endgroup

Philip Taylor



More information about the texhax mailing list