Consider the following example. The code is trying to append something after \mytest
. Strangely, when there is an extra group, the \hook_gput_code:nnn
does not work. There is no error message, just that the compilation process never stops. Why would this happen and what should one do to make the hook work?
\documentclass{article}
% \def\mytest{\normalfont\bfseries Text} % works
\def\mytest{{\normalfont\bfseries Text}} % does not work
\ExplSyntaxOn
\hook_gput_code:nnn { cmd/mytest/after } { mymodule }
{
Some code
}
\ExplSyntaxOff
\begin{document}
\mytest
\end{document}
! Undefined control sequence. \@nnil ->\@nil
(bug either way)\string
on the first token, and expands the rest. You can work around the issue by making the first item in the macro be a single token, for example\def\mytest{\relax{\normalfont\bfseries Text}}
. Since it seems to be a typesetting command, the\relax
shouldn't be a problem, but you can use something else, like\@empty
. Depends on what exactly the command does