As a followup question to Lstinline macro inside another environment, I kind of want to do the same thing for minted as well, but I'm held back by the following:
I used the code from Using minted to define a new environment but that doesn't seem to work so well for the latest version of minted (version 2.0 alpha 3). \mintinline works nicely in the latest version. Preferrably I wouldn't want to choose between the two.
Any known workaround to this?
\documentclass[10pt]{article}
\makeatletter
\IfFileExists{minted.sty}{%
\usepackage{minted}
\usemintedstyle{euryris}
\usepackage{lineno}
\def\gobble##1{}
\renewcommand\DeleteFile[1]{}
\newenvironment{MyEnvironment}{% works fine in v1.7 ?
\VerbatimEnvironment
\minted@resetoptions
\setkeys{minted@opt}{}
\begin{center}
\begin{minipage}{\linewidth}
\begin{VerbatimOut}{\jobname.pyg}}
{%
\end{VerbatimOut}
\minted@pygmentize{python}
\DeleteFile{\jobname.pyg}
\end{minipage}
\end{center}}
}{}
\makeatother
\begin{document}
\section{Environment}
Have some python code:
\begin{MyEnvironment}
print(x**2)
\end{MyEnvironment}
...as the pleasure is all mine.
\section{Inline code}
Some serious inline code right here:~\mintinline{python}{print(x**2)}. Some seriously ugly \jobname.pyg to the right % works fine in v2.0 ?
\end{document}
I'm also looking to embed \mintinline inside another macro. Not sure if the same recipe as lstinline applies?