summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/bezos/checkend.sty
blob: 49f1ec54975eaa7412b2127d65663ffd90b0a036 (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
% +--------------------------------------------------+
% | Documentation in clear text follows              |
% +--------------------------------------------------+
%
% (c) 2002 Javier Bezos. All Rights Reserved.
%
% This file can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
% 
% Please, send your comments and suggestions to <jbezos@wanadoo.es>.
% 
% Usage
% ~~~~~
% When an environment is left open, LaTeX gives an error at the
% end of the document. However it only informs about the first
% of them, while the rest are shown with meaningless errors:
% 
% (\end occurred inside a group at level N)
% 
% This package replaces them with more useful messages
% which show which environments (in reverse order) were
% not closed.
% 
% That's all. There are no user macros. Just use the package.
%
% Code
% ~~~~

\def\fileversion{1.0}
\def\filedate{2002/04/20}

\ProvidesPackage{checkend}[2002/04/20 v1.0 Environment checking]

\def\chkend@checkend{%
  \def\@tempa{document}%
  \ifx\@currenvir\@tempa
  \else
    \count@\errorcontextlines
    \errorcontextlines\z@
    \PackageError{checkend}{%
      \@currenvir \@currenvline \space open at 
         \string\end{document}}%
      {The package has detected an open environment at the 
         end\MessageBreak
       of the document}%
    \errorcontextlines\count@
    \csname end\@currenvir\endcsname
    \endgroup
    \chkend@checkend
  \fi}

\AtEndDocument{\chkend@checkend}

\endinput