2

I want to redefine the frame environment in beamer so that the contents are inside a box in the center of the frame, but when I try defining the new environment like:

\newenvironment{hframe}[1]
{%before
\begin{frame}{{#1}}
\begin{textblock}{11}(2,2)
}{ %after
\end{textblock}
\end{frame}
}

...

\begin{document}

...

\begin{hframe}{title}
some text
\end{hframe}

\end{document}

I got a compiling error: "! File ended while scanning use of \frame.". But if instead I use the following code

\newenvironment{hframe}[1]
{%before
\begin{frame}{{#1}}
\begin{textblock}{11}(2,2)
}{ %after
%\end{textblock}
\end{frame}
}

...

\begin{document}

...

\begin{hframe}{title}
some text
\end{textblock}
\end{hframe}

\end{document}

it works... Any clue of what is happening and how can I include the \end{textblock} in the "end" argument of \newenvironment?

1
  • 1
    Perhaps this question will help: beamer's fragile frame as default. But keep in mind that while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it Commented Oct 29, 2012 at 4:50

2 Answers 2

1

You cannot wrap the beamer frame environment up like this: it's more-or-less a verbatim situation. You'll need instead to create the appropriate beamer theme, which is constructed after the frame is collected.

1

Section 8.1 The Frame Environment in the beamer user guide explains why TeX misses your \end{frame} when it is part of your own environment.

Joseph's suggestion of creating an appropriate theme is a better idea, but (as also explained in that section of the guide) you can pass the fragile option to the frame, and tell it the name of your enclosing environment with the environment=hframe option. Note however the consequences of using fragile.

As you haven't provided a full MWE, this is the best I can do to help you achieve what you were trying:

\documentclass{beamer}
\usepackage{textpos}

\newenvironment{hframe}[1]
{%before
\begin{frame}[fragile,environment=hframe]{{#1}}
\begin{textblock}{11}(2,2)
}{%after
\end{textblock}
\end{frame}
}

\begin{document}

\begin{hframe}{title}
some text
\end{hframe}

\end{document}

You must log in to answer this question.

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