Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any way to control where in the log file or console output \PackageWarning or \ClassWarning messages get placed? I have a class warning (generated by my own document class) that gets buried at the beginning of the log file which I'd like to place at the end, close to where the warnings about labels appear. Is this possible?

share|improve this question
Perhaps not the right platform or workflow but LateX Makefile does handle errors and warnings (including at least some package warnings), displaying them more prominently than the default log output. –  mas Aug 25 '11 at 19:05
Thanks for the comment, but since this is a class file that will be used by many different users, I want to control the placement myself as much as possible. –  Alan Munn Aug 25 '11 at 19:10
Very interesting question, Alan! When reading the biblatex doc., I saw the description of the logreq package, which "provides a frontend for writing machine-readable messages to an auxiliary log file." The output seems to be a set of instructions described in the XML format (reminds me of the Java ant buildfiles). Since I'm not sure if we can selectively redirect the compiler output, a similar approach to this package might help (.log - .xml, messages - commands, and so forth). Another "dirty" idea is to use grep/awk/sed to "filter" the .log file and get the package messages. –  Paulo Cereda Aug 25 '11 at 19:19

2 Answers 2

up vote 4 down vote accepted

I'd use \ClassWarningNoLine that suppresses the line number indication:

\AtEndDocument{\ClassWarningNoLine{myclass}{I've done something}}
share|improve this answer
Great. That's very helpful. I hadn't noticed those versions of the warning commands, and for this kind of warning, it's exactly what is needed. –  Alan Munn Aug 25 '11 at 20:19

I tried


\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\ClassWarning{book}{Class warning.}

This is a test document.

and was able to shove a \ClassWarning to the end of the document. That is, the log file showed

Class book Warning: Class warning.

rather than the other way around. Does this qualify as "exact placement"?

share|improve this answer
Thanks. I discovered this too, after I posted the question, but I thought I'd let someone else answer. In fact, in my case it's not really necessary to redefine \ClassWarning, but simply to wrap it in \AtEndDocument. I think this is about as exact as we'll get. I'll wait to see if anyone else has a different solution. –  Alan Munn Aug 25 '11 at 19:29
Sure, if you have access to \ClassWarning in the document class, redefinition is not required. –  Werner Aug 25 '11 at 19:34
I guess my question wasn't so clear :-) I was assuming from inside the class itself; you were assuming from inside a user document. I've clarified the question for posterity. –  Alan Munn Aug 25 '11 at 19:56
Ahhh, now it makes more sense. I wonder whether the silence package would be of any help. It captures (gobbles) warning messages and may provide a means for producing a warning together with another. –  Werner Aug 25 '11 at 20:00
That's an interesting package, but it would be somewhat perverse to use it inside a class, I think. :-) Using \AtEndDocument seems to put things far enough to the end for my purposes. –  Alan Munn Aug 25 '11 at 20:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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