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

lineno needs to be loaded after amsmath #5

Closed
FrankMittelbach opened this issue Dec 7, 2022 · 4 comments
Closed

lineno needs to be loaded after amsmath #5

FrankMittelbach opened this issue Dec 7, 2022 · 4 comments

Comments

@FrankMittelbach
Copy link

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.

akiyks added a commit to akiyks/perfbook that referenced this issue Dec 8, 2022
LaTeX package lineno v5.0 incorporated patching amsmath code
for compatibility. (Such compatiblity was provided by a separate
package linenoamsmath (now obsoleted).)
This introduced the ristiction of the ordering of loading amsmath
and lineno.

In perfbook, lineno is required by fvextra and amsmath is required
by glossaries which is again required by glossaries-extra.

As a workaround, move the load of fvextra after that of
glossaries-extra.

There is hoping that lineno can loosen this ristriction [1].

Link: [1] latex-lineno/lineno#5
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
paulmckrcu pushed a commit to paulmckrcu/perfbook that referenced this issue Dec 11, 2022
LaTeX package lineno v5.0 incorporated patching of amsmath code
for compatibility. (Pre-v5.0 lineno needs a separate package
linenoamsmath --- now obsolete --- for such compatibility.)
This introduced the ordering requirement that lineno needs to be
loaded after amsmath [1].

In perfbook, lineno is required by fvextra and amsmath is required
by glossaries which is again required by glossaries-extra.
Hence lineno is loaded before amsmath and causes a fatal error with
lineno v5.0.

As a workaround, explicitly load amsmath before fvextra.

Link: [1] latex-lineno/lineno#5
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
cderv added a commit to rstudio/rticles that referenced this issue Dec 12, 2022
cderv added a commit to rstudio/rticles that referenced this issue Dec 12, 2022
@FrankMittelbach
Copy link
Author

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.

@jfine2358
Copy link

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

kwwette commented Jan 19, 2023

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

  • For LaTeX releases after October 2020, lineno now patches amsmath with \AddToHook, so that the packages can be loaded in any order.
  • For LaTeX releases before October 2020 (where \AddToHook is unavailable), lineno will only try to patch amsmath if it is already loaded, otherwise it will print a warning. This will still allow the packages to be loaded in any order, except that amsmath will not be patched if it is loaded after lineno, and hence line numbers won't work correctly in amsmath math environments.

@kwwette kwwette closed this as completed Jan 19, 2023
cderv added a commit to rstudio/rticles that referenced this issue May 11, 2023
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

4 participants