我使用 titlesec 包创建了以下自定义部分。
% in the preamble
\newcounter{phase}
\titleclass{\phase}{straight}[\section]
\titleformat{\phase}{\bfseries\sffamily}{Phase~\thephase:}{1mm}{}
\renewcommand{\thephase}{\arabic{phase}}
\newcounter{task}[phase]
\titleclass{\task}{straight}[\phase]
\titleformat{\task}{\bfseries\itshape}{Task~\thephase.\thetask:}{1mm}{}
\renewcommand{\thetask}{\arabic{task}}
% within the document
\phase{Target selection and testbed preparation} % outputs Phase 1: Target selection and testbed preparation
\label{sec:phase-selection}
...
\task{Identification of target systems} % outputs Task 1.1: Identification of target systems
\label{sec:phase-selection:task-identification}
% later on in the document (ISSUE!)
Task~\ref{sec:phase-selection:task-identification} % outputs Task 1 rather than Task 1.1
为什么标签不包含正确的计数器?
答案1
我认为你需要说:
\renewcommand{\thetask}{\thephase.\arabic{task}}