%% assertions.sty (C) Cláudio L. Lucchesi -- lucchesi@dcc.unicamp.br \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{assertions}[1999/05/24 v0.4 counter preservation] %% 1999/05/13 v0.0 Initial version %% 1999/05/14 v0.1 Using addtocontents %% 1999/05/18 v0.2 A wizard enlarged me :-( %% 1999/05/22 v0.3 compatibility with other packages \DeclareOption{nolist}{% \let\newassertion\newtheorem% \let\listofassertions\relax% \newwrite\AS@loa \immediate\openout\AS@loa=\jobname.loa% \immediate\closeout\AS@loa% \endinput} \ProcessOptions \RequirePackage{ifthen} %% auxiliary commands \def\AS@ifthenelse#1#2#3{% \newif\ifAS@cond% \def\AS@testcond{% \ifthenelse{#1}{\AS@condtrue}{\AS@condfalse}}% \AS@testcond% \ifAS@cond\let\next=\@firstoftwo\else\let\next=\@secondoftwo\fi% \next{#2}{#3}% } %% defaults \def\AS@loafile{loa} %% counter handling \AtBeginDocument{% \begingroup \makeatletter \def\AS@stdctrlist{\\{part}\\{chapter}\\{section}\\{subsection}% \\{subsubsection}\\{paragraph}\\{equation}\\{figure}% \\{table}\\{footnote}} \def\\#1{% \@ifundefined{the#1} {} {\AS@rightappenditem{#1}to\AS@prsctrlist} } \AS@stdctrlist% \def\:{\noexpand\noexpand\noexpand}% \def\\#1{\noexpand\noexpand\noexpand\\{#1}}% \addtocontents{\AS@loafile}{% \:\begin{AS@loa}{\AS@prsctrlist}% }% \makeatother \endgroup } \AtEndDocument{% \begingroup \makeatletter \def\:{\noexpand\noexpand\noexpand}% \addtocontents{\AS@loafile}{\:\end{AS@loa}}% \makeatother \endgroup } \def\preservecounter#1{% \@ifundefined{the#1} {\@nocounterr{#1}} {\AS@rightappenditem{#1}to\AS@prsctrlist} } \global\def\AS@prsctrlist{} \newtoks\ta \newtoks\tb \def\AS@rightappenditem#1to#2{\ta={\\{#1}}\tb=\expandafter{#2}% \global\edef#2{\the\tb\the\ta}} %% list of assertions \newcommand\listofassertions{% \providecommand{\listassertionname}{List of Assertions}% \addcontentsline{toc}{section}{\listassertionname}% \section*{\listassertionname \@mkboth{\MakeUppercase\listassertionname}% {\MakeUppercase\listassertionname}}% \@starttoc{\AS@loafile}% } \def\AS@snapshot#1#2{% \def\\##1{\noexpand\\{{##1}{\arabic{##1}}}}% \global\edef#1{#2}% } \def\AS@shotsnap#1{% \begingroup \def\\##1{% \def\AS@carcdr####1####2{\setcounter{####1}{####2}}% \AS@carcdr##1% }% #1% \endgroup } %% format output \newenvironment{AS@loa}[1]% {% \begingroup \def\\##1{\noexpand\\{##1}} \AS@snapshot{\AS@loainitsnap}{#1}% \endgroup } {% \AS@shotsnap{\AS@loainitsnap} } \global\def\AS@sa#1#2#3#4#5#6{% % #1<-assertion #2<-name #3<-counter #4<-label list #5<-snapshot % #6<-thepage \def\AS@peek##1##2\AS@end{% \ifx##1[\let\AS@next=\AS@ysta\else\let\AS@next=\AS@nsta\fi} \def\AS@prefix{{\bfseries #2~\csname the#3\endcsname}} \medskip\noindent% \AS@shotsnap{#5}\stepcounter{#3}% \AS@ifthenelse{\equal{#4}{}}% {\AS@format{\AS@prefix}}% {\AS@format% {\AS@prefix}% $\mathtt{\{}$#4$\mathtt{\}}$% } % {\dotfill} #6\nopagebreak\par% \smallskip\noindent\ignorespaces% \AS@peek#1\AS@end% \AS@next#1\AS@end% } \newlength{\AS@width} \def\AS@format#1#2 {% \AS@ifthenelse{\equal{#2}{\dotfill}}% {#1 #2 }% {% \settowidth{\AS@width}{#1~\texttt{#2}}% \AS@ifthenelse{\lengthtest{\AS@width < \textwidth}}% {\AS@format{#1~\texttt{#2}}}% {#1 \hfill \nopagebreak\\\AS@format{\texttt{#2}}}% }% } \def\AS@ysta[#1]#2\AS@end{\AS@nsta{\bfseries (#1)} #2\AS@end} \def\AS@nsta#1\AS@end{\ignorespaces #1} %% newassertion \let\AS@latex@newtheorem\newtheorem \def\AS@let#1#2{% \expandafter\let\expandafter\AS@tmp\csname #2\endcsname \expandafter\let\csname #1\endcsname\AS@tmp} \def\newassertion#1{% \@ifnextchar[{\AS@othm{#1}}{\AS@nthm{#1}}} \def\AS@nthm#1#2{% \@ifnextchar[{\AS@xnthm{#1}{#2}}{\AS@ynthm{#1}{#2}}} \def\AS@xnthm#1#2[#3]{% \AS@latex@newtheorem{#1}{#2}[#3]% \preservecounter{#1} \AS@zthm{#1}{#1}{#2}} \def\AS@ynthm#1#2{% \AS@latex@newtheorem{#1}{#2}% \preservecounter{#1} \AS@zthm{#1}{#1}{#2}} \def\AS@othm#1[#2]#3{% \AS@latex@newtheorem{#1}[#2]{#3} \AS@zthm{#1}{#2}{#3}} \def\AS@zthm#1#2#3{% \AS@let{AS@latex@#1}{#1}% \global\@namedef{#1}{\AS@ass{#1}{#2}{#3}}} %% assertion handling \def\AS@ass#1#2#3{% % #1<-command #2<-counter #3<-name \long\def\AS@grab##1##2\end##3{% % ##1<-stack ##2<-delta ##3<-endarg \AS@ifthenelse{\equal{#1}{##3}}% {\AS@doass{#1}{#2}{#3}{##1##2}}% {\AS@grab{##1##2\end{##3}}}% } \AS@grab{}% } \def\AS@doass#1#2#3#4{% % #1<-command #2<-name #3<-counter #4<-assertion \AS@snapshot{\AS@ctrlist}{\AS@prsctrlist}% \global\def\AS@labellist{}% \begingroup \let\AS@latex@label\label% \let\label\AS@label% \AS@let{#1}{AS@latex@#1} \begin{#1} #4 \end{#1} \endgroup \end{#1}% \AS@addtocontents{\AS@loafile}{\AS@sa{#4}}% \begingroup \def\\##1{\noexpand\noexpand\noexpand\\{##1}}% \addtocontents{\AS@loafile}{% {#3} {#2} {\AS@labellist} {\AS@ctrlist} {\thepage}}% \endgroup } \def\AS@label#1{% \AS@latex@label{#1}% \ifthenelse{\equal{\AS@labellist}{}}% {\global\def\AS@labellist{#1}}% {\global\edef\AS@labellist{\AS@labellist, #1}}% }% %% addtocontents \begingroup \makeatletter \catcode`\[=1 % temporary begin-group character \catcode`\]=2 % temporary end-group character \catcode`\{=12 \catcode`\}=12 \global\edef\AS@leftbracechar[{] \global\edef\AS@rightbracechar[}] \makeatother \endgroup \AtBeginDocument{% \let\AS@tm\AS@hide% } \def\AS@hide#1{\noexpand\AS@tm\noexpand#1} \def\AS@show#1{\noexpand\noexpand\noexpand#1} \def\AS@lbchar{\noexpand\AS@lbchar} \def\AS@rbchar{\noexpand\AS@rbchar} {\def\\{\global\let\AS@stoken= } \\ }% \long\def\AS@addtocontents#1#2{% \global\def\AS@content{}% \AS@docontent{#2}% \begingroup% \let\AS@lbchar\AS@leftbracechar% \let\AS@rbchar\AS@rightbracechar% \let\AS@tm\AS@show% \addtocontents{#1}{\AS@content}% \endgroup% } \long\def\AS@docontent#1{% {\AS@sanitize#1\AS@endsanity}} \def\AS@sanitize{\futurelet\AS@next\AS@sanswitch} \def\AS@sanswitch{\ifx\AS@next\AS@endsanity \else\ifcat\noexpand\AS@next\AS@stoken\let\AS@next=\AS@speat \else\ifcat\noexpand\AS@next\bgroup\let\AS@next=\AS@lbeat \else\ifcat\noexpand\AS@next\egroup\let\AS@next=\AS@rbeat \else\let\AS@next=\AS@copytoken\fi\fi\fi\fi \AS@next} \def\AS@speat{\AS@catpad\space\AS@eat} \def\AS@lbeat{\AS@catpad\AS@lbchar\AS@eat} \def\AS@rbeat{\AS@catpad\AS@rbchar\AS@eat} \def\AS@eat{\afterassignment\AS@sanitize \let\AS@next= } \long\def\AS@copytoken#1{% \ifcat\noexpand#1\relax\let\AS@next=\AS@filtercmd% \else\ifcat\noexpand#1\noexpand~\let\AS@next=\AS@prenqueue% \else\let\AS@next=\AS@enqueue\fi\fi \AS@next{#1}} \def\AS@filtercmd#1{% \let\AS@next=\AS@prenqueue% \ifx#1\label\let\AS@next=\AS@gobbletwo% \ifx#1\index\let\AS@next=\AS@gobbletwo% \ifx#1\glossary\let\AS@next=\AS@gobbletwo% \fi\fi\fi\AS@next{#1}} \def\AS@gobbletwo#1#2{\AS@sanitize} \def\AS@enqueue#1{\AS@catpad#1\AS@sanitize} \def\AS@prenqueue#1{\AS@catpad{\AS@tm#1}\AS@sanitize} \def\AS@endsanity\AS@endsanity{} \def\AS@catpad#1{% \xdef\AS@content{\AS@content#1}% } \@onlypreamble\newassertion \@onlypreamble\preservecounter \endinput %% %% End of file `assertions.sty'.