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

Paul Isambert zappathustra at free.fr
Wed Jan 5 20:07:59 CET 2011


Le 05/01/2011 16:40, Philip Taylor (Webmaster, Ret'd) a écrit :
>
> 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.
>
> Alan, check the e-TeX Reference Manual : there are many new
> primitives in e-TeX intended to address exactly this sort
> of problem.
>
>     http://www.tug.org/texmf-dist/doc/etex/base/etex_ref.html

What Phil alludes to is:
First, you're running under eTeX, even though you might not know it.
Second, eTeX has a primitive called \unexpanded, which, as its name 
indicates, returns its argument with no expansion in such contexts as 
writing to an external file. I.e.:

\write15{\unexpanded{<Your material here>}}

will write what you feed it as is.

Best,
Paul


More information about the texhax mailing list