+% \subsection{Numbering things}
+%
+% \begin{macro}{\numberwithin}
+%
+% Does the obvious thing. Optional argument gives numbering style.
+%
+% \begin{macrocode}
+\def\numberwithin{\@testopt\nw@i\arabic}
+\def\nw@i[#1]#2#3{%
+ \@addtoreset{#2}{#3}%
+ \expandafter\xdef\csname the#2\endcsname{%
+ \expandafter\noexpand\csname the#3\endcsname.%
+ \noexpand#1{#2}}%
+}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% \begin{macro}{\removefromreset}
+%
+% Does the obvious thing.
+%
+% \begin{macrocode}
+\def\removefromreset#1#2{%
+ \begingroup%
+ \def\@tempa{#1}%
+ \toks@{}%
+ \def\@elt##1{%
+ \def\@tempb{##1}%
+ \ifx\@tempa\@tempb%
+ \else\toks@\expandafter{\the\toks@\@elt{##1}}%
+ \fi%
+ }
+ \csname cl@#2\endcsname%
+ \expandafter\xdef\csname cl@#2\endcsname{\the\toks@}%
+ \endgroup%
+}
+% \end{macrocode}
+%
+% \end{macro}
+%