[texhax] Write verbatim to file - can't stop

Matthew Leingang leingang at math.harvard.edu
Thu Sep 2 16:03:09 CEST 2004


Hello,

I have a long LaTeX file with several control sequences of the form

\cs{text}

I'd like to change the definition of \cs to write "text" to another file,
unexpanded.

The TeXbook shows on p. 422 how \answer ... \par can write solutions to an
answer file, but that's not the syntax that I have to start with.

I found the answers package on CTAN, which includes an environment
"Filesave", so that

\begin{Filesave}{stuff}
When in the course of human events it becomes necessary...
\end{Filesave}

writes the text to stuff.tex.  But

\renewcommand{\cs}[1]{\begin{Filesave}{stuff}#1\end{Filesave}}

doesn't work, I think because Filesave uses some of the verbatim macros to
disable (make letters) characters like \.  So the \end{Filesave} macro isn't
a macro anymore.  The result is that the whole rest of the file gets slurped
into stuff.tex, and the error is

Runaway argument?
! File ended while scanning use of \next.

If I could figure out what characters have the right catcodes so that
\end{Filesave} gets expanded again, that might work.  Or maybe there's
another existing solution.

Any advice?

TIA,
Matthew Leingang

-- 
Matthew Leingang
Preceptor in Mathematics
Harvard University

URL: http://www.math.harvard.edu/~leingang/
vCard: http://www.math.harvard.edu/~leingang/vCard.vcf




More information about the texhax mailing list