2

I want to create a new environment with one optionnal parameter that is used to set pgfkeys. I want one key to be pass as argument too enumerate to make item appears one at a time (<+->). It seems that enumerate takes that argument as the style of the counters (alph, arabic, roman,...). Is it an expansion problem? Is enumerate looking for a special caracter? What I'm I doing wrong? I also tried with l3keys and got the same problem.

\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}
2

The enumerate wants to see an explicit < so we need to expand the argument first.

\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}

enter image description here

1
  • Thank you very much!
    – sipaq11
    Sep 12 '19 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.