Is it possible to temporally make undefined \csname control sequence not silently expand to \relax?
You cannot alter the behaviour of \csname
, but you can use e-TeX's \ifcsname
to issue an error:
\csname
\ifcsname#1\endcsname
\else
\expandafter\UndefinedName
\fi
#1%
\endcsname
where \UndefinedName
is deliberately not defined. TeX will then issue an error complaining about Undefined control sequence
, followed by #1
(which is what you actually want to complain about).
(Unlike \@ifundefined
, \ifcsname
is expandable and does not add to the hash table.)
You can check the command for existence and invoke the error yourself.
\@ifundefined{/#1/}{%
\GenericError{}{%
Command /#1/ undefined!
}{%
See the definition of \protect\mymacro!
}
}{}%
The \@ifundefined
macro uses \csname
so it will define the macro as \relax
. I don't think that this is an issue (we invoke the error anyways), but you can surround the code by \begingroup ... \endgroup
to make the definition local.