I am writing a long latex document and use many macros for defining mathematical symbols. I would like to ensure that there is no clash in the notation. For example, something like
\newcommand{\symbolone}{A}
\newcommand{\symboltwo}{A}
should not happen. Is there something like an assertion in latex such that I can do
\assert{\symbolone != \symboltwo}
?
Best Answer
My solution introduces the macro
\singledef
which defines control sequence (like\def
) but provides two more features:\singledeflist
internal macro. When the next control sequence is defined via\singledef
then it is defined but it is checked if the same control sequence (equivalent via\ifx
) was defined and saved in\singledeflist
. If yes, then error message is printed and the new control sequence is kept undefined.The code: