TransWikia.com

enumitem option that puts space between bottom of list and next line

TeX - LaTeX Asked by Leo Simon on May 16, 2021

The code below illustrates my problem. I’ve killed off a lot of the space that separate lists, but if I have a line of text immediately after the list, the line gets pushed up so that it overlaps the last list item. I can fix this problem by adding setlist[enumerate, 1]{after=vspace*{10pt}} but this adds a space that I don’t want if there’s no line immediately below the list. Obviously I can kludge fix it by adding spaces manually, but there has to be a way to add a parameter to the setlist specification that resolves this problem. Thanks for any suggestions.

documentclass{amsart}
parindent=0 pt
parskip=12 pt
usepackage{lipsum}
usepackage{enumitem}
defmyTopSep{-8pt}
defmyItemSep{0ex}
defmyParSep{0ex}
defmyParTopSep{0ex}
setlist[enumerate]{topsep=myTopSep,itemsep=myItemSep,partopsep=myParTopSep,parsep=myParSep}
begin{document}
lipsum[1][1-3]
begin{enumerate}
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    This is a line
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    item one
    item two
end{enumerate}
par
Now I'm going to add  verb+setlist[enumerate, 1]{after=vspace*{10pt}}+ etc
par
lipsum[1][1-3]
setlist[enumerate, 1]{after=vspace*{10pt}}
setlist[enumerate, 2]{after=vspace*{10pt}}
lipsum[1][1-3]
begin{enumerate}
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    This is a line
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    item one
    item two
end{enumerate}
lipsum[1][1-3]
end{document}

One Answer

I think the fundamental issue is that you've set parskip=12 pt or, more LaTeX-y, parskip=1baselineskip. IMNSHO, if that's the right value for other parts of your document, it should be the right value for list environments such as enumerate and itemize as well.

If you really must annihilate the non-zero value of parskip around list environments, you could set the options before=vspace{-1baselineskip} and after=vspace{-1baselineskip} along with nosep for level-1 list environments and just nosep for level-2 (and above) list environments.

Aside: setting the option nosep must be easier than setting topsep, itemsep, partopsep, and parsep to 0pt.

enter image description here

documentclass{amsart}
parindent=0pt
parskip=1baselineskip
usepackage{lipsum}
usepackage{enumitem}
setlist[enumerate,1]{nosep,
                      before=vspace{-1baselineskip},
                      after =vspace{-1baselineskip}}
setlist[enumerate,2]{nosep}

begin{document}
lipsum[1][1-4] % filler text
begin{enumerate}
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    This is a line
    item one
    item two
    begin{enumerate}
        item three
        item four
    end{enumerate}
    item one
    item two
end{enumerate}
lipsum[1][5-8] % filler text
end{document}

Correct answer by Mico on May 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP