🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #624

Re: Change bars in TeX/LaTeX?

#624
From: Sylvain Langlois
Date: Mon, 21 Aug 1989 14:38
142 lines
6178 bytes
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)
Technical Details
Message-ID: <SYLVAIN.89Aug21163831@roxy.chorus.fr>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!inria!chorus!sylvain
References: <33900004@zaphod>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!inria!chorus!sylvain
From: sylvain@roxy.chorus.fr (Sylvain Langlois)
Newsgroups: comp.text
Subject: Re: Change bars in TeX/LaTeX?
Message-ID: <SYLVAIN.89Aug21163831@roxy.chorus.fr>
Date: 21 Aug 89 14:38:31 GMT
References: <33900004@zaphod>
Sender: news@chorus.fr
Organization: Chorus Systemes, Saint-Quentin-En-Yvelines, France
Lines: 142
In-reply-to: doug@zaphod.prime.com's message of 16 Aug 89 18:09:00 GMT