Treat tikzpicture like an equation
I see that latexdiff has recently learned to skip over tikzpicture environments by adding it to the PICTUREENV regexp.
While this works (in the sense of producing valid LaTeX output), latexdiff could do better by handling tikzpicture environments like equation environments. In my use case at least (drawing boxes like in http://tex.stackexchange.com/a/306020/21283), an equivalent of --math-markup=whole ("Differencing on the level of whole equations. Even trivial changes to equations cause the whole equation to be marked changed.") would work fine.
I suspect different use cases of tikzpicture may also benefit from the other settings for the --math-markup option.
There are a few special expectations built into latexdiff when processing math content, so simply pretending tikzpicture is a math environment might or might not work. You can test this by manually adding tikzpicture to MATHENV option and then using the math markup option. Of course, this is a kludge as one might very well want equations and tikzpictures marked in different ways, but at least you can check whether this would work in principle. Replicating the mechanisms for equations for tikzpictures, but treating both independently is of course possible but not trivial to implement, and currently my inclination is fix some other issues first. Finally, I don't use tikzpicture myself, and I would not want to introduce any changes without testing. Could you send me some examples with old and new files demonstrating changes to tikzpicture.
Thanks for the suggestion, it appears that it doesn't work out of the box. So far, I arrived at the following command line:
latexdiff-fast -t CCHANGEBAR --math-markup=whole --config="MATHENV=(?:tikzpicture),MATHREPL=,PICTUREENV=" orig.tex new.tex > diff.tex && pdflatex diff.tex && okular diff.pdf
This gives me
! Undefined control sequence.
l.67 \DIFdelbegin \MATHBLOCK
{
?
Example files are orig.tex:
\documentclass{article}
\usepackage{tikz}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\bitrect}[2]{
\begin{pgfonlayer}{foreground}
\draw [thick] (0,0) rectangle (#1,1);
\pgfmathsetmacro\result{#1-1}
\foreach \x in {1,...,\result}
\draw [thick] (\x,1) -- (\x, 0.8);
\end{pgfonlayer}
% \node [below left, align=right] at (0,0) {Type \\ Reset};
\bitlabels{#1}{#2}
}
\newcommand{\rwbits}[3]{
\draw [thick] (#1,0) rectangle ++(#2,1) node[pos=0.5]{#3};
\pgfmathsetmacro\start{#1+0.5}
\pgfmathsetmacro\finish{#1+#2-0.5}
% \foreach \x in {\start,...,\finish}
% \node [below, align=center] at (\x, 0) {R/W \\ 0};
}
\newcommand{\robits}[3]{
\begin{pgfonlayer}{background}
\draw [thick, fill=lightgray] (#1,0) rectangle ++(#2,1) node[pos=0.5]{#3};
\end{pgfonlayer}
\pgfmathsetmacro\start{#1+0.5}
\pgfmathsetmacro\finish{#1+#2-0.5}
% \foreach \x in {\start,...,\finish}
% \node [below, align=center] at (\x, 0) {RO \\ 0};
}
\newcommand{\bitlabels}[2]{
\foreach \bit in {1,...,#1}{
\pgfmathsetmacro\result{#2}
\node [above] at (\bit-0.5, 1) {\pgfmathprintnumber{\result}};
}
}
\begin{document}
Original text.
\begin{tikzpicture}
\bitrect{8}{8-\bit}
\rwbits{0}{1}{SEL}
\rwbits{1}{1}{SEL}
\robits{2}{4}{}
\rwbits{6}{2}{DIR}
\end{tikzpicture}
Original text.
\end{document}
and new.tex:
\documentclass{article}
\usepackage{tikz}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\bitrect}[2]{
\begin{pgfonlayer}{foreground}
\draw [thick] (0,0) rectangle (#1,1);
\pgfmathsetmacro\result{#1-1}
\foreach \x in {1,...,\result}
\draw [thick] (\x,1) -- (\x, 0.8);
\end{pgfonlayer}
% \node [below left, align=right] at (0,0) {Type \\ Reset};
\bitlabels{#1}{#2}
}
\newcommand{\rwbits}[3]{
\draw [thick] (#1,0) rectangle ++(#2,1) node[pos=0.5]{#3};
\pgfmathsetmacro\start{#1+0.5}
\pgfmathsetmacro\finish{#1+#2-0.5}
% \foreach \x in {\start,...,\finish}
% \node [below, align=center] at (\x, 0) {R/W \\ 0};
}
\newcommand{\robits}[3]{
\begin{pgfonlayer}{background}
\draw [thick, fill=lightgray] (#1,0) rectangle ++(#2,1) node[pos=0.5]{#3};
\end{pgfonlayer}
\pgfmathsetmacro\start{#1+0.5}
\pgfmathsetmacro\finish{#1+#2-0.5}
% \foreach \x in {\start,...,\finish}
% \node [below, align=center] at (\x, 0) {RO \\ 0};
}
\newcommand{\bitlabels}[2]{
\foreach \bit in {1,...,#1}{
\pgfmathsetmacro\result{#2}
\node [above] at (\bit-0.5, 1) {\pgfmathprintnumber{\result}};
}
}
\begin{document}
New text.
\begin{tikzpicture}
\bitrect{8}{8-\bit}
\rwbits{0}{1}{SEL}
\rwbits{1}{1}{SEL}
\rwbits{2}{1}{SEL}
\robits{3}{3}{}
\rwbits{6}{2}{DIR}
\end{tikzpicture}
New text.
\end{document}