我希望对自定义计数器的引用进行精确的控制。
例如,
- 我想引用一系列两个独立的计数器
- 我想选择参考文献的格式
我四处寻找,但还没有找到解决方案。
这是一个 MWE。
\documentclass{article}
\newcounter{counterOne}
\newcounter{counterTwo}
\renewcommand{\thecounterTwo}{\alph{counterTwo}}
\begin{document}
\refstepcounter{counterOne}
\refstepcounter{counterTwo}
\label{here} Here
It was \ref{here}.
\bigskip
I would like that it displays : It was \textbf{1.(a)}
\end{document}
编辑:
我试过 David 的答案,但不起作用。这是 MWE。不幸的是,由于我不理解答案中使用的命令,我无法自己修复错误。
\documentclass{article}
\newcounter{counterOne}
\newcounter{counterTwo}
\renewcommand{\thecounterTwo}{\alph{counterTwo}}
\makeatletter
\def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}
\makeatother
\labelformat{counterTwo}{\textbf{\thecounterOne.(#1)}}
\begin{document}
\refstepcounter{counterOne}
\refstepcounter{counterTwo}
\label{here} Here
It was \ref{here}.
\bigskip
I would like that it displays : It was \textbf{1.(a)}
\end{document}
错误是
@firstofone 的参数有一个额外的}。\par l.23 \end{document}
答案1
\documentclass{article}
\newcounter{counterOne}
\newcounter{counterTwo}
\renewcommand{\thecounterTwo}{\alph{counterTwo}}
% \labelformat is defined in current latex to customise the output from \ref
% For older formats load the package \usepackage{varioref} from the core
% tools bundle which originally defined this mechanism.
\labelformat{counterTwo}{\textbf{\thecounterOne.(#1)}}
\begin{document}
\refstepcounter{counterOne}
\refstepcounter{counterTwo}
\label{here} Here
It was \ref{here}.
\bigskip
I would like that it displays : It was \textbf{1.(a)}
\end{document}