1

I'd like to be able to custom-define a frame environment that has two arguments, <+-> and fragile. The first allows me to uncover items in a list environment, the second allows me to use the matlab-prettifier package. There seem to be two hurdles 1) fragile seems incompatible with <+-> 2) I'm unable to custom-define an environment even just with fragile in it. The MWE below illustrates both problems. It compiles correctly as written. There are two commented-out lines. If you uncomment either of them, and comment out the line below, then pdflatex will throw an error Are there workarounds for either or both problems?

\documentclass{beamer}
\usepackage[framed]{matlab-prettifier}
\lstnewenvironment{myMPcolor}{%
            \lstset{basicstyle=\color{red}}
           }{}
%\newenvironment{colorFrame}[fragile][1]{%
\newenvironment{colorFrame}[1]{%
    \setbeamercolor{background canvas}{bg=cyan}
      \begin{frame}[<+->]{\hfill #1 \hfill }
    }{\end{frame}}
\begin{document}
%\begin{frame}[<+->,fragile]{Title}
\begin{frame}[fragile]{Title}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{frame}
\begin{colorFrame}{Title}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\end{colorFrame}
\end{document}
Leo Simon
  • 2,199

1 Answers1

2

Instead of using a frame option, you could directly pass <+-> to the itemize environments:

\documentclass{beamer}
\usepackage[framed]{matlab-prettifier}

\lstnewenvironment{myMPcolor}{%
            \lstset{basicstyle=\color{red}}
           }{}

\begin{document}

\begin{frame}[fragile]{Title}
\begin{itemize}[<+->]
    \item first point
    \begin{itemize}[<+->]
        \item subpoint
    \end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{frame}

\end{document}

If you need a more automatic solution, you could also use

\documentclass{beamer}
\usepackage[framed]{matlab-prettifier}

\lstnewenvironment{myMPcolor}{%
            \lstset{basicstyle=\color{red}}
           }{}

\begin{document}

\begin{frame}[fragile]{Title}
\beamerdefaultoverlayspecification{<+->}
\begin{itemize}
    \item first point
    \begin{itemize}
        \item subpoint
    \end{itemize}
\end{itemize}
\begin{myMPcolor}
This is a matlab command
\end{myMPcolor}
\end{frame}

\end{document}
  • Actually I wanted something slightly more and have posed it as a new question here https://tex.stackexchange.com/questions/422868/creating-a-beginframefragile-macro – Leo Simon Mar 23 '18 at 22:07