缩进列表项目符号并在项目符号和文本之间添加空格

缩进列表项目符号并在项目符号和文本之间添加空格

我正在使用此代码片段制作具有默认文档行间隔的列表,并且它仅缩进第一行。

% Compact list
\newenvironment{compactlist}{
 \begin{list}{{$\bullet$}}{
  \setlength{\partopsep}{0pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlength{\topsep}{0pt}
  \setlength{\itemsep}{0pt}
  \setlength{\itemindent}{\leftmargin}
  \setlength{\leftmargin}{0pt}
 }
}{
 \end{list}
}

但是它将文本缩进到默认缩进级别。如何设置两个水平间距:左边距和项目符号之间(1.25cm),以及项目符号和文本之间(0.63cm)?

更新:

\usepackage{indentfirst}
%\setlength{\parindent}{1.25cm} %uncomment to break indentation

看起来我首先需要让列表遵守为 \parindent 设置的缩进级别。

列表缩进

\documentclass[oneside,draft,14pt]{extreport}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}
\usepackage{vmargin}
\setpapersize{A4}
\fussy
\usepackage{setspace}
\onehalfspacing

\usepackage{indentfirst}
%\setlength{\parindent}{1.25cm} %uncomment to break indentation

% List with default line intervals
\newenvironment{compactlist}{
 \begin{list}{{$\bullet$}}{
  \setlength{\partopsep}{0pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlength{\topsep}{0pt}
  \setlength{\itemsep}{0pt}
  \setlength{\itemindent}{\leftmargin}
  \setlength{\leftmargin}{0pt}
 }
}{
 \end{list}
}

\begin{document}

In 1778, John Parke Custis purchased an 1,100-acre (450 ha) tract of
forested land on the Potomac River north of the town of Alexandria,
Virginia.

\begin{compactlist}
 \item This land became the Arlington Estate. John Custis died in
September 1781, and in 1799 his son, George Washington Parke Custis
("G.W.P.") step-grandson of George Washingto inherited the site. G.W.P
Custis and his wife, Mary, moved onto the estate, and between 1802 and
1814 they constructed Arlington House;
 \item The Custises extensively developed the site.
\end{compactlist}

Much of the steep slope to the east of the house
became a cultivated English landscape park, while a large flower
garden with an arbor was constructed and planted south of the house.

\end{document}

答案1

enumitem包裹是您最方便的选择:

在此处输入图片描述

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\noindent Here is some text.
\begin{itemize}[leftmargin=*,labelindent=12.5mm,labelsep=6.3mm]
  \item Here is some text.
  \item Here is some text.
\end{itemize}
\noindent \rule{12.5mm}{1pt}$\bullet$\rule{6.3mm}{1pt} \par
\noindent Here is some text.
\end{document}

设置leftmargin与左边距齐平(通过*),您需要手动设置labelindent(左边距和项目符号之间的间距)和labelsep(项目符号和文本之间的间距)。

要概括这些设置(而不必通过可选参数在本地进行设置),您可以使用

\setlist[itemize,1]{leftmargin=*,labelindent=12.5mm,labelsep=6.3mm}

它将 的第一级设置itemize为具有所需的布局。您还可以使用 创建自己的列表\newlist。请参阅部分7 克隆基本列表(第 10 页)enumitem文档

要在列表中的项目之间添加垂直间距,请修改属性itemsep。以下是经过此类修改的上述 MWE:

在此处输入图片描述

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\setlist[itemize,1]{leftmargin=*,labelindent=12.5mm,labelsep=6.3mm,itemsep=2\baselineskip}
\begin{document}
\noindent Here is some text.
\begin{itemize}
  \item Here is some text.
  \item Here is some text.
\end{itemize}
\noindent \rule{12.5mm}{1pt}$\bullet$\rule{6.3mm}{1pt} \par
\noindent Here is some text.
\end{document}

其他垂直间距属性包括topseppartopsepparsep文档,再次包括对其影响的描述。

上述 MWE 中的底行规则只是为了验证列表元素之间的长度。

答案2

最终根据我的代码找到了解决方案,因为使用 @Werner 建议的包时,我仍然遇到行距和第二行缩进问题。而且这看起来更简单(我只需要在原始帖子的代码片段中添加两行即可)。

% Compact list (assuming paragraph indent is 1.25cm)
\newenvironment{compactlist}{
 \begin{list}{{$\bullet$}}{
  \setlength{\partopsep}{0pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlength{\topsep}{0pt}
  \setlength{\itemsep}{0pt}
  \setlength{\labelsep}{0.63cm} % horizontal space from bullet to text (as needed)
  \setlength{\itemindent}{2.13cm} % summary indentation: par 1.25cm + bullet 0.63 + magic number picked empirically (0.25cm)
  \setlength{\leftmargin}{0pt} % reset margin so that only first line of list item indented
 }
}{
 \end{list}
}

相关内容