>    \catcode`\~=12%

changing catcodes in an environment looks wrong (the % after the 12 is
definitely wrong)  if you change catcodes then the definition cannot work
in the argument of any command (for the same reasons that \verb does not
work in command arguments) . Leave ~ active but make it expand to the
inactive one eg

\edef~{\string~}%

Reply via email to