我想在附录中列出项目列表,然后在正文中引用这些项目:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{appendix}
\begin{document}
Citing appendix section (\ref{sec:appendix:A})
Autoref citing appendix section (\autoref{sec:appendix:A})
Citing an item under appendix setcion A (\ref{figure::appendix::1})
Autoref citing an item under appendix setcion A (\autoref{figure::appendix::1})
\appendix
\appendixpage
\section{A section}
\label{sec:appendix:A}
\begin{enumerate}
\item Item 1 \label{figure::appendix::1}
\end{enumerate}
\end{document}
如您所见,附录 A 中的第一项被引用为 1 或第 1 项,如何使其显示为附录 A.1 或 A.1 之类的内容?
答案1
\theenumi
进入文档的附录部分后,只需重新定义:
\renewcommand\theenumi{\thesection.\arabic{enumi}}
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{appendix}
\begin{document}
\noindent
\begin{tabular}{@{}ll}
\ref{sec:appendix:A} & Cross-reference an appendix section \\
\autoref{sec:appendix:A} & Autoref-crossreference an appendix section \\
\ref{item:app:b:2} & Cross-reference an item under appendix section B \\
\autoref{item:app:b:2} & Autoref-crossreference an item under appendix section B
\end{tabular}
\appendix
\appendixpage
\renewcommand\theenumi{\thesection.\arabic{enumi}}
\section{A section}
\label{sec:appendix:A}
\begin{enumerate}
\item Item 1 \label{figure::appendix::1}
\end{enumerate}
\section{B section}
\label{sec:appendix:B}
\begin{enumerate}
\item Item 1
\item Item 2 \label{item:app:b:2}
\end{enumerate}
\end{document}