Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a TeX file that I'm editing with several collaborators and we use environments to highlight and discuss proposed changes like the following:

Some text.

\begin{old}
  Text that I propose to remove.
  Which may be more text than fits on a single line

  and even include paragraph breaks.
\end{old}

\begin{new}
  Text that I propose to insert.
\end{new}

Currently, the old/new envs just set a text color, which is fine on screen but less so on a b/w printer. I'd like to use strikethrough/underline as well (like a well-known word processor), is this possible with TeX?

I've experimented with the ulem and soul packages, but they don't seem to work well with environments:

\newenvironment{old}{\ul \bgroup}{\egroup}

and related attempts don't seem to work or produce errors like "missing number". The other method I know of to make commands work in environments

\newsavebox{\oldbox}
\newenvironment{old}{\begin{lrbox}{\oldbox}}{\end{lrbox}\ul{\usebox{\oldbox}}}

doesn't seem to work either.

Is there a way to get the effect that I want? My system is Ubuntu "This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)" if that helps.

share|improve this question
    
Related Question: Changbars to indicate location of conditional text. Should be able to modify this solution to work with multiple authors. –  Peter Grill Jul 26 '12 at 17:43
add comment

1 Answer

up vote 5 down vote accepted

1. Packages
At CTAN, you will find several packages that offer some sort of ‘mark changes’. Mark up changes is in my opinion one of the few places where traditional text processor like LibreOffice Writer, AbiWord or MSWord have an advantage over Latex and a text editor. Marking changes in Latex source clutter the text and make it less readable (you have to compile to read the text). Also, when you are finished, you have to clean up the final source, removing all mark up, more or less by hand.

If you want to go the Latex way, one package you can try is changes, which seems pretty advances. You have the possibility to define different authors, so that each remark can be referred to a user. You can also load the package with the option nocolor, so that deleted text are striked out and added text are underlined:

\usepackage[nocolor]{changes}

One severe limitation is that you cannot mark up multiple paragraph within the same environment.

Since you are on Linux, you can run the included bash-script to remove all changes to clean up. Still, mark up changes in Latex is a lot of work.

Another package is changebar. It marks changes by bars in the margin, so it does not fulfil your requirements fully. On the other hand, you can mark up several paragraph in one environment, and changes may be nested.

Since you are running Linux, you may also try latexdiff. Since I am running Windows, which do not have a Perl installed, I have never used it, but according to its introduction on CTAN:

Latexdiff is a Perl script for visual mark up and revision of significant differences between two latex files. Various options are available for visual markup using standard latex packages such as color. Changes not directly affecting visible text, for example in formatting commands, are still marked in the latex source. A rudimentary revision facility is provided by another Perl script, latexrevise, which accepts or rejects all changes. Manual editing of the difference file can be used to override this default behaviour and accept or reject selected changes only.

Program like WinMerge and similar utilities to compare text document, have also a lot to offer when comparing two source files. You have even utilities that can compare more than two files. The best effect you will have if you compare clean source files, and if you terminates each line with a hard line breaks. In WinMerge, you can copy lines from the left window to the right, and the changes show on a print out.

My favourite is DiffPDF, where I compile the (clean) original source file and the revised one (without marked changes) and compare the PDF-files. A limitation is of course that it is difficult to compare more than two files.

In my opinion, none of the existing solution for Latex will fully satisfy a work group’s requirements. If you are working mainly with text (not figures and tables), may be a better work flow will be to use one of the free text processors for the first, rough draft, and when the document is near finished, convert it to Latex for the final touch up.

UPDATE: In this question Werner is linking to the packages TrackChanges, which, according to the auhtor is:

... is a package for collaboratively editing LaTeX documents. It allows multiple editors to make changes and add annotations to a document. These changes and notes will be color coded by editor and added to the compiled document. The TrackChanges GUI allows the author to quickly find and accept, reject or modify the suggested edits.

It is licences under GPL 2.0. I have never used it, but maybe it is worth a try.

2. Direct use of soul

Based on Bristol’s last comment, I made a minimal example using the soul directly (or more precisely, Heiko Oberdiek’s extended soulutf8.

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures = TeX]{TeX Gyre Pagella}
\usepackage{soulutf8}


\begin{document}

\section{Test}

\ul{This is new text to demonstrate the possibilities inside the soul package. \emph{Someone} told me that you cannot use the package to mark several paragraphs.

But multiple paragraph seems to work OK. You can even emphasize words to be underlined.}.\st{Here is som old old text that I have deleted. Is should not be read.

Also underlining seems to work even if we mark up several \emph{paragraphs}.You can even emphasize words to be striked out.}

\end{document}

The MWE compiled fine on my system (but not with the standalone documentclass),test of soul. Maybe I have misunderstood what is Bristol’s problem with the soul-package.

soul markup cannot be nested (you cannot mark others markup for deletion using the command \st. That limits its usefulness as a mark changes-package.

share|improve this answer
1  
Could you add some detail as to how to do this with these packages, what their respective benefits are, optimally with a bit of code and a picture each? Just pointing to CTAN and a couple of packages is really thin for an answer (cf. the comments to Flagging "not an answer"). –  doncherry Jul 26 '12 at 13:06
    
I'm currently experimenting with "changes", thanks for the reference. Unfortunately, while \deleted{text} works (strikethrough as expected), \newenvironment{old}{\deleted\bgroup}{\egroup} does not - changes text colour but doesn't strike it through. –  Bristol Jul 26 '12 at 15:47
    
Admittedly I have not used the specific packages mentioned here, but I don't think it should be necessary to manually remove the changes. It should be possible to just redefine the environments to no longer show/highlight the deleted/marked up text. @Bristol: Once you have settled on a working solution, you might want to consider asking a separate question on how to automate this process if desired. –  Peter Grill Jul 26 '12 at 17:47
    
@PeterGrill Yes, I agree that it is not strictly necessary to remove the mark up, but your source file will be very cluttered and difficult to reuse, when it is full of mark up. –  Sveinung Jul 26 '12 at 18:20
    
Ok, so first of all thanks for the references to diff etc. but that's not really what I'm looking for. I need a solution so I can propose a change (i.e. leave both the old and new versions in with suitable markup), compile the PDF and print out a copy for someone to read through "offline". So far, I've had no luck getting underline/strikethrough to work at the paragraph level, either with soul/ulem directly or with the changes package that builds on them. I'm starting to wonder if a paragraph-level underline command is even possible in TeX? –  Bristol Jul 30 '12 at 8:33
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.