![如何理解enumitem枚举列表的水平间距?](https://linux22.com/image/324587/%E5%A6%82%E4%BD%95%E7%90%86%E8%A7%A3enumitem%E6%9E%9A%E4%B8%BE%E5%88%97%E8%A1%A8%E7%9A%84%E6%B0%B4%E5%B9%B3%E9%97%B4%E8%B7%9D%EF%BC%9F.png)
\documentclass{article}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\newcommand{\currentsection}{3.5}
\setlist[enumerate,1]{label=\currentsection.\arabic*.}
\setlist[enumerate,2]{align=left,widest=a,leftmargin=*}
\begin{document}
\begin{enumerate}
\item ohai
\begin{enumerate}
\item ok
\item hi
\end{enumerate}
\item ohai
\item ohai
\end{enumerate}
\end{document}
上面的代码片段以某种方式将第二级枚举列表对齐到左侧。我读到http://tug.org/texinfohtml/latex2e.html#list和http://mirrors.ctan.org/macros/latex/contrib/enumitem/enumitem.pdf,但是我还是不明白它是怎么工作的。有没有关于枚举列表水平间距的综合文档?
答案1
这有帮助吗?例如,我一直使用最宽项目的标签宽度来计算事物,因此leftmargin=!
没有效果。leftmargin=*
labelwidth
\documentclass{article}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\newcommand{\currentsection}{3.5}
\setlist[enumerate,1]{label=\currentsection.\arabic*.}
\begin{document}
\begin{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,leftmargin=!]
\item the leftmost point of the left margin is aligned with the rightmost point of the left margin of the enclosing list
\end{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,labelindent=5mm,leftmargin=!]
\item the leftmost point of the left margin is aligned with the rightmost point of the left margin of the enclosing list
\item the label begins 5mm to the right of the left margin
\end{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,labelindent=5mm,labelwidth=15mm,leftmargin=!]
\item the leftmost point of the left margin is aligned with the rightmost point of the left margin of the enclosing list
\item the label begins 5mm to the right of the left margin
\item 15mm is allowed for the label
\end{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,labelwidth=15mm,leftmargin=!]
\item the leftmost point of the left margin is aligned with the rightmost point of the left margin of the enclosing list
\item 15mm is allowed for the label
\end{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,labelsep=5mm,leftmargin=!]
\item the leftmost point of the left margin is aligned with the rightmost point of the left margin of the enclosing list
\item 5mm is left between the rightmost side of the label and the start of the item body
\end{enumerate}
\item ohai
\begin{enumerate}[align=left,widest=a,itemindent=35mm,leftmargin=!]
\item the indentation of the item body, relative to the left margin is 135mm, so the left margin is now further left than in the other cases
\end{enumerate}
\end{enumerate}
\end{document}
如果你设置
\setlist[enumerate,2]{align=left,labelsep=0pt,leftmargin=*}
然后标签左对齐在标签宽度范围内。因此标签右侧会有一些空间。如果您使用
[align=right,labelsep=0pt,leftmargin=!]
然后你会看到空间消失了: