LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

missing cleveref tags

Open xworld21 opened this issue 1 year ago • 2 comments

It appears that cleveref is not working as intended.

\documentclass{article}
\usepackage{cleveref}
\newtheorem{thm}{Theorem}
\begin{document}
\begin{thm}\label{theorem}
  This theorem.
\end{thm}
Reference should start with `Theorem': \Cref{theorem}.
\end{document}

If I understand correctly, the problem is somewhere around here:

<tags>
  <tag>Theorem 1</tag>
  <tag role="refnum">1</tag>
  <tag role="typerefnum">Theorem 1</tag>
</tags>
...
<ref labelref="LABEL:theorem" show="creftypecap~refnum"/>

I gather that there should be a tag with role creftypecap... ? E.g. loading hyperref adds a tag with role "autoref", but for some reason cleveref does not have the same effect.

Edit: fixed location of \newtheorem.

xworld21 avatar Jan 26 '24 21:01 xworld21

@xworld21 could we double-check the intended behavior here? The PDF build shows:

where the pdflatex build also prints the warning:

LaTeX Warning: Cref reference format for label type `thm' undefined on input li
ne 8.

[1{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./test.aux)

LaTeX Warning: There were undefined references.

LaTeXML currently seems to show the linked 1 part of the ref, but doesn't print ??? to signal thm was an unknown label. Maybe we should, and also raise a warning?

Edit: changing thm to theorem fixes both PDF and HTML builds, for what that's worth.

dginev avatar Jan 27 '24 02:01 dginev

Oh, I mistyped the example. The \newtheorem needs to be in the preamble. Then the PDF will show the expected label. image

I investigated a little bit. cleveref.sty patches \newtheorem in order to automatically set the names, so of course LaTeXML won't pick that up. The binding has to do some work to attach itself to defineNewTheorem, or wrap the LaTeXML version of \newtheorem, I suppose.

I'd say the labels should also return ??, ???? so that the missing definitions are visible? At least with ?? one can see the missing tags and fix the problem by calling \crefname manually.

xworld21 avatar Jan 27 '24 11:01 xworld21