我有以下 MWE,它有嵌套编号列表。我试图引用一个特定的项目。但是,在下面给出的 MWE 中,它只给出了子列表编号 3,而不是 1.3。缺少父列表编号。如何获取带有父编号的整个项目编号?
平均能量损失
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\section{Lorem ipsum}
\begin{enumerate}[label={\textbf{\small{~\protect{\theenumi}}}},leftmargin=*]
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
\begin{enumerate}[label={\arabic*.}]
\item Aenean commodo ligula eget dolor.
\item Aenean massa.
\item \label{abc} Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
\end{enumerate}
\item Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
\begin{enumerate}[label={\arabic*.}]
\item Nulla consequat massa quis enim.
\item Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.
\begin{enumerate}
\item In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
\item Nullam dictum felis eu pede mollis pretium.
\item Integer tincidunt~\ref{abc}
\item Cras dapibus.
\end{enumerate}
\end{enumerate}
\item Vivamus elementum semper nisi.
\begin{enumerate}[label={\arabic*.}]
\item Aenean vulputate eleifend tellus.
\item Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
\item Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.
\end{enumerate}
\end{enumerate}
\end{document}
答案1
枚举列表的参考格式是默认使用的——这就是显示而不是的\arabic
原因。3
1.3
用作ref={\arabic{enumi}.\arabic*}
第二级列表的选项,这明确形成了第一级( )和第二级(\theenumi \arabic{enumi}`)enumerate
的组合引用。\arabic{enumi}
\arabic*). If you prefer the bold version of the first level numbers, then say
instead of
由于每隔一个级别都要执行一次此操作,因此使用\setlist[enumerate,2]
宏会方便得多。
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\setlist[enumerate,2]{label={\arabic*.},ref={\arabic{enumi}.\arabic*}}
\section{Lorem ipsum}
\begin{enumerate}[label={\textbf{\small{~\protect{\theenumi}}}},leftmargin=*]
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
\begin{enumerate}
\item Aenean commodo ligula eget dolor.
\item Aenean massa.
\item \label{abc} Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
\end{enumerate}
\item Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
\begin{enumerate}
\item Nulla consequat massa quis enim.
\item Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.
\begin{enumerate}
\item In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
\item Nullam dictum felis eu pede mollis pretium.
\item Integer tincidunt~\ref{abc}
\item Cras dapibus.
\end{enumerate}
\end{enumerate}
\item Vivamus elementum semper nisi.
\begin{enumerate}
\item Aenean vulputate eleifend tellus.
\item Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
\item Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.
\end{enumerate}
\end{enumerate}
\end{document}