4

Im trying to create a short list of changes for a document from one revision to another. and only want to show the redlines on a set string. i.e.

OLD String: I when to the zoo yesterday

NEW String: I went to the zoo today.

Diff string: I wentwhen to the zoo yesterdaytoday.

1

2 Answers 2

8

LyX can make exactly that:

MWE

However, the changes are stored in their own file format (.lyx) but not in the exported LaTeX (.tex) source or the PDF.

For a pure LaTeX solution or see the changes in the PDF, you can use the package changes:

\documentclass{article}
\usepackage{changes}
\begin{document}

I \added{went}\deleted{when} to the zoo \added{today}\deleted{yesterday}

\end{document}

MWE2

If you want the final PDF version, simply load the package with the final option:

\usepackage[final]{changes}

But also can do something more: MWE3

\documentclass{article}
\usepackage{changes}
\definechangesauthor[name={me}, color=magenta]{Fran}
\definechangesauthor[name={you}, color=red]{you}
\begin{document}
I \added[id=Fran]{went}\deleted[id=Fran]{when} to the zoo 
\added[id=Fran]{today}\deleted[id=you]{yesterday}
\listofchanges
\end{document}

See changes on CTAN for more options.

Another solution:

1) old.tex:

\documentclass{article}
\begin{document}
I when to the zoo yesterday
\end{document}

2) new.tex:

\documentclass{article}
\begin{document}
I went to the zoo today
\end{document}

3) In the terminal:

texdiff old.tex new.tex diff.tex

4) Edit diff.tex: Add manually some preamble to define \TLSins and \TSLdel (otherwise you cannot compile the file). The result must be something like:

\documentclass{article}
\usepackage{xcolor}
\colorlet{ins}{blue} 
\colorlet{del}{red}
\usepackage{ulem}
\newcommand\TLSins[1]{\cbstart{}\textcolor{ins}{\uline{#1}}\cbend{}}
\newcommand\TLSdel[1]{\cbdelete{}\textcolor{del}{\sout{#1}}}
\begin{document}
I \protect\TLSdel{when} \protect\TLSins{went} to the zoo \protect\TLSdel{yesterday} \protect\TLSins{today}
\end{document}

MWE4

3

You can also try the latexdiff package.

Basically, it is a diff script that you execute

latexdiff new.tex old.tex > diff.tex

and then you can compile the diff.tex and check the differences.

% new.tex
\documentclass{article}
\begin{document}
I went to the zoo today.
\end{document}

% old.tex
\documentclass{article}
\begin{document}
I when to the zoo yesterday
\end{document}

and the script produces

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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