我希望列表中的项目具有悬挂缩进(即,第一行之后的所有行都缩进一个或多个空格),但传统\hangindent
命令对此不起作用。
\documentclass{article}
\begin{document}
\hangindent=1cm This line of text has a hanging indent that looks fine, as long as it is outside a list environment.
\begin{enumerate}
\item \hangindent=1cm This line is inside a list environment and doesn't have a hanging indent- how can I add one?
\end{enumerate}
\end{document}
如何在列表中添加悬挂缩进?
答案1
您可以使用enumitem
包裹:
\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}% just to generate text for the example
\begin{document}
\begin{enumerate}[leftmargin=!,labelindent=5pt,itemindent=-15pt]
\item \lipsum[4]
\item \lipsum[4]
\end{enumerate}
\end{document}
另一个选择是,不需要软件包,而是使用 TeX 原语\parshape
:
\documentclass{article}
\usepackage{lipsum}
\newlength\listindent
\setlength\listindent{20pt}
\begin{document}
\begin{enumerate}
\parshape 2 0cm \linewidth \listindent \dimexpr\linewidth-\listindent\relax
\item \lipsum[4]
\item \lipsum[4]
\end{enumerate}
\end{document}