我想创建一个缩进列表,其中列表内的新(非逐项)段落根本不缩进(也就是说,它们与正文的左边距对齐。参见下图)。
我正在使用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}