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

equation accidentally adopts theorem label #2276

Open nschloe opened 12 months ago

nschloe commented 12 months ago

MWE:

\documentclass{article}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{equation}
dummy
\end{equation}

\begin{theorem}
\begin{equation}
x = 1
\label{leq}
\end{equation}
\label{lthm}
\end{theorem}

\ref{leq} \ref{lthm}

\end{document}

LaTeX output:

screenshot_2023-12-01-140711

LaTeXML output:

<document xmlns="http://dlmf.nist.gov/LaTeXML">
  <resource src="LaTeXML.css" type="text/css"/>
  <resource src="ltx-article.css" type="text/css"/>
  <para xml:id="p1">
    <equation xml:id="S0.E1">
      <tags>
        <tag>(1)</tag>
        <tag role="refnum">1</tag>
      </tags>
      <Math mode="display" tex="dummy" text="d * u * m * m * y" xml:id="S0.E1.m1">
        <XMath>
          <XMApp>
            <XMTok meaning="times" role="MULOP">⁢</XMTok>
            <XMTok font="italic" role="UNKNOWN">d</XMTok>
            <XMTok font="italic" role="UNKNOWN">u</XMTok>
            <XMTok font="italic" role="UNKNOWN">m</XMTok>
            <XMTok font="italic" role="UNKNOWN">m</XMTok>
            <XMTok font="italic" role="UNKNOWN">y</XMTok>
          </XMApp>
        </XMath>
      </Math>
    </equation>
  </para>
  <theorem class="ltx_theorem_theorem" inlist="thm theorem:theorem" xml:id="Thmtheorem1">
    <tags>
      <tag>Theorem 1</tag>
      <tag role="refnum">1</tag>
      <tag role="typerefnum">Theorem 1</tag>
    </tags>
    <title class="ltx_runin"><tag><text font="bold">Theorem 1</text></tag></title>
    <para xml:id="Thmtheorem1.p1">
      <equation labels="LABEL:leq LABEL:lthm" xml:id="S0.E2">
        <tags>
          <tag>(2)</tag>
          <tag role="refnum">2</tag>
        </tags>
        <Math mode="display" tex="x=1" text="x = 1" xml:id="S0.E2.m1">
          <XMath>
            <XMApp>
              <XMTok meaning="equals" role="RELOP">=</XMTok>
              <XMTok font="italic" role="UNKNOWN">x</XMTok>
              <XMTok meaning="1" role="NUMBER">1</XMTok>
            </XMApp>
          </XMath>
        </Math>
      </equation>
    </para>
  </theorem>
  <para xml:id="p2">
    <p><ref labelref="LABEL:leq"/> <ref labelref="LABEL:lthm"/></p>
  </para>
</document>

Note how the equation got the theorem label lthm, too.

(I faintly remember there was a similar bug once, but I haven't been able to find it.)

nschloe commented 12 months ago

Another one of those: Table picks up section label.

\documentclass{article}

\begin{document}

\section{Lorem}

\begin{table}[t]
  \caption{Ipsum.}
  \label{tab:ipsum}
\end{table}

\label{sec:lorem}

\end{document}
<table inlist="lot" labels="LABEL:sec:lorem LABEL:tab:ipsum" placement="t" xml:id="S1.T1">