I would like to use latexdiff on a document where I have changed the label of my figures. Is there a way to ignore changes of the commands ref
and label
? Here is an example:
old_version.tex
\documentclass{article}
\begin{document}
\begin{figure}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\ref{fig:my_label}
\end{document}
new_version.tex
\documentclass{article}
\begin{document}
\begin{figure}
\caption{Caption}
\label{fig:my_new_label}
\end{figure}
\ref{fig:my_new_label}
\end{document}
In both cases, \ref{...}
prints 1
, i.e., there is no change in the output. Can I configure latexdiff to reflect this?
I tried latexdiff --exclude-textcmd="ref" old_version.tex new_version.tex
and it still highlights the changed label as a change:
\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old_version.tex Sun Jan 5 05:57:46 2020
%DIF ADD new_version.tex Sun Jan 5 05:58:01 2020
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%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{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
\providecommand{\DIFmodbegin}{} %DIF PREAMBLE
\providecommand{\DIFmodend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF LISTINGS PREAMBLE %DIF PREAMBLE
\RequirePackage{listings} %DIF PREAMBLE
\RequirePackage{color} %DIF PREAMBLE
\lstdefinelanguage{DIFcode}{ %DIF PREAMBLE
%DIF DIFCODE_UNDERLINE %DIF PREAMBLE
moredelim=[il][\color{red}\sout]{\%DIF\ <\ }, %DIF PREAMBLE
moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ } %DIF PREAMBLE
} %DIF PREAMBLE
\lstdefinestyle{DIFverbatimstyle}{ %DIF PREAMBLE
language=DIFcode, %DIF PREAMBLE
basicstyle=\ttfamily, %DIF PREAMBLE
columns=fullflexible, %DIF PREAMBLE
keepspaces=true %DIF PREAMBLE
} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF
\begin{document}
\begin{figure}
\caption{Caption}
\DIFdelbeginFL %DIFDELCMD < \label{fig:my_label}
%DIFDELCMD < %%%
\DIFdelendFL \DIFaddbeginFL \label{fig:my_new_label}
\DIFaddendFL \end{figure}
\DIFdelbegin \DIFdel{\ref{fig:my_label}
}\DIFdelend \DIFaddbegin \DIFadd{\ref{fig:my_new_label}
}\DIFaddend
\end{document}
Best Answer
You have to use option
--exclude-safecmd=ref
, not --exclude-textcmd. textcmd is for commands whose argument is text. Note that you can use--show-all
to get a listing of the default settings for safe and text commands.