LuaTeX – How to Resolve Unexpected LaTeX Cmd Errors in LuaTeX

fontskoma-scriptluatexxparse

I have a tex-document with the scartcl class.
In the preamble I redefine \it by \RenewDocumentCommand{\it}{...}{...}.
Moreover, I have to different environment in which I want to comple the document with LuaLaTeX.

  1. Version 1.13.0 (TeX Live 2021/CVE-2023-32700 patched) (on my local machine)
  2. Version 1.15.0 (TeX Live 2022/Debian) (within a podman container)

In the older version on my local machine everything works fine.
I searched the log for "err", "warn" and "depr" and did not find anything concerning.

However, in the newer version in the container I get ! LaTeX cmd Error: Command '\it' undefined. As well as an error that says that the old font command \it will not work anymore.
I tried to fix the first problem by adding \provideDocumentCommand{\it}. That resulted in LaTeX cmd Error: Invalid argument type '\RenewDocumentCommand ' in command and the scratcl error remaining.

Can someone explain to me what the problem is here?

Ty,
Franz

Best Answer

Consider the following short test file:

% franz.tex
\documentclass{scrartcl}
\show\it
\end{document}

If I run on my system (where I keep TeX Live from 2012 on) with

/usr/local/texlive/2021/bin/universal-darwin/pdflatex franz

I get

> \it=macro:
->\protect \it  .
l.2 \show\it

If I do instead

/usr/local/texlive/2022/bin/universal-darwin/pdflatex franz

I get

> \it=undefined.
l.2 \show\it

What happened? In the transition from TL 2021 to TL 2022, the koma classes changed the management of the old font commands. Until TL 2021, those commands were defined so that they would “work” also in the preamble. Later, they are “defined” only at begin document.

This is the cause of the difference: if you do \RenewDocumentCommand{\it}{...}{...} in the preamble, you get no error with TL 2021, because \it indeed has a definition. But you get the error with later releases because in the preamble \it is no longer defined.

Solution:

\providecommand{\it}{}% in case \it isn't defined
\RenewDocumentCommand{\it}{...}{...}

However, I wouldn't recommend reusing \it for any purpose.