9

The beamer manual says:

You can easily add your own actions: An action specification like ⟨action⟩@⟨slide numbers⟩ simply inserts an environment called ⟨actionenv around the \item or parameter of \action with <slide numbers> as overlay specification. Thus, by defining a new overlay-specification-aware environment named ⟨my action nameenv, you can add your own action:

\newenvironment{checkenv}{\only{\setbeamertemplate{itemize item}{X}}}{} 

You can then write

\item<beamer:check@2> Text.

This will change the itemization symbol before Text. to X on slide 2 in beamer mode. The definition of checkenv used the fact that \only also accepts an overlay-specification given after its argument.

I'd like an action like \alert which instead colors its input gray. So I tried:

\documentclass{beamer}

\newenvironment<>{grayenv}{%
  \color#1{gray}}{}

\begin{document}

\begin{frame}
Text is \begin{grayenv}<2-> grayed out\end{grayenv}.
\end{frame}

\begin{frame}
Who's \action<alert@+| gray@+(1)>{gray} now? \action<+(1)->{And now?}
\end{frame}


\begin{frame}
Who's \action<alert@+| grayenv@+(1)>{gray} now? \action<+(1)->{And now?}
\end{frame}
\end{document}

The first frame has the expected output: "grayed out" is grayed out on slide 2. The second frame has "Who's ¡all:¿gray now?" (bold is red), followed by no coloring on the next two slides. The third frame has "gray now?" (not "gray" as desired) grayed out on slide 2.

The only working examples of custom action I have seen are written as checkenv is: not as an overlay-aware environment, but a regular environment that ends its begin code with an \only{...} (see also this longer example).

Is there anyway to pass the overlay specification to the custom environment?

1 Answer 1

7

It appears to me Till got confused: your third example shouldn't work at all if \action wrapped its argument in the actionenv, not passing it as an argument to actioncommand.

Using

\newcommand<>\gray[1]{%
  \textcolor#2{gray}{#1}%
}

appears to work. (FYI: the ?all:2! that you observe was the < all:2 > specification that was not being taken up because no command \gray existed to parse it. (The inverted ? and ! happen to sit in the spaces for > and < if you don't use the T1 fontencoding. Even more tangentially, if you ever see ?From in a scientific paper and have to laugh, you know enough about TeX and RFC822 to qualify as a hopeless geek.)

3
  • 2
    Thanks, I'll give this a try. I knew that ¿all:2! was beamer not evaluating an overlay specification, but I wasn't sure how to fix it. And yes, I've seen "¿From" in papers and chuckled geekily to myself. (To share the joke: it means one author emailed another author TeX code and the second author copied-and-pasted into the tex file without much proofreading.) Dec 6, 2010 at 19:49
  • 2
    Yes, it does appear to work. Thanks! I don't know what the env thing was about then. Dec 7, 2010 at 1:21
  • @MatthewLeingang I ran into the same problem, and Ulrich's suggestion worked. Perhaps the Beamer powers that be could update the user guide in the next version? Jul 2, 2012 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .