![使用嵌套枚举时,如何让更长的标签从第一个环境的标签之后的相同位置开始?](https://linux22.com/image/278125/%E4%BD%BF%E7%94%A8%E5%B5%8C%E5%A5%97%E6%9E%9A%E4%B8%BE%E6%97%B6%EF%BC%8C%E5%A6%82%E4%BD%95%E8%AE%A9%E6%9B%B4%E9%95%BF%E7%9A%84%E6%A0%87%E7%AD%BE%E4%BB%8E%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%8E%AF%E5%A2%83%E7%9A%84%E6%A0%87%E7%AD%BE%E4%B9%8B%E5%90%8E%E7%9A%84%E7%9B%B8%E5%90%8C%E4%BD%8D%E7%BD%AE%E5%BC%80%E5%A7%8B%EF%BC%9F.png)
我希望能够在嵌套enumerate
环境中使用长标签,而不会让它们与上一层重叠。我真的不知道如何正确解释这一点,所以这里有一个 MWE 来说明我想要什么。
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}
有人知道怎么做吗?
答案1
和enumerate
您在上一个问题中说过,您宁愿不切换,enumitem
而是继续使用enumerate
这个套餐。
使用后者并添加
\setlength{\labelsep}{1em}
序言(正如我在您上一个问题中所说的那样)解决了这个问题。
平均能量损失
\documentclass{article}
\usepackage{enumerate}
\setlength{\labelsep}{1em}
\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}
输出:
和enumitem
相反,如果您已经切换到enumitem
,则可以通过在序言中添加以下几行来解决问题:
\setlist[enumerate]{
leftmargin=*
}
这样你修改后的 MWE
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\setlist[enumerate]{
leftmargin=*
}
\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}
产量
答案2
如果是意外使用且特殊更改仍然存在:
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\newlength{\LLwidth}
\settowidth{\LLwidth}{Long Label a)}
\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
Stuff
\leftmarginii\LLwidth
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item
\leftmarginii\LLwidth
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}
答案3
我不完全确定你想要什么,但如果只是嵌套的枚举环境总是比它们的父级“小”,那么这样做就可以了:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{showframe}% <-- just to give some perspective
\usepackage{enumitem}
\setlist{labelindent=0pt, align=left}
\newlength\LLwidth
\settowidth{\LLwidth}{Long Label a}% <-- this is not good for consistency
\setlength{\LLwidth}{3cm}% <-- this is better; but maybe pick a font-based value
\begin{document}
\noindent lksjdf
\begin{enumerate}
\item Hello
\begin{enumerate}
\item Here is a normal enunerate with short labels.
\item It looks pretty.
\item I would like to have all of my labels ``start'' at the same
place.
\item That is to say, after the first label.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item Stuff
\begin{enumerate}[leftmargin=*, labelwidth={\LLwidth}, label={Long Label
\alph*)}]
\item Here is an enumerate with long lables.
\item Notice that the labels start before the label of the containing
enumerate environment.
\setcounter{enumii}{12}% <-- just to see a wider label in effect
\item I find this undesirable.
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item ~ % <-- prevent the overlap
\begin{enumerate}[leftmargin=*, labelwidth={\LLwidth}, label={Long Label
\alph*)}]
\item As you can see, the issue becomes even more obvious when there
is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}
如果您使用长标签做一堆奇怪的事情,我建议您使用功能\setlist
来enumitem
保持列表环境中的一致性。