GeneralThrowing custom warnings and errors

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
aikon
Posts: 2
Joined: Thu Apr 29, 2010 3:32 pm

Throwing custom warnings and errors

Post by aikon »

Hi everyone,

I have tried searching the intertubes (including this forum) but have so far come up dry. I am trying to find a consistent way to throw my on warnings and errors in LaTeX. Does this facility exist? How do I go about doing it?

Use case: As an example, I want to have a macro to mark a block of text as TODO. Among other things, such as making the text RED in the output, I would like to throw a warning to the compiler to indicate that there are unfinished portions of the document. This is useful because (ideally) when I am finished a document, it should compile without any warnings or errors -- if I can manually throw one when there are sections marked TODO, then I will know I am not done.

What I have found so far: I have found that I can throw an error to the compiler by using `\typeout{! my_error_message_here}', but there are a few shortcomings still. First, I don't know how to list /where/ this error is happening (e.g. current line number). Second, I would also like to be able to double-click on this error in e.g. TeXnicCenter to take me to the source line that threw the error. Third (and lastly), I would like to do all of the above but also with WARNINGS instead of ERRORS.

So, any advice or at least pointing in the right direction would be welcome =)

-Aikon

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Throwing custom warnings and errors

Post by josephwright »

Code: Select all

\PackageError{MyPackage}{Some text here}{Some more text here}
\PackageWarning{MyPackage}{Some text here}
\PackageInfo{MyPaclage}{Some text here}
Joseph Wright
aikon
Posts: 2
Joined: Thu Apr 29, 2010 3:32 pm

Re: Throwing custom warnings and errors

Post by aikon »

Thanks, Joseph; Murphy's law successfully predicted that I would find those shortly after making my first post =P
Post Reply