在 Beamer 中,如何使用 pgfkeys 传递参数进行枚举?

在 Beamer 中,如何使用 pgfkeys 传递参数进行枚举?

我想创建一个带有一个可选参数的新环境,该参数用于设置 pgfkeys。我希望将一个键作为参数传递给枚举,以使项目一次出现一个(<+->)。似乎枚举将该参数作为计数器的样式(字母、阿拉伯语、罗马语……)。这是一个扩展问题吗?枚举是否在寻找特殊字符?我做错了什么?我也尝试过 l3keys,但遇到了同样的问题。

\documentclass{beamer}
\usepackage{xparse}
\usepackage{pgfplots}
\usepackage[T1]{fontenc}  %%% without that the < > appear as inversed ! and ?

\pgfkeys{
/enume/.is family, /enume,
default/.style = 
{opt = empty},
opt/.estore in = \theopt,
}

\NewDocumentEnvironment {myenum} {o} {%
\pgfkeys{/enume, default, #1}%
The key value is : \theopt 

%\begin{enumerate}[<+->]    % with this line it is working  (but it doesn't use the parameter)
\begin{enumerate}[\theopt]  % with this line it is not working
}{%
\end{enumerate}
}%

\begin{document}
\begin{frame}
\begin{myenum}[opt={<+->}]
\item I have a cat.

\item It is blue.
\end{myenum}
\end{frame}
\end{document}

答案1

想要enumerate看到明确的答案<,所以我们需要先扩展论点。

\documentclass{beamer}
\usepackage{xparse}
\usepackage{pgfplots}
\usepackage[T1]{fontenc}  %%% without that the < > appear as inversed ! and ?

\pgfkeys{
/enume/.is family, /enume/.cd,
default/.style = 
{opt = empty},
opt/.estore in = \theopt,
}

\NewDocumentEnvironment {myenum} {o} {%
\pgfkeys{/enume, default, #1}%
The key value is : \theopt 

%\begin{enumerate}[<+->]    % with this line it is working  (but it doesn't use the parameter)
\edef\temp{\noexpand\begin{enumerate}[\theopt]}  % with this line it is not working
\temp
}{%
\end{enumerate}
}%

\begin{document}
\begin{frame}
\begin{myenum}[opt={<+->}]
\item I am owned by a cat.

\item They are blue.
\end{myenum}
\end{frame}
\end{document}

在此处输入图片描述

相关内容