In LaTeX commands only letters are allowed,neither - nor _. For internal LaTeX commands also @ are used, but without extra effort this is allowed in packages and classes only. In the expl3 context some other characters are also valid. So an answer depends on what you are doing. BTW: In LaTeX preambles you should avoid \def and prefer \newcommand, \renewcommand, \NewDocumentCommand etc.
– cabohahMar 03 '23 at 16:32
If you are writing a package for others to use: Be sure that your commands use a "namespace" prefix. Bad: \dothis. Good: \zzdothis where zz is related to your package name. Same for internal package commands. That prevents conflict with other packages trying to use the same macro names.
– rallgMar 03 '23 at 17:07
-nor_. For internal LaTeX commands also@are used, but without extra effort this is allowed in packages and classes only. In theexpl3context some other characters are also valid. So an answer depends on what you are doing. BTW: In LaTeX preambles you should avoid\defand prefer\newcommand,\renewcommand,\NewDocumentCommandetc. – cabohah Mar 03 '23 at 16:32\dothis. Good:\zzdothiswherezzis related to your package name. Same for internal package commands. That prevents conflict with other packages trying to use the same macro names. – rallg Mar 03 '23 at 17:07