Open Adeline-Lacroix opened 2 years ago
This is a known limitation. I cite from the documentation of latexdiff:
There is an incompatibility between the C
package, which C uses for underlining and striking out in the UNDERLINE style, the default style, and the way citations are generated. In order to be able to mark up citations properly, they are enclosed with an C<\mbox> command. As mboxes cannot be broken across lines, this procedure frequently results in overfull boxes, possibly obscuring the content as it extends beyond the right margin. The same occurs for some other packages (e.g., siunitx). If this is a problem, you have two possibilities.
Use C
type markup (option C<-t CFONT>): If this markup is chosen, then changed citations are no longer marked up with the wavy line (additions) or struck out (deletions), but are still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the C package will also work. Choose option C<--disable-citation-markup> which turns off the marking up of citations: deleted citations are no longer shown, and added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older)
Unfortunately, still I am not aware of a better solution. But as the real solution to this lies probably with ulem and so beyond my control. For completeness sake: in the past I had investigated the soul package as an alternative means to achieve underlining and strike-out. This seemed to cope with the citations, but did not work with equations. I decided that longer citations causing overfull boxes and running outside the right margin was the lesser evil but if you happened to not rely on equations, then it might be an option for you to define a custom style based on soul.
As it's technically an an unsolved issue, I will not close it, but gave it the "WONTFIX" label to indicate that I currently see no way to address this (except doing the citation processing outside latex, the approach of latexdiffcite. Unfortunately latexdiffcite seems to have been abandoned by its developer.
Closed as Duplicate of #188
FYI @ftilmann, following #277 (swap ulem for lua-ul), using LuaLaTeX, and removing mbox
es manually in the generated diff .tex
file did the trick for me (that is, I finally got colored/decorated long citations that nicely wrap at the expected line break). Given the (low?) likelhihood that there is a ulem package fix, maybe this is the way forward to workaround/fix #17, #60, #188, #255, #270, and maybe other issues (e.g., for commands that don't work nicely with \mbox
es)?
Yes, indeed this looks like a way forward - I will need to test this and then put some logic in that does the markup correctly if lua-ul is imported, as I understand some commands have to be adapted
Let me know if I can help. I would have attempted a PR but am a bit overwhelmed by the code.
Apart from @michaelmhoffman's changes to the preambles, I can see some logic in the code for when ulem is not used, but I'm not entirely sure if that would work as is:
Hi,
Latexdiff is working perfectly except that long citation extend off the page, in the margin.
I tried to solve the problem using the microtype package and \begin{sloppypar}....\end{sloppypar} but it did not worked...
I also tried to use latexdiffcite (, but it did not worked neither as I got an error regarding the bibliography that I did not have with latexdiff.
(I am on mac Monterey).
Any help would be much appreciated...