28.03.2013 Views

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

446 Appendix D. L AT E X Programming<br />

D.2.7 Issuing errors <strong>and</strong> warnings<br />

Classes <strong>and</strong> packages may be programmed <strong>to</strong> issue their own error messages<br />

<strong>and</strong> warnings. This is useful <strong>to</strong> indicate which file is responsible<br />

for the message.<br />

Error messages are generated with<br />

\ClassError{class name}{error text}{help}<br />

\PackageError{package name}{error text}{help}<br />

where error text is the message printed <strong>to</strong> the moni<strong>to</strong>r <strong>and</strong> <strong>to</strong> the transcript<br />

file, <strong>and</strong> help is additional text printed after the user responds with<br />

H. If the texts contain comm<strong>and</strong> names that are <strong>to</strong> be printed literally,<br />

they must be preceded by \protect; spaces are generated with \space,<br />

<strong>and</strong> new lines with \MessageBreak. For example,<br />

\PackageError{ghost}{%<br />

The \protect\textwidth\space is <strong>to</strong>o large\MessageBreak<br />

for the paper you have selected}<br />

{Use a smaller width.}<br />

produces the error message<br />

! Package ghost Error: The \textwidth is <strong>to</strong>o large<br />

(ghost) for the paper you have selected.<br />

See the ghost package documentation for explanation.<br />

Type H for immediate help.<br />

Typing H 〈return〉 produces<br />

Use a smaller width.<br />

after which L AT E X halts again <strong>to</strong> wait for a response as described in Section<br />

C.1.<br />

Warnings may also be issued from classes <strong>and</strong> packages in a similar<br />

way. The difference is that there is no help text, <strong>and</strong> the processing does<br />

not s<strong>to</strong>p for a response. The line number of the input file where the<br />

warning occurred may be optionally suppressed.<br />

\ClassWarning{class name}{warning text}<br />

\ClassWarningNoLine{class name}{warning text}<br />

\PackageWarning{package name}{warning text}<br />

\PackageWarningNoLine{package name}{warning text}<br />

For example, with the warning<br />

\PackageWarning{ghost}<br />

{This text is haunted}<br />

one obtains the message<br />

Package ghost Warning: This text is haunted on input line 20.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!