Customize line spacing within a single list of enumerate environment

1,250

in case that this features you like to have in all enumerate lists:

\documentclass[12pt]{article}
%\usepackage{enumitem}
\usepackage{etoolbox} % <--- added
\AtBeginEnvironment{enumerate}{\linespread{.84}\selectfont}% <--- added

\begin{document}
\begin{enumerate}
    \item Shall I compare thee to a summer's day?
    Thou art more lovely and more temperate.
    \item Rough winds do shake the darling buds of May,
    And summer' lease hath all too short a date.
\end{enumerate}
\end{document}

enter image description here

note: package etoolbox provide bunch of very helpful macros. among them is \AtBeginEnvironment which insert at beginning of named environment's the code which you like to execute at its beginning. this make the same result as it is obtained, when you all your enumitem lists write as

{\linespace{0.84}\selectfont}
\begin{enumerate}
    \item Shall I compare thee to a summer's day?
    Thou art more lovely and more temperate.
    \item Rough winds do shake the darling buds of May,
    And summer' lease hath all too short a date.
\end{enumerate}
}

in your case i use it to reduce line spreading in all enumerate list from normal 1 to 0.84. this has nothing with package enumitem, however it works also with it if you use it for other list settings.

in case, that you wish to change line spreading only in one ˙enumeratelist, than you use above showed example and omitetoolboxand definition with\AtBeginEnvironment`.

for more help you should provide complete small document which we can copy and test. solution in my mwe (minimal working example) works as advertised :-).

Share:
1,250

Related videos on Youtube

Musen
Author by

Musen

Back to Beijing. But, hey, I still miss Philly steaks.

Updated on August 01, 2022

Comments

  • Musen
    Musen over 1 year

    For example, the following code

    \documentclass{article}
    \usepackage{enumitem}
    
    \begin{document}
    
    \begin{enumerate}[itemsep=0ex]
    \item Shall I compare thee to a summer’s day?
    Thou art more lovely and more temperate.
    \item Rough winds do shake the darling buds of May,
    And summer’s lease hath all too short a date.
    \end{enumerate}
    
    \end{document}
    

    will yield the texts in the following format

    sonnet

    I want to reduce the space between space within a list, like the space between "temperate" and the "shall I" line. I tried enumerate package keywords like itemsep, parsep, or nosep, and none of them worked. Both itemsep and parsep reduced space between sentence 1 and 2 rather than line 1 and 2.

    I think enumerate should be able to control this but I cannot find it.

    • cfr
      cfr almost 6 years
      Welcome! Please edit to make your code compilable. That's much more useful than a mere fragment. Your snippet isn't supported by core LaTeX, we don't know what class you are using etc.
    • cfr
      cfr almost 6 years
      Also your curly apostrophes don't typeset.
    • Admin
      Admin almost 6 years
      It sounds like you want to decrease the line spacing, in which case this is nothing to do with the enumerate environment. Try \renewcommand{\baselinestretch}{0.8}.
    • Musen
      Musen almost 6 years
      @cfr Thank you for your comment! I left class file out for not being wordy. It should compile now.
    • cfr
      cfr almost 6 years
      The class can affect the typesetting of the environment, so leaving it out means we don't know what the starting point is. Your apostrophes still disappear, though.
    • cfr
      cfr almost 6 years
      You want less than the standard line spacing? Use setspace's commands locally, I guess. But, really, just don't do this. Unless you are being forced to make it look like Word. Then you might want to load the philosophy package and be done with it.
    • cfr
      cfr almost 6 years
      @Andrew Are you sure that won't affect the spacing between items and between the list and surrounding text?
    • Musen
      Musen almost 6 years
      @cfr Hi, I think your suggestion does work! Even though you may not think it is elegant enough, can you write it as an answer? Thus I can endorse it and make other people know this solution?
    • Admin
      Admin almost 6 years
      @cfr No, not really. That's why I said "try" :) Happy to delete the comment if you prefer.
    • cfr
      cfr almost 6 years
      @Andrew No, wasn't suggesting that. I don't know it will; just wondered if you knew it wouldn't.
  • Musen
    Musen almost 6 years
    Can you explain a little bit more about command AtBeginEnvironment and what it does? Also wondering why you made it even without \usepackage{enumitem}?
  • Musen
    Musen almost 6 years
    Also, I can see it works in the minimal case I set up, but it does not work in my real document. I think your explanation may guide me to a practical solution.
  • Emera Jade
    Emera Jade almost 6 years
    @Musen If it works in your MWE but not in your real document, it might be helpful to show your complete document or preamble. It could be another package specific settings that interfere with enumitem.
  • rickhg12hs
    rickhg12hs almost 2 years
    With the enumitem package, you could also just include the before option. E.g., \begin{enumerate}[before=\linespread{.84}\selectfont].