brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
961 stars 101 forks source link

refstepcounter not working #2282

Open davpoole opened 11 months ago

davpoole commented 11 months ago

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 commented 11 months ago

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

dginev commented 11 months ago

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).

davpoole commented 11 months ago

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"

teepeemm commented 3 months ago

There's a related discussion in #746.