如何在项目和子项目标签之间放置一个点来引用嵌套列表

如何在项目和子项目标签之间放置一个点来引用嵌套列表

我希望用 Ai 而不是 Ai 作为第一项的引用

\documentclass[twoside]{book}
\usepackage{enumerate}

\begin{document}  
\begin{enumerate}[A.]
  \item\label{FirstItem} First Item
  \begin{enumerate}[i.]
    \item\label{FirstSub} First Subitem
  \end{enumerate}
\end{enumerate}%[A.]
To reference the First Item,  \ref{FirstItem} and the first subitem, \ref{FirstSub}.
\end{document}

答案1

抱歉,我之前的回答是废话。这个有效:

只需添加\makeatletter\renewcommand{\p@enumii}{\theenumi.}\makeatother

\documentclass[twoside]{book}
\usepackage{enumerate}
\makeatletter\renewcommand{\p@enumii}{\theenumi.}\makeatother
\begin{document}  
\begin{enumerate}[A.]
\item\label{FirstItem}
First Item
\begin{enumerate}[i.]
\item\label{FirstSub}
First Subitem
\end{enumerate}
\end{enumerate}%[A.]
To reference the First Item,  \ref{FirstItem} and the first subitem, \ref{FirstSub}.
\end{document}

在此处输入图片描述


旧答案

只需添加\renewcommand{\labelenumii}{\theenumi.\theenumii}

\documentclass[twoside]{book}
\usepackage{enumerate}
\renewcommand{\labelenumii}{\theenumi.\theenumii}
\begin{document}  
\begin{enumerate}[A.]
\item\label{FirstItem}
First Item
\begin{enumerate}[i.]
\item\label{FirstSub}
First Subitem
\end{enumerate}
\end{enumerate}%[A.]
To reference the First Item,  \ref{FirstItem} and the first subitem, \ref{FirstSub}.
\bigskip
I want to have A.i instead of Ai.   I could put the dot myself if I could make the reference to the subitem just print i, which I also can't figure out.
\end{document}

答案2

使用enumitem而不是enumerate您可以使用的ref键:

\documentclass[twoside]{book}

\usepackage{enumitem}

\begin{document}  



\begin{enumerate}[label=\Alph*.]
\item\label{FirstItem}
First Item

\begin{enumerate}[label=\roman*.,ref=\theenumi\roman*]% \theenumi is the first level counter
\item\label{FirstSub}
First Subitem
\end{enumerate}

\end{enumerate}%[A.]


To reference the First Item,  \ref{FirstItem} and the first subitem,
\ref{FirstSub}.
\bigskip

I want to have A.i instead of Ai.   I could put the dot myself if I could make the reference to the subitem just print i, which I also can't figure out.



\end{document}

在此处输入图片描述

相关内容