![创建不同“类别”的标签](https://linux22.com/image/303274/%E5%88%9B%E5%BB%BA%E4%B8%8D%E5%90%8C%E2%80%9C%E7%B1%BB%E5%88%AB%E2%80%9D%E7%9A%84%E6%A0%87%E7%AD%BE.png)
我正在尝试撰写一篇论文,我想为恒等式和方程式设置不同类别的标签。也就是说,我想要类似这样的东西,\label{eq:firsteq}
即\label{id:firstid}
我恒等式的编号系统(\ref{id: whatever)
与我的方程式的编号系统不同(\ref{eq: whatever})
。
例如说我有
\begin{equation}\label{eq:firsteq} a = b \end{equation}
\begin{equation}\label{id:firstid} c = d \end{equation}
然后我想要一些东西,这样当我打电话时
\ref{eq:firsteq}
\ref{id:firstid}
我得到的是 1 和 1,而不是 1 和 2。我尝试谷歌搜索,在 caption 包下找到了一些用于对数字进行不同枚举的方法,但我没有对数字进行这种操作。感谢您的帮助!
答案1
我在这里所做的是\meaning
确定equation
环境的定义方式。然后,我identity
使用不同的计数器和标签格式(括号,而不是圆括号)在同一行上创建了一个环境。
equation
使用适当的环境成为用户的责任identity
。
\documentclass{article}
\usepackage[T1]{fontenc}
\newcounter{identity}
\makeatletter
\newenvironment{identity}
{$$\refstepcounter{identity}}
{\eqno\hbox{[\arabic{identity}]}$$\@ignoretrue}
\makeatother
\begin{document}
\meaning\equation
\meaning\endequation
\begin{equation}\label{eq:firsteq} a = b \end{equation}
\begin{identity}\label{id:firstid} c = d \end{identity}
Reference equation \ref{eq:firsteq}.
Reference identity \ref{id:firstid}.
\end{document}