2

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.

4
  • 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, 2018 at 14:05
  • I think my problem is different because I'm not using any background colors. Nov 2, 2018 at 19:17
  • Check the answer please
    – koleygr
    Nov 2, 2018 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, 2018 at 23:34

1 Answer 1

3

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:

enter image description here

2
  • How would I use it to adjust the top and bottom margins? Nov 3, 2018 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, 2018 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .