Tracking changes

I'm writing a thesis using latex. My supervisor asked me to make few changes so, after checking this site, I found several solutions to track them, and finally decided to use the changes package.

I sent him my document with more than 100 changes. He approved almost all them, and then he suggested several new ones.... and asked me to send a new document with ONLY the new changes.

I know that using changes package I can use 'final' option to disable markup of changes, but my latex code still has all the \added{} \replaced{}{} and \deleted{}, so my question is:

Is there any easy way to hide changes from revision 1, and show new ones I'll add now?

EDIT: As suggested, I'm adding an example that shows what I've, and another one of what I'm looking for.

This is what my first revised text may look like:

\documentclass{article}

\usepackage{changes}
% Example of what first revision may be

\begin{document}

This is \deleted{unnecessary}text.

\end{document}


And this is what my second revised text I want to look like (of course, I don't want to manually remove the \added, \deleted, \replaced commands, just want the changes package to ignore them)

\documentclass{article}

\usepackage{changes}
% Example of what second revision should look like

\begin{document}

This is new text.

This is text.

This is nice text.

\added{This should be seen as a change in revision 2 of document}

\end{document}


So, if you compile both documents, you'll see what I want to achieve, but, obviously, without having to manually remove the \added, \deleted, \replaced commands.

I'm using Miktex+Texmaker (windows port), and it defaults to pdflatex to compile.

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. You might also want to add to your question how you're including the pdfs etc. – Aradnix Sep 8 '14 at 15:07
• Problem is I know I can hide revision markups passing the 'final' option to the changes package, but I have no idea on how to make it "locally" to specific changes. My only 'hope' is I can mark changes as different authors, and that there is a chance to hide/show changes by 'author name'.... – Ishmar Sep 8 '14 at 15:24
• Doing this manually will quickly become a nightmare. I suggest you look into learning how to use a version control system like git or mercurial and then find a way to use latexdiff or similar. – Seamus Sep 8 '14 at 15:35
• Fact is I DO have everything in a git repo, but since it didn't seem easy to install latexdiff on windows, I decided to use the changes package, although even if I don't want, guess my best bet will beto remove all changes commands written so far and use latexdiff as suggested :( That's why I'm asking, I don't want to do that if I can avoid it. Guess there will be only one or two more revisions to text, and they will have to be done this week – Ishmar Sep 8 '14 at 15:40
• Consider writing an awk (or perl or python) script to expand those three macros in your source. Then just go ahead with new changes. – Ethan Bolker Sep 8 '14 at 15:45

Replace each instance of \added with \xadded in your source file. Define \xadded appropriately. Do the same for the other two change commands. You can do that with awk (as below) or with search and replace in your favorite editor.

version1.tex:

\documentclass{article}

\usepackage{changes}
% Example of what first revision may be

\newcommand{\xdeleted}[1]{}
\newcommand{\xreplaced}[2]{#1}

\begin{document}

\emph{embedded} \TeX{} on more than one line.}

This is \deleted{unnecessary}text.

\end{document}


version2.tex, after replacement:

\documentclass{article}

\usepackage{changes}
% Example of what first revision may be

\newcommand{\xdeleted}[1]{}
\newcommand{\xreplaced}[2]{#1}

\begin{document}

\emph{embedded} \TeX{} on more than one line.}

This is \xdeleted{unnecessary}text.

\end{document}


The script I used:

#!/usr/bin/awk
# Rename a few TeX macros
#
{
gsub(/\\added/,"\\xadded",$0); gsub(/\\deleted/,"\\xdeleted",$0);
gsub(/\\replaced/,"\\xreplaced",$0); print }  Leaving my original awkward partial solution for a little while. Here's the start of awk program to expand the three macros. #!/usr/bin/awk # Expand a few TeX macros # # delete the macro name # leaving the parentheses doesn't hurt /\\added/ { sub(/\\added/,"",$0)
}

# delete the macro name and its argument
/\\deleted/ {
sub(/\\deleted.*\}/,"",$0) } # should delete the macro name and its SECOND argument /\\replaced/ { sub(/\\replaced/,"",$0)
}
{print}


Calling the OP's input file expandsome.tex, the command

 \$ awk -f expand.awk < expandsome.tex > expanded.tex


produces

documentclass{article}

\usepackage{changes}
% Example of what first revision may be

\begin{document}

This is {new} text.

This is text.

\end{document}


I haven't yet figured out the regular expression syntax for deleting the second argument to \replace. I have no time now. If someone wants to contribute then I won't have to find the time tomorrow or the day after ...

This is not a robust solution. If a change spreads over more than one line it will fail. It will also fail for multiple similar changes on any single line.

Can you use Vim the text editor?

How to remove \added

Type the following in normal mode: (Notice: instead of typing <esc> and <enter>, press the actual keys esc and enter on the keyboard.)

<esc>qa/\\added\><enter>dt{yi{da{"0P<esc>q
1000@a


The first line records and stores a macro into register a that finds, and replaces, a single \added{...} with ... — even if ... contains nested groupings itself — For instance, \added{123\emph{foo}456} becomes 123\emph{foo}456.

The second line executes that macro 1000 times.

How to remove \deleted

<esc>qb/\\deleted\><enter>dt{da{<esc>q
1000@b


The first line records and stores a macro into register b that finds, and removes, a single \deleted{...{...}...}.

The second line executes b 1000 times.

How to remove \replaced

<esc>qc/\\replaced\><enter>dt{yi{da{da{"0P<esc>q
1000@c


etc. etc.

The difficulty with perl or awk scripts is, as far as I know, to find a reliable way to parse nested TeX groupings.

As someone mentioned, tracking changes with the change package is not the way to go if you have to track the changes more than once.

If I were you, I'd invest the time to learn and set up git, the cvs. You don't need to know much about it, just the most basic commands (git add, git commit, what else?).

Then you have to delete the commands you used for marking the changes: \add, \changed and \deleted probably.

After that check in this as first version. To get a comparison between any of the versions you checked in using git, use latexbatchdiff, see here: https://tex.stackexchange.com/a/44092/4736 .