[texhax] Passing Underscore

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Tue Sep 19 01:46:27 CEST 2006



Peter Abbott wrote:

 > I have file names containing the _ (underscore) character and need to
 > pass the _ into a macro as part of a file name. \_ inserts protect command etc.
 >
 > Can I declare it as a 'normal' character?

You can, but then something else wanting it to have
its canonical catcode would get confused.  I suggest
you hide the underscore in a control sequence, where
it can lose its pathological catcode without causing
problems :

\documentclass {article{
\begin {document}
\def \noescape {}
\edef \fileone {\expandafter \expandafter \expandafter \noescape \expandafter \string \csname file_one\endcsname}
\include \fileone
\end {document}

This will happily \include a file called "file_one" without problems.

Philip Taylor
-- 
l2tabuen : Just say "No".


More information about the texhax mailing list