GeneralProblem with newfile.sty: using writeverbatim in a macro

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
dguaspari
Posts: 3
Joined: Thu Sep 13, 2007 5:20 pm

Problem with newfile.sty: using writeverbatim in a macro

Post by dguaspari »

I'm trying to use newfile.sty and find myself unable to define a macro that contains the writeverbatim environment.

For example, LaTeX works fine on this file:

\documentclass[12pt]{report}
\usepackage{newfile}

\newoutputstream{charax}
\openoutputfile{\jobname.drp}{charax}

\begin{writeverbatim}{charax}
A
\end{writeverbatim}

\closeoutputstream{charax}

\begin{document}

\input{\jobname.drp}

\end{document}


But if I enclose the writeverbatim environment within a macro, LaTeX fails with the message

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

Here's the packaged version:

\documentclass[12pt]{report}
\usepackage{newfile}

\newoutputstream{charax}
\openoutputfile{\jobname.drp}{charax}

\newcommand{\Fee}{
\begin{writeverbatim}{charax}
A
\end{writeverbatim}
}

\Fee

\closeoutputstream{charax}

\begin{document}

\input{\jobname.drp}

\end{document}

In case it's relevant, I'm using MiKTeX 2.7. I haven't been able to find anything about this on the web. Any help would be appreciated.

--
David Guaspari

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
rf
Posts: 21
Joined: Mon Jul 20, 2009 5:27 pm

Problem with newfile.sty: using writeverbatim in a macro

Post by rf »

This is the traditional "verbatim within another
command" problem (see http://www.tex.ac.uk/cgi-bin/texfaq2htm ... verbwithin)
\openoutputfile{\jobname.drp}{charax}

\begin{writeverbatim}{charax}
A
\end{writeverbatim}

\closeoutputstream{charax}
looks like a simplified example, since it contains no
parameter-derived text and so may just as well appear
outwith a macro; what in fact are you aiming to achieve?
Post Reply