请问如何声明一个新的环境,我可以在其中放置带有外部本地图像的物品?
有什么好的建议吗?
答案1
这是一个定义新的覆盖感知环境的选项myitemize
,该环境本地重新定义itemize item
模板以使用图像;而不是example-image-a
使用您选择的图像并根据您的需要调整长度:
\documentclass{beamer}
\newenvironment<>{myitemize}
{\setbeamertemplate{itemize item}{\includegraphics[width=20pt]{example-image-a}}%
\begin{actionenv}#1%
\begin{itemize}
}
{\end{itemize}\end{actionenv}}
\begin{document}
\begin{frame}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\begin{myitemize}
\item First.
\item Second.
\end{myitemize}
\end{frame}
\end{document}
上述解决方案只会更改用于第一级项目的符号;要更改所有级别的符号,请更改
\setbeamertemplate{itemize item}{\includegraphics[width=20pt]{example-image-a}}%
到
\setbeamertemplate{itemize items}{\includegraphics[width=20pt]{example-image-a}}%
为了为每个级别获取不同的图像,你可以执行以下操作
\documentclass{beamer}
\newenvironment<>{myitemize}
{\setbeamertemplate{itemize item}{\includegraphics[width=20pt]{example-image-a}}%
\setbeamertemplate{itemize subitem}{\includegraphics[width=15pt]{example-image-b}}%
\setbeamertemplate{itemize subsubitem}{\includegraphics[width=10pt]{example-image-c}}%
\begin{actionenv}#1%
\begin{itemize}
}
{\end{itemize}\end{actionenv}}
\begin{document}
\begin{frame}
\begin{itemize}
\item First.
\begin{itemize}
\item First.
\item Second.
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{itemize}
\item Second.
\end{itemize}
\begin{myitemize}
\item First.
\begin{myitemize}
\item First.
\item Second.
\begin{myitemize}
\item First.
\item Second.
\end{myitemize}
\end{myitemize}
\item Second.
\end{myitemize}
\end{frame}
\end{document}