# Using latexdiff to generate changebars for graphics inside figures

I am trying to utilize latexdiff to highlight the changes between different version of a document. One thing that I have run into is that sometimes graphics in figures change. Obviously, latexdiff can't tell if two images with the same filename are different, so I resorted to just renaming the files. What I've noticed though is that, although latexdiff generates the diff markup inside the figure environment, I don't see any output margin bar next to it.

I tried manipulating the FLOATSAFE/TRADITIONALSAFE/IDENTICAL configuration options - TRADITIONALSAFE had no change, and IDENTICAL just broke the compilation step (not surprising). The following is an MWE:

Given the two tex files:

a.tex

\documentclass[11pt]{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\includegraphics[scale=0.1]{a}
\caption{Figure A}
\label{fig:a}
\end{figure}

\end{document}


b.tex

\documentclass[11pt]{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\includegraphics[scale=0.1]{b}
\caption{Figure B}
\label{fig:b}
\end{figure}

\end{document}


And using command:

latexdiff -t CHANGEBAR a.tex b.tex >diff.tex

I get:

diff.tex:

\begin{document}

\begin{figure}
\centering
\DIFdelbeginFL %DIFDELCMD < \includegraphics[scale=0.1]{a}
%DIFDELCMD <     %%%
\DIFdelbeginFL %DIFDELCMD < \label{fig:a}
%DIFDELCMD < %%%

\end{document}


I'm wondering if anyone has come up with a decent workaround. Ideally, the whole figure would have a changebar - I don't really care if it's the caption or the picture that changed, just that the figure somehow changed.

• Your a.tex is identical with your b.tex (I presume a copy/paste error) - even though it is obvious what you mean you might edit your question – frederik Jun 16 '15 at 14:30

You can use the changebar package but need to change the \DIFaddbegin/end and \DIFaddbegin/end commands rather than \DIFadd/del as is done by the -t option.

%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF
\RequirePackage[pdftex]{changebar} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{\protect\cbdelete} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF IDENTICAL PREAMBLE %DIF PREAMBLE

I obtained this by running latexdiff -f IDENTICAL --show-preamble and then editing the middle block by hand. Use --preamble / -p option to read in this preamble. If you like to use the changebars only in figures (really floating environments, also including tables), change the \DIFaddbeginFL etc. commands instead