I am trying to define a .sty file to help adding slides with code samples in my presentations. The minted package is a nice-looking solution for adding syntax-highlighting, but I can't get it to work together with a custom environment using \begin{frame}.
my beamerthemetheme.sty file is defined as below:
\usepackage{minted}
\newenvironment{Sli}[1]{
\begin{frame}[fragile]
{}
#1
\end{frame}
}%
my main.tex file is as follows:
\documentclass[aspectratio=169]{beamer} %. Aspect Ratio 16:9
\usetheme{theme}
\begin{document}
\Sli{
\begin{minted}{python}
import numpy as np
\end{minted}
}
\end{document}
But it is impossible to get the \Sli command working together with minted.
When written as defined above I get a Runaway argument? error. I've tried moving things around and small changes and the error changes but I still can't get it working. Curiously, if I use the commands directly without separating it in the \Sli command it works:
\documentclass[aspectratio=169]{beamer} %. Aspect Ratio 16:9
\usetheme{theme}
\begin{document}
\begin{frame}[fragile]
\begin{minted}{python}
import numpy as np
\end{minted}
\end{frame}
\end{document}
Any thoughts on how I can fix the \Sli command definition to make it work?
frames inside a command or an environment. – BambOo May 08 '20 at 21:04\end{frame}in your code. That's in particular important from fragile frames. There are workaround for this https://tex.stackexchange.com/questions/326787/difficulty-in-creating-macro-newcommand-for-the-beginning-and-end-of-frames-i but they'll just create more problems. – samcarter_is_at_topanswers.xyz Sep 26 '22 at 13:58