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
514 stars 72 forks source link

citeautoscript from revtex4-1 causes errors #171

Closed jokuha closed 5 years ago

jokuha commented 5 years ago

revtex is a LaTeX package for scientific writing, widely used in Physics, e.g., by APS and AIP publications and the arXiv. It has a package option "citeautoscript" that correctly puts superscripted citations after punctuation, even when it is before in the source code. This allows to easily adjust the style of the manuscript. Now, this option causes latexdiff to fail with the error

! Argument of \super@cite@swap has an extra }.

Can this be fixed? easily?

Now, I would be happy to get the latexdiff simply ignore the option and not ge the fixes in that case, thus can I tell latexdiff (or git latexdiff, for that matter) to simply ignore the option? With 'git latexdiff' editing the source is quite cumbersome, so an automatic option would be very useful...

ftilmann commented 5 years ago

Based on the information I cannot really answer this. It would be most helpful, if you could construct an MWE (i.e., old file and new file) that demonstrates the problem.

jokuha commented 5 years ago

Old file

\documentclass[citeautoscript,aip,jcp]{revtex4-1} \begin{document} \end{document}

New file

\documentclass[citeautoscript,aip,jcp]{revtex4-1} \begin{document} text~\cite{ref}, \end{document}

Then running

latexdiff old.tex new.tex > ! change.tex pdflatex change

will result in this error:

! Argument of \super@cite@swap has an extra }.

ftilmann commented 5 years ago

There is the option --disable-citation-markup, which prevent the actual \cite command to be marked up. But the comma afterwards is marked up by latexdiff, of course, which does trip up revtex4-1:

\DIFaddbegin \DIFadd{text~}\cite{ref}\DIFadd{,
 }\DIFaddend

So as you say leaving out the citeautoscript option seems to be the best work-around. There is currently no way to do this automatically, but there is some idea to allow user-defined filter scripts. There is even a pending PR (#167 ) for this (see --filter-script patch) but that patch still has some serious issues, so will not be integrated into master as is.

For new projects I would advise to simply leave out the citeautoscript option, and only add it for the submitted version (which can probably be done manually). Sorry to not be able to be more helpful