2

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}
  • 1
    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 7:28
  • 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
  • I am not sure this type of comments is acceptable on stackexchange sites. I am sorry I forgot to accept your other answer, but it would possibly have been more productive to leave a comment there to remind me to give you the credit you deserve. My first reaction when I saw your comment was to fire a snarky remark back at you, which doesn't help either of us. – gTcV Aug 29 '19 at 0:26
  • Some commands process empty optional arguments differently than missing optional arguments (see \subfig). These are difficult to emulated using \newcommand. See tex.stackexchange.com/questions/80180/… for example. – John Kormylo Aug 29 '19 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.