%    Supported drivers sofar:
%         dvitops           (James Clark)
%         dvips             (Tom Rokicki)
%         dvitoln03         (Brian {Hamilton Kelly})
%         emTeX (dvidrv)    (Eberhard Mattes)
%         VTeX              (Michael Vulis)
%	  PDFTeX	    (Piet van Oostrum)
%	  XeTeX		    (Apostolos Syropoulos)
%	  luaTeX
%
% change history
%
%       Revisions:
%               Support for twosided.sty added. January, 1987.
%
%               Warning message added to indicate that another pass is
%               required. May, 1987.
%
%               Converted to work with dvitops.  March 1990.
%               Neil Winton (nwinton@axion.bt.co.uk)
%
%               Usage by several drivers SPQR spqr@uk.ac.soton.ecs
%
% v2.0 22-11-90 JLB  merged the original file with  Niel Winton's mods
%        now supports both DVI2LN3 and DVItoPS specials. This introduces 
%        one extra user-command, \device{<device>}. If he says \device{PS} 
%        the PostScript \specials (DVItoPS by James Clark) will be used, 
%        anything else gives the original LN03 \specials.
%
% v2.1 06-04-91 SPQR changed the \ifPS statements to be case
%        statements which check the value of a counter called \driver@setup, 
%        and issue specials accordingly. dvitops, dvips and LN03 are only
%        drivers supported.
% v2.2 07-03-91 JLB  Located all \specials in one place by defining
%        the use of three new macros. Supplied a user command to select 
%        the driver and added code to \document for initializing the 
%        \special-macros.
% v2.2a 08-03-91 JLB \ps@scale needs a different value for DVItoPS and DVIPS
%        so moved initialization of it inside \setup@specials
% v2.2b 08-03-91 JLB The definitions of the \connect macro needed extra
%        \space commands, because its arguments can be control sequences.
% v2.2c 08-04-91 JLB Removed use of \cb@beginSaves and \cb@saveBeginPoint
%        because - it didn't work as specified
%                - seemed unnecessary
%                - broke PostScript support because of use of \xdef
%        \cb@processActive now calls \cb@setBeginPoint instead of 
%        \cb@saveBeginPoint. Left the code and comment in for now 
%        until I'm sure this change doesn't break anything else...
% v2.2d 30-4-91  EN  changed resolution dependent parameters in dvips 
%        specials so it will work on any device using the device's resolution.
%        Additionally added \newif\ifouterbars. \outerbarstrue will put 
%        the bars to the outside of the pages.
%        Without the twoside option this will give right hand side bars.
%        The positioning of right edge changebars was off by \changebarsep, 
%        this has been corrected also.
%        I do not know if there are changes needed in other than Tom Rokicki's 
%        drivers since this is the only one I can test.
% v2.2e 13-6-91  JB  The documentation stated that the greylevel of the 
%        changebar could be modified with the command 
%        \setcounter{\changebargrey}{percentage}.
%        This was a mistake, \changebargrey was allocated using \newcount 
%        (always). Now modified to use \newcount for plain TeX and 
%        \newcounter for LaTeX.
% v2.2f 15-10-91 JB  Added support for the emTeX drivers, based on
%        information from Eberhard Mattes about version 1.4j of the dvidrv
%        program. Also started updating the documentation towards doc.sty
%        standards.
% v2.3  15-10-91 JB  Started merging this version of changebar.sty with
%        version, dated 1988, distributed with DVItoLN03. This will eventually
%        result in version 3.0, hopefully documented using doc.sty.
%        Removed vain attempt to make file compatile with plain.
% v2.4  16-10-91 JB Reduced the number of points defined to two per
%        bar, removed the need for \cb@tempcnt while removing the problem
%        with incorrect changebars across pageboundaries in PostScript
%        mode. Also \ps@scale has been removed.
% v3.0  14-nov-91 JB Completed converting the documentation to doc.sty
%        format. Also solved the problem with bars appearing on the wrong
%        side.
% 
% v3.1  02-07-93 JB Finally got round to include Erich Neuwirth's comments
%       and made a new distribution. Erich corrected the placement of the
%       bars and the conversion of the coordinates when DVIps (Rokicki)
%       is used. Also included Hal Peterson's comments about spaces
%       creeping into the output.
% 
% v3.1b 11-10-93 Spurious white space crept into footnotes because of
%       a missing %-sign. Found by Norm Walsh <walsh@cs.umass.edu>.
%       Fixed.
%
% v3.2b 30-06-95 Finally got the LaTeX2e version working; see \changes
%       entries in the .dtx file to see what changed.
%       Changebar now uses the LaTeX option mechanism; so \driver 
%       disappeared.
%       New options are leftbars and rightbars, tracon and traceoff.
%
% v3.2c 26-03-96 Reintroduced the \driver command in compatibility
%       mode. Fixed the checksum.
%       Juergen Vollmer <vollmer@ipd.info.uni-karlsruhe.de> enhanced
%       the shell script which automatically adds changebar commands
%       to your document.
%
% v3.3a 26-09-97 Finally fixed the diagonal bars by (re-)introducing
%       four points for each bar (instead of two). Made it work with
%       LaTeX's twocolumn option. Fixed positioning problems.
%
% v3.3b 30-09-97 It turns out that the emTeX driver and dvips have
%       different ideas about their origin. Had to subtract 1 inch
%       from horizontal positions for emTeX drivers.
%
% v3.3d 28-10-97 It now turns out that Xdvi shows the changebars with
%       an offset of 1 inch; removed inappropriate pieces of code.
%
% v3.3e Added support for Textures (1.7.7), provided by James Ashton
%       <James.Ashton@keating.anu.edu.au>
%       Added chbar.1 to the distribution. The file was provided by
%       John A. Murdie <john@minster.cs.york.ac.uk>
%
% v3.3i Changebar didn't pay enough attention to the setting of
%       twoside. In onesided documents the value of \evensidemargin
%       should be ignored.
%       \cb@startSpanBars no longer pushes points on the current stack
%       as this confused the algorithm and was wrong anyway.
%       Introduced a tracing facility for the stack mechanisms
%       Now use the history stack to determine the final page on which
%       the beginning and ending of the changebars appear. This fixes
%       most problems with floating objects and diagonal bars at page
%       boundaries.
%       Redefined \cbstart and \cbend in terms of the LaTeX
%       environment. This catches wrong use of \cbstart ...\cbend with
%       respect to TeX's grouping levels. 
%
% v3.3j The rightbars option was broken; 
%       found by Richard Stanton" <stanton@haas.berkeley.edu>
%       In the oneside mode \cb@even@right received no value instead
%       \cb@even@left was set equal to \cb@odd@left and reset
%       afterwards.
%
% v3.4a Michael Vulis submitted the code for VTeX support
%
% v3.4b Changebar and the color package clash;
%       found by Erwin Achermann <acherman@inf.ethz.ch>
%       Because of the extra group and box level for floating objects. 
%       The redefinition in this package of \@endfloat didn't take
%       that into account.
%       repaired a few typos in the documentation.
%       Introduced support for coloured changebars with the dvips
%       driver.
%
% v3.4c small typo repaired
%
% v3.4d Autodetect VTeX and provide the right default driver;
%       added possibility of having changebar.cfg to specify a default
%       driver. 
%       Issue an error when \cbcolor is used when the color option
%       isn't specified.
%
% v3.4e Double column floats didn't carry a change bar because the
%       LaTeX macro \end@dblfloat wasn't adapted for changebar
%       Changebars in the first column appeared twice because of
%       an error in the conditional which decides where to put the 
%       bar.
%       The color error is now a warning.
%       Fixed a few typos.
%       Reverted the change in the definition of \cbstart and \cbend
%       as it prevented changebars starting inside an environment and
%       ending outside of it.
%
% v3.4f Fixed a problem with \changebarwidth; it seemed to become 
%       hardwired due to a bug in the stack handling. \cb@checkpage
%       effectively changed the value of \cb@curbarwd.
%
% v3.4g When the preamble of the document changes the value of the
%       page counter the code gets confused when the new page number
%       is even. Now initialize \cb@pagecount to \c@page - 1.
%       The mechanism with \cb@pagecount and \cb@page may need a
%       redesign to make it robust.
%
% v3.4h Herbert Voss (Herbert dot Voss at alumni dot TU-Berlin dot DE>
%       suggested to support the xcolor package as well as the color 
%       package.
%
% v3.5a Piet van Oostrum: Resolved bugs in twocolumn mode, mid-document
%       changes to page number, covering parts with large depth (like
%       formulas and parboxes), added pdflatex support.
%
% v3.5b JLB: added an extra check (after the call to \ProcessOptions
%       to ensure that pdftex.def is used when in pdf producing mode,
%       even when the document still contains the option "dvips"
%
% v3.5c JLB: Add a small change in the TeXtures specific code that 
%       was submitted by Blue Sky Systems; made it work with both the
%       color and xcolor packages.
%
% v3.6a Apostolos Syropoulus submitted support for XeTeX
%
% v3.6a JLB: a small change in the XeTeX macros
%
% v3.6b JLB: set changebarsep to 0.5\marginparsewp instead of 30pt 
%       in order to prevent the changebar crossing a marginal paragraph.
%
% v3.6c JLB: changed the definition of \cb@checkPDF in order to prevent 
%       an extra page at the end of the document, filled with "spsp"
%
% v3.6d JLB: Added \relax at the end of \openin statements in order to
%         prevent TeX from looking too far ahead.
%
% v3.7a JLB: Added support for LuaTeX based on the pdfTEX and XeTeX code
%
% v3.7b JLB: In creating the support for luaTeX a XeTeX error message got
%         inadvertantly remove, reinserted.
%         After adding those four lines the production of changebar.dtx
%         led to a runaway argument error. It turned out that the comma's, 
%         used in were in one instance replaced by \TeX-code. Replaced
%         the comma's with ";" to solve this.
%
% v3.7c JLB: Arash Esbati reported inconsistent spacing whit or without the
%        optional argumenty to \cbstart or \begin{changebar}.
%
% v3.7d JLB: Arash Esbati reported a simlar phenomenon when \nochangebars
%        is used. Similar solution was needed.
%
% v3.7e JLB: Daniel Flipo and Bruno Winckler reported that changebar no longer
%        works when \usepackage[french]{babel} is used. This was caused by the
%        solution implemented in v3.7b. This time use "/" is chosen as separator.
%
% Known problems
%        - changebars for marginal paragraphs collide with changebars
%          for the main body of text
%        - With PostScript a dictstack overflow seems to occur with
%          many changebars. cb@maxpoint=20 seems to help
%        - I have received the file chgbar.sty, which was written by
%          David B. Johnson (dbj@titan.rice.edu) back in 1990. It uses
%          LaTeX marginpar mechanism to implement change bars. I Haven't
%          yet dared to see if I can merge these two packages into one
%	 - When using \cbstart with an optional parameter that is different
%	   from \changebarwidth the distance between the text margin and
%	   the changebar will not be \changebarsep. Instead, the center of
%	   the changebar will be aligned with the other changebars. The
%	   solution to this would be to give an additional parameter to the
%	   \cb@connect macro to indicate if the bar is on the left or on the
%	   right. \cb@connect can then do the proper positioning. In that
%	   case it is easier not to include the 0.5\changebarwidth
%	   correction in the calculations in \cb@positions.
%	 - The syntax \cbcolor[rgb]{1,0,0} doesn't work with the xcolor option.
