summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/listoftheorem.sty
blob: 905167dacdeef3146177fb54f62542526477ed85 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%%
%%	LaTeX Style sheet to permit theorem environments to generate
%%	table-of-contents-like entries similar to those produced
%%	bye the \listoffigures command.
%%   		...Art Mulder, July/90         art@maccs.DCSS.mcmaster.ca
%%                                         ...!uunet!utai!utgpu!maccs!art
%%
%%	Permission granted to do whatever you want with this style
%%	file.  Use at your own risk, it works for me, but I make no
%%	warranty as to its performance.

%% STEP ONE:
%% modify one of the 'begin theorem' commands so that it executes an
%% \addcontentsline, on a file called whatever the theorem is.  ie: if
%% this is a "theo" type theorem, them write on a file called foo.theo

%% %% based on \@thm macro found in latex.tex and modified to suit 
%% %% my purposes
%% 
%% % \@thm{NAME}{TEXT} ==
%% %   BEGIN
%% %    \addcontentsline{NAME}{figure}{\theNAME}
%% %%	^ above line added by art mulder
%% %    \refstepcounter{NAME}
%% %    if next char = [
%% %       then \@ythm{NAME}{TEXT}
%% %       else \@xthm{NAME}{TEXT}
%% %    fi
%% %   END
%% 
%% \def\@thm#1#2{\addcontentsline{#1}{figure}{\protect
%% 	\numberline{\csname the#1\endcsname}}
%% 	\refstepcounter
%%     {#1}\@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
%% 
%% THIS ABOVE CODE WORKS, HOWEVER IT MAKES NO PROVISION FOR INCLUDING
%% THE OPTIONAL ARGUMENT IN THE LISTING.  THIS NEXT CODE (UP TO STEP TWO)
%% DOES INCLUDE THE OPTIONAL ARGUMENT IN THE LISTING.

%% based on \@xthm and \@ythm macros found in latex.tex

% \@xthm{NAME}{TEXT} ==
%   BEGIN
%    \addcontentsline{NAME}{figure}{\theNAME}
%%	^ above line added by art mulder
%    \@begintheorem{TEXT}{\theNAME}
%    \ignorespaces
%   END
%
% \@ythm{NAME}{TEXT}[OPARG] ==
%   BEGIN
%    \addcontentsline{NAME}{figure}{\theNAME OPARG}
%%	^ above line added by art mulder
%%        Put the Optional Argument into the List-Of file
%    \@opargbegintheorem{TEXT}{\theNAME}{OPARG}
%    \ignorespaces
%   END

\def\@xthm#1#2{\addcontentsline{#1}{figure}{\protect
 	\numberline{\csname the#1\endcsname}}
	\@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
\def\@ythm#1#2[#3]{\addcontentsline{#1}{figure}{\protect
 	\numberline{\csname the#1\endcsname}{\ignorespaces #3}}
	\@opargbegintheorem{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

%% STEP TWO:
%% write \listof{}{} macro to generate lists of desired theorem 
%% environments.

%% based on listoffigures macro from book.doc (or book.sty)

\def\listof#1#2{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
  \fi\chapter*{List of #1\@mkboth
     {LIST OF \uppercase{#1}}{LIST OF \uppercase{#1}}}
     \@starttoc{#2}\if@restonecol \twocolumn\fi}

%\def\l@figure{\@dottedtocline{1}{1.5em}{2.3em}

%%--------------------
%% INSTRUCTIONS FOR USE:
%% - read the sections in the LaTeX manual in regards to:
%%	\addcontentsline, \newtheorem
%% - use a theorem envornment as usual (all changes there are "behind the 
%%	scenes" so you don't have to do anything different)
%% - insert a \listof command in your document wherever you want a 
%%	listing to go (DISCLAIMER: I have only tried this at the 
%%	front of the book, following the Table of Contents)
%% - the listof command has the following form:
%%		\listof{HEADING}{THEOREM_ENV_NAME}
%%   where:
%%	HEADING = whatever you want to follow the words
%%		"List Of" in the heading.
%%	THEOREM_ENV_NAME = the environment name that you gave
%%		to your theorem environment.

%% EXAMPLE USAGE:
%% - define a theorem environment:
%%	\newtheorem{lem}{Lemma}[section]
%%		^ define a "Lemma" theorem environment, numbered within
%%		  chapters (NO CHANGE from before use of
%%		  listoftheorem.sty)
%%
%% - request a list of theorems
%%	\listof{Lemmas}{lem}
%%		^ will now get a listing similar to a "list of figures"
%%		  entitled "List Of Lemmas".
%%
%% - use the lemma theorem environment
%%	\begin{lem}
%%		blah blah
%%	\end{lem}
%%		^ In addition to what the theorem environment would 
%%		  normally do, this will write a "list of lemmas"
%%		  entry on a file entitled foo.lem, where foo is the name
%%		  of the document (as in foo.tex).
%%		  Note there is NO CHANGE in use from before use of
%%		  listoftheorem.sty

%% BUGS:
%% - two theorem environments can share a counter (see numbered_like
%%   option in definition of Theorem environments in LaTeX manual)
%%   But there is no way for two theorem environments to share listing.