我正在使用minted
包来处理我的代码:
\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}
但包裹总是给我这样的:
我的问题是如何使该代码看起来像:
答案1
我使用包(由 加载)的命令\floatstyle
和。\newfloat
\floatname
float
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}