5

I think a lot of people may be wondering this function, and I know there must be a great answer of this question. However, I cannot find it maybe because I do not know an adequate keyword for this problem.

I use the following code right after \begin{document} when I use beamer.

\let\OLDitemize\itemize
\let\OLDenumerate\enumerate
\renewcommand\itemize{\OLDitemize\addtolength{\itemsep}{??\baselineskip}}
\renewcommand\enumerate{\OLDenumerate\addtolength{\itemsep}{???\baselineskip}}

Then, I can adjust the inter-item-gap of itemize environment by substituting number into ??. Likewise, so can one of enumerate environment by doing number into ???.

For example, if I change 2 into ?? and 4 into ???, then the whole of inter-item-gap of itemize and enumerate environments are changed.

However, I want adjust gap of items according to item level in the whole of the program. That is, if I write the following code,

\begin{itemize}
    \item a
    \item b
    \item c
    \begin{itemize}
        \item d
        \item e
        \item f
    \end{itemize}
    \item g
    \item h
    \item i
\end{itemize}

the result I want to get is like the following: sep

Please let me know how to change item-gap according to the level of items. As occasion arises, I am using \vspace command like \vspace{.7\baselineskip}. This makes the code so dirty to become unreadable.

Actually, label is out of my point. I want to set the gap of item at will, regardless of whether itemize or enumerate.

4

With the enumitem package, you can specify the spacing parameters independently for each level of the itemize, with \seteumerate[<level>]{}. Below, I show it with a unique itemsep and topsep, though all the spacing parameters may be brought into play.

\documentclass{article}
\usepackage{enumitem}
\setitemize[1]{itemsep=10pt,topsep=10pt}
\setitemize[2]{itemsep=0pt,topsep=-2pt}
\begin{document}
\begin{itemize}
    \item a
    \item b
    \item c
    \begin{itemize}
        \item d
        \item e
        \item f
    \end{itemize}
    \item g
    \item h
    \item i
\end{itemize}
\end{document}

enter image description here

P.S. The MWE works in beamer, too. However, Alan Munn points out in a comment that because beamer modifies the list environments to make them overlay-aware, it really doesn't play nicely with enumitem.

\documentclass{beamer}
\usepackage{enumitem}
\setitemize[1]{itemsep=10pt,topsep=10pt}
\setitemize[2]{itemsep=0pt,topsep=-2pt}
\begin{document}
\begin{frame}{beamer frame title}
\begin{itemize}
    \item a
    \item b
    \item c
    \begin{itemize}
        \item d
        \item e
        \item f
    \end{itemize}
    \item g
    \item h
    \item i
\end{itemize}
\end{frame}
\end{document}

enter image description here

  • Oh my god. It doesn't work on Beamer! – Danny_Kim Aug 2 '16 at 12:13
  • @Danny_Kim I updated my answer to show that, yes, it does work in beamer. – Steven B. Segletes Aug 2 '16 at 12:17
  • @Danny_Kim In my MWE, I \setitemize in the preamble. However, if your settings are overriding those, you can always choose the \setitemize in the actual frame. – Steven B. Segletes Aug 2 '16 at 12:19
  • 1
    just adding \usepackage{enumitem} makes errors. "TeX capacity exceeded, sorry [grouping levels=255].\labelenumi ->{\labelenumi }\end{frame}." and "Fatal error occurred, no output PDF file produced!." – Danny_Kim Aug 2 '16 at 12:25
  • 1
    @StevenB.Segletes Because beamer modifies the list environments to make them overlay-aware, it really doesn't play nicely with enumitem. – Alan Munn Aug 2 '16 at 12:39
2
\documentclass{beamer}
\newcommand\nosep{\vspace{-1ex}\setlength\itemsep{-0.75ex}}

\begin{document}
\begin{frame}{foo}{bar}
\begin{itemize}
    \item a
    \item b
    \item c
    \begin{enumerate}\nosep
        \item d
        \item e
        \item f
    \end{enumerate}
    \item g
    \item h
    \item i
\end{itemize}   
\end{frame} 
\end{document}

enter image description here

  • Thank you for answer. Should I set whenever I use the item? – Danny_Kim Aug 2 '16 at 10:47
  • Yes, in all cases where you want the reduced space. – user2478 Aug 2 '16 at 10:54
  • Isn't there any methods to set the whole document at once? Imagine the line of codes is big. Then how can I change step by step, when I want to change the gap in the entire, – Danny_Kim Aug 2 '16 at 10:56
  • not really, because you have to know the situation: re you are inside another list environment or not. And, of course, beamer already redefines all list environments. With another document class, like article, it is pretty simple to get such behaviour. – user2478 Aug 2 '16 at 11:00
  • Ah, thank you. my situation is that I have already a lot of pages made by beamer. However, I want to change the gap of all items. TT – Danny_Kim Aug 2 '16 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.