%%
%% This is file `comments.sty',
%%
%% Copyright (C) 1991 -- 2004 by Torsten Schaub,
%%                            all rights reserved.
%% Please report errors to: Torsten Schaub
%%                          torsten@cs.uni-potsdam.de
\ProvidesPackage{comments}[2001/03/09 v0.7 The comments package]
\RequirePackage[normalem]{ulem}

%% -- declarations --------------------------------------------------
\def\TODAY{\number\day/\ifcase\month\or 01\or 02\or 03\or 04\or 05\or 
    06\or 07\or 08\or 09\or 10\or 11\or 12\fi/\number\year}
\def\timenow{%
  \@tempcnta=\time \divide\@tempcnta by 60 \number\@tempcnta:\multiply
  \@tempcnta by 60 \@tempcntb=\time \advance\@tempcntb by -\@tempcnta
  \ifnum\@tempcntb <10 0\number\@tempcntb\else\number\@tempcntb\fi}
\def\MFONT{\scriptsize\rm}
\def\BFONT{\scriptsize\it}
\def\VERSION{\jobname.tex \ \ \TODAY~at~\timenow\ \ \ page \thepage}
\def\DRAFTMSG{\small\textit{\today} ---}
%% TS added Jan 04, 2005
\def\SVNREVISION{0}
\def\SVNMSG{\small\textit{\SVNREVISION}}

\addtolength{\oddsidemargin}{-14mm}  % let's have a big right margin
\addtolength{\evensidemargin}{-14mm} % for \comments

\@mparswitchfalse
\setlength{\marginparwidth}{29mm}               % Breite
\setlength{\marginparsep}{1mm}                  % Abstand vom Rand
\setlength{\marginparpush}{0mm}                 % space between 2 marginpars
%\setlength{\fboxsep}{.1mm}

%% -- counters --------------------------------------------------
\newcounter{commentctr}

%% -- ulem-based commands ---------------------------------------
\newcommand{\CHD}[1]{\uwave{#1}\comment{CHANGED}}
\newcommand{\comwave}[2]{\uwave{#1}\comment{#2}}

\newcommand{\DELETE}[2]{\sout{#1}\comment{DELETE{#2}}}
\newcommand{\DEL}[1]{\DELETE{#1}{\ignorespaces}}
\newcommand{\DELc}[2]{\DELETE{#1}{\par {#2}}}
\newcommand{\DELed}[1]{\comment{DELETED}}
% \newcommand{\DELced}[2]{\comment{DELETEed\par {#2}}\ignorespaces}
\newcommand{\DELced}[2]{\ignorespaces\comment{DELETED}}
\newcommand{\noDEL}[2]{{#1}\ignorespaces\comment{NOT~DELETED}}

\newcommand{\INSERT}[2]{\uline{#1}\comment{INSERT{#2}}}
\newcommand{\INS}[1]{\INSERT{#1}{\ignorespaces}}
\newcommand{\INSc}[2]{\INSERT{#1}{\par {#2}}}
\newcommand{\INSed}[1]{{#1}\comment{INSERTED}}
% \newcommand{\INSced}[2]{\comment{INSERTED\par {#2}}}
\newcommand{\INSced}[2]{{#1}\comment{INSERTED}}

\newcommand{\REWRITE}[2]{\uwave{#1}\comment{REWRITE{#2}}}
\newcommand{\REW}[1]{\REWRITE{#1}{\ignorespaces}}
\newcommand{\REWc}[2]{\REWRITE{#1}{\par {#2}}}
%\newcommand{\REWed}[1]{{#1}\ignorespaces\comment{REWRITTEN}}
% \newcommand{\REWced}[2]{\comment{REWRITTEN\par {#2}}}
%\newcommand{\REWced}[2]{{#1}\ignorespaces\comment{REWRITTEN}}

\newcommand{\REPLACE}[3]{\sout{#1}\comment{REPLACE{#3}}\underbar{#2}}
\newcommand{\REP}[2]{\REPLACE{#1}{#2}{\ignorespaces}}
\newcommand{\REPc}[3]{\REPLACE{#1}{#2}{\par {#3}}}
\newcommand{\REPed}[2]{\ignorespaces\comment{REPLACED}{#2}}
% \newcommand{\REPced}[3]{\comment{REPLACED\par {#3}}{#2}}
\newcommand{\REPced}[3]{\ignorespaces\comment{REPLACED}{#2}}
\newcommand{\noREP}[2]{{#1}\comment{NOT~REPLACED}}

% \newcommand{\REPd}[2]{\REPLACE{}{#2}{D:\par {#1}}}

%% -- commands --------------------------------------------------
\newcommand{\howmanycoms}{%
\begin{center}
\frame{\Large\bf There remain \thecommentctr\ comments to be addressed !!!}
\message{*** THERE ARE *\thecommentctr* COMMENTS ***}
\end{center}
}

\newcommand{\com}[1]%
{\message{Attention ... #1 ...}%
  \mbox{}\\ 
  \noindent
  \framebox[\linewidth][c]{\stepcounter{commentctr}{\BFONT\thecommentctr: #1}}
                                %  \mbox{}
  \ignorespaces
}
% --------------------------------------------------
\newcommand{\margincomment}[1]%
{%
  {\setlength{\fboxsep}{1pt}%
    \marginpar{\raggedright\hspace{0pt}\MFONT{#1}\par}%
    }%
  \ignorespaces}
% --------------------------------------------------
\newcommand{\comment}[1]%
{%
  \def\@currentlabel{\thecommentctr} % TS 04/06/18 (found in latex.lst)
  \stepcounter{commentctr}%
  \margincomment{\raisebox{.1ex}{\framebox{\rm\thecommentctr}}\ #1}%
  {\setlength{\fboxsep}{1pt}%
    \raisebox{.3ex}{{\tiny\framebox{\rm\thecommentctr}}}%
    }%
                                %\setlength{\fboxsep}{3pt}%
  \message{Attention ... COMMENT *\thecommentctr* ...}%
  \ignorespaces}
% --------------------------------------------------
\newcommand{\new}[1]{#1\comment{NEW!}}
% --------------------------------------------------
\newcommand{\tbf}{\com{TO BE FILLED}}
\newcommand{\tbfc}[1]{\margincomment{#1}\tbf}
%
\newcommand{\tbr}{\com{TO BE REFINED}}
\newcommand{\tbrc}[1]{\margincomment{#1}\tbr}
%
\newcommand{\tbc}{\com{TO BE COMPLETED}}
\newcommand{\tbcc}[1]{\margincomment{#1}\tbc}
%
\newcommand{\tbrw}{\com{TO BE REWRITTEN}}
\newcommand{\tbrwc}[1]{\margincomment{#1}\tbrw}
%
\newcommand{\comc}[2]{\margincomment{#2}\com{#1}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\@oddfoot{\hbox to \textwidth{%
$\bullet\bullet\bullet\quad$%
\DRAFTMSG\/%
%% TS added Jan 04, 2005
\SVNMSG\/%
$\quad\bullet\bullet\bullet$%
\hfil%
{p\thepage:\small\#\thecommentctr} --- $\bigcirc_R\ \bigcirc_M$}%
}
\def\@evenfoot{\@oddfoot}
\def\@oddhead{%
\scriptsize\rm
\null\hfil
e[\theequation]   \ %
f[\thefootnote]   \ %
\ifx\thetheorem\undefined\else    t[\thetheorem]    \ \fi%
\ifx\thedefinition\undefined\else d[\thedefinition] \ \fi%
\ifx\thesubsubsection\undefined%
    \ifx\thesubsection\undefined%
        \ifx\thesection\undefined%
            \else s[\thesection]
        \fi
        \else s[\thesubsection]
    \fi
    \else s[\thesubsubsection]
\fi
\hfil\VERSION\ {\#\thecommentctr}}
\def\@evenhead{\@oddhead}
\addtolength{\headsep}{10pt}

\def\stamp{\date{%
    \begin{tabular}{|ccc|}
      \multicolumn{3}{c}{\it --- Preliminary Draft ---}
      \\[2ex]\hline
      \texttt{\jobname.tex} &---& \texttt{\today} at \texttt{\timenow{h}}
      \\
      \textit{Read} {\LARGE $\bigcirc$} && \textit{Modified} {\LARGE $\bigcirc$}
      \\[1pt]\hline
    \end{tabular}}}

\def\enddocument{\par
{\vfill\noindent%\large
This article was processed using the comments style on \today.\\
There remain \thecommentctr\ comments to be processed.
% TS: Mar 9 \hfill$\bigcirc_\mathit{Read}\ \bigcirc_\mathit{Modified}$
}
\message{*** THERE ARE *\thecommentctr* COMMENTS ***}
\@checkend{document}\clearpage\begingroup
\if@filesw \immediate\closeout\@mainaux
\def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
\def\bibcite{\@testdef b}\@tempswafalse \makeatletter\input \jobname.aux
\if@tempswa \@warning{Label(s) may have changed.  Rerun to get
cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}
