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

cleveref now refers to appendices as sections #362

Open
jpcirrus opened this issue Nov 9, 2024 · 11 comments
Open

cleveref now refers to appendices as sections #362

jpcirrus opened this issue Nov 9, 2024 · 11 comments

Comments

@jpcirrus
Copy link

jpcirrus commented Nov 9, 2024

Using hyperref 2024-11-05 v7.01l with LaTeX 2024-11-01 and the example file:

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}

\cref{sec:one} and \cref{sec:a}

\section{Section One}\label{sec:one}
Lorem.

\section{Appendix A}\label{sec:a}
Lorem.

\end{document}

cleveref now refers to sections in the appendix as section instead of appendix. I suspect this is related to the issue with \refstepcounter and related to latex3/latex2e#1393, #360, #361 and fffd2e0.

@u-fischer
Copy link
Member

Try this (or switch to something else, e.g. zref-clever)

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\makeatletter
\AddToHook{cmd/appendix/before}{\def\cref@section@alias{appendix}}
\makeatother
\begin{document}

\cref{sec:one} and \cref{sec:a}

\section{Section One}\label{sec:one}
Lorem.

\appendix
\section{Appendix A}\label{sec:a}
Lorem.

\end{document}

@jpcirrus
Copy link
Author

jpcirrus commented Nov 9, 2024

That does it, thanks. Unfortunately, the source markdown document is being compiled to latex by pandoc with the pandoc-crossref filter, so am forced to use cleveref until the filter is updated.

@jpcirrus
Copy link
Author

jpcirrus commented Nov 9, 2024

Looking through the cleveref source I see there is a command \crefalias that does just that, so the fix can be simplified to \AddToHook{cmd/appendix/before}{\crefalias{section}{appendix}}

@clason
Copy link

clason commented Nov 11, 2024

Same issue with other \crefnames that share a counter, e.g.

\newtheorem{theorem}{Satz}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\crefname{theorem}{Satz}{Sätze}

in which case \cref on a lemma would refer to "Satz x.y".

@u-fischer Is this something that can be fixed, or is the official stance now that cleveref is abandonware and should be replaced going forward? (Unfortunately, zref-clever is not a drop-in replacement...)

EDIT: Again, I only found your tex.SE answer after posting this... https://tex.stackexchange.com/questions/730148/cref-refers-to-lemmas-as-theorems

@u-fischer
Copy link
Member

@clason without complete example I can't test, but probably you can fix it with https://tex.stackexchange.com/a/730164/2388.

or is the official stance now that cleveref is abandonware

Well the only one who can give an official stance about cleveref is its maintainer. So contact him and ask.

Generally, we are trying to fix issues with cleveref and add firstaid code for it. But cleveref has 8000 lines of code. It redefines various public and internal definitions from a large number of packages and from the kernel and there is no testsuite one can use to check for problems so some fixes are still missing.

and should be replaced going forward

well it would be nice if there were a replacement that does not patch everything but makes use of the new interfaces provided by LaTeX like the hooks and the properties. But someone would have to tackle the task to do that.

@clason
Copy link

clason commented Nov 11, 2024

@clason without complete example I can't test, but probably you can fix it with https://tex.stackexchange.com/a/730164/2388.

Yes, indeed! (Sorry, I really should get in the habit of checking tex.se before Github; open source work has ruined me in that regard...)

Well the only one who can give an official stance about cleveref is its maintainer. So contact him and ask.

Of course (although I doubt that I would get an answer if you don't...) My question was more along the lines of "is the team close to (very understandably) throwing in the towel on this and saying 'if you want to use an abandoned and outdated package, you should use an outdated kernel"? But it sounds like you're not quite there yet (and I cannot stress enough how appreciated your enormous efforts are), so I'll postpone the significant investment for my templates still.

well it would be nice if there were a replacement that does not patch everything but makes use of the new interfaces provided by LaTeX like the hooks and the properties. But someone would have to tackle the task to do that.

Oh, for sure, that is not on your plate at all. (Actually all I'm hoping for is for someone to write a cref-compatible wrapper for zref-clever -- in fact, that's what I first thought zref-clever was!)

@u-fischer
Copy link
Member

Actually all I'm hoping for is for someone to write a cref-compatible wrapper for zref-clever -- in fact, that's what I first thought zref-clever was!

Well I don't know what is missing or is not cref compatible, but if you make a list or examples you could ask the zref-clever author.

@clason
Copy link

clason commented Nov 11, 2024

Basically, I would love to have a package I can import instead of cleveref that lets me use zref without changing the (existing, large) document. I don't think the zref-clever author is interested in that; otherwise they would have not used a very different interface to begin with.

But I've taken enough of your time already (and thanks)!

@elcarlosIII
Copy link

I can confirm this issue. I've gone through the commit list. The problem does not occur in commit

48bdab913d4e8a2fcfe229ef6b5302f6fd22b644 (docu)

but in

697ed67f60dbf235d7843ec43e6f09114e707a81 (adapt nameref to new label handling)

so the problem was probably introduced in the latter commit.

Same issue with other \crefnames that share a counter, e.g.

\newtheorem{theorem}{Satz}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\crefname{theorem}{Satz}{Sätze}

in which case \cref on a lemma would refer to "Satz x.y".

@u-fischer Is this something that can be fixed, or is the official stance now that cleveref is abandonware and should be replaced going forward? (Unfortunately, zref-clever is not a drop-in replacement...)

EDIT: Again, I only found your tex.SE answer after posting this... https://tex.stackexchange.com/questions/730148/cref-refers-to-lemmas-as-theorems

@u-fischer
Copy link
Member

@elcarlosIII

so the problem was probably introduced in the latter commit.

I know which changes where made in hyperref and in the kernel.

or is the official stance now that cleveref is abandonware

the only one who can give an official stance about the status of cleveref is its maintainer. So ask him.

Is this something that can be fixed

well as I wrote above and in the tex.sx answer, the easiest and best currently is to set the alias explicitly through a hook.

As long as the maintenance status is so vage it is very difficult to work on a fundamental solution.

@Enivex
Copy link

Enivex commented Jan 31, 2025

Same issue with other \crefnames that share a counter, e.g.

\newtheorem{theorem}{Satz}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\crefname{theorem}{Satz}{Sätze}

in which case \cref on a lemma would refer to "Satz x.y".

@u-fischer Is this something that can be fixed, or is the official stance now that cleveref is abandonware and should be replaced going forward? (Unfortunately, zref-clever is not a drop-in replacement...)

EDIT: Again, I only found your tex.SE answer after posting this... https://tex.stackexchange.com/questions/730148/cref-refers-to-lemmas-as-theorems

On my system I not only had to include amsthm, but also thmtools, to fix this issue. That is, if I do

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[nameinlink,capitalize,noabbrev]{cleveref}

then cleveref works as expected, without anything else fancy in the preamble.

I tried to migrate to zref-clever once before, but at that time it wasn't yet working in texlive (which my collaborators were using) due to the kernel version being too old. Maybe now is the time to try again. It's pretty clear that cleveref isn't going to see updates (it's been 7 years).

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

5 participants