Is there a way to incorporate a minted
environment inside a varwidth
environment? I have colored backgrounds for code snippets, and I did manage to put a minted
environment inside a minipage
, based on the answer to my previous question:
minted Environment Inside minipage Environment
However, it is really frustrating to manually adjust the width of the minipage for each code snippet. I tried wrapping the minted
environment with the varwidth
environment in minted.sty
, but am getting some weird errors.
minted
usesfancyvr
to print the material. Therefor the environmentVerbatim
is in used. Instead of this environment you can redefine some internals and use the environmentBVerbatim
which is also provided byfancyvrb
minted.sty
file, since I'm still quite new to this. Could you perhaps help out a bit? Or maybe suggest an alternative, if jumping into theminted
internals is just too cumbersome?varwidth
and a nestedminted
is not unexpected; but even if it worked, you'd not get anything more than withminipage
, sinceVerbatim
always uses the full text width available (as set by the document or by theminipage
you're in).BVerbatim
;-)