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
518 stars 73 forks source link

siunitx new macros are not recognized #282

Open joe6302413 opened 1 year ago

joe6302413 commented 1 year ago

Following the update of siunitx v3, new macros, such as \qty, \qtyrange and \qtylist, are introduced to replace the old macros starting with \SI. The current package does not recognize the new macros and provide \mbox protection.

The issue can be worked around by using --append-mboxsafecmd='qty,qtyrange,num,qtylist,qtyproduct...etc', but it would be easier to update the package behavior with siunitx since it is one of the most used package.

ftilmann commented 1 year ago

Thanks for letting me know. I guess for many years latexdiff will have to support old and new syntaxes. As I am not an active user of siunitx, would you be able to provide the list of commands, patterns, which would need to be protected. You started making this list but the "..etc" suggest there are more. If you had a short test document with the new SIunitx commands would be great (my installation of texlive still has the old siunitx).

joe6302413 commented 1 year ago

Sorry for mispress the closing button, but hope my reply will make it closer to close.

I have tested all the combinations (not good at perl nor latex). It seems the current stable version can take care of some of the siunitx commands (see the "already safe cmd.txt"). I have no clue what makes a command safe or mbox safe, but I presume that a safecmd should not be in mboxsafecmd as they require less treatment. Here I have listed all the commands to my knowledge into safecmd and mbox safecmd (see the files).

My testing tex file is attached as siunitx_test and siunitx_test_old with random changes in the inputs.

Hope these are helpful. Thank you.

siunitx_safecmd.txt siunitx_mboxsafecmd.txt already safe cmd.txt

siunitx_test.txt siunitx_test_old.txt

ftilmann commented 1 year ago

Thanks for contributing PR. This solves the issue

snaunheim commented 1 year ago

Dear @joe6302413 and @ftilmann, First of all, thanks for solving this issue.

Sadly, I noticed that the solution does not work if the corresponding siunitx-command is using options, e.g. \num[round-mode=places, round-precision=2, exponent-mode=scientific]{123456789}.

I've modified the testing files to make life easier, but I don't know how to fix this issue. Maybe you have an idea?

siunitx_test.txt siunitx_test_old.txt