我试图linerange
在 中使用lstinputlisting
。该命令能够读取文件但会忽略第一行的内容。我希望如果我使用以下代码来查看List 1
开头的最后一行List 2
,这对应于源文件的第 20 行:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\begin{document}
% List 1
\lstinputlisting[linerange=10-20, numbers=left]{ERC.sol}
% List 2
\lstinputlisting[linerange=20-30, numbers=left]{ERC.sol}
\end{document}
这就是我得到的编译后的 pdf,正如您所见,第 20 行(第 1 行List 2
)未正确显示并在第二个列表中被省略:
这是ERC.sol
我正在使用的文件。
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
/**
* @dev Interface of the ERC20 standard.
*/
interface ERC20I is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() external view returns (string memory);
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function mint(address to, uint256 amount) external;
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function burn(address from, uint256 amount) external;
}