5

I have the following problem: I want to create a beamer presentation and introduced a new environment using xparse. The environment has one optional argument (+ two mandatory). Now I want to create an overlay effect such that on frame 1 the optioal argument is of a value and on frame 2 it should be not there. I thought of something like

\begin{MyEnv}{...}\alt<2->{}{[a]} ...

This leads not to the expected behavior as \alt is evaluated after the environment is opened. I thought of adding \expandafter before the \begin{MyEnv} but that did not help.

Below is a minimal working example.

One idea was to use the empty string to indicate that no argumnt is given. This is critical as the argument seems to be incorrctly expanded. There ia a second question about the described problem.

\documentclass[a4paper,10pt]{article}
\usepackage{xparse}
\NewDocumentEnvironment{MyEnv}{m O{x}}{Start (#1, #2)\par}{\par End}
\newcommand{\argument}{[o]}
\begin{document}
\begin{MyEnv}{a}
OK
\end{MyEnv}

\begin{MyEnv}{a}[b]
OK
\end{MyEnv}

\begin{MyEnv}{a}\argument{}
Not OK (should be a,o)
\end{MyEnv}
\end{document}
12
\expandafter\begin{MyEnv}

would expand the token after \begin except that is { which is not expandable so the \expandafter has no effect.

You can do

 \def\foo{\begin{MyEnv}}
 \expandafter\foo\argument

But do you really want to? (Anything else that works is likely to be equivalent to this, possibly with the syntax hidden a little)

| improve this answer | |

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.