文档enumitem
显示了下图:
我正在尝试重新定义itemize
环境,以便我可以超出默认的嵌套级别。我想将每个新的嵌套级别缩进与之前的级别相似的距离。因此,根据上图,我认为\leftmargin
要使用的正确变量是:
\documentclass{article}
\usepackage{enumitem}
\usepackage{pifont, graphicx}
\let\oldlabelitemi\labelitemi
\let\oldlabelitemii\labelitemii
\let\oldlabelitemiii\labelitemiii
\let\oldlabelitemiv\labelitemiv
\setlistdepth{9}
\setlist[itemize, 1]{label=\oldlabelitemi, leftmargin=25pt}
\setlist[itemize, 2]{label=\oldlabelitemii, leftmargin=30pt}
\setlist[itemize, 3]{label=\oldlabelitemiii, leftmargin=35pt}
\setlist[itemize, 4]{label=\scalebox{0.7}{\ding{117}}, leftmargin=40pt}
\setlist[itemize, 5]{label=\scalebox{0.7}{\ding{110}}, leftmargin=45pt}
\setlist[itemize, 6]{label=\scalebox{0.7}{\ding{115}}, leftmargin=50pt}
\setlist[itemize, 7]{label=\scalebox{0.7}{\ding{108}}, leftmargin=55pt}
\setlist[itemize, 8]{label=\scalebox{0.7}{\ding{53}}, leftmargin=60pt}
\setlist[itemize, 9]{label=\oldlabelitemiv, leftmargin=65pt}
\renewlist{itemize}{itemize}{9}
\begin{document}
\begin{itemize}
\item 1
\begin{itemize}
\item 2
\begin{itemize}
\item 3
\begin{itemize}
\item 4
\begin{itemize}
\item 5
\begin{itemize}
\item 6
\begin{itemize}
\item 7
\begin{itemize}
\item 8
\begin{itemize}
\item 9
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}
但是,当我编译它时,左边距似乎随着每个新的嵌套级别而增加:
为什么会发生这种情况?我该如何防止它发生?
答案1
您可以为整个列表(包括所有级别)设置全局设置,然后\setlist*
仅使用带星号的版本来更改单个级别。例如,在下面的代码中,我只更改标签,但您也可以更改leftmargin
等等。
\documentclass{article}
\usepackage{enumitem}
\usepackage{pifont, graphicx}
\usepackage{kantlipsum}
\let\oldlabelitemi\labelitemi
\let\oldlabelitemii\labelitemii
\let\oldlabelitemiii\labelitemiii
\let\oldlabelitemiv\labelitemiv
\setlistdepth{9}
\renewlist{itemize}{itemize}{9}
\setlist[itemize]{
align=left,
leftmargin=*, % or use fixed length like 0.5em etc.
listparindent=1.5em, % indentation for subsequent paragraphs
label=\scalebox{0.7}{\ding{117}}, % Default label
}
\setlist[itemize, 1]{label=\oldlabelitemi}
\setlist[itemize, 2]{label=\oldlabelitemii}
\setlist[itemize, 3]{label=\oldlabelitemiii}
\setlist[itemize, 9]{label=\oldlabelitemiv}
\begin{document}
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\begin{itemize}
\item \kant[2][1]\kant[3][1]
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}