0

I'm trying to reproduce the enumerate enviorment of this post (A fancy and beautiful type of enumerate) in Beamer. My MWE, adapted from there, is the following:

\documentclass{beamer}

\usepackage{tikz} \newcommand{\Colorlist}{red,blue,green,yellow} \newcommand{\SebastianoItem}[1]{\foreach \X[count=\Y] in \Colorlist {\ifnum\Y=#1\relax \xdef\SebastianoColor{\X} \fi } \tikz[baseline=(SebastianoItem.base),remember picture]{% \node[fill=\SebastianoColor,inner sep=4pt,font=\sffamily,fill opacity=0.5] (SebastianoItem){#1)};} } \newcommand{\SebastianoHighlight}{\tikz[overlay,remember picture]{% \fill[\SebastianoColor,fill opacity=0.5] ([yshift=4pt,xshift=-\pgflinewidth]SebastianoItem.east) -- ++(4pt,-4pt) -- ++(-4pt,-4pt) -- cycle; }}

\begin{document} \begin{frame} \renewcommand{\labelenumi}{\SebastianoItem{\arabic{enumi}}}

Some general advices. \begin{enumerate} \item No fast food. \item Don't drink to much alcohol. \item No pineapple on pizza. \SebastianoHighlight \item Don't use onions in food. \end{enumerate}

\end{frame} \end{document}

When I uncomment the \renewcommand and the \SebastianoHighlight lines, the code compiles, so I guess the errors are there. I know that renewing commands in Beamer are trickier than in the Article documentclass. However, I can't find a solution. Any ideas?

  • 1
    Half of the problem is the Beamer does enumerate differently, and to customize the labels you should use a different command. See https://tex.stackexchange.com/a/7513/119 for example. – Willie Wong Sep 10 '20 at 17:48

1 Answers1

2

In beamer:

\setbeamertemplate{enumerate item}{\SebastianoItem{\arabic{enumi}}}

Similarly for enumerate subitem, enumerate subsubitem, and enumerate mini template.

edit file:

\documentclass{beamer}

\usepackage{tikz} \newcommand{\Colorlist}{red,blue,green,yellow} \newcommand{\SebastianoItem}[1]{\foreach \X[count=\Y] in \Colorlist {\ifnum\Y=#1\relax \xdef\SebastianoColor{\X} \fi } \tikz[baseline=(SebastianoItem.base),remember picture]{% \node[fill=\SebastianoColor,inner sep=4pt,font=\sffamily,fill opacity=0.5] (SebastianoItem){#1)};} } \newcommand{\SebastianoHighlight}{\tikz[overlay,remember picture]{% \fill[\SebastianoColor,fill opacity=0.5] ([yshift=4pt,xshift=-\pgflinewidth]SebastianoItem.east) -- ++(4pt,-4pt) -- ++(-4pt,-4pt) -- cycle; }}

\setbeamertemplate{enumerate item}{\SebastianoItem{\arabic{enumi}}}

\begin{document} \begin{frame} %\renewcommand{\labelenumi}{\SebastianoItem{\arabic{enumi}}}

Some general advices. \begin{enumerate} \item No fast food. \item Don't drink to much alcohol. \item No pineapple on pizza. \SebastianoHighlight \item Don't use onions in food. \end{enumerate}

\end{frame} \end{document}

output: enter image description here

M.Ahmadi
  • 1,477