Fancy bullet lists with TikZ

At the end of October there was a question on TSX on how to create visually appealing counters in LaTeX documents. One of the answers (by Sandor Kazi) was the following:

\documentclass{beamer}
 
 
\usepackage{enumitem}
\usepackage{refcount}
\usepackage{tikz}
    \usetikzlibrary{calc}
 
\makeatletter
\newcommand\statuslabel[3][]{%
    \def\scale{#1}
    \ifx\scale\empty\def\scale{1}\fi
 
    \let\no\relax
    \let\n\relax
    \newcommand \no {#2}
    \newcommand \n {#3}
    \def \colorbef {blue}
    \def \colorat {orange}
    \def \coloraft {black!40}
 
    \let\stop\relax
    \sbox\z@{\@tempcnta=0\no\relax}\ifdim\wd0>\z@\relax\@latex@warning{Not a number (\#2): \no}\def\stop{1}\fi
    \sbox\z@{\@tempcnta=0\n\relax}\ifdim\wd0>\z@\relax\@latex@warning{Not a number (\#3): \n}\def\stop{1}\fi
    \ifx\stop\relax
        \ifnum\no>\n\@latex@warning{Wrong parameter order?}\def\stop{1}\fi
    \fi
 
    \ifx\stop\relax
    \else
        \def \no {1}
        \def \n {1}
        \def \colorat {red}
        \def \stop {??}
    \fi
 
    \begin{tikzpicture}[scale=0.1*\scale]
 
    \def \radiusout {2cm}
    \def \radiusin {1.3cm}
    \ifnum\n=1
        \def \margin {0}
    \else
        \def \margin {25/\n}
    \fi
 
    \foreach \s in {1,...,\n}
    {
        \node[circle, scale=\scale] at (0,0) {\tiny\stop};
        \fill[\ifnum\s>\no\coloraft\relax\else\ifnum\s<\no\colorbef\else\colorat\fi\fi]
            ({90-360/\n * (\s - 1)-\margin}:\radiusout) arc ({90-360/\n * (\s - 1)-\margin}:{90-360/\n * (\s)+\margin}:\radiusout) --
            ({90-360/\n * (\s)+\margin}:\radiusin) arc ({90-360/\n * (\s)+\margin}:{90-360/\n * (\s - 1)-\margin}:\radiusin);
    }
    \end{tikzpicture}
}
\makeatother
 
\makeatletter
\newcounter{myenum} % to create unique labels
\newenvironment{myenum}
  {\stepcounter{myenum}
   \edef\nref{\getrefnumber{myenum@\arabic{myenum}}}
   \edef\nref{\expandafter\@firstofone\nref}
   \begin{enumerate}[
     label=\protect\statuslabel{\arabic*}{\nref},
     ref=\arabic*]}
  {\label{myenum@\arabic{myenum}}%
   \end{enumerate}}
\makeatother
 
\begin{document}
 
\begin{frame}
 
\begin{myenum}
\item example
\item example
\item example
\item fsdfs
\end{myenum}
 
\end{frame}
 
\end{document}

visu

Uwe

Uwe Ziegenhagen mag LaTeX und Python, auch gern in Kombination. Hat Dir dieser Beitrag geholfen und möchtest Du Dich dafür bedanken? Dann unterstütze doch vielleicht die Dingfabrik Köln e.V. mit einem kleinen Beitrag. Details zur Bezahlung findest Du unter Spenden für die Dingfabrik.

More Posts - Website