2

I thought I had tamed enumitem. I had this itemize fix and this enumerate fix.

Then I tried a [<+->] construct. It failed. Commmenting the enumitem section prevents errors but I'd rather not have to do this.

On its current state, this code produces two errors, one because of the [<+->] and another because of the \onslide.

 \documentclass{beamer}

 \usepackage{enumitem}
 \setitemize{label=\usebeamerfont*{itemize item}%
   \usebeamercolor[fg]{itemize item}
   \usebeamertemplate{itemize item}}%https://tex.stackexchange.com/a/24491
 \setenumerate[1]{%
   label=\protect\usebeamerfont{enumerate item}%
         \protect\usebeamercolor[fg]{enumerate item}%
         \insertenumlabel.}%https://tex.stackexchange.com/a/45950

 \begin{document}
 \begin{frame}
 \begin{itemize}[<+->]
 \item 1
 \item 2
 \end{itemize}
 \onslide<2>{text}
 \end{frame}
 \end{document}
  • What do you need the enumitem package for, that cannot be done with beamer alone? – user36296 Mar 4 '17 at 12:37
  • @samcarter I added it to change itemize's items conveniently. Not sure if I'm using it in the future but I'd like to have the option to. – Kurzd Mar 5 '17 at 6:19
3

The answer is easy: Don't use enumitem with beamer.

Beamer has it's own mechanism to change the appearance of the itemize item and it's very flexible -- so no need to use another package.

\documentclass{beamer}

\setbeamertemplate{itemize item}{\includegraphics[width=2em]{duck}}

\begin{document}
    \begin{frame}
        \begin{itemize}[<+->]
            \item 1
            \item 2
        \end{itemize}
        \onslide<2>{text}
    \end{frame}
\end{document}

enter image description here

  • 1
    It does seem that not using enumitem is the beter choice. – Kurzd Mar 11 '17 at 14:45
8

You can use \beamerdefaultoverlayspecification{<+->} as a workaround (see beamer documentation page 89).

\documentclass{beamer}

\usepackage{enumitem}
\setlist[itemize]{%
    label=\usebeamerfont*{itemize item}%
        \usebeamercolor[fg]{itemize item}%
        \usebeamertemplate{itemize item}%
}%http://tex.stackexchange.com/a/24491
\setlist[enumerate,1]{%
    label=\protect\usebeamerfont{enumerate item}%
        \protect\usebeamercolor[fg]{enumerate item}%
        \insertenumlabel.%
}%http://tex.stackexchange.com/a/45950

\begin{document}
\begin{frame}
    \beamerdefaultoverlayspecification{<+->}
    \begin{itemize}
        \item 1
        \item 2
    \end{itemize}
    \onslide<2>{text}
\end{frame}
\end{document}

Just for fun: You could also define a new key for enumitem to specify the default overlay specification. I, however, would rather recommend using \beamerdefaultoverlayspecification directly as shown above.

\documentclass{beamer}

\usepackage{enumitem}
\setlist[itemize]{%
    label=\usebeamerfont*{itemize item}%
        \usebeamercolor[fg]{itemize item}%
        \usebeamertemplate{itemize item}%
}%http://tex.stackexchange.com/a/24491
\setlist[enumerate,1]{%
    label=\protect\usebeamerfont{enumerate item}%
        \protect\usebeamercolor[fg]{enumerate item}%
        \insertenumlabel.%
}%http://tex.stackexchange.com/a/45950

% definition of new key for enumitem:
\makeatletter
\enitkv@key{enumitem}{overlay}{%
    \beamerdefaultoverlayspecification{#1}%
}
\makeatother

\begin{document}
\begin{frame}
    \begin{itemize}[overlay=<+->]
        \item 1
        \item 2
    \end{itemize}
    \onslide<2>{text}
\end{frame}
\end{document}

Why I would recommend using the first approach: The second approach has no advantage because it is internally using the first. The first approach uses standard commands which -- if a reader does not know them already -- can easily look them up in the documentation. The second approach on the other hand may confuse other people reading your code because they will most likely assume the key to be defined by the enumitem package and when they try it in their own code will be frustrated that it does not work. And you need to remember that you need to define this key for every single document where you want to use it (and possibly need to look up the definition every single time).

The first is faster to type because the autocompletion will do it for you. Using the autocompletion also ensures that you do not make typing mistakes.

The layout should be consistent. Therefore you should use \beamerdefaultoverlayspecification once in your preamble and then you will probably not need it again.


Edit: I have replaced \setitemize and \setenumerate by \setlist because according to footnote 7 on page 9 in the enumitem documentation those are deprecated.

  • 2
    oh you just did exactly what I was posting:-) I'll delete mine! – David Carlisle Mar 4 '17 at 8:52
  • I'm leaning more towards the second option since I won't always use [<+->]. What makes you prefer the first option? I copied the enumerate block and placed the 1 with a 2 to be able to use nested enumerates. Is this the recommended thing to do? – Kurzd Mar 5 '17 at 6:02
  • @Kurzd I have added my reasons for why I prefer the first option to my anwer. If you are sure that you want \beamerdefaultoverlayspecification{<+->} just for a single itemize you can use it locally inside of that itemize. Without knowing your specific use case, however, I would in general recommend using it globally because I think it is easier to follow a presentation if the slides build up matching to how one is talking. – jakun Mar 5 '17 at 10:19
  • @Kurzd If you want to apply options to all levels you can leave out the number: \setlist[enumerate]. If you want to apply options to some levels you can list them, seperated by commas: \setlist[enumerate,1,2]. (see enumitem documentation page 9) – jakun Mar 5 '17 at 10:38

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.