Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to remove the spacing below the code of a minted environment? When I have a block of code underneath another it doesn't produce any spacing (which is what I want), but it does for text (which I don't want). Is there somthing similar like belowskip of the listings package that I can use as a global option?

\documentclass{article}

\usepackage{minted}

\begin{document}

\newminted{python3}{linenos=true} % belowskip=0pt?

\begin{python3code}
print("Hello world")
\end{python3code}

Some text

\end{document}
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

minted uses the package fancyvrb to create the environment. fancyvrb uses a modification of trivlist. So you can have to modify the trivlist.

One possibility is shown below. Here I created a new key belowskip.

EDIT

In combination width \newminted it also works (see comment below):

% pdflatex --shell-escape 
\documentclass{article}

\usepackage{minted}
\makeatletter
\newlength\minted@belowskip
\define@key{minted@opt}{belowskip}[\@topsepadd]
{\setlength{\minted@belowskip}{#1}}

\def\minted@endparenv{%
  \addpenalty\@endparpenalty\addvspace\minted@belowskip\@endpetrue}
\def\FV@EndList{%
  \FV@ListProcessLastLine
  \FV@EndListFrame
  \minted@endparenv
  \endgroup
  \@endpetrue}
\makeatother
\newminted{python3}{linenos=true, belowskip=4cm}
\begin{document}

\begin{python3code}
print("Hello world")
\end{python3code}

Some text


\begin{python3code}
print("Hello world")
\end{python3code}

Some text

\end{document}

Orig

% pdflatex --shell-escape 
\documentclass{article}

\usepackage{minted}
\makeatletter
\newlength\minted@belowskip
\define@key{minted@opt}{belowskip}[\@topsepadd]
{\setlength{\minted@belowskip}{#1}}

\def\minted@endparenv{%
  \addpenalty\@endparpenalty\addvspace\minted@belowskip\@endpetrue}
\def\FV@EndList{%
  \FV@ListProcessLastLine
  \FV@EndListFrame
  \minted@endparenv
  \endgroup
  \@endpetrue}
\makeatother
\begin{document}

\begin{minted}[belowskip=4cm]{python}
print("Hello world")
\end{minted}

Some text


\begin{minted}[belowskip=0pt]{python}
print("Hello world")
\end{minted}

Some text

\end{document}
share|improve this answer
    
Seems to break if I use it as an option in my environment: \newminted{python3}{linenos=true, belowskip=0pt} \begin{python3code} ... –  pg-robban Dec 4 '11 at 20:28
    
@pg-robban: It works also with \newmindet. –  Marco Daniel Dec 4 '11 at 20:53
    
Must be a conflict with the other packages I'm using: package calc error 'xkv@tempa@toks' invalid at this point. But the MWE seems to be working so I'll accept this answer. Thank you! –  pg-robban Dec 4 '11 at 21:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.