像使用 LaTeX 一样在 HTML 中引用定理

Val*_*rio 6 html css counter

我正在编写一些包含数学内容的网页(使用 MathJax),并且我正在寻找一种方法来进行与 LaTeX 定理引用等效的操作,如下例所示:

\begin{theorem} \label{thm:commute}
    a+b=b+a
\end{theorem} 
According to Theorem (\ref{thm:commute}), $2+3=3+2$.
Run Code Online (Sandbox Code Playgroud)

我使用以下 CSS/HTML 代码来生成自动定理编号:

.theorem:before {
    font-style: normal; 
    font-weight: bold; 
    content: "Theorem " counter(chap)"."counter(sect)"."counter(thm)" ";  
}
.theorem {
    counter-increment: theorem ;  
}
Run Code Online (Sandbox Code Playgroud)
<div class="theorem">     
    \(a+b=b+a\)
</div>
Run Code Online (Sandbox Code Playgroud)

我需要相当于 LaTeX 的命令\label,以及\ref为定理分配名称的命令,以便稍后可以在网页上引用它,并且将显示counter(chap)"."counter(sect)"."counter(thm).