4

If I do the following:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{enumitem}
\setstretch{2}
\setlist[itemize]{topsep=.1em,itemsep=.1em,parsep=0em,partopsep=0em}
\setlist*[itemize]{first=\setstretch{1}}    % This undesirably affects the spacing before the list

\begin{document}

\def\text{test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph}

\text

\begin{itemize} \item one \item two \item three \end{itemize}

\text

\end{document}

Then I get:

bad spacing between list and previous paragraph

But that is not what I want. I want to keep the spacing just before the list unchanged, but change only the spacing between lines of the list. Is there any way I can automatically achieve this for all itemize/enumerate lists, regardless of the interline-spacing of their surrounding text?

user21820
  • 868
  • 7
  • 19
  • 4
    Coukd you please post a small, yet complete, example code? – Bernard Apr 13 '22 at 18:07
  • @DavidCarlisle: first=\par\setstretch causes a compile error... – user21820 Apr 13 '22 at 18:20
  • use \setlist*[itemize]{first=\singlespacing}. – Ulrike Fischer Apr 13 '22 at 18:52
  • @DavidCarlisle: Why do we need \endgraf instead of \par? – user21820 Apr 13 '22 at 19:07
  • @UlrikeFischer: What if I want something else like \setstretch{1.3}? Anyway how does \singlespacing work? Its internal mechanism might give an answer to my question. – user21820 Apr 13 '22 at 19:10
  • @DavidCarlisle: Um, it doesn't work at all (made it worse); did \endgraf actually work for you? – user21820 Apr 13 '22 at 19:12
  • @DavidCarlisle: Ok sure; I just wanted to make sure it wasn't somehow my fault for it not working. – user21820 Apr 13 '22 at 19:15
  • @DavidCarlisle: That's why I initially asked in a comment on the other thread, because using first instead of before solves the problem of affecting the entire previous paragraph (when there is no empty line before the start of the list, not here), but doesn't solve the space in-between that and the list. – user21820 Apr 13 '22 at 19:19
  • 1
    ah before and \endgraf then:-), incidentally do you really want setstretch{2} it is so spacy to be hardly readable, and way more than "doublespaced" (eg the setspace package uses \setstretch {1.667} for \doublespace – David Carlisle Apr 13 '22 at 19:24
  • @DavidCarlisle: No, as you all requested, this is just a toy example. I simply want an automated solution that would work with any choice of interline-spacing in the surrounding environments and any choice of spacing inside the lists. After looking at the definition of \singlespacing, I think I have a solution, so I'm going to post it. – user21820 Apr 13 '22 at 19:37

3 Answers3

4

On way is simply to adjust for the changed baseline:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{enumitem}
\setstretch{2}
\setlist[itemize]{topsep=.1em,itemsep=.1em,parsep=0em,partopsep=0em}
\setlist*[itemize]{first=\vspace{\baselineskip}\setstretch{1}\vspace{-\baselineskip}}    % This undesirably affects the spacing before the list

\begin{document}

\def\text{test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph}

\text

\begin{itemize} \item one \item two \item three \end{itemize}

\text

\end{document}

David Carlisle
  • 757,742
3

How about this, using the before and after keys?

    \documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage{setspace}
    \usepackage{enumitem}
    \setstretch{2}
    \setlist[itemize]{topsep=.1em, itemsep=.1em,parsep=0em, partopsep=0em}
    \setlist[itemize]{before=\begin{singlespace}, after=\end{singlespace}}
\begin{document}

\def\text{test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph}

\text

\begin{itemize}
\item one\text
\item two
\item three
\end{itemize}

\text

\end{document} 

enter image description here

Bernard
  • 271,350
  • No, this fails to address my question; I said "regardless of the interline-spacing of their surrounding text". So your proposal fails in many many situations, including but not restricted to nested lists. – user21820 Apr 13 '22 at 19:08
  • 2
    I'm afraid there's no obvious solution about the spacing of the list w.r.t. the surrounding text. Maybe some guru (which I'm not) will find something… – Bernard Apr 13 '22 at 19:18
  • See my answer. Yours isn't an answer at all (see the nested lists in mine), and I think you should delete it. – user21820 Apr 13 '22 at 20:09
  • Your last edit (after my previous comments) does make your post an answer to my question (and works with nested lists), but is not general at all. It also fails in some special cases (e.g. if there is no empty line before the \begin{itemize}), which is the reason the first key is correct and your choice of before key is wrong. So clearly there is something very wrong with the voters on TeX SE. – user21820 Apr 14 '22 at 09:28
0

After a commenter suggested \singlespacing, I looked at its definition and I think the following works in all cases:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{enumitem}
\setstretch{2}
\setlist[itemize,enumerate]{topsep=.1em,itemsep=.1em,parsep=0em,partopsep=0em}
\setlist*[itemize,enumerate]{first=\vskip\baselineskip\setstretch{1.1}\vspace{-\baselineskip}}

\begin{document}

\def\text{test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph test paragraph}

\text

\begin{itemize} \item one \item two \item three \begin{enumerate} \item a \item b \end{enumerate} \item four \end{itemize}

\text

\end{document}

The 1.1 can obviously be changed arbitrarily. It produces:

proper spacing before list

user21820
  • 868
  • 7
  • 19