0

To surround the code with a box, the documentation suggested to use listing environment. But the code has no effect at all. What is the issue here:

enter image description here

My MWE:

\documentclass[a4paper , 12pt]{article}
\usepackage{minted}
\usemintedstyle{manni}
\begin{document}
\begin{listing}[H]
\begin{minted}{java}
class Test
{
    public static void main(String args[])
    {
        System.out.println("Hello World");
    }
}
\end{minted}
\end{listing}
\end{document} 
1

To put a box, you don't need to wrap minted inside listing. A simple frame=single will do it. But listing wrapper is helpful in putting a caption (putting a \label) and producing a list of listings.

\documentclass[a4paper , 12pt]{article}
\usepackage{minted}
\usemintedstyle{emacs}
\renewcommand\listingscaption{Program}
\renewcommand\listoflistingscaption{List of Java codes}
\begin{document}
\listoflistings
\begin{listing}
\begin{minted}[bgcolor=olive!10]{java}  %% or frame=single
class Test
{
    public static void main(String args[])
    {
        System.out.println("Hello World");
    }
}
\end{minted}
\caption{My Java Code}\label{java:sample}
\end{listing}
\end{document}

enter image description here

If you want a frame add frame=single as in

\begin{minted}[bgcolor=olive!10,frame=single]{java}

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.