在 enumitem 中,before= 和 after= 是如何工作的?

在 enumitem 中,before= 和 after= 是如何工作的?

我尝试为维特根斯坦《逻辑哲学论》中的引文定义一个新的描述环境,两边缩进,单倍行距。正文是一倍半行距:

\usepackage[inline,shortlabels]{enumitem}
\newlist{tlpquote}{description}{1}
\setlist[tlpquote]{font=\normalfont,parsep=6pt,itemsep=6pt,topsep=6pt,align=left,labelindent=27pt,labelwidth=36pt,labelsep*=11pt,leftmargin=!,rightmargin=27pt,before=\singlespacing,after=\onehalfspacing}

但是,结果似乎使引文后的正常段落变成单倍行距。此外,如果我的列表中只有一项,则行距为 1.5 倍,而不是单倍行距。

我使用以下内容使引用环境单倍行距(我在 sx.xs 上找到了它):

\let\oldquote\quote
\let\oldendquote\endquote
\renewenvironment{quote}{\vspace{\dimexpr-12pt-\topsep+\baselineskip\relax}\begin{spacing}{1}\oldquote}
{\oldendquote\end{spacing}\vspace{\dimexpr-12pt-\topsep+\baselineskip\relax}}

并且运行正常。我想我不理解 enumitem 的 before= 和 after= 选项。(当然,我对 enumitem 的了解实际上很少。真正理解,而不是能够工作,主要是借助这里的答案:-)

以下是 MWE:

\documentclass[11pt,oneside]{extbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}

\pagestyle{plain}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\usepackage{setspace}
\onehalfspacing

\usepackage[inline,shortlabels]{enumitem}
\newlist{tlpquote}{description}{1}

\setlist[tlpquote]{font=\normalfont,parsep=6pt,itemsep=6pt,topsep=6pt,align=left,labelindent=27pt,labelwidth=36pt,labelsep*=11pt,leftmargin=!,rightmargin=27pt,before=\singlespacing,after=\onehalfspacing}

% single space in quotes
\let\oldquote\quote
\let\oldendquote\endquote
\renewenvironment{quote}{\vspace{\dimexpr-12pt-\topsep+\baselineskip\relax}\begin{spacing}{1}\oldquote}
{\oldendquote\end{spacing}\vspace{\dimexpr-12pt-\topsep+\baselineskip\relax}}

\usepackage{ragged2e}
\RaggedRight

\setlength{\parindent}{18pt}
\newcommand{\forceindent}{\leavevmode{\parindent=1cm\indent}}

\begin{document}

The puzzles mount up when Wittgenstein brings in the notions of use,
projection, and sense to characterize propositional signs and propositions:

\begin{tlpquote}
\item [{3.11}] We use the sense-perceptible sign (sound or written sign,
etc.) of the proposition as a projection of the possible situation.


The method of projection is the thinking of the sense of the proposition.

\item [{3.12}] {[}T{]}he proposition is the propositional sign in its \emph{projective
relation} to the world.
\item [{3.13}] To the proposition belongs everything which belongs to the
projection, but not what is projected.

In the proposition, therefore, its \emph{sense is not yet contained},
but the possibility of expressing it.

\end{tlpquote}

\noindent Answering these questions is complicated by the fact that in the \emph{Tractatus}
there are a number of further characterizations of the notion of sense.
As we saw in the last section there is a notion of sense of pictures
as a possible situation. It's clear that this holds for propositions
as well:
\begin{tlpquote}
\item [{4.031(2)}] One can say, instead of, This proposition has such and
such a sense, This proposition presents such and such a situation.
\end{tlpquote}

In addition, A propositional sign is a fact, some determinate way in which its
constituent parts are connected. Such a fact, however, is not a picture
until it is used to project a possible state of things. Projecting
is the same as presenting.

\begin{tlpquote}
\item [{4.022}] The proposition \emph{shows} its sense.


The proposition shows how things stand, if it is true. And it says,
that they do so stand.
\end{tlpquote}


In my view these remarks don't, in the end, point to a single notion
of proposition. However, they do yield two closely connected and mutually
consistent notions.

\begin{quote}A propositional sign is a fact, some determinate way in which its
constituent parts are connected. Such a fact, however, is not a picture
until it is used to project a possible state of things. Projecting
is the same as presenting.\end{quote}

\noindent First, it involves taking the sign-fact to be the realization of a
possible way in which the constituents of the fact are connected---the
realization of logical form---that is also a possible way in which
objects can be connected. This factor is what the ``logical part
of the symbol'' or the ``form of a proposition'' from the \emph{NB}
theory becomes when form is reconceived as possibility of structure.
From this factor we also can see what it means for a picture to ``contain
a possibility'': a (fact used as a) picture is (a fact treated as)
the realization of a possibility.

\end{document}

答案1

我建议使用这个:

\usepackage{etoolbox}
\AtBeginEnvironment{tlpquote}{\singlespacing} 
\AfterEndEnvironment{tlpquote}{\onehalfspacing}

您还需要tlpquote在新段落中开始您的内容:否则,您将弄乱间距。(同一个段落不能[轻易地]同时是单倍行距和非单倍行距。)\noindent因此,以 开头的段落应该与以下段落分开tlpquote

附言:我enumitem一直在用,但还是需要查找所有内容……

答案2

问题在于一个段落与以下 tlpquote 之间缺少空行。代码before实际上位于环境之前,因此也位于par列表代码之前。before=xxx将在前一个段落末尾打印文本。\singlespacing影响整个段落,当它在段落末尾发出时,它将“向后反击”。因此,您应该确保通过在\endgraf之前添加来结束段落\singlespacing

\documentclass[11pt,oneside]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\usepackage{setspace}
\onehalfspacing

\usepackage[inline,shortlabels]{enumitem}
\newlist{tlpquote}{description}{1}

\setlist[tlpquote]{before=\endgraf\singlespacing}

\begin{document}
The puzzles mount up when Wittgenstein brings in the notions of use,
projection, and sense to characterize propositional signs and propositions:
\begin{tlpquote}
\item [{3.11}] We use the sense-perceptible sign (sound or written sign,
etc.) of the proposition as a projection of the possible situation.
\end{tlpquote}
The puzzles mount up when Wittgenstein brings in the notions of use,
projection, and sense to characterize propositional signs and propositions:
\end{document}

在此处输入图片描述

相关内容