Adjust top and bottom margins using minted

I've been using the listings package with the following setup to produce a compact layout of code samples:

\lstset{
basicstyle=\footnotesize\ttfamily,breaklines=true,
framextopmargin=50pt,framexleftmargin=30pt,framexbottommargin=-5pt
}


How would one control the top and bottom margins for minted? It doesn't have the same options.

• Possibly you are looking for this: tex.stackexchange.com/q/228058/120578. If it solves your problem, please tell us to mark as a duplicate. – koleygr Nov 2 '18 at 14:05
• I think my problem is different because I'm not using any background colors. – Björn Lindqvist Nov 2 '18 at 19:17
• Check the answer please – koleygr Nov 2 '18 at 19:32
• minted basically uses a slightly modified version of trivlist. By wrapping it with tcolorbox features might be the simplest way to achieve your needs. – egreg Nov 3 '18 at 23:34

Check this:

\documentclass{article}
\usepackage{minted}

\BeforeBeginEnvironment{minted}{\medskip}
\AfterEndEnvironment{minted}{\medskip}

\begin{document}
\lipsum*[1] Some text

\begin{minted}{c}
int main() {
printf("hello, world");
return 0;
}
\end{minted}

Some text \lipsum*[2]
\end{document}


It is @user11232's answer from here but without background colors.

Output:

• How would I use it to adjust the top and bottom margins? – Björn Lindqvist Nov 3 '18 at 20:04
• You are right... It didn't worked with changes... I edited... You can change \medskip to \bigskip or \smallskip.. or even \medskip\smallskip or \vspace{1cm} etc – koleygr Nov 3 '18 at 20:17