7

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 \added{new} text.

This is \deleted{unnecessary}text.

This is \replaced{nice}{bad} 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.

Thanks in advance

8
  • 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
    Commented Sep 8, 2014 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
    Commented Sep 8, 2014 at 15:24
  • 5
    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
    Commented Sep 8, 2014 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
    Commented Sep 8, 2014 at 15:40
  • 1
    Consider writing an awk (or perl or python) script to expand those three macros in your source. Then just go ahead with new changes. Commented Sep 8, 2014 at 15:45

5 Answers 5

5

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{\xadded}[1]{#1}
\newcommand{\xdeleted}[1]{}
\newcommand{\xreplaced}[2]{#1}

\begin{document}

This is \added{new} text. This is more \added{new text with
\emph{embedded} \TeX{} on more than one line.}

This is \deleted{unnecessary}text.

This is \replaced{nice}{bad} text. 

\end{document}

version2.tex, after replacement:

\documentclass{article}

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

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

\begin{document}

This is \xadded{new} text. This is more \xadded{new text with
\emph{embedded} \TeX{} on more than one line.}

This is \xdeleted{unnecessary}text.

This is \xreplaced{nice}{bad} 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.

This is {nice}{bad} 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.

2

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.

0

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 .

0

@ishmar I know you specifically asked for the changes package but I have to do it often when working with my professor for a camera-ready paper. Here's my way to do it in case you find it useful too especially when you just looked at the pdf, read changes and then click on the pdf to go to the exact latex page and edit it on Overleaf:

Required Command and Packages

\usepackage{xcolor}
\usepackage{soul}
\newcommand{\newtext}[1]{\textcolor{green!50!black}{#1}}
\newcommand{\removedtext}[1]{\textcolor{red!50!black}{\st{#1}}} 

Your Text

How to keep track changes in Latex\\
\newtext{This is newly added text} and \removedtext{This one is old}.\\
This is very \removedtext{helpful}\newtext{useful}.

Output

How to keep track changes in Latex

0

I think instead of hiding previous changes, you should accept the approved changes and create a new file containing the changes. Then add new changes as usual in this newer version of file.

For this changes package provides a bash script named delcmdchanges located at <texpath>/scripts/changes/, where <texpath> is the installation path of texlive in your system usually /usr/share/texlive/texmf-dist. Run this script interactively with -i option to accept all approved changes.

delcmdchanges.bash [options] <inputfile> <outputfile>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .