0

I have a code block using minted and mdframed and a caption afterwards.

\begin{mdframed}
\begin{minted}[tabsize=4]{c++}
    some code
\end{minted}
\end{mdframed}
\begingroup\captionof{listing}{some caption\label{lst:label}}\endgroup

The caption however is too far away from the code. I tried adding negative vertical space right after the frame, however it doesn't work correctly. Up to \vspace{-4em} nothing happens, but with \vspace{-5em}, the caption is moved right into the code block.

How can I move the caption that it is positioned right after the code block?

1

I figured it out, thanks to this question.

When I use \unskip after the frame, the caption will be positioned right after it. \vspace also works now, but is not needed anymore, at least for my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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