Is there any way to generate custom errors/warnings in LaTeX?
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 warnigns is
\GenericWarning
The expl3
bundle has another interface for warnings and similar messages, see Part XVII in source3.pdf
.
Just use the built-in \errmessage
for errors, e.g. \let\GenerateWarning=\errmessage
.
The kind of warnings Latex generates are just messages; \let\GenerateWarning=\message
will not interrupt the compile. Latex uses the commands \@latex@warning
and \@latex@warning@no@lines
to create these for its own warnings: you check the source you find in latex.ltx
.
You can use \typeout{msg}
. The command will print msg on the terminal and in the log file.