Borys Bradel's Blog

Indicating changed text in latex with change bars

Tags: latex March 28, 2010    

Sometimes, the changes that are made to a document need to be indicated or highlighted in some way. The easiest way to achieve this goal in latex is to indicate text in different colours, strike out deleted text, and add change bars. The three packages that allow these three actions are the color, ulem, and changebar packages respectively. The ulem and changebar packages were already on my system. The color package can be installed in Ubuntu via the latex-xcolor package in Ubuntu's package manager.

The color package has the color command, the ulem package has the sout command, and the changebar package has the cbstart and cbend commands.

The colour management in the changebar package did not work for me, so I use my own commands that add colours along with change bars.

The following are the lines I have at the beginning of my latex document:

\usepackage{color}

\usepackage[]{changebar}

\usepackage[normalem]{ulem}

\newcommand{\cmstart}{\cbstart \color{red}}

\newcommand{\cmend}{\cbend \color{black}}

\newcommand{\cblue}{\color{blue}}

\newcommand{\cred}{\color{red}}

\newcommand{\cblack}{\color{black}}

The ulem package redefines the em command. Since I wanted the normal way of showing emphasis via em, I added the appropriate parameter.

Footnotes need to have the change bars added to them separately.

To display change bars in margins of dvi files I found that I needed to add the following command:

\setlength{\changebarsep}{3cm}

However, that leads to no change bars in the margin of the produced pdf file. Therefore, when generating the final pdf, the setlength command needs to be commented out or deleted.

Also, the changebar package does not work very well across page boundaries. In particular, if the change bars start and end outside of paragraphs that span multiple pages, the pdf generation crashes. The easiest solution that I found is to start and the change bars within the paragraphs.

The following example illustrates the usage of the various commands.

The original two nonsensical paragraphs:

This sentence is a really, really, really strange sentence that is here for testing purposes. First, that is this and maybe that. The test is now complete.

Another paragraph. Another really, really, really strange sentence.

The edited paragraphs with some text added and removed, the first round of edits in red and the second in blue:

\cred \cmstart \sout{This sentence is a really, really, really strange sentence that is here for testing purposes.} The first point is \sout{First,} that is this and maybe that. The test is now \cmend \cred complete. \cblack

Another paragraph. Another \cmstart \sout{really, really, really} \cblue very \cred \cmend strange sentence.

Copyright © 2010 Borys Bradel. All rights reserved. This post is only my possibly incorrect opinion.

Previous Next