[Tex/LaTex] Trouble combining enumitem and beamer

beamerenumitemincompatibilitylistsoverlays

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}

Best Answer

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.