3

I'm trying to create a myframe environment which wraps a Beamer frame environment but sets a default title. Additionally, I want to be able to pass optional arguments to myframe which should then forward these arguments to frame (particularly, I need the fragile argument to work).

I thought the following would work, but it doesn't. How do I fix this code?

\documentclass{beamer}

\newenvironment{myframe}[1][]{
    \begin{frame}[#1]{Default Title}
}{
    \end{frame}
}

\begin{document}

\begin{myframe}
    Hello world
\end{myframe}

\begin{myframe}[fragile]
    \begin{verbatim}
        Hello world
    \end{verbatim}
\end{myframe}

\end{document}
gTcV
  • 1,065
  • 2
    I'm note sture you can wrap the fragile options. As far as I remember when the fragile env is in play the macros behind it looks explicitly for \end{frame} to do their thing, and when it is hidden like this it is never seen. – daleif Aug 28 '19 at 07:28
  • 1
    A start to fix things would be to provide feed back to answers you've gotten to your other questions. – Keks Dose Aug 28 '19 at 20:18
  • Some commands process empty optional arguments differently than missing optional arguments (see \subfig). These are difficult to emulated using \newcommand. See https://tex.stackexchange.com/questions/80180/identification-of-an-empty-macro-from-pgfplots-using-ifx for example. – John Kormylo Aug 29 '19 at 17:00
  • Hiding \end{frame} behind a custom environment is an exceptionally bad idea - in many situations the code looks for the verbatim string \end{frame}. – samcarter_is_at_topanswers.xyz Sep 24 '22 at 13:31
  • Can you please clarify if all frames without title should have the default title or only some of them? – samcarter_is_at_topanswers.xyz Sep 24 '22 at 13:56

0 Answers0