![如何添加对整个计数器的引用?](https://linux22.com/image/460176/%E5%A6%82%E4%BD%95%E6%B7%BB%E5%8A%A0%E5%AF%B9%E6%95%B4%E4%B8%AA%E8%AE%A1%E6%95%B0%E5%99%A8%E7%9A%84%E5%BC%95%E7%94%A8%EF%BC%9F.png)
我想创建对我的枚举列表的完整引用。我使用包列表标签,所以我能够在表格内逐项列出。
\begin{document}
\storestyleof {enumerate}
\begin{listliketab}
\newcounter{tabenum}\setcounter{tabenum}{0}
\newcounter{tabenumm}[tabenum] % Dodanie [tabenum] wymusza wyzerowanie tabenumm, gdy tabenum wzrosnie
\setcounter{tabenumm}{0}
\newcommand{\nextnum}{\refstepcounter{tabenum}{B\thetabenum.}}
\newcommand{\nextnumm}{\refstepcounter{tabenumm}{B\thetabenum.\thetabenumm}}
% https://latex.org/forum/viewtopic.php?t=10815
\begin{tabular}{l l | l | l}
\nextnum\label{num:Red} & Red & green & blue \\
\nextnum & Happy & sad & confused \\
\nextnumm & Happy & sad & confused \\
\nextnum & Happy & sad & confused \\
\nextnumm & Happy & sad & confused \\
\nextnumm\label{num:Reddd} & Hapyy & sad & Happy \\
\nextnum & Sad & Happy & Sad \\
\nextnumm\label{num:Redd} & Hapyy & sad & Happy \\
\end{tabular}
\end{listliketab}
Reference \ref{num:Red}
Reference \ref{num:Reddd}
\vspace{1cm}
当我使用时\ref{num:Red} \ref{num:Reddd}
我得到
Reference 1 Reference 2
但我想收到
Reference B1. Reference B3.2
我怎样才能实现它?
答案1
引用的格式由命令控制\the...
,因此如果您希望能够以与列表相同的格式引用列表项,您应该做的是直接在和的定义中使用\thetabenum
,并修改\thetabenumm
和以包含格式。\nextnum
\nextnumm
\thetabenum
\thetabenumm
\documentclass{article}
\usepackage{listliketab}
\begin{document}
\storestyleof {enumerate}
\begin{listliketab}
\newcounter{tabenum}\setcounter{tabenum}{0}
\newcounter{tabenumm}[tabenum] % Dodanie [tabenum] wymusza wyzerowanie tabenumm, gdy tabenum wzrosnie
\setcounter{tabenumm}{0}
\newcommand{\nextnum}{\refstepcounter{tabenum}\thetabenum}
\newcommand{\nextnumm}{\refstepcounter{tabenumm}\thetabenumm}
\renewcommand{\thetabenum}{B\arabic{tabenum}.}
\renewcommand{\thetabenumm}{\thetabenum\arabic{tabenumm}}
% https://latex.org/forum/viewtopic.php?t=10815
\begin{tabular}{l l | l | l}
\nextnum\label{num:Red} & Red & green & blue \\
\nextnum & Happy & sad & confused \\
\nextnumm & Happy & sad & confused \\
\nextnum & Happy & sad & confused \\
\nextnumm & Happy & sad & confused \\
\nextnumm\label{num:Reddd} & Hapyy & sad & Happy \\
\nextnum & Sad & Happy & Sad \\
\nextnumm\label{num:Redd} & Hapyy & sad & Happy \\
\end{tabular}
\end{listliketab}
Reference \ref{num:Red}
Reference \ref{num:Reddd}
\end{document}