[texhax] How to write a TeX code into file literally

Yue Wu vanopen at gmail.com
Sun Oct 9 08:49:11 CEST 2011


Hello list,

I'm trying to write a TeX code into file, then use it again, but I meet
some trouble. My TeX code has # sign, after write to external file, the
# will be doubled:

\newwrite\testwrite
\openout\testwrite=testwrite
\immediate\write\testwrite{\halign{#&#\cr
hello&test\cr
}}

Then I tried to set #'s catcode to 12(other):

\newwrite\testwrite
\openout\testwrite=testwrite
{\catcode`\#=12
\immediate\write\testwrite{\halign{#&#\cr
hello&test\cr
}}
}

then the file will be empty.

So my question is, how to write literally the TeX code like:

\halign{#&#\cr
hello&test\cr
}

into file without doubling any charctors?

-- 
Regards,
Yue Wu

Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University(中國藥科大學)
No.24, Tongjia Xiang Street, Nanjing 210009, China


More information about the texhax mailing list