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

FR: support for aliascnt package #2444

Open
mbertucci47 opened this issue Dec 13, 2024 · 5 comments
Open

FR: support for aliascnt package #2444

mbertucci47 opened this issue Dec 13, 2024 · 5 comments

Comments

@mbertucci47
Copy link

This is a feature request for support for the aliascnt package. My main use case for it is creating sibling theorems that work correctly with cleveref and hyperref's \autoref. Here's an example.

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

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\providecommand{\lemmaautorefname}{Lemma}

\begin{document}

\cref{foo}

\autoref{foo}

\begin{lemma}\label{foo}
Some lemma text
\end{lemma}

\end{document}

test-1

So the lemma is incorrectly referred to as a theorem by \cref and \autoref. But with the features provided by aliascnt, the names are correct.

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

\newtheorem{theorem}{Theorem}
\newaliascnt{lemma}{theorem}
\newtheorem{lemma}[lemma]{Lemma}
\aliascntresetthe{lemma}

\providecommand{\lemmaautorefname}{Lemma}

\begin{document}

\cref{foo}

\autoref{foo}

\begin{lemma}\label{foo}
Some lemma text
\end{lemma}

\end{document}

test-1

@xworld21
Copy link
Contributor

Strange, I cannot reproduce your example. Cleveref does not need aliascnt to work, only hyperref does. I get 'lemma 1 / Theorem 1' with LaTeX (with many versions of TeX Live) and 'lemma 1 / Lemma 1' with LaTeXML without using aliascnt. If anything, LaTeXML's implementation of \autoref is not faithful. Which versions are you using, exactly?

LaTeXML needs additional calls to \crefname when using nonstandard theorem environments (already reported). Here 'theorem' and 'lemma' work out of the box.

@mbertucci47
Copy link
Author

mbertucci47 commented Dec 13, 2024

@xworld21 The cleveref issue needs a current LaTeX (2024-11-01 or later) to reproduce. And you're right about LaTeXML not being faithful with \autoref.

I now see the issue you're referring to, #2306. By "nonstandard", do you mean using amsthm instead of the kernel \newtheorem?

@xworld21
Copy link
Contributor

The cleveref issue needs a current LaTeX (2024-11-01 or later) to reproduce. And you're right about LaTeXML not being faithful with \autoref.

Oh no, that sounds like a LaTeX regression. I suggest reaching out to the cleveref developer and the TeX Live mailing list because it sounds like an unintended breaking change (I am happy to do it if you prefer – I am a heavy cleveref user myself!).

By "nonstandard", do you mean using amsthm instead of the kernel \newtheorem?

I confess I don't actually have a definition of 'standard'. I am referring to the environment names 'theorem', 'lemma', etc. Many are automatically supported by LaTeXML, although I do not remember how, exactly. If you define environments like 'thm', 'lem', you will need to call \crefname by hand.

@mbertucci47
Copy link
Author

mbertucci47 commented Dec 13, 2024

@xworld21 The cleveref maintainer has been unresponsive for years and the LaTeX team is well-aware of the issues with recent kernels and cleveref. They are constantly patching the cleveref code in firstaid because cleveref makes assumptions about internal kernel code that no longer apply. See latex3/latex2e#1393, latex3/hyperref#362, https://tex.stackexchange.com/q/730148/208544, https://tex.stackexchange.com/q/711418/208544; really just search "cleveref" on TeX-SX to see the long list of issues. The recommendation is to move to zref-clever but obviously it will take a long time to convince most people to do this.

Using aliascnt is one way to work around the incompatibility. It would be nice if latexml supported it so that the same file worked locally and with latexml, even if it would otherwise work with latexml.

If you define environments like 'thm', 'lem', you will need to call \crefname by hand.

Yes, but lemma is one of the supported counters out-of-the-box by cleveref. In cleveref.sty you'll find

      \crefname@preamble{page}{page}{pages}%
      \crefname@preamble{table}{table}{tables}%
      \crefname@preamble{part}{part}{parts}%
      \crefname@preamble{chapter}{chapter}{chapters}%
      \crefname@preamble{section}{section}{sections}%
      \crefname@preamble{appendix}{appendix}{appendices}%
      \crefname@preamble{enumi}{item}{items}%
      \crefname@preamble{footnote}{footnote}{footnotes}%
      \crefname@preamble{theorem}{theorem}{theorems}%
      \crefname@preamble{lemma}{lemma}{lemmas}%
      \crefname@preamble{corollary}{corollary}{corollaries}%
      \crefname@preamble{proposition}{proposition}{propositions}%
      \crefname@preamble{definition}{definition}{definitions}%
      \crefname@preamble{result}{result}{results}%
      \crefname@preamble{example}{example}{examples}%
      \crefname@preamble{remark}{remark}{remarks}%
      \crefname@preamble{note}{note}{notes}%
      \crefname@preamble{algorithm}{algorithm}{algorithms}%
      \crefname@preamble{listing}{listing}{listings}%
      \crefname@preamble{line}{line}{lines}%

Note \crefname@preamble is just an internal version of \crefname.

@xworld21
Copy link
Contributor

The recommendation is to move to zref-clever but obviously it will take a long time to convince most people to do this.

Oh. I suppose LaTeXML should support that too.

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

No branches or pull requests

3 participants