40

I have trouble combining two things for a set of slides:

  1. Adjust item separation globally
  2. Use default overlays of lists locally (parameter [<+->])

I use enumitem for 1. but it seems to disturb beamer quite a bit. To begin with, I had to employ some trickery to not have enumtitle overwrite the selected slide style.

With the linked solution in effect, adding [<+->] to an itemize does not have any effect at all. I would expect it to overwrite the global setting, but evidently it does not.

How can I achieve 1. and 2. simultaneously?

Minimal failing example:

\documentclass{beamer}

\usepackage{enumitem}
\setitemize{itemsep=1.5em,%
  label=\usebeamerfont*{itemize item}%
        \usebeamercolor[fg]{itemize item}%
        \usebeamertemplate{itemize item}%
}

\begin{document}

\begin{frame}
  \begin{itemize}[<+->]
    \item On slide 1
    \item On slide 2
  \end{itemize}
\end{frame}

\end{document}
25

As you already mentioned, enumitem "disturbs" beamer. This is because the document class (beamer in this case) defines (or redefines) all the necessary commands/macros and environments to it's liking. Then, each loaded package does the same sequentially. As such, since enumitem follows the document class, it redefines the itemize (and other) environments, thereby removing beamer's modified overlay specification.

It is possible to tap into the main level list environment parameters by patching the command \@listI. The following shows the definition of the three levels contained in beamerbaselocalstructure.sty:

%
% List stuff
%

\setlength\leftmargini  {2em}
\setlength\leftmarginii  {2em}
\setlength\leftmarginiii  {2em}
\setlength  \labelsep  {.5em}
\setlength  \labelwidth{\leftmargini}
\addtolength\labelwidth{-\labelsep}

\def\@listi{\leftmargin\leftmargini
            \topsep 3\p@ \@plus2\p@ \@minus2.5\p@
            \parsep 0\p@
            \itemsep3\p@ \@plus2\p@ \@minus3\p@}
\let\@listI\@listi
\def\@listii{\leftmargin\leftmarginii
              \topsep    2\p@ \@plus1\p@ \@minus2\p@
              \parsep    0\p@   \@plus\p@
              \itemsep   \parsep}
\def\@listiii{\leftmargin\leftmarginiii
              \topsep    2\p@ \@plus1\p@ \@minus2\p@
              \parsep    0\p@   \@plus\p@
              \itemsep   \parsep}

A patch using \patchcmd, as provided by etoolbox, that changes \itemsep3\p@ to \itemsep2em (say) modifies the command globally from 3pt to 2em:

\documentclass{beamer}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\makeatletter
\patchcmd{\@listI}{\itemsep3\p@}{\itemsep2em}{}{}
\makeatother

\begin{document}

\begin{frame}
\begin{itemize}[<+->]
  \item First.
  \item Second.
  \item Third.
\end{itemize}
\end{frame}

\end{document}

The use of the \makeatletter/\makeatother pair is required, since the macro definition of \@listI contains @. Note that this patch does not modify the shrink (3pt) or stretch (2pt) of \itemsep.

  • Looks clean and works well, thanks! Of course, enumitem offers the useful possibility to change itemsep locally, too, but I guess you can't have everything. – Raphael Oct 14 '11 at 10:17
  • Patching \@listii in the same way does not seem to have any effect. Is there something special to consider? – Raphael Jul 13 '15 at 13:56
  • I just patched \patchcmd{\@listii}{\itemsep\parsep}{\itemsep3\p@}{}{} to have slightly sparser spacing of sub-lists, and that command worked for me. How did you try to patch listii? – Supernormal Oct 30 '15 at 10:36
  • This answer did not work for me. However this other answer did. – Luke Davis Feb 20 '18 at 23:00
13

You can redefine the \itemize command as defined in beamerbaselocalstructure.sty; in the following example I defined a global itemsep length of 2em (the line signaled with %NEW) for this command:

\documentclass{beamer}

\makeatletter
\renewcommand{\itemize}[1][]{%
  \beamer@ifempty{#1}{}{\def\beamer@defaultospec{#1}}%
  \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
      {\usebeamertemplate{itemize \beameritemnestingprefix item}}
      {\setlength\itemsep{2em}% NEW
        \def\makelabel##1{%
          {%
            \hss\llap{{%
                \usebeamerfont*{itemize \beameritemnestingprefix item}%
                \usebeamercolor[fg]{itemize \beameritemnestingprefix item}##1}}%
          }%
        }%
      }
  \fi%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}
\makeatother

\begin{document}

\begin{frame}
\begin{itemize}[<+->]
  \item First.
  \item Second.
  \item Third.
\end{itemize}
\end{frame}

\end{document}

Here's a portion of the resulting third slide:

enter image description here

11

Adding \tracingall shows that TeX is spinning around a cyclic definition of \\description which is an internal saved version of the description environment. It's quite easy for this to happen if two packages are saving the"original" version of something.

\\description [#1]->\beamer@origdescription 
#1<-

\beamer@origdescription ->\@protected@testopt \description \\description {}

\@protected@testopt #1->\ifx \protect \@typeset@protect \expandafter \@testopt 
\else \@x@protect #1\fi 

\@testopt #1#2->\kernel@ifnextchar [{#1}{#1[{#2}]}
#1<-\\description 
#2<-

\kernel@ifnextchar #1#2#3->\let \reserved@d =#1\def \reserved@a {#2}\def \reser


\@ifnch ->\ifx \@let@token \@sptoken \let \reserved@c \@xifnch \else \ifx \@let

\reserved@c ->\\description [{}]

\\description [#1]->\beamer@origdescription 
#1<-

While it's easy to see why TeX hangs, fixing it depends what you want to do. You could re-assert the beamer or enumitem version. But if you want an environment with the features of both that may take a bit more coordination and knowledge of both packages neither of which I have this morning:-)

for example this keeps beamers defininition and stops the looping.

\let\olddescription\description
\let\oldenddescription\enddescription
\usepackage{enumitem}
\let\description\olddescription
\let\enddescription\oldenddescription

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.