summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/editbar.sty
blob: 3214dc108b5689138f40309ac375a9eede6c8e60 (plain)
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
\iffalse %

          LaTeX Style: editbar.sty  2.0

          Written by:  Michael R. Van Geest
                       Unisys Corp.
                       M.S. 4522
                       2276 Highcrest Road
                       Roseville, MN 55113

          Internet:    mrv@unirsvl.rsvl.unisys.com

          Date:        August 17, 1994

          TeX Drivers Supported: DVIPS    


          General Information:

             editbar.sty is a LaTeX style to be used to print edit bars
             (change bars) with PostScript as the final output.

             DVIPS is the only driver currently supported, but others could
             be used.

             Generation of edit bars on one page and/or spanning 
             multiple pages.

             The output routine of LaTeX is modified to include the edit
             bar commands to span multiple pages.


          Macro usage:

             ebarsetup   - Place after \begin{document}

             ebarcleanup - Place before \end{document}
                           It is adviseable to put a \clearpage before
                           \ebarcleanup.

             genebaron   - Start generating edit bars.

                           Put in a \hbox to 0pt to not affect letter spacing.

                              Example: \hbox to 0pt{\genebaron\hss}

                           If the first item in a sentence or data item,
                           put \hskip0pt before it.

                              Example: \hskip0pt\hbox to 0pt{\genebaron\hss}

             genebaroff  - End generating edit bars.


          Counters that can be modified are:

             \ebaroddside   - Distance in points from the left side of the
                              paper to where the edit bar on the odd side
                              of the paper is placed.

                              Currently set to 508.
      
             \ebarevenside  - Distance in points from the left side of the
                              paper to where the edit bar on the even side
                              of the paper is placed.

                              Currently set to -30.

             \ebarbarheight - Height of edit bar in points on current line. 
                              Currently set to 12 (1 pica).
              
             \ebarbarwidth  - Edit bar width in points, currently set to 2.


          Auxilary files that are created are: 

            \jobname.ebo - Edit bar out file.

                           \count0 is written to this file in the output
                           routine by the \write command.

            \jobname.ebi - Edit bar in file.  The contents of \jobname.ebo
                           are copied to this file after 1 pass of LaTeX.
                           This file is used as input to the genebaron
                           and genebaroff macros to find out which page(s)
                           to place the edit bars.

          Notes:  1. The .ebo and .ebi files must be deleted if revisions
                     are made to the original .tex file.

                  2. Three passes must be run to ensure correct ebar
                     generation.

                     Pass 1 - Write editbar on and off to .ebo file

                     Pass 2 - Read editbar on and offs from .ebi file 
                              generated on pass one.  

                              If spanning pages, write ebar span on and
                              off macros to the aux file.  

                              The reason this is done, is because TeX reads
                              ahead a couple of pages, and will set count
                              registers incorrectly, resulting in incorrect
                              page spanning.  

                              By writing edit bar page span macros to the aux
                              file, the next pass can do an ifx to check
                              that the edit bar is spanning the correct pages.

                     Pass 3 - Read editbar on and offs from pass two.
                              Also check for macros written to aux file
                              from pass 2 for edit bar page spanning.


          Restrictions:

             -  Does not span multiple chapters.  The edit bar must
                end at the chapter.  This is because count0 is used 
                as the edit bar counter to place on odd or even sides 
                if two sided styles are used.  If one sided styles
                are used, the odd side edit bar code is used.

             -  Nested edit bars are not supported.

                Examples:

                   \genebaron Text \genebaron text \genebaroff
     
                   \genebaron Text \genebaroff text \genebaroff

             -  Does support paper resolution.  The DVIPS
                PostScript def Resolution is used.

             -  Edit bars in Longtable.sty should work.


          Sample Usage:

             \documentstyle[editbar]{book}
             %
             \begin{document}
             %
             \ebarsetup{}%
             %
             Paragraph on page 1
             %
             \newpage 
             This paragraph \hbox to 0pt{\genebaron\hss}has an edit bar on it.
             %  
             \newpage
             %
             This is a paragraph that has an edit bar around it.
             %
             This \genebaroff{}is a paragraph with end edit bar that ends it.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             More stuff.
             %
             \clearpage\ebarcleanup{}%
             \end{document}

\fi %

\def\fileversion{v2.0}
\def\filedate{17AUG94}
\wlog{Style-Option: `editbar' \fileversion \space\space <\filedate> (M.R.V.G.)}

% Dimen Register - truepagetotal
%
% This is set in the sample output routine.  Must be used for edit bars
% to work correctly.
%
\newdimen\truepagetotal
%
%
% Read Register - ebarin
% Edit Bar read in file
%
\newread\ebarin

% Write Register - ebarout
% Edit Bar write out file
%
\newwrite\ebarout

% Count Register - ebarnest
%
\newcount\ebarnest
\ebarnest=0

% Count Register - ebarcount
%
\newcount\ebarcount
\ebarcount=0

% Count Register - ebaroddside
%
\newcount\ebaroddside
\ebaroddside=508

% Count Register - ebarevenside
%
\newcount\ebarevenside
\ebarevenside=-30

% Count Register - ebarbarwidth
%
\newcount\ebarbarwidth
\ebarbarwidth=2

% Count Register - ebarbarheight
%
\newcount\ebarbarheight
\ebarbarheight=12

% Count Register - ebarpagesspan
%
\newcount\ebarpagesspan
\ebarpagesspan=0

% Count Register - ebaroncapture
%
\newcount\ebaroncapture
\ebaroncapture=0

% Count Register - ebaroncapturesave
%
\newcount\ebaroncapturesave
\ebaroncapturesave=0

% Count Register - ebaroffcapture
%
\newcount\ebaroffcapture
\ebaroffcapture=0

% Count Register - ebarsubtract
%
\newcount\ebarsubtract
\ebarsubtract=0

% If - ifebarfileopen
% Checks to see if the ebarfile is open
%
\newif\ifebarfileopen
%
% If - ifebarspanpages
% Checks for ebar spanning pages
%
\newif\ifebarspanpages
\ebarspanpagesfalse %
%
% Def - Text for ifx checking on ebar page spanning
%
\def\ebarcheckonmsg{ebarspanon}
\def\ebarcheckoffmsg{ebarspanoff}
%
%    ebarsetup
%
%    Sets up the input and output ebar files     
%
%    Place at the top of the document
%
\globaldefs1%
\def\ebarsetup{% 
\immediate\openin\ebarin=\jobname.ebi %
\ifeof\ebarin%
   \typeout{No file \jobname.ebi}%
   \global\ebarfileopenfalse%
\else%
   \global\ebarfileopentrue%
\fi%
\immediate\openout\ebarout=\jobname.ebo %
}%
%
%    ebarcleanup
%
%    Closes the ebar output file, then opens the ebar output file for read,
%    then copies the ebar output file to the ebar input file for the next
%    pass to read the ebar input file
%
%    Place at the end of the document
%
\def\ebarcleanup{%
\immediate\closein\ebarin%
\immediate\closeout\ebarout%
%%
\immediate\openin\ebarin=\jobname.ebo %
\immediate\openout\ebarout=\jobname.ebi %
%%
\ebarfileopentrue%
%%
\loop%
   \immediate\read\ebarin to \ebarinin%
   \ifeof\ebarin%
     \ebarfileopenfalse%
   \fi%
   \ifebarfileopen%
     \immediate\write\ebarout{\ebarinin}%
\repeat%
%%
\closein\ebarin%
\closeout\ebarout%
}%
%
%    ebargeton
%
%    Gets the next ebar reference from the ebar input file
%
%    Specifically, gets the relative page number output from the prior
%    pass of genebar macro
%
\def\ebargeton{%
\immediate%
\ifeof\ebarin%
%
\else%
   \immediate\read\ebarin to \ebarinon%
   \global\ebaroncapture=\ebarinon%
   \global\ebaroncapturesave=\ebarinon%
\fi%
}
%
%    ebargetoff
%
%    Gets the next ebar reference from the ebar input file
%
%    Specifically, gets the relative page number output from the prior
%    pass of genebar macro
%
\def\ebargetoff{%
\immediate%
\ifeof\ebarin%
%
\else%
   \immediate\read\ebarin to \ebarinoff%
   \global\ebaroffcapture=\ebarinoff%
\fi%
}
%
%    endebarthispage
%
%    Check edit bar status to end an edit bar on this page
%
\def\endebarthispage{%
   \expandafter\ifx\csname EBARSPANONat%
      Count\romannumeral\ebarcount%
      Page\romannumeral\count0%
      \endcsname%
      \ebarcheckonmsg
%
% TRUE Statement, Macro is defined
%
      \message{Ebar Spanning Pages On}
      \global\ebarspanpagestrue
   \fi %
%
   \ifebarspanpages
      \genebaroffpage{}%
   \fi%
}%
%
%    beginebarnextpage
%
%    Check edit bar status to begin an edit bar on next page
%
\def\beginebarnextpage{%
   \ifebarspanpages
      \genebaronpage{}%
   \fi%
   \expandafter\ifx\csname EBARSPANOFFat%
      Count\romannumeral\ebarcount%
      Page\romannumeral\count0%
      \endcsname%
      \ebarcheckoffmsg
%
% TRUE Statement, Macro is defined
%
      \message{Ebar Spanning Pages Off}
      \global\ebarspanpagesfalse
   \fi
}%
%
%    ebarspecialstart, ebarspecialodd, ebarspecialeven, and ebarspecialend
%
%    Start, Odd and even pages, and end special macros
%                              
\newtoks\ebarendline
\ebarendline={ }%
%
%
\def\ebarspecialstart{%
   \special{ps:%
      /SPECIALSTART pop                    %  FOR DEBUGGING PostScript
      Resolution 72 div /Point exch def    %  Get points conversion
      currentpoint exch pop                %  Get current Y point       
      Point \the\ebarbarheight\the\ebarendline %
      mul sub  /Y1point exch def           %  Get current Y point 
                                           %    minus ebar height
      }%
}%
%
\def\ebarspecialodd{%
      \special{ps:%
      /SPECIALODD pop                           %  FOR DEBUGGING PostScript
         Point \the\ebaroddside\the\ebarendline %
         mul   /Xpoint exch def                 %  Get X point
         }%
}%
%
\def\ebarspecialeven{%
      \special{ps:%
      /SPECIALEVEN pop                           %  FOR DEBUGGING PostScript
         Point \the\ebarevenside\the\ebarendline %
         mul  /Xpoint exch def                   %  Get X point
         }%
}%
%
\def\ebarspecialend{%
   \special{ps:%
      /SPECIALEND pop                          %  FOR DEBUGGING PostScript
      gsave                                    %
      Point \the\ebarbarwidth\the\ebarendline  %
      mul setlinewidth                         %  Edit Bar width
      currentpoint exch pop \the\ebarsubtract\the\ebarendline % 
                                               %  Get current Y point
      Point mul sub /Y2point exch def          %  minus adjustment
      Xpoint Y1point moveto                    %
      Xpoint Y2point lineto stroke             %
      grestore}%
}%
%
%    genebaron
%
%    Writes the relative page number to the ebar output file,
%    reads from the ebar input file if open and generates the ebar on
%
%    Place where the ebar will occur
%
\def\genebaron{%
   \write\ebarout{\the\count0}%
   \global\advance\ebarcount by 1 %
\ifeof\ebarin%
\else%
   \global\advance\ebarnest by 1 %
%
   \ifnum\ebarnest=1 %
   \else%
     \@latexerr{Edit bar are nested, bad results can occur.}%
               {Please use genebaroff before using genebaron}%
   \fi%
%
   \ebargeton%                                        % Get ebar on page
   \ebargetoff%                                       % Get ebar off page
%
   \global\ebarpagesspan=\ebaroffcapture%             % Get page span
   \global\advance\ebarpagesspan by -\ebaroncapture%
%
   \ifnum\ebarpagesspan>0%
%
    \immediate\write \@auxout{\gdef\string\EBARSPANONat%
       Count\romannumeral\ebarcount%
       Page\romannumeral\ebaroncapture{ebarspanon}}
    \immediate\write \@auxout{\gdef\string\EBARSPANOFFat%
       Count\romannumeral\ebarcount%
       Page\romannumeral\ebaroffcapture{ebarspanoff}}
%
   \fi %
%
   \special{ps:%
   /GENEBARON pop                    %  FOR DEBUGGING PostScript
   }%
%
   \ebarspecialstart%
%
   \if@twoside%
      \ifodd\ebaroncapture%
         \ebarspecialodd%
      \else%
         \ebarspecialeven%
      \fi%
   \else%
      \ebarspecialodd%
   \fi%
\fi%
}%
%
%    genebaronpage
%
%    Fake ebar on for page begin
%
%
\def\genebaronpage{%
\ifeof\ebarin%
\else%
   \special{ps:%
   /GENEBARONPAGE pop                    %  FOR DEBUGGING PostScript
   }%
   \ebarspecialstart%
%
   \if@twoside%
      \ifodd\count0%
         \ebarspecialodd%
      \else%
         \ebarspecialeven%
      \fi%
   \else%
      \ebarspecialodd%
   \fi%
\fi%
}%
%
%    genebaroff
%
%    Writes the relative page number to the ebar output file, and
%    generates special code for end
%
%    Place where the ebar will occur
%
\def\genebaroff{\write\ebarout{\the\count0}%
\ifeof\ebarin%
\else%
   \global\ebarsubtract=0 %
   \global\advance\ebarnest by -1 %
%
   \ifnum\ebarnest=0 %
   \else%
     \@latexerr{Edit bar are nested, bad results can occur.}%
               {Please use genebaron before using genebaroff}%
   \fi%
%
   \special{ps:%
   /GENEBAROFF pop                    %  FOR DEBUGGING PostScript
   }%
   \ebarspecialend%
\fi%
}%
%
%    genebaroffpage
%
%    Fake ebar off for page end
%
\def\genebaroffpage{%
\ifeof\ebarin%
\else%
   \global\ebarsubtract=\pagegoal % Get pagegoal
   \ifdim\truepagetotal < \pagegoal %
      \global\advance\ebarsubtract by -\truepagetotal      % subtract truepagetotal
    \else
      \global\advance\ebarsubtract by -\pagegoal           % subtract pagegoal
   \fi
%
   \global\divide\ebarsubtract by 65536 % Divide by scaled points
%
   \special{ps:%
   /GENEBAROFFPAGE   pop              %  FOR DEBUGGING PostScript
   }%
   \ebarspecialend%
\fi%
}%
%
%
\globaldefs0%
%
% Sample shipout routine changes
%
\def\@outputpage{\begingroup\catcode`\ =10
     \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii
    \if@specialpage
     \global\@specialpagefalse\@nameuse{ps@\@specialstyle}\fi
     \if@twoside
       \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
            \let\@themargin\oddsidemargin
          \else \let\@thehead\@evenhead
          \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
     \fi\fi
%
     {\setbox0=\vbox{\unvcopy\@outputbox}      % MRV 07JAN94
      \global\truepagetotal=\ht0}              % Get true page total
%
     \shipout
     \vbox{\normalsize \baselineskip\z@ \lineskip\z@
           \let\par\@@par %% 15 Sep 87
           \vskip \topmargin \moveright\@themargin
           \vbox{\setbox\@tempboxa
                   \vbox to\headheight{\vfil \hbox to\textwidth
                                       {\let\label\@gobble \let\index\@gobble
                                         \@thehead}} %% 22 Feb 87
                 \dp\@tempboxa\z@
                 \box\@tempboxa
                 \vskip \headsep
%
                 \box\@outputbox
%
                 \endebarthispage%
%
                 \baselineskip\footskip
                 \hbox to\textwidth{\let\label\@gobble
                           \let\index\@gobble  %% 22 Feb 87
                           \@thefoot}}}\global\@colht\textheight
           \endgroup\stepcounter{page}\let\firstmark\botmark%
%
           \beginebarnextpage{}}
%