ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
512 stars 72 forks source link

Error 'Missing } inserted' when using tikz-dependency #303

Closed anka-213 closed 1 month ago

anka-213 commented 1 month ago

Here is a minimal example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz-dependency}
\begin{document}
No content
\end{document}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz-dependency}
\begin{document}
    \begin{dependency}
        \begin{deptext}[column sep=0.4cm]
              the\_Det : Det \& black\_A : A \& cat\_N : N \\
              \& PositA black\_A : AP \&  \\
        \end{deptext}
        \depedge{3}{1}{det}
        \depedge{3}{2}{amod}
        \deproot{3}{root}
    \end{dependency}
\end{document}

Running latexdiff with it would wrap the ampersands in a command, which is not allowed:

    \begin{dependency}
        \begin{deptext}[column sep=0.4cm]
              \DIFaddFL{the\_Det : Det \& black\_A : A \& cat\_N : N }\\
              \DIFaddFL{\& PositA black\_A : AP \&  }\\
        \end{deptext}
        \depedge{3}{1}{det}
        \depedge{3}{2}{amod}
        \deproot{3}{root}
    \end{dependency}

I tried adding --exclude-safecmd='&' to no avail.

anka-213 commented 1 month ago

Based on this https://github.com/ftilmann/latexdiff/blob/33316f4c875f3a5bcd9b681c17015dc1deff7a5e/latexdiff#L2667 i discovered that --exclude-safecmd=AMPERSAND works.

ftilmann commented 1 month ago

I like this: a bug report that already does the hard work of finding the pathway to solution. I have simply made it default behaviour now to declare \& (ie \AMPERSAND internally) an unsafe command if tikz-dependency package is detected or declared. The fix is a little of a hack as really it should only be considered unsafe within dependency environment, and here is declared globally unsafe. It's not difficult to fix do this fix also, but I am not sure the usage number of dependency, and the relatively minor inconvenience of invisible changes to \& in the text do not convince me it's worth the additional code complexity. Commit a789b50