🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #6249

Re: Change/Side Bars in TeX/LaTeX wanted

#6249
From: Brian T. Schellenberger
Date: Thu, 27 Apr 1989 17:38
144 lines
6322 bytes
Changebars are lines on the side of the page to indicate that given
text has changed since the last revision of a docuemnt.

And I have EMailed this to many people; it is a common request, so I'm 
going to *post* it this time; please copy if if you are going to want it
someday!

This is not original with me; I got it at the TUG conference a couple of
years ago.  I've never used it myself, so no guarantees.  It seems to be
designed for LaTeX, but if you actually use plain TeX, you are presumably
enough of a TeXpert to make the necessary adaptions.


\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
-- 
-- Brian, the Man from Babble-on.		...!mcnc!rti!sas!bts
--
"Every jumbled pile of person has a thinking part that wonders what the part
that isn't thinking isn't thinking of" -- THEY MIGHT BE GIANTS
Technical Details
Message-ID: <1012@sas.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!xanth!mcnc!rti!sas!bts
References: <11939@grebyn.COM> <8550@polya.Stanford.EDU> <8551@polya.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!xanth!mcnc!rti!sas!bts
From: bts@sas.UUCP (Brian T. Schellenberger)
Newsgroups: comp.text
Subject: Re: Change/Side Bars in TeX/LaTeX wanted
Message-ID: <1012@sas.UUCP>
Date: 27 Apr 89 17:38:46 GMT
References: <11939@grebyn.COM> <8550@polya.Stanford.EDU> <8551@polya.Stanford.EDU>
Reply-To: bts@sas.UUCP (Brian T. Schellenberger)
Organization: SAS Institute Inc, Cary NC
Lines: 144