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.

mintedusesfancyvrto print the material. Therefor the environmentVerbatimis in used. Instead of this environment you can redefine some internals and use the environmentBVerbatimwhich is also provided byfancyvrb– Marco Daniel Jun 26 '13 at 05:10minted.styfile, since I'm still quite new to this. Could you perhaps help out a bit? Or maybe suggest an alternative, if jumping into themintedinternals is just too cumbersome? – Chatterjee Jun 26 '13 at 10:08varwidthand a nestedmintedis not unexpected; but even if it worked, you'd not get anything more than withminipage, sinceVerbatimalways uses the full text width available (as set by the document or by theminipageyou're in). – egreg Jun 26 '13 at 10:42BVerbatim;-) – Marco Daniel Jun 26 '13 at 15:09