%%
%% This is file `changes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% changes.dtx  (with options: `changes')
%% 
%% changes.dtx
%% Copyright 2007 Ekkart Kleinod (ekkart@ekkart.de)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or any later version.
%% The latest version of this license is in
%%  http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% The current maintainer of this work is Ekkart Kleinod.
%% 
%% This work consists of the files
%%  changes.drv
%%  changes.dtx
%%  changes.ins
%%  README
%% and the derived files
%%  changes.sty
%%  changes.pdf
%%  changes.example1.tex
%%  changes.example2.tex
%%  changes.example3.tex
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{changes}
[2007/10/10 v0.5.2 changes-Paket]
\typeout{*** changes-Paket 2007/10/10 v0.5.2 ***}
\RequirePackage{xkeyval}
\RequirePackage{ifthen}
\newboolean{Changes@optiondraft}
\setboolean{Changes@optiondraft}{true}
\DeclareOptionX{draft}{
 \typeout{changes-option '\CurrentOption'}
}
\DeclareOptionX{final}{
 \setboolean{Changes@optiondraft}{false}
 \typeout{changes-option '\CurrentOption'}
}
\DeclareOptionX{ulem}{
 \typeout{ulem-option '#1', passed to package ulem}
 \PassOptionsToPackage{#1}{ulem}
}
\DeclareOptionX{xcolor}{
 \typeout{xcolor-option '#1', passed to package xcolor}
 \PassOptionsToPackage{#1}{xcolor}
}
\DeclareOptionX*{
 \PackageWarning{Unknown changes-option '\CurrentOption'}
}
\ProcessOptionsX\relax
\RequirePackage{xcolor}
\RequirePackage{pdfcolmk}
\RequirePackage{ulem}
\ifthenelse{\isundefined{\addto}}
 {
  \def\listchangesname{\"Anderungen}
  \def\changesaddname{Eingef\"ugt}
  \def\changesdeletename{Gel\"oscht}
  \def\changesreplacename{Ersetzt}
  \def\changesauthorname{Autor}
  \def\changesanonymousname{Anonym}
  \def\changesnoloc{\"Anderungsliste erst nach dem n\"achsten Durchlauf verf\"ugbar.}
 }{
  \addto\captionsngerman{\def\listchangesname{\"Anderungen}}
  \addto\captionsgerman{\def\listchangesname{\"Anderungen}}
  \addto\captionsenglish{\def\listchangesname{Changes}}

  \addto\captionsngerman{\def\changesaddname{Eingef\"ugt}}
  \addto\captionsgerman{\def\changesaddname{Eingef\"ugt}}
  \addto\captionsenglish{\def\changesaddname{Added}}

  \addto\captionsngerman{\def\changesdeletename{Gel\"oscht}}
  \addto\captionsgerman{\def\changesdeletename{Gel\"oscht}}
  \addto\captionsenglish{\def\changesdeletename{Deleted}}

  \addto\captionsngerman{\def\changesreplacename{Ersetzt}}
  \addto\captionsgerman{\def\changesreplacename{Ersetzt}}
  \addto\captionsenglish{\def\changesreplacename{Replaced}}

  \addto\captionsngerman{\def\changesauthorname{Autor}}
  \addto\captionsgerman{\def\changesauthorname{Autor}}
  \addto\captionsenglish{\def\changesauthorname{Author}}

  \addto\captionsngerman{\def\changesanonymousname{Anonym}}
  \addto\captionsgerman{\def\changesanonymousname{Anonym}}
  \addto\captionsenglish{\def\changesanonymousname{anonymous}}

  \addto\captionsngerman{\def\changesnoloc{\"Anderungsliste erst nach dem n\"achsten \LaTeX-Lauf verf\"ugbar.}}
  \addto\captionsgerman{\def\changesnoloc{\"Anderungsliste erst nach dem n\"achsten Durchlauf verf\"ugbar.}}
  \addto\captionsenglish{\def\changesnoloc{List of changes is available after the next \LaTeX\ run.}}
 }
\newcommand{\Changes@extension}{loc}
\newcommand{\setlocextension}[1]{
 \renewcommand{\Changes@extension}{#1}
}
\newcounter{Changes@AuthorCount}
\setcounter{Changes@AuthorCount}{0}
\newcounter{Changes@iAuthor}
\newcommand{\definechangesauthor}[3][\@empty]{
 \stepcounter{Changes@AuthorCount}
 \@namedef{Changes@Author\theChanges@AuthorCount}{#2}
 \@namedef{Changes@AuthorName#2}{#1}
 \@namedef{Changes@AuthorColor#2}{#3}
 \newcounter{Changes@AddCount#2}
 \newcounter{Changes@DeleteCount#2}
 \newcounter{Changes@ReplaceCount#2}
 \colorlet{Changes@Color#2}{#3}
}
\definechangesauthor{\@empty}{blue}
\newboolean{Changes@AuthorPositionLeft}
\setboolean{Changes@AuthorPositionLeft}{false}
\newcommand{\Changes@AuthorMark}[1]{%
 \textsuperscript{#1}%
}
\newcommand{\setauthormarkup}[2][left]{%
 \ifthenelse{\equal{#1}{left}}
  {\setboolean{Changes@AuthorPositionLeft}{true}}
  {\setboolean{Changes@AuthorPositionLeft}{false}}
 \renewcommand{\Changes@AuthorMark}[1]{#2}
}
\newcommand{\Changes@Remark}[2]{%
 \footnote{\textcolor{Changes@Color#1}{#2}}%
}
\newcommand{\setremarkmarkup}[1]{%
 \renewcommand{\Changes@Remark}[2]{#1}%
}
\newcommand{\Changes@temp}{\@empty}
\newcommand{\added}[1][\@empty]{%
 \renewcommand{\Changes@temp}{#1}%
 \Changes@added%
}
\newcommand{\Changes@added}[2][\@empty]{%
 \ifthenelse{\boolean{Changes@optiondraft}}%
  {%
   \textcolor{Changes@Color\Changes@temp}{%
    \ifthenelse{\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    #2%
    \ifthenelse{\not\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    \ifthenelse{\equal{\@empty}{#1}}%
     {}{\Changes@Remark{\Changes@temp}{#1}}%
   }%
   \stepcounter{Changes@AddCount\Changes@temp}%
  }{#2}%
}
\newcommand{\deleted}[1][\@empty]{%
 \renewcommand{\Changes@temp}{#1}%
 \Changes@deleted%
}
\newcommand{\Changes@deleted}[2][\@empty]{%
 \ifthenelse{\boolean{Changes@optiondraft}}%
  {%
   \textcolor{Changes@Color\Changes@temp}{%
    \ifthenelse{\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    \sout{#2}%
    \ifthenelse{\not\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    \ifthenelse{\equal{\@empty}{#1}}%
     {}{\Changes@Remark{\Changes@temp}{#1}}%
   }%
   \stepcounter{Changes@DeleteCount\Changes@temp}%
  }{\@bsphack \expandafter \@esphack}%
}
\newcommand{\replaced}[1][\@empty]{%
 \renewcommand{\Changes@temp}{#1}%
 \Changes@replaced%
}
\newcommand{\Changes@replaced}[3][\@empty]{%
 \ifthenelse{\boolean{Changes@optiondraft}}%
  {%
   \textcolor{Changes@Color\Changes@temp}{%
    \ifthenelse{\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    #2%
    \sout{#3}%
    \ifthenelse{\not\boolean{Changes@AuthorPositionLeft}}%
     {\ifthenelse{\equal{\@empty}{\Changes@temp}}%
      {}{\Changes@AuthorMark{\Changes@temp}}%
     }{}%
    \ifthenelse{\equal{\@empty}{#1}}%
     {}{\Changes@Remark{\Changes@temp}{#1}}%
   }%
   \stepcounter{Changes@ReplaceCount\Changes@temp}%
  }{#2}%
}
\def\changes@chopline#1;#2;#3;#4;#5;#6 \\{
 \def\Changes@InID{#1}
 \def\Changes@InColor{#2}
 \def\Changes@InName{#3}
 \def\Changes@InAdded{#4}
 \def\Changes@InDeleted{#5}
 \def\Changes@InReplaced{#6}
}
\newcommand{\listofchanges}{%
 \ifthenelse{\boolean{Changes@optiondraft}}
  {
   \section*{\listchangesname}
   \IfFileExists{\jobname.\Changes@extension}
    {
     \newboolean{Changes@MoreLines}
     \setboolean{Changes@MoreLines}{true}
     \newread\Changes@InFile
     \openin\Changes@InFile = \jobname.\Changes@extension
      \whiledo{\boolean{Changes@MoreLines}}{
      \read\Changes@InFile to \Changes@Line
       \ifeof\Changes@InFile
        \setboolean{Changes@MoreLines}{false}
       \else
        \expandafter\changes@chopline\Changes@Line\\
        \begin{tabbing}
         mm\=mmmmmm\=\kill
         \ifthenelse{\equal{\Changes@InID}{}}
          {\textcolor{\Changes@InColor}{\changesauthorname: \changesanonymousname}\\}
          {\textcolor{\Changes@InColor}{\changesauthorname: \Changes@InID}
           \ifthenelse{\equal{\Changes@InName}{}}{}
           { \textcolor{\Changes@InColor}{(\Changes@InName)}}
           \\
          }
         \>\changesaddname:\>\Changes@InAdded\\
         \>\changesdeletename:\>\Changes@InDeleted\\
         \>\changesreplacename:\>\Changes@InReplaced\\
        \end{tabbing}
       \fi
      }
     \closein\Changes@InFile
    }{
     \emph{\changesnoloc}
    }
  }{}
}
\AtEndDocument{
 \newwrite\Changes@OutFile
 \immediate\openout\Changes@OutFile = \jobname.\Changes@extension
 \setcounter{Changes@iAuthor}{0}
 \whiledo{\value{Changes@iAuthor} < \value{Changes@AuthorCount}}{
  \stepcounter{Changes@iAuthor}
  \def\Changes@ID{\@nameuse{Changes@Author\theChanges@iAuthor}}
  \immediate\write\Changes@OutFile{\Changes@ID;%
   \@nameuse{Changes@AuthorColor\Changes@ID};%
   \@nameuse{Changes@AuthorName\Changes@ID};%
   \the\value{Changes@AddCount\Changes@ID};%
   \the\value{Changes@DeleteCount\Changes@ID};%
   \the\value{Changes@ReplaceCount\Changes@ID}}
 }
 \closeout\Changes@OutFile
}
%% Copyright 2007 Ekkart Kleinod
%%
%% End of file `changes.sty'.
