我怎样才能使我的列表(枚举)与段落的开头对齐?

我怎样才能使我的列表(枚举)与段落的开头对齐?

我在将列表左侧与段落左侧对齐时遇到问题。这是我当前的代码:

代码:

\documentclass[draft, 12pt]{article}
\usepackage{fullpage}
\usepackage{enumitem}
\parindent = 0pt

\begin{document}

This is a random and long sentence that apparently takes up two lines just so that I 
can see what happens with alignment and indentation. Note my \texttt{parindent = 0pt}.

\begin{enumerate}
    \item This is list one first item.
\end{enumerate}

\begin{enumerate}[leftmargin = 0pt]
    \item This is list two first item.
\end{enumerate}

\end{document}

视觉表现:

      这是一个随机的长句子,显然占用了两行,只是为了让我看看对齐和缩进会发生什么。请注意我的 parindent = 0pt。

           1. 这是列表一的第一项。

1. 这是列表二的第一项。

答案1

解决方案取决于您期望列表中有多少个项目。如果项目数量为 9 或更少,请使用:

labelindent=0pt,labelwidth=0.75em,leftmargin=!

但对于 10 到 99 你应该使用更大的labelwidth=1.25em

在此处输入图片描述

笔记:

代码:

\documentclass[draft, 12pt]{article}
\usepackage{fullpage,showframe}
\usepackage{enumitem}
%\parindent = 0pt
\usepackage[parfill]{parskip}% Use this instead of \parindent = 0pt

\begin{document}

This is a random and long sentence that apparently takes up two lines just so that I 
can see what happens with alignment and indentation. Previously \verb|parindent = 0pt|, but
now this uses the \verb|parskip| package.

\begin{enumerate}[labelindent=0pt,labelwidth=1.25em,leftmargin=!]
    \item This is list one first item.
    \item This is list one second item.
    \item \ldots
    \item[9.] This is list one ninth item.
    \item[10.] This is list one tenth item.
\end{enumerate}

\bigskip
If you don't expect to go past 9 then use:
\begin{enumerate}[labelindent=0pt,labelwidth=0.75em,leftmargin=!]
    \item This is list two first item.
    \item \ldots
    \item[9.] This is list two ninth item.
\end{enumerate}

\end{document}

答案2

您还可以使项目编号左对齐,从而与文本区域的左侧对齐,使用以下wide选项:

\documentclass[draft, 12pt]{article}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{enumitem}

\usepackage{lipsum}
\begin{document}

This is a random and long sentence that apparently takes up two lines just so that I
can see what happens with alignment and indentation.

\noindent
\begin{enumerate}[wide = 0pt, labelwidth = 1.3333em, labelsep = 0.3333em, leftmargin = \dimexpr\labelwidth + \labelsep\relax ]%
    \item This is list one first item.
    \item This is list one second item.
    \item \ldots
    \item[9.] \lipsum[9]
    \item[10.] \lipsum[10]
\end{enumerate}

\end{document} 

在此处输入图片描述

相关内容