3

I am working on a long document. Those reviewing it only want to read the changes, not the entire (multi-hundred page) document over again whenever I make edits. It would be much easier if I didn't have to manually place and remove {color{red} ... } blocks to mark the edits, not to mention much easier to remove the colors later. I would obviously need to be able to set a start point and have all changes from then tracked, not just on a save-by-save basis, as each revision would need to be compiled repeatedly during the process. Is there a way to do this?

3
  • 2
    have you considered using a version control system, such as git? Such software allows for easy viewing of they types of changes you describe, and more :)
    – cmhughes
    Dec 29, 2014 at 22:20
  • 1
    Can't upvote the suggestion of version control enough. Examples: what did I change on November 14? and what sets of changes have I ever done? Dec 30, 2014 at 3:12
  • How would I use git for this? As far as I know git is for versioning software repositories, and doesn't have a way to do this kind of edit highlighting. Also I'm on windows.
    – Elliot
    Jan 5, 2015 at 21:48

6 Answers 6

3

Found a script called LatexDiff that will compare two latex documents and create a 3rd showing the differences between them. Not quite automated but better than doing it manually. It is a bit tricky to get working, though.

1
3

Have you checked out meld? It can easily compare up to three verions of a file and show the differences between them. The files are editable in meld itself, so you can compare, reverse changes or copy them over. There also seems to be a version control view, but I haven´t tried it yet.

This is Meld´s interface

compare up to three files

3
  • 1
    Seems a nice tool. Could you please add a little description to your answer and a link to the meld site? Mar 6, 2015 at 4:52
  • 1
    I´ve added an other screenshot. Just click on the word "meld" and it will lead you to the download page. Hope this helps. Mar 7, 2015 at 14:09
  • Thank you. I'm sure your answer will be useful for many users. Mar 7, 2015 at 15:29
2

A bit of self promotion: my commenting package may be relevant to your needs. It does not offer automation in the sense that you still need to mark your changes using macros. However it allows you to mark changes / put comments per-author and has a simple interface to specify dates and exclude comments/marks before/after a certain date.

An example of usage:

\documentclass[draft]{article}

\usepackage{commenting}

\declareauthor{joe}{Joseph}{blue}
\declareauthor{pete}{Peter}{red}
\declareauthor{bob}{Robert}{green}

\setdefaultauthor{joe} % if no author is specified, joe is used

\authorcommand{joe}{comment} % define \joe as alias of \comment[joe]

\onlyauthors{default,joe,pete} % exclude comments from bob

% Display only comments dated between 08/01 and 15/01
\NoCommentsBefore{08/01}
\NoCommentsAfter{15/01}
% \IncludeNonDatedComments % default behaviour

\newcommand{\lipsum}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}

\begin{document}
\lipsum{}
\comment{I am joe}% comment by default author, not dated
\lipsum{}
\changed[pete](10/01){\lipsum}% this change is dated
\comment[bob]{This is awful}
\comment[joe]{Bla bla}
\lipsum{}
\changed[joe][Bob please check]{\lipsum}
\lipsum{}
\comment[joe]{Add comment on lipsum}
\lipsum{}
\annot[pete]{Add reference?}
\lipsum{}
\joe(16/01){I think this paragraph is unnecessary}% will be filtered out because outside date bounds
\lipsum{}
\annot[pete](12/01){Citation needed}
\lipsum{}
\end{document}

From which you can obtain

preview

And by just removing the draft option you obtain

no draft preview

1

git is clearly the best option. If you're reluctant to get there, why don't you at least define commands? Something along the lines of:

\newcommand{\changes1215}[1]{\color{red}#1}

Then, for today's changes:

\newcommand{\changes1215}[1]{#1}
\newcommand{\changes1230}[1]{\color{red}#1}

That way you don't have to track down the previous changes at least, ans you can even do some kind of (very degraded) versioning.

2
  • As far as I know, \newcommand{\changes1215}{...}\newcommand{\changes1230}{...} shouldn't work... Does \newcommand do something fancy here? Jan 15, 2015 at 22:13
  • no, it doesn't, and that doesn't work; just something stupid I wrote (another one, I mean). Though the idea is there, whether using letters instead of numbers, or with a \def\afterDate{141215}\newcommand{\changes}[2]{\ifnum#1>\afterDate\textcolor{red}{#2}\fi#2} which should do the trick, no?
    – luneart
    Jan 16, 2015 at 8:57
0

As others said before: I think you need to use a version control tool, and highly recommend git, which also works on Windows.

To generate a document with marked changes (to any prior version), I use the awesome scm-latexdiff tool. This might be a bit tricky to install on Windows, but should work nonetheless, since it's Python-based.

To do so, I record my changes with the version control tool (either git or Mercurial) and use scm-latexdiff to generate a PDF showing the changes with one simple command.

The image below shows the result of running

scm-latexdiff 123456:document.tex

on one of my recent documents (obvisously the command was run with a real git hash and another document name :) ).

Screenshot of diff.pdf-Document

And the best thing: this works for any editor and helps with selecting differences to any arbitray timepoint in the past, as long as you commited a version of your document at that point.

0

Here is how. With the following R script, you don't need to manually work with LatexDiff anymore. Everything fully automated:

Step 1: Install strawberry Perl

Step 2: Download latexdiff from CTAN (the zip file)

Step 3: Unzip the latexdiff files and copy them to the strawberry\Perl\bin folder (wherever you installed strawberry)

Step 4: use the following r script (only works in windows for now, but can easily be changed for mac) and open it in R. set the directory of your files, as well as the file names, and run entire script. This should generate a pdf called “difference_highlighted.pdf”

#set folder and files
folder = "yourfoldername"
newfile = "new.tex"
oldfile = "old.tex"

#execute
setwd(folder)
system(paste("cmd.exe /c \"latexdiff ", oldfile," ", newfile,  " > 
difference_highlighted.tex\"" , sep = ""), intern =TRUE)
system(paste("cmd.exe /c \"pdflatex difference_highlighted.tex\""))
system(paste("cmd.exe /c \"bibtex difference_highlighted\""))
system(paste("cmd.exe /c \"pdflatex difference_highlighted.tex\""))
system(paste("cmd.exe /c \"pdflatex difference_highlighted.tex\""))
0

You must log in to answer this question.

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