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

latexdiff --lua : swap ulem for lua-ul #277

Open Keks-Dose opened 1 year ago

Keks-Dose commented 1 year ago

As far as I can see, latexdiff uses the ulem packages. The latter has issues with hyphenation. I swapped ulem for the package lua-ul in the diff.tex and got proper hyphenation.

Ok, but then we need luacolor as well. For both you need to compile with Lua(La)TeX.

LuaLaTeX became so fast recently that I'm finally starting to move everything to LuaLaTeX, away from pdfLaTeX. So at least to me a switch that made latexdiff use lua-ul and luacolor came just in time.

By the way: I don't know how you are doing it but latexdiff does a better job than its counterpart software in text processing software. It is an indispensable piece of software in the realms of TeX.

michaelmhoffman commented 1 year ago

Adding \usepackage{lua-ul} to the top of latexdiff output, replacing \sout with \strikeThrough and \uwave with \underLine made my ERROR: Extra }, or forgotten \endgroup. problems go away when I had biblatex \textcite in some added or deleted text.

michaelmhoffman commented 1 year ago

cb6c5138d597b51dcbc2816049b4cd29b73f0d41 is a fork that hard-codes the switch to lua-ul, and the commit message has some thoughts on how one might implement an option to do it instead.

michaelmhoffman commented 1 year ago

Also unsure why direct use of luacolor is needed, it seems to work for me fine with color and lualatex.

ftilmann commented 1 year ago

The simplest implementation would be to introduce another markupstyle UNDERLINE_LUA which would be activated with latexdiff -t UNDERLINE_LUA. The only issue I see with this is discoverability, as few people bother to read the man pages. So far I have not used luatex myself (maybe the improved underlining is a reason to switch). Is there anything diagnostic in the .tex source that would allow latexdiff to detect likely use of luatex. I also wonder if usage of the luatex underline commands gets round the issues with underlining citation commands (as \uwave{\cite{..}} does not work).

michaelmhoffman commented 1 year ago

The simplest implementation would be to introduce another markupstyle UNDERLINE_LUA which would be activated with latexdiff -t UNDERLINE_LUA.

That makes sense.

The only issue I see with this is discoverability, as few people bother to read the man pages.

I think many people might discover this via Googling an error message and ending up here.

Is there anything diagnostic in the .tex source that would allow latexdiff to detect likely use of luatex.

Many LuaLaTeX or XeLaTeX documents will load either the unicode-math or fontspec packages. However that unfortunately is not specific only to Lua, lua-ul won't work from XeLaTeX, and isn't 100% reliable in any sense. If you want something that is triggered in use of LuaLaTeX only it is best to do it from within the .tex source itself. The iftex package will do this.

I also wonder if usage of the luatex underline commands gets round the issues with underlining citation commands (as \uwave{\cite{..}} does not work).

Yes, I believe lua-ul solves these problems.

Keks-Dose commented 11 months ago

First of all: thank you for the fork, I tested it and after installing perl-Algorith-Diff it worked. Looks way better in my case, two-column text, partially in tcolorboxes, where hyphenation is essential. Great!

I found out that the changebar package doesn't work with luatex, will write to the maintainers.

The package luacolor is only needed for highlighting text, apologies for my wrong assumption in my first post.

So if somebody implemented the UNDERLINE_LUA option (and the maintainers of changebar add luatex support) that would be very helpful!

Keks-Dose commented 6 months ago

As of yesterday the maintainer of changebar published a new version including support for LuaTeX.