%% 
%% 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 (C) 1994,1999 Johannes Braams, All rights reserved. 
%% 
%% This program can be redistributed and/or modified under the terms 
%% of the LaTeX Project Public License Distributed from CTAN 
%% archives in directory macros/latex/base/lppl.txt; either 
%% version 1 of the License, or any later version. 
%% 
%% 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. 
%% 
%% Copyright 1994-1999 (C) Johannes Braams.  All rights reserved.
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt; either
%% version 1 of the License, or any later version.
%% For further copyright information see and any other copyright notices
%% in this file.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{changebar}
           [1998/03/17 v3.3f 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@topleft
\newcount\cb@topright
\newcount\cb@botleft
\newcount\cb@botright
\newdimen\cb@curbarwd
\newcount\cb@page
\newcount\cb@pagecount
\cb@pagecount=0
\newif\ifouterbars
\newif\if@cb@trace
\newdimen\cb@odd@left
\newdimen\cb@odd@right
\newdimen\cb@even@left
\newdimen\cb@even@right
\def\cb@positions{%
  \global\cb@odd@left=\hoffset
  \global\cb@even@left\cb@odd@left
  \global\advance\cb@odd@left by \oddsidemargin
  \global\cb@odd@right\cb@odd@left
  \global\advance\cb@odd@right by \textwidth
  \global\advance\cb@odd@right by \changebarsep
  \global\advance\cb@odd@right by 0.5\changebarwidth
  \global\advance\cb@odd@left by -\changebarsep
  \global\advance\cb@odd@left by -0.5\changebarwidth
  \global\advance\cb@even@left by \evensidemargin
  \global\cb@even@right\cb@even@left
  \global\advance\cb@even@left by -\changebarsep
  \global\advance\cb@even@left by -0.5\changebarwidth
  \global\advance\cb@even@right by \textwidth
  \global\advance\cb@even@right by \changebarsep
  \global\advance\cb@even@right by 0.5\changebarwidth
  }
{\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{textures}{\global\chardef\cb@driver@setup=4\relax}
\DeclareOption{Textures}{\global\chardef\cb@driver@setup=4\relax}
\DeclareOption{outerbars}{\outerbarstrue}
\DeclareOption{innerbars}{\outerbarsfalse}
\DeclareOption{leftbars}{%
  \def\cb@positions{%
    \global\cb@odd@left=\hoffset
    \global\cb@even@left\cb@odd@left
    \global\advance\cb@odd@left by \oddsidemargin
    \global\advance\cb@odd@left by -\changebarsep
    \global\advance\cb@odd@left by -0.5\changebarwidth
    \global\advance\cb@even@left by \evensidemargin
    \global\advance\cb@even@left by -\changebarsep
    \global\advance\cb@even@left by -0.5\changebarwidth
    \global\let\cb@odd@right\cb@odd@left
    \global\let\cb@even@right\cb@even@left
    }}
\DeclareOption{rightbars}{%
  \def\cb@positions{%
    \global\cb@odd@right=\hoffset
    \global\cb@even@right\cb@odd@right
    \global\advance\cb@odd@right by \oddsidemargin
    \global\advance\cb@odd@right by \textwidth
    \global\advance\cb@odd@right by \changebarsep
    \global\advance\cb@odd@right by 0.5\changebarwidth
    \global\advance\cb@even@right by \evensidemargin
    \global\advance\cb@even@right by \textwidth
    \global\advance\cb@even@right by \changebarsep
    \global\advance\cb@even@right by 0.5\changebarwidth
    \global\let\cb@odd@left\cb@odd@right
    \global\let\cb@even@left\cb@even@right
    }}
\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
\newcommand\cb@trace[1]{%
  \if@cb@trace
    \GenericWarning
      {(changebar)\@spaces\@spaces}%
      {Package changebar: #1}%
  \fi
  }
\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}%
      \def\Textures{TEXTURES}%
      \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
      \ifx\tempa\Textures \global\chardef\cb@driver@setup=4\fi
    \egroup}
  {\def\do{\noexpand\do\noexpand}
    \xdef\@preamblecmds{\@preamblecmds \do\driver}
    }
\fi
\def\cb@trace@defpoint#1#2{%
  \cb@trace{%
    defining point \the#1 at position \the#2
    \MessageBreak
    cb@pagecount: \the\cb@pagecount; page \thepage}}
\def\cb@trace@connect#1#2#3{%
  \cb@trace{%
    connecting points \the#1 and \the#2; barwidth: \the#3
    \MessageBreak
    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,)}%
    \cb@trace@defpoint##1##2}
  \def\cb@connect##1##2##3{%
    \special{ln03:connect \the##1\space\space \the##2\space \the##3}%
    \cb@trace@connect##1##2##3}
  \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}%
    \cb@trace@defpoint##1##2}
  \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}%
    \cb@trace@connect##1##2##3}
  \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}%
    \cb@trace@defpoint##1##2}
    \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}%
    \cb@trace@connect##1##2##3}
    \let\cb@resetpoints\relax
\or
  \def\cb@defpoint##1##2{%
    \special{em:point \the##1,\the##2}%
    \cb@trace@defpoint##1##2}
  \def\cb@connect##1##2##3{%
    \special{em:line \the##1,\the##2,\the##3}%
    \cb@trace@connect##1##2##3}
  \let\cb@resetpoints\relax
\or
  \def\cb@defpoint##1##2{%
     \special{rawpostscript
                \expandafter\cb@removedim\the##2\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{rawpostscript
                gsave 1 setlinecap \thechangebargrey\space 100 div setgray
                \expandafter\cb@removedim\the##3\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
 \else
  \PackageWarning{Changebar}{changebars not supported in unknown setup}
  \def\cb@defpoint##1##2{\cb@trace@defpoint##1##2}
  \def\cb@connect##1##2##3{\cb@trace@connect##1##2##3}
  \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@topleft=\cb@nextpoint
  \cb@curbarwd#1\relax
  \cb@push\cb@currentstack
  \ifvmode
    \cb@setBeginPoints
  \else
   \vbox to \z@{%
     \vskip -\ht\strutbox
     \cb@setBeginPoints
     \vskip \ht\strutbox}\fi
   \cb@advancePoint}
\def\cb@advancePoint{%
  \global\advance\cb@nextpoint by 4\relax
  \ifnum\cb@nextpoint>\cb@maxpoint
    \global\cb@nextpoint=\cb@minpoint\relax
  \fi}
\def\cb@end{%
  \cb@pop\cb@currentstack
  \ifnum\cb@topleft=\cb@nil
    \PackageWarning{Changebar}%
      {Badly nested changebars; Expect erroneous results}%
  \else
    \cb@setEndPoints
  \fi
  \ignorespaces}
\def\cb@setBeginPoints{%
  \cb@topright=\cb@topleft\advance\cb@topright by\@ne
  \ifodd\cb@pagecount
    \cb@defpoint\cb@topleft\cb@even@left
    \cb@defpoint\cb@topright\cb@even@right
  \else
    \cb@defpoint\cb@topleft\cb@odd@left
    \cb@defpoint\cb@topright\cb@odd@right
  \fi
  \cb@writeAux\cb@topleft
  }
\def\cb@setEndPoints{%
  \cb@topright=\cb@topleft\advance\cb@topright by\@ne
  \cb@botleft=\cb@topleft\advance\cb@botleft by\tw@
  \cb@botright=\cb@topleft\advance\cb@botright by\thr@@
  \ifodd\cb@pagecount
    \cb@defpoint\cb@botleft\cb@even@left
    \cb@defpoint\cb@botright\cb@even@right
  \else
    \cb@defpoint\cb@botleft\cb@odd@left
    \cb@defpoint\cb@botright\cb@odd@right
  \fi
  \cb@writeAux\cb@botright
  \edef\cb@leftbar{%
    \noexpand\cb@connect{\cb@topleft}{\cb@botleft}{\cb@curbarwd}}%
  \edef\cb@rightbar{%
    \noexpand\cb@connect{\cb@topright}{\cb@botright}{\cb@curbarwd}}%
  \if@twocolumn
    \if@firstcolumn\cb@leftbar\else\cb@rightbar\fi
  \fi
  \ifouterbars
    \ifodd\cb@pagecount\cb@leftbar\else\cb@rightbar\fi
  \else
    \ifodd\cb@pagecount\cb@rightbar\else\cb@leftbar\fi
  \fi
  }%
\def\cb@writeAux#1{%
  \if@filesw
    \begingroup
      \edef\point{\the#1}%
      \edef\level{\the\cb@curbarwd}%
      \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{%
  \let\cb@writeAux\@gobble
  \setbox\@cclv \vbox{%
    \cb@resetpoints
    \cb@startSpanBars
    \unvbox\@cclv
    \boxmaxdepth\maxdepth}%
  \global\advance\cb@pagecount by\@ne
  \cb@buildstack\cb@processActive
  \cb@makecol}
\let\cb@vtryfc\@vtryfc
\def\@vtryfc{%
  \let\cb@writeAux\@gobble
  \setbox\@outputbox \vbox{%
    \cb@resetpoints
    \cb@startSpanBars
    \unvbox\@cclv
    \boxmaxdepth\maxdepth}%
  \global\advance\cb@pagecount by \@ne
  \cb@buildstack\cb@processActive
  \cb@vtryfc}
\def\cb@processActive{%
  \cb@pop\cb@endstack
  \ifnum\cb@topleft=\cb@nil
  \else
    \setbox\@cclv\vbox{%
      \unvbox\@cclv
      \boxmaxdepth\maxdepth
      \advance\cb@pagecount by -1\relax
      \cb@setEndPoints}%
    \cb@push\cb@historystack
    \cb@push\cb@beginstack
    \expandafter\cb@processActive
  \fi}
\def\cb@startSpanBars{%
  \cb@pop\cb@beginstack
  \ifnum\cb@topleft=\cb@nil
  \else
    \cb@setBeginPoints
    \cb@push\cb@currentstack
    \expandafter\cb@startSpanBars
  \fi
  }
\def\cb@buildstack{%
  \cb@initstack\cb@endstack
  \cb@pushNextActive}
\def\cb@pushNextActive{%
  \cb@pop\cb@historystack
  \ifnum\cb@topleft=\cb@nil
  \else
    \ifnum\cb@page>\cb@pagecount
      \cb@push\cb@historystack
    \else
      \ifodd\cb@topleft
        \cb@push\cb@endstack
      \else
        \cb@pop\cb@endstack
      \fi
      \expandafter\expandafter\expandafter\cb@pushNextActive
    \fi
  \fi}
\def\cb@initstack#1{\xdef#1{}}
\cb@initstack\cb@historystack
\newwrite\cb@write
\newread\cb@read
\immediate\openout\cb@write=\jobname.cb\relax
\cb@initstack\cb@endstack
\cb@initstack\cb@beginstack
\cb@initstack\cb@currentstack
\def\cb@pop#1{%
  \ifx #1\cb@historystack
    \ifeof\cb@read
    \else
      {\endlinechar=-1\read\cb@read to\@temp
       \xdef\cb@historystack{\cb@historystack\@temp}%
      }%
    \fi
  \fi
  \ifx#1\@empty
    \cb@topleft=\cb@nil\cb@page=0\relax
  \else
    \expandafter\cb@carcdr#1e#1%
  \fi}
\def\cb@carcdr#1n#2p#3l#4e#5{%
  \cb@topleft=#1\cb@page=#2\relax\cb@curbarwd=#3\xdef#5{#4}}
\def\cb@push#1{%
  \xdef#1{\the\cb@topleft n\the\cb@page p\the\cb@curbarwd 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@initstack\cb@historystack
  \immediate\closein\cb@read
  \immediate\openin\cb@read=\jobname.cb%
  \let\cb@barpoint=\cb@checkHistory}
\def\cb@checkHistory#1#2#3{%
  \cb@pop\cb@historystack
  \ifnum #1=\cb@topleft\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@currentstack
  \ifnum\cb@topleft=\cb@nil
  \else
    \cb@push\cb@currentstack
    \global\cb@curbarwd=\cb@curbarwd
    \egroup
    \global\setbox\@currbox=%
        \vbox\bgroup\cb@start[\cb@curbarwd]\unvbox\@currbox\cb@end
  \fi
  \cb@endfloat}
\let\cb@footnote=\@footnotetext
\long\def\@footnotetext#1{%
  \cb@pop\cb@currentstack
  \ifnum\cb@topleft=\cb@nil
    \cb@footnote{#1}%
  \else
    \cb@push\cb@currentstack
    \edef\cb@temp{\the\cb@curbarwd}%
    \cb@footnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\let\cb@mpfootnote=\@mpfootnotetext
\long\def\@mpfootnotetext#1{%
  \cb@pop\cb@currentstack
  \ifnum\cb@topleft=\cb@nil
    \cb@mpfootnote{#1}%
  \else
    \cb@push\cb@currentstack
    \edef\cb@temp{\the\cb@curbarwd}%
    \cb@mpfootnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\endinput
%% 
%% End of file `changebar.sty'.
