tags:

views:

252

answers:

1

Hi, I am using the following beamer command

\newcommand{\imgslide}[2]{
        {\setbeamertemplate{background canvas}{
        \includegraphics [width=\paperwidth,height=\paperheight]{images/#1}} 
            \begin{frame}[plain]
                \txtonimg{#2}
            \end{frame}
        }
}

And I get errors repeatedly.

The same content when manually written works well.

And the command included within the above command is:

\newcommand{\txtonimg}[1]{
\begin{center}
 \fcolorbox{red}{black}{
 \textcolor{white}
 {#1}
 }
 \end{center}
 }

The error is:

]
! Too many }'s.
\endframe ->\egroup 
            \begingroup \def \@currenvir {frame}
l.107       \end{frame}

Everything seems good to me, on repeated testing.

+1  A: 

Beamer uses a good deal of \catcode-related trickery, and it's likely that that is what's causing your problems. Since I can't reproduce your error without a minimal example, I can only speculate (in general in the future if you want the most efficient help, provide a complete minimal example that exhibits the problem - in doing so you'll often narrow it down yourself, but at the least you ensure others can reproduce it faithfully).

Try adding the fragile option to the frame in your definition, as in

\begin{frame}[plain,fragile]

I'm not sure what the trade-offs are, but this causes the frame environment to behave more like a normal environment.

Steve