[comp.text.tex] Partial solution to diff mark query

epstein@trwacs.UUCP (Jeremy Epstein) (02/02/91)

Since several people asked me for results of my query, here it is.

A few days ago I asked:
	I'm looking for a tool to automatically generate change bars
	in LaTeX documents.  Essentially what I need is the "diffmk"
	utility, except using LaTeX commands rather than troff.

	Alternately, if someone can tell me what TeX or LaTeX commands
	can be used to generate change bars, I'll modify diffmk myself
	and distribute the results.

The best solution I've found so far is to install the changebar style
from David B. Johnson (dbj@titan.rice.edu).  Then use the difftex
shell script (a modification of diffmk) to insert the change bar commands
automatically (copy at the end of this message).  The script automatically
puts in change bars for anything added or changed, and puts little arrows
to mark where stuff has been deleted.  Note that it's line sensitive,
not word sensitive, so the change bars are approximate.

The change bars look beautiful.  The problem is that the change bar
environment seems rather shaky.  Not being a LaTeX guru, I can't say
what the problem is, but one of my large documents (100 pages) gets
the following error at the very end:

! Float(s) lost.
\@latexerr ...for immediate help.}\errmessage {#1}

\@doclearpage ... \@latexerr {Float(s) lost}\@ehb
                                                  \gdef \@currlist {}\fi \@m...

\@specialoutput ...penalty > -\@Mii \@doclearpage
                                                  \else \ifnum \outputpenalt...
<output> ... \outputpenalty <-\@M \@specialoutput
                                                  \else \@makecol \@opcol \@...

\clearpage ...rite \m@ne {}\vbox {}\penalty -\@Mi

\enddocument ->\@checkend {document}\clearpage
                                               \begingroup \if@filesw \immed...

\end #1->\csname end#1\endcsname
                                 \if@endpe \global \let \@gtempa \@doendpe \...
l.39 \end{document}

All of the change bars seem properly set, but part of the last page
of the document is missing.  The LaTeX manual provides very little
comfort in debugging this error.

Anyway, thanks to everyone who supplied suggestions, and especially
thanks to Michael Ernst (mernst@theory.lcs.mit.edu) for the changebar
style.

--Jeremy


#! /bin/sh
#
# difftex: derived from diffmk.  Given two input LaTeX files
# (oldfile and newfile), generates a third file (markfile)
# which is a version of newfile with change bars.  Any deleted
# lines are marked with a left arrow.
#
# Be sure that you have [changebar] in your \documentstyle
# after running this script.
#
#	@(#)diffmk.sh 1.4 88/02/08 SMI; from S5R2 1.2
#
PATH=/bin:/usr/bin
if test -z "$3" -o "$3" = "$1" -o "$3" = "$2"; then
	echo "usage: difftex oldfile newfile markfile -- markfile must be different"
	exit 1
fi
diff -e $1 $2 | (sed -n -e '
/[ac]$/{
	p
	a\
\\chgbarbegin
: loop
	n
	/^\.$/b done1
	p
	b loop
: done1
	a\
\\chgbarend\
.
	b
}

/d$/{
	s/d/c/p
	a\
\\marginpar{$\\Leftarrow$}\
.
	b
}'; echo '1,$p') | ed - $1 >$3

echo "Reminder: make sure you have 'changebar' in your style list"
exit 0
-- 
Jeremy Epstein			UUCP: uunet!trwacs!epstein
Trusted X Research Group	Internet: epstein@trwacs.fp.trw.com
TRW Systems Division		Voice: +1 703/876-8776
Fairfax Virginia