latex-lineno / lineno

lineno – Line numbers on paragraphs
Other
11 stars 2 forks source link

lineno needs to be loaded after amsmath #5

Closed FrankMittelbach closed 1 year ago

FrankMittelbach commented 1 year ago

With the new version lineno supports the amsmath environments (thanks for that!) but unfortunately it introduces an order dependency.

\documentclass{article}
\usepackage{lineno}
\usepackage{amsmath}

\begin{document}
aaa
\end{document}

errors with 
! LaTeX Error: Command \gather already defined.

It might be better (and in fact much simpler) to make use LaTeX's hook system and make the alterations automatically after amsmath got loaded, via

\AddToHook{package/amsmath/after}{....}

In this case the changes happen only after the environments got defined in amsmath and not at all if amsmath is not loaded ever.

FrankMittelbach commented 1 year ago

Hi Karl, this is causing more and more issues and questions out there, because other packages load either amsmath or lineno internally and are now producing suprising ordering issues. If you would change to using hooks all this would go away. For compatibility with old installations you could simply check if hook commands are already defined and if not don't do any updates ie auto-support amsmath only with installations that are 2020 or later. If you need assistance setting it up we can probably help but hooks are actually quite simple to use.

daamien commented 1 year ago

related: https://tex.stackexchange.com/questions/669008/package-minted-and-tcolorbox-produces-latex-error-command-gather-already-defin

jfine2358 commented 1 year ago

Related: "conflict between lineno and amsmath packages in TeXLive 2022? Some environments (like \gather) are already defined", title of post https://tug.org/pipermail/texhax/2023-January/025962.html.

In that thread on texhax I suggest (see https://tug.org/pipermail/texhax/2023-January/025967.html)

How about asking TeXLive to revert lineno to the previous version (which it seems does not have this conflict with amsmath). Perhaps overall this would make the best of what there is.

kwwette commented 1 year ago

Fixed in version 5.1, which should appear on CTAN soon.