如何在 documentclass{book} 中运行此代码?

如何在 documentclass{book} 中运行此代码?
  \documentclass{beamer}
 \usepackage{tikz}

\newcommand\bpebble[3]{%
\tikz{
\node[inner sep=0pt] 
 (image) {\includegraphics[#1]{#2}};%
\node[inner sep=0pt] 
 at (image.center) {#3};%
 }
}

\setbeamertemplate{enumerate item}{\bpebble{height=2ex}{papiro}{\insertenumlabel}}
\setbeamertemplate{enumerate subitem}{\bpebble{height=1.8ex}{bricks}{\insertsubenumlabel}}
  \setbeamertemplate{enumerate subsubitem}{\bpebble{height=1.6ex}{scroll}{\insertsubsubenumlabel}}

  \setbeamercolor*{enumerate item}{fg=white} 
\setbeamercolor*{enumerate subitem}{fg=white} 
 \setbeamercolor*{enumerate subsubitem}{fg=black} 

 \begin{document}

\begin{frame}
 \begin{enumerate}
\item First.
\item Second.
\begin{enumerate}
\item First.
\item Second.
\begin{enumerate}
\item First.
\item Second.
\end{enumerate}
\item Third.
\end{enumerate}
\item Third.
\item Fourth.
 \end{enumerate}
\end{frame}

 \end{document}

答案1

尝试以下示例。我没有所需的图像文件,因此example-image.pdf来自mwe包被使用。

\documentclass{book}
\usepackage{tikz}
\usepackage{enumitem}

\newcommand\bpebble[3]{%
  \tikz{
    \node[inner sep=0pt] (image) {\includegraphics[#1]{#2}};
    \node[inner sep=0pt] at (image.center) {#3};
  }%
}

\setlist[enumerate, 1]{
  label=\protect\bpebble{height=2ex}{example-image}{\arabic*}
}
\setlist[enumerate, 2]{
  label=\protect\bpebble{height=1.8ex}{example-image}{\arabic*}
}
\setlist[enumerate, 3]{
  label=\protect\bpebble{height=1.6ex}{example-image}{\arabic*}
}

\begin{document}
\begin{enumerate}
  \item First.
  \item Second.
  \begin{enumerate}
    \item First.
    \item Second.
    \begin{enumerate}
      \item First.
      \item Second.
    \end{enumerate}
    \item Third.
  \end{enumerate}
  \item Third.
  \item Fourth.
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容