帶有 enumitem 的引用

帶有 enumitem 的引用

如果在其他地方問過這個問題,我很抱歉。我到處尋找但沒有找到。

我正在編寫一份包含大量清單和參考文獻的文檔。我想引用清單中的一個條目,而無需明確寫出\label{}每個條目。我以為這個enumitem包可以解決這個問題,但也許我錯了。

這是一個例子:

\begin{theorem} There are four equivalent things
\begin{enumerate}[label=(\roman{*}), ref=(\roman{*})]
   \item Thing 1
   \item Thing 2
   \item Thing 3
   \item Thing 4
\end{enumerate}

然後在本文後面我稱之為

Theorem~\ref[(ii)]{thm:4.1} 

文字顯示為Theorem ??(ii)]thm:4.1

這樣的事可能嗎?還是這個要求太高了?

答案1

這裡的主要問題是\ref不支持選修的爭論。因此,第一個令牌[被認為是強制的參數傳遞給\ref,它沒有\label與之關聯的適當參數。相反,您可以使用以下選項之一,預設情況下所有這些選項都支持enumitem:

在此輸入影像描述

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}\label{thm:labelA} There are four equivalent things
\begin{enumerate}[label=(\roman*), ref=(\roman*)]
   \item \label{thm:labelA:thing1} Thing 1
   \item \label{thm:labelA:thing2} Thing 2
   \item \label{thm:labelA:thing3} Thing 3
   \item \label{thm:labelA:thing4} Thing 4
\end{enumerate}
\end{theorem}

Theorem~\ref{thm:labelA}\ref{thm:labelA:thing2}.

\begin{theorem}\label{thm:labelB} There are four equivalent things
\begin{enumerate}[label=(\roman*), ref=\thetheorem(\roman*)]
   \item \label{thm:labelB:thing1} Thing 1
   \item \label{thm:labelB:thing2} Thing 2
   \item \label{thm:labelB:thing3} Thing 3
   \item \label{thm:labelB:thing4} Thing 4
\end{enumerate}
\end{theorem}

Theorem~\ref{thm:labelB:thing2}.

\end{document}

第一個需要手動分離theorem環境標籤和枚舉項,而第二個則透過新增至\thetheorem清單ref的屬性來將其組合在一個步驟中。

相關內容