如何將我的清單(枚舉)與段落的開頭對齊?

如何將我的清單(枚舉)與段落的開頭對齊?

我在將清單左側與段落左側對齊時遇到問題。這是我目前的程式碼:

代碼:

\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}

視覺表現:

      這是一個隨機的長句子,顯然佔據了兩行,這樣我就可以看到對齊和縮排會發生什麼。注意我的父母 = 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} 

在此輸入影像描述

相關內容