LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

refstepcounter not working

Open davpoole opened this issue 1 year ago • 4 comments
trafficstars

I am trying to create a numbering so \ref produces chapter.number (as it does in \caption{}\label{foo} \ref{foo}).

I have a simple example that works in latex and produces what I want. Latex produces: The first figure is 1.1. The second figure is 1.2. The third figure is 1.3. Latexml produces: The first figure is [1]. The second figure is [1]. The third figure is [1]. with all of the hyperlinks pointing to the chapter heading.

It seems like a problem with refstepcounter. I want it to work just like \caption in latexml

Here is the zipped file to reproduce the problem: Testref.zip

Thanks! David

davpoole avatar Dec 13 '23 20:12 davpoole

\refstepcounter{aicapnum}\label{fig2} should make fig2 have the value of \theaicapnum but even that doesn't work.

davpoole avatar Dec 13 '23 22:12 davpoole

This issue is probably for Bruce to comment on, as he is the principle author of latexml's RefStepCounter mechanism.

I will just point out that the code currently starts with a comment: https://github.com/brucemiller/LaTeXML/blob/faa73d9351388d85e2481b77b131084be46b5e5a/lib/LaTeXML/Package.pm#L724-L725

which may be hinting that we may eventually want to become more precise in matching the implementation in latex.ltx, which would make the attached example behave as expected.

This improvement may happen automatically when we can load latex.ltx raw, which has some active work underway (again by Bruce).

dginev avatar Dec 13 '23 23:12 dginev

I created a simpler example. Latex gives "The value is 6" latexML gives "The value is 1".

\documentclasss{book}

\newcounter{myctr}%[chapter]

\begin{document}
\chapter{Chap1}
\refstepcounter{myctr}\refstepcounter{myctr}\refstepcounter{myctr}
\refstepcounter{myctr}\refstepcounter{myctr}\refstepcounter{myctr}
\label{fig1}

The value is \ref{fig1}.

\end{document}

It is even weirder if the documentclass is {article} and \chapter{Chap1} is commented out. Latexml says "The value is testCap2" where testCap2 is the name of the file!

So it seems like my heading is misleading.... It should be "refstepcounter not working"

davpoole avatar Dec 15 '23 04:12 davpoole

There's a related discussion in #746.

teepeemm avatar Aug 30 '24 15:08 teepeemm