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

color related issues #268

Open mstsirkin opened 2 years ago

mstsirkin commented 2 years ago

we are changing colors for latexdiff: our document has lots of URLs which are blue, so we are using green for added text. Two issues arise:

  1. URLs within added text are still blue. would be nice to be able to change their color to green too (maybe a different shade).

  2. when there are differences within listings, these use styles from DIFCODE_UNDERLINE and seem to ignore whatever we put in preamble.

ftilmann commented 1 year ago

Sorry, this has been sitting around for some time. I hope answers are still useful. The request is probably a bit too niche compared to some other open issues, so that I will be not be able to tackle this myself in the foreseeable future, but I try to give some pointers. If you come up with a workable solution, we can see how to integrate it into latexdiff.

  1. URLs within added text are still blue. would be nice to be able to change their color to green too (maybe a different shade).

I presume the \url command (if that is what you are using) is excluded from the argument of \DIFadd to prevent interference. I don't know the hyperref package very well (if that is what you are using for url's but presumably there is a command to change link color locally, or an option to \url to choose the colour. If so you could redefine \DIFaddbegin to change link colour to green and \DIFaddend to change link colour back to blue. How to do this in TeX/latex is a bit involved but you can look at preamble section HIGHLIGHTGRAPHICS how such redefinitions are set up.

ftilmann commented 1 year ago
  1. when there are differences within listings, these use styles from DIFCODE_UNDERLINE and seem to ignore whatever we put in preamble.

If you generate the diff file, the preamble should contain a section

%DIF DIFCODE_UNDERLINE %DIF PREAMBLE
  moredelim=[il][\color{red}\sout]{\%DIF\ <\ }, %DIF PREAMBLE
  moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ } %DIF PREAMBLE
} %DIF PREAMBLE

You should simply be able to change blue to green here. Do you mean you do this and it still comes out blue? That would be a bug that I would feel compelled to tackle but would need more detail, e.g. a MWE. To avoid having to make this change every time you could save the whole latexdiff additions to preamble in a separate file and use --preamble option to load it. If you already do this and it comes out blue, then again that would be a bug, but more detail would help, ideally an MWE and your preamble file.

cniethammer commented 1 year ago

I would like to jump in and bump up this request for changing colors via the preamble file.

Currently I try to generate diffs for the MPI Standard that includes a lot of latex code in listing environments. Having a latexdiff related file in the main directory of this 1000+pdf pages document is not desirable. A single configuration file would be highly favored. Note: An option I see would be to be able to give a custom latexdiff-configuration directory for these kind of extension files - if easier to implement.

Thanks.