我有一个自定义枚举列表,它定义了工作包。即使是第一个嵌套级别,一切工作正常。但在下一个较低的嵌套级别,编号不会继续:
我已经创建了命令\crcItem{<hook>}
,作为工作包引用的钩子。强制对象仅用于引用,不显示。然而我更愿意,\item[<hook>]
但我无法重塑命令。
这是我的源代码:
\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{hyperref}
\usepackage[noabbrev]{cleveref}
% ==== List for Workpackages
%
\newlist{workpackages}{enumerate}{3}
\setlist[workpackages]{
align=left,
% leftmargin=*,
labelindent=0em,leftmargin=*,
% font=\normalfont,
% first=\bfseries,
topsep=3pt,
font=\sffamily\bfseries,
% nosep,
label={WP\,\arabic*:},
ref = {\bfseries WP\,\arabic*},
resume
}
\setlist[workpackages,2]{
ref={\bfseries\theworkpackagesi\alph*},
align=left,
% leftmargin=0pt,
labelindent=*em,leftmargin=*,
% font=\normalfont,
% first=\bfseries,
topsep=0pt,
font=\sffamily\bfseries,
% nosep,
label={\theworkpackagesi\alph*:}
}
\providecommand{\mylist}{}
\newcommand{\crcWP}[1]{\ref{\mylist:#1}}
\newcommand{\crcItem}[1]{\item\label{\mylist:#1}}
\begin{document}
\def\mylist{abc}
abcdefghiklmnop
\begin{workpackages}
\crcItem{A} some text
\crcItem{B} some text
\begin{workpackages}
\crcItem{B1} some text
\crcItem{B2} some text
\end{workpackages}
\end{workpackages}
abcdefghiklmnop
abcdefghiklmnop
\begin{workpackages}
\crcItem{C} some text
\crcItem{D} some text
\begin{workpackages}
\crcItem{D1} some text
\crcItem{D2} some text
\end{workpackages}
\end{workpackages}
\crcWP{A}
\crcWP{B}
\crcWP{C}
\crcWP{D}
% ==== new section
\def\mylist{def}
\restartlist{workpackages}
abcdefghiklmnop
\begin{workpackages}
\crcItem{A} some text
\crcItem{B} some text
\begin{workpackages}
\crcItem{B1} some text
\crcItem{B2} some text
\end{workpackages}
\end{workpackages}
abcdefghiklmnop
abcdefghiklmnop
\begin{workpackages}
\crcItem{C} some text
\crcItem{D} some text
\begin{workpackages}
\crcItem{D1} some text
\crcItem{D2} some text
\end{workpackages}
\end{workpackages}
\crcWP{A}
\crcWP{B}
\crcWP{D2}
\crcWP{D1}
\end{document}
答案1
对于级别大于 1 的列表,您可以使用label*
键。
这是一个有效的代码:
\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{hyperref}
\usepackage[noabbrev]{cleveref}
% ==== List for Workpackages
%
\newlist{workpackages}{enumerate}{2}
\setlist[workpackages, 1]{
wide=0pt,leftmargin=*,
topsep=3pt,
font=\sffamily\bfseries,
% nosep,
label={WP\,\arabic*:},
ref={\sffamily\bfseries WP\,\arabic*:},
}
\setlist[workpackages,2]{
label*=\alph*:,
wide=0pt,leftmargin=*,
topsep=0pt,
font=\sffamily\bfseries,
ref={\theworkpackagesi\,\alph*: }
}
\begin{document}
\def\mylist{abc}
abcdefghiklmnop
\begin{workpackages}
\item \label{first} some text
\item some text
\begin{workpackages}
\item \label{second} some text
\item some text
\end{workpackages}
\end{workpackages}
abcdefghiklmnop
abcdefghiklmnop
\begin{workpackages}[resume*]
\item some text
\item some text
\begin{workpackages}
\item \label{third}some text
\item s\label{fourth}ome text
\end{workpackages}
\end{workpackages}\bigskip
\ref{first}, \ref{second}, \ref{third}, \ref{fourth}.
\end{document}