summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/remark.sty
blob: 771ae1d73e39a0a9744e4d295b6d370f5765cc62 (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
124
125
126
127
128
129
130
%       ****************************************
%       *         REMARK ENVIRONMENTS         *
%       ****************************************
%
%  The user creates his own remark-like environments with the command
%      \newremark{NAME}{TEXT}[COUNTER]  or
%      \newremark{NAME}[OLDNAME]{TEXT}
%  This defines the environment NAME to be just as one would expect a 
%  remark environment to be, except that it prints ``TEXT'' instead of 
%  ``Remark''.  
%
%  If OLDNAME is given, then environments NAME and OLDNAME use the same 
%  counter, so using a NAME environment advances the number of the next 
%  NAME environment, and vice-versa.
%  
%  If COUNTER is given, then environment NAME is numbered within COUNTER.
%  E.g., if COUNTER = subsection, then the first NAME in subsection 7.2
%  is numbered TEXT 7.2.1.
%  
%  The way NAME environments are numbered can be changed by redefining
%  \theNAME.
%
%  DOCUMENT STYLE PARAMETERS
%
%  \@rmkcounter{COUNTER} : A command such that
%               \edef\theCOUNTER{\@rmkcounter{COUNTER}}
%         defines \theCOUNTER to produce a number for a remark environment.
%         The default is:
%            BEGIN \noexpand\arabic{COUNTER} END
%
%  \@rmkcountersep : A separator placed between a remark number and
%         the number of the counter within which it is numbered.
%         E.g., to make the third remark of section 7.2 be numbered
%         7.2-3, \@rmkcountersep should be \def'ed to '-'.  Its
%         default is '.'.
%
%  \@beginremark{NAME}{NUMBER} : A command that begins a remark
%         environment for a 'remark' named 'NAME NUMBER' --
%         e.g., \@beginremark{Lemma}{3.7} starts Lemma 3.7.
%      
%  \@opargbeginremark{NAME}{NUMBER}{OPARG} : A command that begins a remark
%         environment for a 'remark' named 'NAME NUMBER' with optional
%         argument OPARG -- e.g., \@beginremark{Lemma}{3.7}{Jones}
%         starts `Lemma 3.7 (Jones):'.
%      
%  \@endremark : A command that ends a remark environment.
%
% \newremark{NAME}{TEXT}[COUNTER] ==
%   BEGIN
%     if \NAME is definable
%       then \@definecounter{NAME}
%            if COUNTER present
%              then \@addtoreset{NAME}{COUNTER} fi
%                   \theNAME ==  BEGIN \theCOUNTER \@rmkcountersep
%                                       eval\@rmkcounter{NAME}      END
%              else \theNAME ==  BEGIN eval\@rmkcounter{NAME} END
%            \NAME == \@rmk{NAME}{TEXT}
%            \endNAME == \@endremark
%       else  error
%     fi
%   END
%
% \newremark{NAME}[OLDNAME]{TEXT}==
%   BEGIN
%     if \NAME is definable
%       then \theNAME == \theOLDNAME
%            \NAME == \@rmk{OLDNAME}{TEXT}
%            \endNAME == \@endremark
%       else  error
%     fi
%   END
%
% \@rmk{NAME}{TEXT} ==
%   BEGIN
%    \refstepcounter{NAME}
%    if next char = [ 
%       then \@yrmk{NAME}{TEXT}
%       else \@xrmk{NAME}{TEXT}
%    fi
%   END
%
% \@xrmk{NAME}{TEXT} ==
%   BEGIN
%    \@beginremark{TEXT}{\theNAME}
%    \ignorespaces
%   END
%
% \@yrmk{NAME}{TEXT}[OPARG] ==
%   BEGIN
%    \@opargbeginremark{TEXT}{\theNAME}{OPARG}
%    \ignorespaces
%   END
%
\def\newremark#1{\@ifnextchar[{\@ormk{#1}}{\@nrmk{#1}}}

\def\@nrmk#1#2{%
\@ifnextchar[{\@xnrmk{#1}{#2}}{\@ynrmk{#1}{#2}}}

\def\@xnrmk#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}\@addtoreset{#1}{#3}%
\expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
  \csname the#3\endcsname \@rmkcountersep \@rmkcounter{#1}}%
\global\@namedef{#1}{\@rmk{#1}{#2}}\global\@namedef{end#1}{\@endremark}}}

\def\@ynrmk#1#2{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}%
\expandafter\xdef\csname the#1\endcsname{\@rmkcounter{#1}}%
\global\@namedef{#1}{\@rmk{#1}{#2}}\global\@namedef{end#1}{\@endremark}}}

\def\@ormk#1[#2]#3{\expandafter\@ifdefinable\csname #1\endcsname
  {\global\@namedef{the#1}{\@nameuse{the#2}}%
\global\@namedef{#1}{\@rmk{#2}{#3}}%
\global\@namedef{end#1}{\@endremark}}}

\def\@rmk#1#2{\refstepcounter
    {#1}\@ifnextchar[{\@yrmk{#1}{#2}}{\@xrmk{#1}{#2}}}

\def\@xrmk#1#2{\@beginremark{#2}{\csname the#1\endcsname}\ignorespaces}
\def\@yrmk#1#2[#3]{\@opargbeginremark{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

%DEFAULT VALUES
\def\@rmkcounter#1{\noexpand\arabic{#1}}
\def\@rmkcountersep{.}
%deleted September 2, 1986 MDK
%\def\@makermknumber#1#2{\bf #1 #2:}
\def\@beginremark#1#2{\trivlist \item[\hskip \labelsep{\bf #1\ #2}]}
\def\@opargbeginremark#1#2#3{\trivlist
      \item[\hskip \labelsep{\bf #1\ #2\ (#3)}]}
\def\@endremark{\endtrivlist}