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?

\newenvironment{MyEnvironment}{% works fine in v1.7 ?

Have some python code:
...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 ?

I'm also looking to embed \mintinline inside another macro. Not sure if the same recipe as lstinline applies?

1 Answer 1


Depending on what you are doing, you may want to take a look at the \newminted and \newmintinline macros. These allow you to create custom versions with your own default arguments.

If you do need to create your own environment containing minted, this works and is simpler, since it doesn't get into the minted internals:


The minipage and center won't necessarily be needed, depending on your final objective.

You should be able to treat \mintinline like you would \lstinline without any trouble. Also, in most situations you should be able to treat it just like any other macro, so long as you aren't using the # and % characters.

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.