[comp.text] Change bars in TeX/LaTeX?

doug@zaphod.prime.com (08/17/89)

I'm wondering if someone has a good general change bar mechanism for
TeX.  I wrote a simple one which works on a paragraph at a time
granularity (which is easy since the paragraph is a vbox and you can
combine it with a rule mark and a label trivially) but doing a better one
looks very hairy.  Already done?  

----------------------------------------------------------------------------
Douglas S. Rand
Internet:   doug@primerd.prime.com
Snail:	    Prime Computer, 500 Old Conn Path, MS10C-17, Framingham, Ma 01701
Disclaimer: PRIME and I agree sometimes, but that's just a coincidence

chris@mimsy.UUCP (Chris Torek) (08/19/89)

In article <33900004@zaphod> doug@zaphod.prime.com writes:
>I'm wondering if someone has a good general change bar mechanism for
>TeX.  I wrote a simple one which works on a paragraph at a time
>granularity (which is easy since the paragraph is a vbox and you can
>combine it with a rule mark and a label trivially) but doing a better one
>looks very hairy.  Already done?  

There is a fancy changebar style in the Clarkson archives, but it uses
ln03-specific `\special's to draw the bars.  If we ever get a standard
for \special, this style might become more useful.

On the other hand, I have never understood why people like changebars.
(They do point out which lines have changed.  So would inline markup.
The only advantage to changebars is that they can be masked away when
the document is photocopied; but when the document is typeset
electronically, inline markup could be deleted easily.  Moreover, the
inline markup would show which *words* have changed, rather than which
lines, and could include the old wording as well.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

sylvain@roxy.chorus.fr (Sylvain Langlois) (08/21/89)

In article <33900004@zaphod> doug@zaphod.prime.com writes:
>   I'm wondering if someone has a good general change bar mechanism for
>   TeX.

Try the following stuff (I didn't write it myself, it's coming from
the TeXhax mailing list, and I lost the original author's address, sorry)

\makeatletter
%
%   Change bars are accomplished using the 'changebar' environment.
%   The text inside will be typeset with change bars in the left margin,
%   e.g.,
%		Input		    Output
%	    \begin{changebar}	    ...
%	    Some text here.\\	 |  Some text here.
%	    More text.		 |  More text.
%	    \end{changebar}
%
%   The text is first typeset into a vbox. Then that box is split up using
%   the \vsplit operation.  Each box is placed onto the current page along
%   with a rule of the proper dimensions. 
%
%   The width of the change bar is determined from \changebarwidth.  The
%   default width is \arrayrulewidth.  The separation of the rule from the
%   left margin is controlled by \changebarsep.
%
%   Restrictions:
%
%   You can't put a float, such as a 'figure' or 'table' environment or a
%   footnote, inside a 'changebar', not even via \begin{figure}[h], etc.,
%   to force the float into the change bar area.  You could instead put a
%   'changebar' inside of a 'figure' or 'table' or footnote.
%
%   Nested 'changebar' environments are not supported.
%
%   \changebar ==
%   BEGIN
%	\par						% Start a new paragraph
%	\box\changebarbox :=		    % Save up text in a temporary vbox
%	    \vbox\bgroup
%	    \hsize=\textwidth		% Set the horizontal size in this box
%   END
%
%   \endchangebar ==
%   BEGIN
%	\egroup				    % Matching brace for temporary vbox
%	\begingroup				% Localize parameter changes
%	    \vbadness := \@Mi	    % Suppress "Underfull \vbox" from \vsplit
%	    \vfuzz := \maxdimen		% Suppress "Overfull \vbox" from \vsplit
%	    \splittopskip := 0pt	    % Don't insert glue after \vsplit
%	    \offinterlineskip			    % No space between rules
%	    \changebarsize ::= \dimen0
%	    \lostglue ::= \skip0
%	    \thislinebox ::= \box0
%	    \changebarsize := height + depth of \changebarbox
%	    WHILE \changebarsize > 0pt
%	    BEGIN
%		\lostglue := height + depth of \changebarbox
%	    	\box\thislinebox := \vsplit\changebarbox	% Take a chunk
%		\box\thislinebox := \vbox{\unvbox\thislinebox}	    % Reset size
%		\lostglue := \lostglue - (height + depth of \changebarbox)
%			% \lostglue is now the difference between the old &
%			% new box
%		\lostglue := \lostglue - (height + depth of \thislinebox)
%			% \lostglue is now as big as the glue lost to the
%			% \vsplit operation, i.e.,
%			% \lostglue + \thislinebox =
%			%	(old \changebarbox - new \changebarbox)
%		\vtop{				% Align rule with chunk of text
%		    \llap					% No-width rule
%			{\vtop to 0pt			    % Box up the rule(s)
%			    {\offinterlineskip		% No glue between rules
%			    \hrule to size of \thislinebox
%			    \hrule to size of \lostglue
%			}
%		    \hskip \changebarsep}
%		    }
%		\box\thislinebox			    % Put box on page
%		\endgroup
%	    END

\newif\ifdebug
\newdimen\changebarwidth \changebarwidth=\arrayrulewidth
\newskip\changebarsep \changebarsep=\parindent
\newcount\@cbp
\def\@cbpenalty{\ifvmode \mark{\Penalty \@cbp}\fi\Penalty\@cbp}
\def\changebar{\par
%    \let\Penalty=\penalty
%    \def\penalty{\afterassignment\@cbpenalty \@cbp=}%
\chardef\@changebarbox=0
\setbox\@changebarbox = \vbox\bgroup}
\def\endchangebar{\egroup
    \vbadness\@Mi			% Suppress "Underfull box" from \vsplit
    \vfuzz\maxdimen			% Suppress "Overfull box" from \vsplit
    \splittopskip = 0pt			    % Don't insert glue after \vsplit
    \dimendef\changebarsize = 0
    \skipdef\lostglue = 0
    \chardef\thislinebox = 1
    \ifdebug \showbox\@changebarbox \fi
    \changebarsize = \ht\@changebarbox		    % Initialize loop control
    \advance\changebarsize by\dp\@changebarbox
    \noindent \leavevmode\strut
    \offinterlineskip					% No space between rules
    \@whiledim \changebarsize > \z@ \do
	{\lostglue = \changebarsize			    % Save old box size
	\setbox\thislinebox = \vsplit\@changebarbox to 1sp	% Take a chunk
	\setbox\thislinebox = \vbox{\unvbox\thislinebox	    % Reset the box size
	}\ifdebug \showbox\thislinebox \fi
%	\splitfirstmark			% Any marks (penalties!) before line?
	\changebarsize = \ht\@changebarbox
	\advance\changebarsize by\dp\@changebarbox	% Compute remaining size
	\advance\lostglue by-\changebarsize	% Difference between old and new
	\advance\lostglue by-\ht\thislinebox
	\advance\lostglue by-\dp\thislinebox		% Glue lost to \vsplit
	\ifdim\lostglue < \z@ \lostglue = \z@ \fi		% No glue lost
	\ifdebug \showthe\lostglue \fi
	\hbox
	{\llap
	    {\vtop to \z@		% Prepare an invisible box for the rule
		{\hrule \@height\ht\thislinebox \@depth\dp\thislinebox
			\@width\changebarwidth			    % First rule
%		\ifdebug \hrule \@height\changebarwidth \@depth \z@
%			\@width 10pt			%%%% marker rule %%%%%
%		\fi
		\hrule \@depth\lostglue \@height\z@
			\@width\changebarwidth			% Second rule
	    \vss}\hskip\changebarsep		% Space between bar and text
	}\box\thislinebox			% Now put the chunk on the page
	}\vskip\lostglue			% and insert the missing glue
%	\splitbotmark			    % Any marks (penalties!) after line?
	}\ifdebug \showlists \fi
}
\makeatother



--
----------------
Sylvain Langlois		  "Dogmatic attachement to the supposed merits
(sylvain@chorus.fr)		   of a particular structure hinders the search
(sylvain%chorus.fr@uunet.uu.net)   of an appropriate structure" (Robert Fripp)