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.

I'm using the minted package. How can I get the caption to show before the code in the document?

\documentclass[a4paper]{scrartcl}
\usepackage{minted}
\begin{document}
    \begin{listing}[H]
        \caption{This is below the code.}
        \inputminted{matlab}{myfile.m}
        \label{lst:the-code}
    \end{listing}
\end{document}
share|improve this question
    
You might want to use the matlab-prettifier package; see this answer. –  Jubobs Apr 28 at 15:29

1 Answer 1

up vote 8 down vote accepted

The floatrow package will do the trick, but it must be loaded before minted to prevent it from loading the float package.

\documentclass[a4paper]{scrartcl}    
\usepackage{floatrow}
\usepackage{minted}    
\floatsetup[listing]{style=Plaintop}    
\begin{document}    
    \begin{listing}[H]    
        \caption{This is below the code.}    
        \inputminted{matlab}{myfile.m}    
        \label{lst:the-code}    
    \end{listing}    
\end{document}

enter image description here

share|improve this answer

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.