Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

citation in the margin #255

Closed
Adeline-Lacroix opened this issue Feb 1, 2022 · 6 comments
Closed

citation in the margin #255

Adeline-Lacroix opened this issue Feb 1, 2022 · 6 comments
Labels

Comments

@Adeline-Lacroix
Copy link

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...

@ftilmann
Copy link
Owner

ftilmann commented Feb 6, 2022

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.

  1. 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.

  2. 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.

@ftilmann
Copy link
Owner

ftilmann commented Feb 8, 2022

Closed as
Duplicate of #188

@ftilmann ftilmann marked this as a duplicate of #188 Feb 8, 2022
@ftilmann ftilmann closed this as completed Feb 8, 2022
@briochemc
Copy link
Contributor

briochemc commented Mar 18, 2024

FYI @ftilmann, following #277 (swap ulem for lua-ul), using LuaLaTeX, and removing mboxes 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 \mboxes)?

@ftilmann
Copy link
Owner

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

@ftilmann ftilmann added High and removed wontfix labels Mar 18, 2024
@ftilmann ftilmann reopened this Mar 18, 2024
@briochemc
Copy link
Contributor

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:

latexdiff/latexdiff

Lines 1347 to 1349 in 535ca8e

if ( ! $ulem ) {
# modes not using ulem: citation is safe
push (@SAFECMDLIST, $citpat);

@ftilmann
Copy link
Owner

As there is a solution now when using lualatex and I can't do anything about the limitations of ulem, I am closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants