![使用属性进行枚举](https://linux22.com/image/243554/%E4%BD%BF%E7%94%A8%E5%B1%9E%E6%80%A7%E8%BF%9B%E8%A1%8C%E6%9E%9A%E4%B8%BE.png)
我如何才能轻松地定制\enumerate
环境,以便每行不被编号为1.
、2.
等,而是被编号为Property 1.
、Property 2.
等?
答案1
例如,您可以使用该enumitem
包来定制enumerate
环境。
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=Property \arabic*.,itemindent=*]
\item First
\item Second
\end{enumerate}
\end{document}
enumitem
还允许您定义自己的列表环境:
\documentclass{article}
\usepackage{enumitem}
\newlist{Properties}{enumerate}{2}
\setlist[Properties]{label=Property \arabic*.,itemindent=*}
\begin{document}
\begin{Properties}
\item First
\item Second
\end{Properties}
\end{document}
设置itemindent
为*
自动计算整个标签所需的宽度。如果不设置,标签将会超出左边距。
如果项目文本太长,一行无法容纳,下一行将从左边距稍微缩进:
如果您希望第二行与项目文本的开头对齐,请使用leftmargin=*
代替itemindent=*
。如果您希望第二行不缩进,请使用leftmargin=0pt
除了itemindent=*
。以下示例总结了这一点:
\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem}
\begin{document}
Just changing the label:
\begin{enumerate}[label=Property \arabic*.]
\item First, with a very long text that should extend to the next line if I'm not very much mistaken.
\item Second.
\end{enumerate}
\hrule\medskip
With \verb|itemindent=*|:
\begin{enumerate}[label=Property \arabic*.,itemindent=*]
\item First, with a very long text that should extend to the next line if I'm not very much mistaken.
\item Second.
\end{enumerate}
\hrule\medskip
With \verb|leftmargin=*|:
\begin{enumerate}[label=Property \arabic*.,leftmargin=*]
\item First, with a very long text that should extend to the next line if I'm not very much mistaken.
\item Second.
\end{enumerate}
\hrule\medskip
With \verb|itemindent=*,leftmargin=0pt|:
\begin{enumerate}[label=Property \arabic*.,itemindent=*,leftmargin=0pt]
\item First, with a very long text that should extend to the next line if I'm not very much mistaken.
\item Second.
\end{enumerate}
\end{document}