I'm trying to write \newcommand macros that will check the user's inputs to arguments and return an error message if an error (for example, value out of range) is found. Is there a good reference? Thanks

  • I think you need to be a bit more specific about where your issue is. The LaTeX Companion and the 'class guide' (texdoc clsguide) both include details of for example \PackageError. – Joseph Wright Feb 13 '15 at 7:07

source2e (section 14 Error handling) describes techniques to write errors and warnings (and information) to the end user. Here are some references:

These commands are intended for use by package and class writers, to give information to authors. The syntax is:


and similarly for classes (use \Class... instead of \Package...). The Error commands print the <error> message, and present the interactive prompt; if the author types h, then the <help> information is displayed. The Warning commands produce a warning but do not present the interactive prompt. The WarningNoLine commands do the same, but don't print the input line number. The Info commands write the message to the .log file.

Within the messages, the command \MessageBreak can be used to break a line, \protect can be used to protect command names, and \space is a space, for example:

  Your hovercraft is full of eels,\MessageBreak
  and \protect\foo\space is \foo}


Package ethel warning: Your hovercraft is full of eels,
(ethel)                and \foo is FOO on input line 54.

The above macros are specialized versions of more generic constructions:

  • \GenericInfo{<continuation>}{<info>}

  • \GenericWarning{<continuation>}{<warning>}

  • \GenericError{<continuation>}{<error>}{<further help>}{<help info>}

Also, a rudimentary way of sending information to the console is to use \typeout{...}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.