1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
% \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}
%</changes>
% \end{macrocode}
%
%\Finale
\endinput
|