我想創建一個縮進列表,其中列表中的新(非逐項列出)段落根本不縮進(也就是說,它們與正文的左邊距對齊。請參見下圖)。
我正在使用enumitem
具有以下選項的套件:
labelsep=8pt,
labelindent=0.5\parindent,
itemindent=0pt,
leftmargin=*,
listparindent=-\leftmargin
(* 應該用於計算\leftmargin
其他參數的值和自動計算的標籤寬度)。然而,這並沒有達到預期的結果(請參閱下面的 MWE)。如果我設定相反
leftmargin=3cm
listparindent=-\leftmargin
它按預期工作(但我不想將左邊距設定為特定值,我想要的是固定\labelindent
和\labelsep
)。插入
\noindent\hskip-\leftmargin
在有問題的段落開頭也可以,但確實不是很有系統。我應該如何設定enumerate
選項來實現我想要的?
微量元素
\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{%
labelsep=8pt,%
labelindent=0.5\parindent,%
itemindent=0pt,%
leftmargin=*,%
listparindent=-\leftmargin%
}
\begin{document}
A normal paragraph of text just to show where
the left margin lies, for comparison. New paragraphs
inside enumerate should start at that left margin.
\begin{enumerate}[label=Case \arabic*:]
\item By setting the enumerate options in a
(I think) sensible manner, I don't achieve what I want
This paragraph shouldn't be indented at all!
\item I want to set the options so that new paragraphs
behave like the following one
\noindent\hskip-\leftmargin
This paragraph is indeed not indented at all!
\end{enumerate}
\begin{enumerate}[resume*,leftmargin=3cm,listparindent=-\leftmargin]
\item Setting a specific value for leftmargin also works\dots
But this is not what I want :-(
\end{enumerate}
\end{document}
我會避免在所有enumerate
環境中這樣做;為此定義一個新列表。
答案1
我不確定你為什麼要這樣做。但是,方法如下:
\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem}
\setlist[enumerate]{
labelsep=8pt,
labelindent=0.5\parindent,
itemindent=0pt,
leftmargin=*,
before=\setlength{\listparindent}{-\leftmargin},
}
\begin{document}
A normal paragraph of text just to show where
the left margin lies, for comparison. New paragraphs
inside enumerate should start at that left margin.
\begin{enumerate}[label=Case \arabic*:]
\item By setting the enumerate options in a
(I think) sensible manner, I don't achieve what I want
This paragraph shouldn't be indented at all!
\item I want to set the options so that new paragraphs
behave like the following one
This paragraph is indeed not indented at all!
\end{enumerate}
\begin{enumerate}[resume*,leftmargin=3cm,listparindent=-\leftmargin]
\item Setting a specific value for leftmargin also works\dots
This is what I want.
\end{enumerate}
This is what I want. % just to show the left margin
\end{document}
\listparindent
當 的值\leftmargin
確定後,必須延遲設定。
答案2
或者不就是這樣嗎(我發現第一個段落的左邊距非零,而該項目中的後續段落的左邊距為零看起來不太好):
\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{%
wide =0.5\parindent,
listparindent=0pt%
}%
\begin{document}
A normal paragraph of text just to show where the left margin lies, for comparison. New paragraphs
inside enumerate should start at that left margin.
\begin{enumerate}[label=Case \arabic*:]
\item By setting the enumerate options in a
(I think) sensible manner, I don't achieve what I want
This paragraph shouldn't be indented at all! This paragraph shouldn't be indented at all!
\item I want to set the options so that new paragraphs
behave like the following one.
This paragraph is indeed not indented at all!
\item Setting a specific value for leftmargin also works\dots
But is this what you want?
\end{enumerate}
\end{document}