0

This is a follow up to my question in this thread, in response to which @samcarter showed me how to combine <+-> with fragile. In the example below, I've tried to further automate his code by creating a fragileFrame environment which includes both of the above features. (Obviously, in this MWE it doesn't gain me much, but in my actual code, my beamer frames contain a lot of customization, which I don't want to have rewrite every time. However the environment construction throws an error. To verify that it really is the fragile option that's causing the error, I've created a normalFrame environment that is identical except for the fragile option, and compiles without error. Is there a way to get around this?

\documentclass{beamer}
\usepackage[framed]{matlab-prettifier}
\lstnewenvironment{myMPcolor}{%
            \lstset{basicstyle=\color{red}}
           }{}
\newenvironment{fragileFrame}[1]{%
    \beamerdefaultoverlayspecification{<+->}
      \begin{frame}[fragile]{#1}
    }{\end{frame}}
\newenvironment{normalFrame}[1]{%
    \beamerdefaultoverlayspecification{<+->}
      \begin{frame}{#1}
    }{\end{frame}}
\begin{document}
\begin{normalFrame}{Title}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\end{normalFrame}
\begin{fragileFrame}{Title}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{fragileFrame}
\end{document}
0
2

As said in a comment to your previous question, hiding the frame environment in a new environment is a bad idea - this usually causes more problems than it solves.

However if you really must do it:

\documentclass{beamer}

\usepackage[framed]{matlab-prettifier}
\lstnewenvironment{myMPcolor}{%
            \lstset{basicstyle=\color{red}}
           }{}

\newenvironment{slide}
    {\begin{frame}[fragile,environment=slide]}
    {\end{frame}}

\begin{document}

\begin{slide}
\frametitle{title}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{slide} 

\end{document}
1
  • Cool. Thanks very much. I'll take my chances on hiding frames inside new environments. I've been doing it without problems----until this one---for years. – Leo Simon Mar 24 '18 at 3:09

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.