% \CheckSum{442} % % \iffalse meta-comment % % Copyright (C) 2007-2011 % Ekkart Kleinod (ekleinod@edgesoft.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\\ % \url{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. % % Some code for providing multilanguage documentation was % used from the pst-pdf package by Rolf Niepraschk and Hubert Gaesslein. % \fi % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % \changes{v0.1}{2007/01/16}{Initial version.} % \changes{v0.2}{2007/01/17}{new convenience commands, LPPL, bugfixes: missing babel package, ifthen-placement, loc, author markup} % \changes{v0.3}{2007/01/22}{english documentation, replaced command changed with command replaced} % \changes{v0.4}{2007/01/24}{pdfcolmk for improved markup, introduced author-ids, first CTAN version} % \changes{v0.5}{2007/08/26}{reimplementation without array package, UTF-8, grayed text, change pf command arguments} % \changes{v0.5.1}{2007/08/27}{deleted text is striked out again using package ulem, greying didn't work} % \changes{v0.5.2}{2007/10/10}{package options for pdfcolmk, ulem, and xcolor} % \changes{v0.5.3}{2010/11/22}{use class options (final, draft) as well} % \changes{v0.5.4}{2011/04/25}{extract user documentation; default language changed to English; script for removal of commands} % \GetFileInfo{changes.dtx} % %^^A -------------------------------------------------------------------------- % % \maketitle % % \tableofcontents % \cleardoublepage % % \input{user} % %^^A -- source code % % \StopEventually % % \section{The documented sourcecode} % % \iflanguage{english}{}{ % The sourcecode is documented in English only. % This is intended, please do not provide translations for the text below, just corrections or improvements. % } % % \subsection{Package information and options} % % \begin{macrocode} %<*changes> % \end{macrocode} % % Set needed \LaTeX-format to \LaTeXe{}, provide name, date, version. % Type some information to the console. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{changes} [2011/04/25 v0.5.4 changes-Paket] \typeout{*** changes-Paket 2011/04/25 v0.5.4 ***} % \end{macrocode} % % Package \chpackage{xkeyval} provides options with key-value-pairs. % \begin{macrocode} \RequirePackage{xkeyval} % \end{macrocode} % % Package \chpackage{ifthen} provides improved \texttt{if} as well as a \texttt{while}-loop. % \begin{macrocode} \RequirePackage{ifthen} % \end{macrocode} % % \minisec{Options} % Option \choption{draft}, \emph{default} is \texttt{true}. % \begin{macrocode} \newboolean{Changes@optiondraft} \setboolean{Changes@optiondraft}{true} \DeclareOptionX{draft}{ \setboolean{Changes@optiondraft}{true} \typeout{changes-option '\CurrentOption'} } % \end{macrocode} % % Option \choption{final}, sets \choption{draft} to \texttt{false}. % \begin{macrocode} \DeclareOptionX{final}{ \setboolean{Changes@optiondraft}{false} \typeout{changes-option '\CurrentOption'} } % \end{macrocode} % % Options for package \chpackage{ulem} are directly passed to the package. % \begin{macrocode} \DeclareOptionX{ulem}{ \typeout{ulem-option '#1', passed to package ulem} \PassOptionsToPackage{#1}{ulem} } % \end{macrocode} % % Options for package \chpackage{xcolor} are directly passed to the package. % \begin{macrocode} \DeclareOptionX{xcolor}{ \typeout{xcolor-option '#1', passed to package xcolor} \PassOptionsToPackage{#1}{xcolor} } % \end{macrocode} % % Unknown options generate package warning. % \begin{macrocode} \DeclareOptionX*{ \PackageWarning{Unknown changes-option '\CurrentOption'} } % \end{macrocode} % % Process the options. % \begin{macrocode} \ProcessOptionsX*\relax % \end{macrocode} % % Package \chpackage{xcolor} provides coloured text. % \begin{macrocode} \RequirePackage{xcolor} % \end{macrocode} % % Package \chpackage{pdfcolmk} solves the problem of coloured text and page breaks (has to be loaded after \chpackage{xcolor}). % \begin{macrocode} \RequirePackage{pdfcolmk} % \end{macrocode} % % Package \chpackage{ulem} provides commands for striking out text. % \begin{macrocode} \RequirePackage{ulem} % \end{macrocode} % % \subsection{Definitions} % % Declaration of language dependent names and identifiers. % The check for \chcommand{addto} is a check for the \chpackage{babel} package. % If the babel package is not loaded, the default language is English, in order to use an own language, the user has to redefine the variables. % \begin{macrocode} \ifthenelse{\isundefined{\addto}} { \def\listchangesname{Changes} \def\changesaddname{Added} \def\changesdeletename{Deleted} \def\changesreplacename{Replaced} \def\changesauthorname{Author} \def\changesanonymousname{anonymous} \def\changesnoloc{List of changes is available after the next \LaTeX\ run.} }{ \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 nach dem n\"achsten \LaTeX-Lauf verf\"ugbar.}} \addto\captionsgerman{\def\changesnoloc{\"Anderungsliste nach dem n\"achsten Durchlauf verf\"ugbar.}} \addto\captionsenglish{\def\changesnoloc{List of changes is available after the next \LaTeX\ run.}} } % \end{macrocode} % % File extension. % \begin{macrocode} \newcommand{\Changes@extension}{loc} % \end{macrocode} % % \begin{macro}{\setlocextension} % Set a new file extension. % Argument: new extension. % \begin{macrocode} \newcommand{\setlocextension}[1]{ \renewcommand{\Changes@extension}{#1} } % \end{macrocode} % \end{macro} % % \subsection{management of authors} % % Author counter. % \begin{macrocode} \newcounter{Changes@AuthorCount} \setcounter{Changes@AuthorCount}{0} \newcounter{Changes@iAuthor} % \end{macrocode} % % \begin{macro}{\definechangesauthor} % Define a new author. % Mandatory arguments: author's id and author's colour. % Optional argument: author's name. % % Store id, name and colour using named variables. % Define counter and colour per author. % \begin{macrocode} \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} } % \end{macrocode} % \end{macro} % % Define default-author (anonymous) with empty id and blue color. % \begin{macrocode} \definechangesauthor{\@empty}{blue} % \end{macrocode} % % Position of the authors markup relative to the text. % \emph{true} = left, \emph{false} = right (default). % \begin{macrocode} \newboolean{Changes@AuthorPositionLeft} \setboolean{Changes@AuthorPositionLeft}{false} % \end{macrocode} % % \begin{macro}{\Changes@AuthorMark} % Markup of the author. % Default: superscripted. % \begin{macrocode} \newcommand{\Changes@AuthorMark}[1]{% \textsuperscript{#1}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\setauthormarkup} % Redefine the author markup. % Mandatory argument: markup definition. % Optional argument: markup position (default = left). % \begin{macrocode} \newcommand{\setauthormarkup}[2][left]{% \ifthenelse{\equal{#1}{left}} {\setboolean{Changes@AuthorPositionLeft}{true}} {\setboolean{Changes@AuthorPositionLeft}{false}} \renewcommand{\Changes@AuthorMark}[1]{#2} } % \end{macrocode} % \end{macro} % % \begin{macro}{\Changes@Remark} % Markup of remarks. % Default: in a footnote. % \begin{macrocode} \newcommand{\Changes@Remark}[2]{% \footnote{\textcolor{Changes@Color#1}{#2}}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\setremarkmarkup} % Redefining the remark markup. % Mandatory argument: markup definition. % \begin{macrocode} \newcommand{\setremarkmarkup}[1]{% \renewcommand{\Changes@Remark}[2]{#1}% } % \end{macrocode} % \end{macro} % % \subsection{Change commands} % % Temporary variable for exchange of optional parameters between interlocked commands. % \begin{macrocode} \newcommand{\Changes@temp}{\@empty} % \end{macrocode} % % \begin{macro}{\added} % The command formats text as new text. % It's rather complicated for defining a command with two optional parameters. % % Mandatory argument: added text. % Optional arguments: author's id, remark % \begin{macrocode} \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}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\deleted} % The command formats text as deleted text. % It's rather complicated for defining a command with two optional parameters. % % The \choption{final}-part is taken from a tip from \texttt{de.comp.text.tex}. % It solves the problem of additional space caused by an empty command. % % Mandatory argument: deleted text. % Optional arguments: author's id, remark % \begin{macrocode} \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}% } % \end{macrocode} % \end{macro} % % \begin{macro}{\replaced} % The command formats text as replaced text. % It's rather complicated for defining a command with two optional parameters. % % Mandatory arguments: new text and old text. % Optional arguments: author's id, remark % \begin{macrocode} \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}% } % \end{macrocode} % \end{macro} % % \subsection{List of changes} % % \begin{macro}{\changes@chopline} % Auxiliary command for reading the content of the loc-files. % The content is read line by line. % One line is parsed with this macro, the order of entries is: id, color, name, added, deleted, replaced. % The contents have to be separated by a semicolon. % \begin{macrocode} \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} } % \end{macrocode} % \end{macro} % % \begin{macro}{\listofchanges} % This command outputs a list of changes, sorted by authors. % The values are read from the loc-file, if it exists. % If no loc-file exists, an according message is generated. % \begin{macrocode} \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} } }{} } % \end{macrocode} % \end{macro} % % At the end of the document: write the list of changes in the loc-file, therefore open file, write values, close file. % Changes are written as \LaTeX-formatted text, so they can simply be read via \chcommand{input}. % % The order of entries is: id, color, name, added, deleted, replaced. % The contents have to be separated by a semicolon. % \begin{macrocode} \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 } % \end{macrocode} % % \begin{macrocode} % % \end{macrocode} % %\Finale \endinput