# How do before= and after= work in enumitem?

I've tried to define a new description environment for quotations from Wittgenstein's Tractatus, indented on both sides and single space. The main text is one and half space:

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


However, the result seems to make the normal paragraph after the quotation single spaced. Moreover, if I have only one item in the list, it's one and half spaced, not single spaced.

I use the following to make the quote environment single spaced (I found this on 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}}


and this works just fine. I figure I don't understand the before= and after= options of enumitem. (Of course, there's actually very little about enumitem that I do actually understand, as opposed to being able to make work, mostly with the help of answers here :-)

Here's an 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.

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}


I'd recommend using this:

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


You also need to start your tlpquote in a new paragraph: otherwise, you'll mess up the spacing. (The same paragraph can't [easily] be both single and not-single spaced.) The paragraph starting with \noindent should therefore be separated from the following tlpquote.

PS. I use enumitem all the time, but still need to look everything up....

The problem is the missing empty line between one paragraph and the following tlpquote. The before code is really before the environment, and so also before any par from the list code. before=xxx would print the text at the end of the preceding paragraph. \singlespacing affects a whole paragraph and when it is issued at the end of a paragraph it will "fight backward". So you should make sure that the paragraph is ended by adding \endgraf before \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}


• I found that \endgraf has to be added to after= as well, otherwise subsequent tlpquote environments appear in onehalfspacing. – ss1789 Nov 17 '15 at 19:16
• Can you show an example? – Ulrike Fischer Nov 17 '15 at 21:26
• I think I figured out what the problem is. I had been using both before= and after=. So in your MWE I added after=\onehalfspacing, which produced the effect mentioned. So I modified to after=\endgraf\onehalfspacing, which fixed it; but then I noticed that by deleting after= the effect also vanished. So everything works, but I'd be curious to know why. Thanks! – ss1789 Nov 18 '15 at 0:35
• after is inserted at the end of the last item (try after=xxx), so it has like before a "backward" effect. But it is unnecessary as the grouping ends the singlespacing anyway. – Ulrike Fischer Nov 18 '15 at 10:11