File: changebar.sty

package info (click to toggle)
latex2html 98.1-pre2-b6-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,880 kB
  • ctags: 2,808
  • sloc: perl: 34,603; makefile: 690; sh: 107
file content (472 lines) | stat: -rw-r--r-- 15,399 bytes parent folder | download | duplicates (3)
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
%% 
%% This is file `changebar.sty',
%% generated with the docstrip utility.
%% 
%% The original source files were:
%% 
%% changebar.dtx  (with options: `package')
%% 
%% 
%% This is a generated file. 
%% 
%% Copyright 1994-1996 Johannes Braams. All rights reserved. 
%% 
%% For further copyright information see any other copyright notices in 
%% this file. 
%% 
%% This file is distributed in the hope that it will be useful, 
%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
%% 
%% For error reports concerning UNCHANGED versions of this file no more 
%% than one year old, send a bug report, using latex-bugs.tex to me at 
%% the address jlbraams@cistron.nl. 
%% 
%% Please do not request updates from me directly. Primary 
%% distribution is through the CTAN archives. 
%% 
%% 
%% IMPORTANT COPYRIGHT NOTICE: 
%% 
%% You are NOT ALLOWED to distribute this file alone. 
%% 
%% You are allowed to distribute this file under the condition that it is 
%% distributed together with all the files listed in manifest.txt. 
%% 
%% If you receive only some of these files from someone, complain! 
%% 
%% Permission is granted to copy this file to another file with a clearly 
%% different name and to customize the declarations in that copy to serve 
%% the needs of your installation. 
%% 
%% However, NO PERMISSION is granted to generate or to distribute a 
%% modified version of this file under its original name. 
%% 
%% You are NOT ALLOWED to change this file. 
%% 
%% 
%% MODIFICATION ADVICE: 
%% 
%% If you want to customize this file, it is best to make a copy of the 
%% source file(s) from which it was produced. Use a different name for 
%% your copy(ies) and modify the copy(ies); this will ensure that your 
%% modifications do not get overwritten when you install a new release of 
%% the standard system. You should also ensure that your modified source 
%% file does not generate any modified file with the same name as a 
%% standard file. You can then easily distribute your modifications by 
%% distributing the modified and renamed copy of the source file; this 
%% will ensure that other users can safely use your modifications. 
%% 
%% You will also need to produce your own, suitably named, .ins file to 
%% control the generation of files from your source file; this file 
%% should contain your own preambles for the files it generates, not 
%% those in the standard .ins file. 
%% 
%% The names of the source files used are shown above. 
%% 
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{changebar}
           [1996/03/26 v3.2c Indicate changes with marginal bars]
\def\cb@maxpoint{80}
\def\cb@minpoint{1}
\def\cb@nil{0}
\newcount\cb@nextpoint
\cb@nextpoint=\cb@minpoint
\newcount\cb@currentpoint
\newcount\cb@page
\newcount\cb@pagecount
\cb@pagecount=0
\newif\ifouterbars
\newif\if@cb@trace
\newdimen\cb@odd
\newdimen\cb@even
\def\cb@positions{%
  \global\cb@odd =\hoffset
  \global\advance\cb@odd by \oddsidemargin
  \ifouterbars
    \global\advance\cb@odd by \textwidth
    \global\advance\cb@odd by \changebarsep
    \global\advance\cb@odd by 0.5\changebarwidth
  \else
    \global\advance\cb@odd by -\changebarsep
    \global\advance\cb@odd by -0.5\changebarwidth
  \fi
  \global\cb@even =\hoffset
  \global\advance\cb@even by \evensidemargin
  \if@twoside
    \ifouterbars
      \global\advance\cb@even by -\changebarsep
      \global\advance\cb@even by -0.5\changebarwidth
    \else
      \global\advance\cb@even by \textwidth
      \global\advance\cb@even by \changebarsep
      \global\advance\cb@even by 0.5\changebarwidth
    \fi
  \else
    \ifouterbars
      \global\advance\cb@even by \textwidth
      \global\advance\cb@even by \changebarsep
      \global\advance\cb@even by 0.5\changebarwidth
    \else
      \global\advance\cb@even by -\changebarsep
      \global\advance\cb@even by -0.5\changebarwidth
    \fi
  \fi}
{\catcode`\p=12\catcode`\t=12 \gdef\cb@removedim#1pt{#1}}
\DeclareOption{DVItoLN03}{\global\chardef\cb@driver@setup=0\relax}
\DeclareOption{dvitoln03}{\global\chardef\cb@driver@setup=0\relax}
\DeclareOption{DVItoPS}{\global\chardef\cb@driver@setup=1\relax}
\DeclareOption{dvitops}{\global\chardef\cb@driver@setup=1\relax}
\DeclareOption{DVIps}{\global\chardef\cb@driver@setup=2\relax}
\DeclareOption{dvips}{\global\chardef\cb@driver@setup=2\relax}
\DeclareOption{emTeX}{\global\chardef\cb@driver@setup=3\relax}
\DeclareOption{emtex}{\global\chardef\cb@driver@setup=3\relax}
\DeclareOption{outerbars}{\outerbarstrue}
\DeclareOption{innerbars}{\outerbarsfalse}
\DeclareOption{leftbars}{%
  \def\cb@positions{%
    \global\cb@odd\hoffset
    \global\advance\cb@odd by \oddsidemargin
    \global\advance\cb@odd by -\changebarsep
    \global\advance\cb@odd by -0.5\changebarwidth
    \global\cb@even\hoffset
    \global\advance\cb@even by \evensidemargin
    \global\advance\cb@even by -\changebarsep
    \global\advance\cb@even by -0.5\changebarwidth
    }}
\DeclareOption{rightbars}{%
  \def\cb@positions{%
    \global\cb@odd =\hoffset
    \global\advance\cb@odd by \oddsidemargin
    \global\advance\cb@odd by \textwidth
    \global\advance\cb@odd by \changebarsep
    \global\advance\cb@odd by 0.5\changebarwidth
    \global\cb@even\hoffset
    \global\advance\cb@even by \evensidemargin
    \global\advance\cb@even by \textwidth
    \global\advance\cb@even by \changebarsep
    \global\advance\cb@even by 0.5\changebarwidth
    }}
\DeclareOption{traceon}{\@cb@tracetrue}
\DeclareOption{traceoff}{\@cb@tracefalse}
\DeclareOption*{\OptionNotUsed\PackageError
      {Unrecognised option `\CurrentOption'}%
      {known options are dvitoln03, dvitops, dvips
        and emtex,\MessageBreak
        outerbars, innerbars, leftbars and rightbars.}}
\ExecuteOptions{innerbars,traceoff,dvips}
\ProcessOptions\relax
\if@compatibility
  \def\driver#1{%
    \bgroup\edef\next{\def\noexpand\tempa{#1}}%
      \uppercase\expandafter{\next}%
      \def\LN{DVITOLN03}%
      \def\DVItoPS{DVITOPS}%
      \def\DVIPS{DVIPS}%
      \def\emTeX{EMTEX}%
      \global\chardef\cb@driver@setup=0\relax
      \ifx\tempa\LN      \global\chardef\cb@driver@setup=0\fi
      \ifx\tempa\DVItoPS \global\chardef\cb@driver@setup=1\fi
      \ifx\tempa\DVIPS   \global\chardef\cb@driver@setup=2\fi
      \ifx\tempa\emTeX   \global\chardef\cb@driver@setup=3\fi
    \egroup}
  {\def\do{\noexpand\do\noexpand}
    \xdef\@preamblecmds{\@preamblecmds \do\driver}
    }
\fi
\def\cb@trace@defpoint#1#2{%
  \wlog{Changebar trace: defining point \the#1 at position \the#2}
  \wlog{Changebar trace: cb@pagecount: \the\cb@pagecount;
    page \thepage}}
\def\cb@trace@connect#1#2#3{%
  \wlog{Changebar trace: connecting points \the#1 and \the#2;
      barwidth: \the#3}
  \wlog{Changebar trace: cb@pagecount: \the\cb@pagecount;
    page \thepage}}
\def\cb@setup@specials{%
\ifcase\cb@driver@setup
  \def\cb@defpoint##1##2{%
    \special{ln03:defpoint \the##1(\the##2,)}%
    \if@cb@trace\cb@trace@defpoint##1##2\fi}
  \def\cb@connect##1##2##3{%
    \special{ln03:connect \the##1\space\space \the##2\space \the##3}%
    \if@cb@trace\cb@trace@connect##1##2##3\fi}
  \def\cb@resetpoints{%
    \special{ln03:resetpoints \cb@minpoint \space\cb@maxpoint}}
\or
  \def\cb@defpoint##1##2{%
    \special{dvitops: inline
                \expandafter\cb@removedim\the##2\space 6.5536 mul\space
                /CBarX\the##1\space exch def currentpoint exch pop
                /CBarY\the##1\space exch def}%
    \if@cb@trace\cb@trace@defpoint##1##2\fi}
  \def\cb@connect##1##2##3{%
    \special{dvitops: inline
                gsave \thechangebargrey\space 100 div setgray
                \expandafter\cb@removedim\the##3\space 6.5536 mul\space
                CBarX\the##1\space\space CBarY\the##1\space\space moveto
                CBarX\the##2\space\space CBarY\the##2\space\space lineto
                stroke grestore}%
    \if@cb@trace\cb@trace@connect##1##2##3\fi}
  \let\cb@resetpoints\relax
\or
  \def\cb@defpoint##1##2{%
     \special{ps:
                \expandafter\cb@removedim\the##2\space
                Resolution\space mul\space 72.27\space div\space
                /CBarX\the##1\space exch def currentpoint exch pop
                /CBarY\the##1\space exch def}%
    \if@cb@trace\cb@trace@defpoint##1##2\fi}
    \def\cb@connect##1##2##3{%
      \special{ps:
                gsave \thechangebargrey\space 100 div setgray
                \expandafter\cb@removedim\the##3\space
                Resolution\space mul\space 72.27\space div\space
                setlinewidth
                CBarX\the##1\space\space CBarY\the##1\space\space moveto
                CBarX\the##2\space\space CBarY\the##2\space\space lineto
                stroke grestore}%
    \if@cb@trace\cb@trace@connect##1##2##3\fi}
    \let\cb@resetpoints\relax
\or
  \PackageWarning{Changebar}%
    {changebars only supported for v1.5+ of dvidrv}%
  \def\cb@defpoint##1##2{%
    \special{em:point \the##1,\the##2}%
    \if@cb@trace\cb@trace@defpoint##1##2\fi}
  \def\cb@connect##1##2##3{%
    \special{em:line \the##1,\the##2,\the##3}%
    \if@cb@trace\cb@trace@connect##1##2##3\fi}
  \let\cb@resetpoints\relax
\else
  \PackageWarning{Changebar}{changebars not supported in unknown setup}
  \def\cb@defpoint##1##2{%
    \if@cb@trace\cb@trace@defpoint##1##2\fi
    }
  \def\cb@connect##1##2##3{%
    \if@cb@trace\cb@trace@connect##1##2##3\fi
    }
  \let\cb@resetpoints\relax
\fi
\global\let\cb@setup@specials\relax}
\newcommand\cbstart{\@ifnextchar [{\cb@start}%
                                  {\cb@start[\changebarwidth]}}
\newcommand\cbend{\cb@end}
\newcommand\cbdelete{\@ifnextchar [{\cb@delete}
                                   {\cb@delete[\deletebarwidth]}}
\def\cb@delete[#1]{\vbox to \z@{\vss\cb@start[#1]\vskip #1\cb@end}}
\newenvironment{changebar}%
               {\@ifnextchar [{\cb@start}%
                              {\cb@start[\changebarwidth]}}%
               {\cb@end}
\newcommand\nochangebars{%
  \def\cb@start[##1]{}%
  \def\cb@delete[##1]{}%
  \let\cb@end\relax}
\newlength{\changebarwidth}
\setlength{\changebarwidth}{2pt}
\newlength{\deletebarwidth}
\setlength{\deletebarwidth}{4pt}
\newlength{\changebarsep}
\setlength{\changebarsep}{30pt}
\newcounter{changebargrey}
\setcounter{changebargrey}{65}
\def\cb@start[#1]{%
  \cb@currentpoint=\cb@nextpoint
  \@tempdima#1\relax
  \cb@push\cb@currentlist
  \ifvmode
    \cb@setBeginPoint\cb@currentpoint
  \else
   \vbox to \z@{%
     \vskip -\ht\strutbox
     \cb@setBeginPoint\cb@currentpoint
     \vskip \ht\strutbox}\fi
  \cb@writeAux\cb@advancePoint}
\def\cb@advancePoint{%
  \global\advance\cb@nextpoint by 2\relax
  \ifnum\cb@nextpoint>\cb@maxpoint
    \global\cb@nextpoint=\cb@minpoint\relax
  \fi}
\def\cb@end{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \PackageWarning{Changebar}%
      {Badly nested changebars; Expect erroneous results}%
  \else
    \cb@setEndPoint\cb@currentpoint
    \global\advance\cb@currentpoint by1\cb@writeAux
  \fi}
\def\cb@setBeginPoint#1{%
  \ifodd\cb@pagecount
    \cb@defpoint{#1}{\cb@even}%
  \else
    \cb@defpoint{#1}{\cb@odd}%
  \fi}
\def\cb@setEndPoint#1{%
  \@tempcnta=#1\advance\@tempcnta by1\relax
  \ifodd\cb@pagecount
    \cb@defpoint{\@tempcnta}{\cb@even}%
  \else
    \cb@defpoint{\@tempcnta}{\cb@odd}%
  \fi
  \cb@connect{#1}{\@tempcnta}{\@tempdima}}%
\def\cb@writeAux{%
  \if@filesw
    \begingroup
      \edef\point{\the\cb@currentpoint}%
      \edef\level{\the\@tempdima}%
      \let\the=0%
      \edef\cb@temp{\write\@auxout
        {\string\cb@barpoint{\point}{\the\cb@pagecount}{\level}}}%
      \cb@temp
    \endgroup
  \fi}
\let\cb@makecol\@makecol
\def\@makecol{%
  \setbox\@cclv \vbox{%
    \cb@resetpoints
    \cb@beginSaves
    \unvbox\@cclv
    \boxmaxdepth\maxdepth}%
  \gdef\cb@beginSaves{}
  \global\advance\cb@pagecount by 1\relax
  \cb@buildActive\cb@processActive
  \cb@makecol}
\let\cb@vtryfc\@vtryfc
\def\@vtryfc{%
  \setbox\@outputbox \vbox{%
    \cb@resetpoints
    \cb@beginSaves
    \unvbox\@cclv
    \boxmaxdepth\maxdepth}%
  \gdef\cb@beginSaves{}
  \global\advance\cb@pagecount by 1\relax
  \cb@buildActive\cb@processActive
  \cb@vtryfc}
\def\cb@processActive{%
  \cb@pop\cb@spanlist
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \setbox\@cclv\vbox{%
      \unvbox\@cclv
      \boxmaxdepth\maxdepth
      \advance\cb@pagecount by -1\relax
      \cb@setEndPoint\cb@currentpoint}%
    \cb@saveBeginPoint\cb@currentpoint
    \cb@push\cb@history
    \cb@processActive
  \fi}
\def\cb@saveBeginPoint#1{%
  \ifodd\cb@pagecount
    \xdef\cb@beginSaves{\cb@defpoint{#1}{\cb@even}\cb@beginSaves}%
  \else
    \xdef\cb@beginSaves{\cb@defpoint{#1}{\cb@odd}\cb@beginSaves}%
  \fi}
\def\cb@beginSaves{}                % initially empty
\def\cb@buildActive{\cb@initlist\cb@spanlist\cb@pushNextActive}
\def\cb@pushNextActive{%
  \cb@pop\cb@history
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \ifnum\cb@page>\cb@pagecount
      \cb@push\cb@history
    \else
      \ifodd\cb@currentpoint
        \cb@push\cb@spanlist
      \else
        \cb@pop\cb@spanlist
      \fi
      \cb@pushNextActive
    \fi
  \fi}
\def\cb@initlist#1{\xdef#1{}}
\cb@initlist\cb@history
\newwrite\cb@write
\newread\cb@read
\immediate\openout\cb@write=\jobname.cb\relax
\cb@initlist\cb@spanlist
\cb@initlist\cb@currentlist
\def\cb@pop#1{%
  \ifx #1\cb@history
    \ifeof\cb@read
    \else
      {\endlinechar=-1\read\cb@read to\@temp
       \xdef\cb@history{\cb@history\@temp}%
      }%
    \fi
  \fi
  \ifx#1\@empty
    \cb@currentpoint=\cb@nil\cb@page=0\relax
  \else
    \expandafter\cb@carcdr#1e#1%
  \fi}
\def\cb@carcdr#1n#2p#3l#4e#5{%
  \cb@currentpoint=#1\cb@page=#2\relax\@tempdima=#3\xdef#5{#4}}
\def\cb@push#1{%
  \xdef#1{\the\cb@currentpoint n\the\cb@page p\the\@tempdima l#1}}
\def\cb@barpoint#1#2#3{\immediate\write\cb@write{#1n#2p#3l}}
\AtBeginDocument{%
  \cb@setup@specials
  \cb@positions
  \immediate\closeout\cb@write
  \immediate\openin\cb@read=\jobname.cb}
\AtEndDocument{%
  \clearpage
  \cb@initlist\cb@history
  \immediate\closein\cb@read
  \immediate\openin\cb@read=\jobname.cb%
  \let\cb@barpoint=\cb@checkHistory}
\def\cb@checkHistory#1#2#3{%
  \cb@pop\cb@history
  \ifnum #1=\cb@currentpoint\relax
    \ifnum #2=\cb@page\relax
    \else
      \cb@error
    \fi
  \else
    \cb@error
  \fi}
\def\cb@error{%
  \PackageWarning{Changebar}%
    {Changebar info has changed.\MessageBreak
     Rerun to get the bars right}
  \gdef\cb@checkHistory##1##2##3{}%
  \let\cb@barpoint=\cb@checkHistory}
\let\cb@endfloat=\end@float
\def\end@float{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \cb@push\cb@currentlist
    \global\@tempdima=\@tempdima
    \egroup
    \global\setbox\@currbox=%
        \vbox\bgroup\cb@start[\@tempdima]\unvbox\@currbox\cb@end
  \fi
  \cb@endfloat}
\let\cb@footnote=\@footnotetext
\long\def\@footnotetext#1{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \cb@footnote{#1}%
  \else
    \cb@push\cb@currentlist
    \edef\cb@temp{\the\@tempdima}%
    \cb@footnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\let\cb@mpfootnote=\@mpfootnotetext
\long\def\@mpfootnotetext#1{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \cb@mpfootnote{#1}%
  \else
    \cb@push\cb@currentlist
    \edef\cb@temp{\the\@tempdima}%
    \cb@mpfootnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\endinput
%% 
%% End of file `changebar.sty'.