[texhax] To not expanding macros, is there anything else besides \string?

Reinhard Kotucha reinhard.kotucha at web.de
Wed Jan 5 17:11:22 CET 2011

On 4 January 2011 Barhorst, Alan wrote:

 > Hello, I am sorry for the naivety of this question, but here it
 > goes.  I am trying to use \immediate\write on file 14 and 15 for
 > information that is generated/input in my main LaTeX session. They
 > are solutions to problems that I want to assemble in an appendix.
 > The problem is that any macro I pass to the write command gets
 > immediately expanded, and all I have found in the literature is
 > that I need to put \string in front of every macro.  What I am
 > hoping is that there is one big wrapper macro I can place around
 > anything I want to write to a file for later expansion.  If there
 > is such a creature I would appreciate someone who could point it
 > out to me.  There seems to be hints of this in styles such as
 > inlinedef, but it seems to not work or I don't understand how it
 > works.

Instead of prepending \string to each special character, you can also
change their category codes.  This is what verbatim environments
usually do.  You could try the moreverb package, which allows to write
to a file:


You get its documentation with:

 texdoc moreverb


Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.

More information about the texhax mailing list