我希望引用时自动重复item
in 和enumerate
环境中的文本。这类似于 MS Word 插入整个文本的交叉引用选项。也可以适用于标题。
\documentclass{article}
\begin{document}
\begin{enumerate}
\item Item 1 ...\label{item:1}
\item Item 2 ...\label{item:2}
\item Item 3 ...\label{item:3}
\end{enumerate}
In Item~\ref{item:1} it is stated that:
\ref{item:1} <==== How to make this display the whole text of Item 1?
\end{document}
答案1
最好稍微改变列表语法,因为乳胶通常根本不保存文本。
\documentclass{article}
\newcommand\itemtext[2]{%
\expandafter\gdef\csname item#1\endcsname{#2}%
\label{#1}#2}
\newcommand\useitemtext[2]{\csname item#1\endcsname}
\begin{document}
\begin{enumerate}
\item \itemtext{item:1}{Item 1 ...}
\item \itemtext{item:2}{Item 2 ...}
\item \itemtext{item:3}{Item 3 ...}
\end{enumerate}
In Item~\ref{item:1} it is stated that:
\useitemtext{item:1}
\end{document}
答案2
您也可以使用该clipboard
包来代替。
\documentclass{article}
\usepackage{clipboard}
\begin{document}
\begin{enumerate}
\item \Copy{item:1}{Item 1} ...\label{item:1}
\item Item 2 ...\label{item:2}
\item Item 3 ...\label{item:3}
\end{enumerate}
In Item~\ref{item:1} it is stated that:
\Paste{item:1}
\end{document}