1

I am using minted package for my code:

\begin{listing}[htbp]
\begin{minted}[baselinestretch=1, 
                linenos, 
                xleftmargin=1.5em,
                breaklines]{solidity}
contract Delegate {
    address public owner;
    function pwn() {
        owner = msg.sender;
    }  }
contract Delegation {
    address public owner;
    Delegate delegate;
    function() {
      if(delegate.delegatecall(msg.data)) {
        this;
    }  }  }
\end{minted}
\caption{The Triangle example}
\label{list:triangle}
\end{listing}

but the package always gives me like:

enter image description here

My question is how to make this code look like:

enter image description here

1 Answer 1

1

I use the commands \floatstyle, \newfloat and \floatname of the package float (loaded by minted).

\documentclass{article}
\usepackage{minted}

\floatstyle{ruled}
\newfloat{listing}{H}{lox}
\floatname{listing}{\strut Listing}

\begin{document}

\begin{listing}[htbp]
\begin{minted}[baselinestretch=1, 
                linenos, 
                xleftmargin=2em,
                breaklines]{solidity}
contract Delegate {
    address public owner;
    function pwn() {
        owner = msg.sender;
    }  }
contract Delegation {
    address public owner;
    Delegate delegate;
    function() {
      if(delegate.delegatecall(msg.data)) {
        this;
    }  }  }
\end{minted}
\caption{The Triangle example}
\label{list:triangle}
\end{listing}

\end{document}

Output of the above code

You must log in to answer this question.

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