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

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

Closed
Keks-Dose opened this issue Nov 20, 2022 · 8 comments
Closed

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

Keks-Dose opened this issue Nov 20, 2022 · 8 comments

Comments

@Keks-Dose
Copy link

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
Copy link

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 added a commit to michaelmhoffman/latexdiff that referenced this issue Feb 23, 2023
This hack just changes in the DATA section:

ulem -> lua-ul
[normalem] ->
\sout -> \strikeThrough
\uwave -> \underLine

When this is used, output must be compiled with lualatex.

Some thoughts on implementing this in upstream latexdiff:

1. To make this an actual option, instead of hardcoding this change,
one would probably want to make general commands that call the right
ulem or lua-ul commnad, with separate preamble sections for either
ulem:

\RequirePackage[normalem]{ulem}
\newcommand[1]{\DIFstrikethrough}{\sout{ftilmann#1}}
\newcommand[1]{\DIFunderline}{\uwave{ftilmann#1}}

or lua-ul

\RequirePackage{lua-ul}
\newcommand[1]{\DIFstrikethrough}{\strikeThrough{ftilmann#1}}
\newcommand[1]{\DIFunderline}{\underLine{ftilmann#1}}

and then could make these changes instead

\RequirePackage[normalem]{ulem} ->
\sout -> \DIFstrikethrough
\uwave -> \underLine

This, however, would require adding in the logic to have either lua-ul or ulem into
the code.

I also hope the indirection like this won't break some LaTeX macro
somewhere but can't be sure of that.

Other options I considered would be:
- duplicating all these sections to have a ulem and a lua-ul
version (yuck)
- searching for these words and replacing them when reading in
preamble sections (D:)
- simply eliminating ulem support (working around it certainly seems to have caused a
lot of headaches for the creators of latexdiff)

2. lua-ul doesn't have the capacity out of the box to produce wavy
underlines like ulem, but is very configurable and it could be added.
Instructions are even in the lua-ul manual.
@michaelmhoffman
Copy link

cb6c513 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
Copy link

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

@ftilmann
Copy link
Owner

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
Copy link

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
Copy link
Author

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
Copy link
Author

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

@ftilmann
Copy link
Owner

This seems to be solved by the merged #299 PR

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

No branches or pull requests

3 participants