[Tex/LaTex] ny way to generate custom errors/warnings in LaTeX

compilingerrorsmacroswarnings

I want something like \ifmmode\else\GenerateWarning{The command \backslash uzuka is supported only in math mode.}\fi, which is supposed to generate a warning "The command \uzuka is supported only in math mode.". Is there a command or a package with this capacibility?

Best Answer

For LaTeX, use the commands described in section 4.9 of clsguide.pdf:

  • \PackageWarning and \PackageWarningNoLine if you are writing a package
  • \ClassWarning and \ClassWarningNoLine if you are writing a class
  • The internal generic version for warnings is \GenericWarning

The expl3 bundle has another interface for warnings and similar messages, see Part III, chapter 11 in source3.pdf.