summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/warning/warning.sty
blob: 67f97468396d5ba3afca1b41bbc27823c4a46ede (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
%%
%% warning.sty
%%
%% Global warnings at the end of the screen output and the logfile
%%
%% Copyright 2001  Harald Harders (h.harders@tu-bs.de)
%%
%% License: LPPL
%%
%% Sometimes a class or package has to make a global warning such as
%% ``Rerun for this or that reason'' or ``This is draft, change this
%% before the final run''. If you are generating them with
%% \AtEndDocument{\PackageWarningNoLine{packagename}{warning}}
%% the warning appears very early before the filelist. Then the
%% warning can easily be overseen. This package provides a command
%% that surely puts the warning at the end near to the global
%% warnings generated by LaTeX itself.
%% You can add a warning to a list of user defined warnings using the
%% command \addglobalwarning as it can be seen in the example below.
%%
%% This package could be useful for the warnings generated e.g. by
%% the packages changebar.sty or longtable.sty.
%%
%% Harald Harders
%%
%%
%% Example:
%%
%% \documentclass{article}
%% \usepackage{warning}
%% \addglobalwarning{%
%%   \ClassWarningNoLine{testclass}{This is a global warning}}
%% \addglobalwarning{%
%%   \PackageWarningNoLine{testpackage}{This is another global warning}}
%% \begin{document}
%% Hello
%% \end{document}
%%
%%
\ProvidesPackage{warning}[2001/08/17 v0.01 Global warnings at end of logfile]

% Define a command that adds new warnings to the list of warnings.
% Modification of the \addto command provided by babel.def.
\def\addglobalwarning#1{%
  \ifx\wrn@warning\@undefined
    \def\wrn@warning{#1}%
  \else
    \ifx\wrn@warning\relax
      \def\wrn@warning{#1}%
    \else
      {\toks@\expandafter{\wrn@warning#1}%
        \xdef\wrn@warning{\the\toks@}}%
    \fi
  \fi
}

% Expand \@@end command. I have the feeling that is not too stable.
% Thus not used.
%\let\wrn@end\@@end
%\def\@@end{\wrn@warning\wrn@end}

% Expand \@refundefined command. This does not work if undefined
% references appear after the execution of \AtEndDocument which can happen.
% Thus not used.
%\AtEndDocument{%
%  \let\wrn@refundefined=\@refundefined
%  \def\@refundefined{\wrn@refundefined\wrn@warning}}

% Expand \@dofilelist
% This works with or without \listfiles because \listfile has to be
% used in the preamble and therefor is executed before this definition.
\AtBeginDocument{%
  \let\wrn@dofilelist\@dofilelist
  \def\@dofilelist{\wrn@dofilelist\wrn@warning}%
}

\let\wrn@warning\relax

\endinput
%% EOF