在某个enumerate
环境中,我想要:
- 为项目提供自定义显示名称,
\label
这些项目,\ref
这些项目,并让其显示显示名称。
我发现我可以通过将其作为可选参数传递来修改显示名称\item
。但是,更改后\ref
不再打印任何内容。
\documentclass{article}
\usepackage{enumerate}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\alph*)]
\item \label{Orange} It's orange.
\item \label{Round} It's round.
\item \label{Great} It's great.
\end{enumerate}
By properties \ref{Orange}, \ref{Round}, and \ref{Great} the item is a fruit.
\begin{enumerate}[label=Orangeaaa, leftmargin=*]
\item[(Orange)] \label{OrangeB} It's orange.
\item[(Round)] \label{RoundB} It's round.
\item[(Great)] \label{GreatB} It's great.
\end{enumerate}
By properties \ref{OrangeB}, \ref{RoundB}, and \ref{GreatB} the item is a fruit.
\end{document}
我想读这个By properties (Orange), (Round), and (Great), the item is a fruit.
。
如何实现这一点?
答案1
下面的示例提供了\setitem{<label>}
设置\item[<label>]
和更新- s\@currentlabel
所需的宏。\label
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\alph*)]
\item \label{Orange} It's orange.
\item \label{Round} It's round.
\item \label{Great} It's great.
\end{enumerate}
By properties \ref{Orange}, \ref{Round}, and \ref{Great} the item is a fruit.
\makeatletter
\newcommand{\setitem}[1]{\item[#1]\def\@currentlabel{#1}}
\makeatother
\begin{enumerate}[label=Orangeaaa, leftmargin=*]
\setitem{(Orange)} \label{OrangeB} It's orange.
\setitem{(Round)} \label{RoundB} It's round.
\setitem{(Great)} \label{GreatB} It's great.
\end{enumerate}
By properties \ref{OrangeB}, \ref{RoundB}, and \ref{GreatB} the item is a fruit.
\end{document}