![5 级或更多级的深度列表,显示所有子部分以及引用 \ref {} 时的内容](https://linux22.com/image/460634/5%20%E7%BA%A7%E6%88%96%E6%9B%B4%E5%A4%9A%E7%BA%A7%E7%9A%84%E6%B7%B1%E5%BA%A6%E5%88%97%E8%A1%A8%EF%BC%8C%E6%98%BE%E7%A4%BA%E6%89%80%E6%9C%89%E5%AD%90%E9%83%A8%E5%88%86%E4%BB%A5%E5%8F%8A%E5%BC%95%E7%94%A8%20%5Cref%20%7B%7D%20%E6%97%B6%E7%9A%84%E5%86%85%E5%AE%B9.png)
这是我的第一个查询,我正在学习使用 Latex。您好!!我想看看如何使用\ref{A.i.2.b.ii}
(五个级别)进行引用,以及\ref{B.ii.3.b.ii.}
在另一部分中完全引用 pdf。我希望区分子部分,以便知道我想要查看的区域位于何处。不过,我只得到了第一个引用2.
和第二个引用的结尾1.ii.
,我希望能够完整显示整个部分;在 pdf 中A.i.2.b.ii
也是如此。B.ii.3.b.ii.
我尝试使用一些代码但困难在于它没有深度问题。
当我尝试使用一些参数(不使用 MyEnumerate 并且级别少于 5 个)时,它对我找到的一些代码有效。不过,我需要 5 个级别(或者更多),这就是困难的开始,当我添加更多级别时,我尝试引用以\ref{A.ii.2.b.ii}
查看特定于级别的路径A.ii.2.b.ii
,但2
元素出现了,其他引用也发生了同样的情况。下面是我在搜索了许多示例后实现的代码。
\usepackage{enumitem}
\begin{document}
\section{Adding item}
\newlist{myEnumerate}{enumerate}{6}
\setlistdepth{6}
\newlist{myEnumerate}{enumerate}{6}
\setlist[myEnumerate,1]{label={\Alph*.},ref={\Alph*.}}
\setlist[myEnumerate,2]{label={\theenumi.\roman*.},ref={\theenumi.\alph*.}}
\setlist[myEnumerate,3]{label={\theenumi\theenumii.\arabic*.},ref={\theenumi\theenumii.\arabic*.}}
\setlist[myEnumerate,4]{label={\theenumi\theenumii\theenumiii.\alph*.},ref={\theenumi\theenumii\theenumiii.\alph*.}}
\setlist[myEnumerate,5]{label={\theenumi\theenumii\theenumiii.\theenumiv\roman*.},ref={\theenumi\theenumii\theenumiii.\theenumiv\roman*.}}
\begin{myEnumerate}%[Alph.]
\item \label{A.}
\begin{myEnumerate}%[A.roman.]
\item \label{A.i.} I want this to appear as the subsection.5 A.i. for full reference.
\begin{myEnumerate}% [A.i.arabic.]
\item \label{A.i.1.} I want this to appear as the subsection A.i.1. for full reference.
\item \label{A.i.2.} I want this to appear as the subsection A.i.2. for full reference.
\begin{myEnumerate}%[A.i.2.alph.]
\item \label{A.i.2.a.} I want this to appear as the subsection A.i.2.a. for full reference.
\item \label{A.i.2.b.} I want this to appear as the subsection A.i.2.b. for full reference.
\begin{enumerate}%[A.i.2.b.roman.]
\item \label{A.i.2.b.i.} I want this to appear as the subsection A.i.2.b.i. for full reference.
\item \label{A.i.2.b.ii.} I want this to appear as the subsection A.i.2.b.ii. for full reference.
\item \label {A.i.2.b.iii.} I want this to appear as the subsection A.i.2.b.iii for full reference.
\end{enumerate}%[A.i.2.b.roman.]
\end{myEnumerate}%[A.i.2.alph.]
\end{myEnumerate}%[A.i.arabic.]
\item \label{A.ii.} I want this to appear as the subsection A.ii. for full reference.
\begin{enumerate}%[A.ii.arabic.]
\item \label{A.ii.1.} I want this to appear as the subsection A.ii.1. for full reference.
\end{enumerate}%[A.ii.arabic.]
\end{myEnumerate}%[A.roman]
\item \label{B.}
\begin{myEnumerate}%[B.roman.]
\item \label{B.i} I want this to appear as the subsection B.i. for full reference.
\item \label{B.ii.} I want this to appear as the subsection B.ii. for full reference.
\begin{myEnumerate}%[B.ii.arabic.]
\item \label{B.ii.1.} I want this to appear as the subsection B.ii.1. for full reference.
\item \label{B.ii.2.} I want this to appear as the subsection B.ii.2. for full reference.
\item \label{B.ii.3.} I want this to appear as the subsection B.ii.3. for full reference.
\begin{myEnumerate}%[B.ii.3.alph.]
\item \label{B.ii.3.a.} I want this to appear as the subsection B.ii.3.a. for full reference.
\item \label{B.ii.3.b.} I want this to appear as the subsection B.ii.3.b. for full reference.
\begin{myEnumerate}%[B.ii.3.b.roman]
\item \label{B.ii.3.b.i.} I want this to appear as the subsection B.ii.3.b.i. for full reference.
\item \label{B.ii.3.b.ii.} I want this to appear as the subsection B.ii.3.b.ii for full reference.
\item \label{B.ii.3.b.iii.} I want this to appear as the subsection B.ii.3.b.iii for full reference.
\end{myEnumerate}%[B.ii.3.b.roman]
\end{myEnumerate}%[B.ii.3.alph.]
\item \label{B.ii.4.} I want this to appear as the subsection B.ii.4. for full reference.
\item \label{B.ii.5.} I want this to appear as the subsection B.ii.5. for full reference.
\end{myEnumerate}%[B.ii.arabic.]
\item \label{B.iii} I want this to appear as the subsection B.iii. for full reference.
\end{myEnumerate}%[B.roman]
\item \label{D} the same for the others.. THANK YOU!!!
\end{myEnumerate}%[Alph]
\section{Reference to item}
I want to reference this $\backslash$item $A.i.2.b.ii.$ completely, but it comes out like this \ref{A.i.2.b.ii.}.
I want to reference this $\backslash$item $B.i.3.b.ii.$ completely, but it comes out like this \ref{B.ii.3.b.ii.}.
I want to reference this $\backslash$item $B.ii.3$ completely, but it comes out like this \ref{B.ii.3.}.
I want to reference this $\backslash$item $A.i.2.$ completely, but it comes out like this \ref{A.i.2.}.
I want to reference this $\backslash$item $B.ii.$ completely, but it comes out like this \ref{B.ii.}.
\end{document}
我尝试了其他变化,但它们都有效。
%\renewcommand{\theenumi}{\Alph{enumi}}
%\renewcommand{\theenumii}{\roman{enumii}}
%\renewcommand{\theenumiii}{\arabic{enumiii}}
%\renewcommand{\theenumiv}{\alph{enumiv}}
%\renewcommand{\theenumv}{\roman{enumv}}
%\renewcommand{\labelenumi}{\theenumi}
%\renewcommand{\labelenumii}{\theenumi.\theenumii.}
%\renewcommand{\labelenumiii}{\theenumi.\theenumii.\theenumiii.}
%\renewcommand{\labelenumiv}{\theenumi.\theenumii.\theenumiii.\theenumiv.}
%\setlist*[myEnumerate,1]{label={\Alph*.},ref={\theenumi\Alph*.}}
%\renewcommand{\theenumi}{\Alph{enumi}}
%\setlist[myEnumerate,2]{label={\theenumi.\roman*.},ref={theenumi\roman*.}}
%\setlist[myEnumerate,3]{label={\theenumi\theenumii.\arabic*.},ref=%{\bfseries\theenumii\arabic*.}}
%\setlist[myEnumerate,4]{label={\series\Alph*.\series\roman*.\series\arabic*.\series\alph*.}}
%\setlist[myEnumerate,5]{label={\series\roman*.}}
%\renewcommand{\theenumi}{\Alph{enumi}}
%\renewcommand{\theenumii}{\roman{enumii}}
%\renewcommand{\theenumiii}{\arabic{enumiii}}
%\renewcommand{\theenumiv}{\alph{enumiv}}
%\renewcommand{\theenumv}{\roman{enumv}}
提前非常感谢您,我感谢您的帮助。
答案1
为了在标签和引用中定义分层的编号方案,只需使用label*
提供的键即可enumitem
; 来自enumitem
文档:“label*
类似label
,但是其值附加到了父标签之后。”
而且由于您没有区分标签和其\ref
错误,因此您不需要提供ref
值。
\documentclass{article}
\usepackage{enumitem}
\newlist{myEnumerate}{enumerate}{6}
\setlist[myEnumerate,1]{label={\Alph*.}}
\setlist[myEnumerate,2]{label*={\roman*.}}
\setlist[myEnumerate,3]{label*={\arabic*.}}
\setlist[myEnumerate,4]{label*={\alph*.}}
\setlist[myEnumerate,5]{label*={\roman*.}}
\begin{document}
\section{Adding item}
\begin{myEnumerate}%[Alph.]
\item \label{A.}
\begin{myEnumerate}%[A.roman.]
\item \label{A.i.} I want this to appear as the subsection A.i. for full reference.
\begin{myEnumerate}% [A.i.arabic.]
\item \label{A.i.1.} I want this to appear as the subsection A.i.1. for full reference.
\item \label{A.i.2.} I want this to appear as the subsection A.i.2. for full reference.
\begin{myEnumerate}%[A.i.2.alph.]
\item \label{A.i.2.a.} I want this to appear as the subsection A.i.2.a. for full reference.
\item \label{A.i.2.b.} I want this to appear as the subsection A.i.2.b. for full reference.
\begin{myEnumerate}%[A.i.2.b.roman.]
\item \label{A.i.2.b.i.} I want this to appear as the subsection A.i.2.b.i. for full reference.
\item \label{A.i.2.b.ii.} I want this to appear as the subsection A.i.2.b.ii. for full reference.
\item \label {A.i.2.b.iii.} I want this to appear as the subsection A.i.2.b.iii for full reference.
\end{myEnumerate}%[A.i.2.b.roman.]
\end{myEnumerate}%[A.i.2.alph.]
\end{myEnumerate}%[A.i.arabic.]
\item \label{A.ii.} I want this to appear as the subsection A.ii. for full reference.
\begin{enumerate}%[A.ii.arabic.]
\item \label{A.ii.1.} I want this to appear as the subsection A.ii.1. for full reference.
\end{enumerate}%[A.ii.arabic.]
\end{myEnumerate}%[A.roman]
\item \label{B.}
\begin{myEnumerate}%[B.roman.]
\item \label{B.i} I want this to appear as the subsection B.i. for full reference.
\item \label{B.ii.} I want this to appear as the subsection B.ii. for full reference.
\begin{myEnumerate}%[B.ii.arabic.]
\item \label{B.ii.1.} I want this to appear as the subsection B.ii.1. for full reference.
\item \label{B.ii.2.} I want this to appear as the subsection B.ii.2. for full reference.
\item \label{B.ii.3.} I want this to appear as the subsection B.ii.3. for full reference.
\begin{myEnumerate}%[B.ii.3.alph.]
\item \label{B.ii.3.a.} I want this to appear as the subsection B.ii.3.a. for full reference.
\item \label{B.ii.3.b.} I want this to appear as the subsection B.ii.3.b. for full reference.
\begin{myEnumerate}%[B.ii.3.b.roman]
\item \label{B.ii.3.b.i.} I want this to appear as the subsection B.ii.3.b.i. for full reference.
\item \label{B.ii.3.b.ii.} I want this to appear as the subsection B.ii.3.b.ii for full reference.
\item \label{B.ii.3.b.iii.} I want this to appear as the subsection B.ii.3.b.iii for full reference.
\end{myEnumerate}%[B.ii.3.b.roman]
\end{myEnumerate}%[B.ii.3.alph.]
\item \label{B.ii.4.} I want this to appear as the subsection B.ii.4. for full reference.
\item \label{B.ii.5.} I want this to appear as the subsection B.ii.5. for full reference.
\end{myEnumerate}%[B.ii.arabic.]
\item \label{B.iii} I want this to appear as the subsection B.iii. for full reference.
\end{myEnumerate}%[B.roman]
\item \label{D} the same for the others.. THANK YOU!!!
\end{myEnumerate}%[Alph]
\end{document}