如何删除 Solidity 列表中不需要的控制信息(如图所示)

如何删除 Solidity 列表中不需要的控制信息(如图所示)

我正在使用论文模板。以下是链接:

https://www.overleaf.com/read/yyjwyqtvzfwt#ef4aff

任何人都可以通过上述链接访问我的所有文档吗?

我正在尝试将 Solidity 代码清单表示为图形。我编写了以下代码清单以表示为图形,如下所示:

\begin{figure}
  \caption{Example of Information Flow Rules}
\begin{lstlisting}
[language=Solidity, label={lst:Etahinter1}]
contract IFR{
function initOwner(address _owner) public { owner = _owner;}
function EasyTokill() public {
   if (msg.sender == owner)
   { /* sensitive code like selfdestruct or Ether transfer statement */ ... }}
}
\end{lstlisting}
\end{figure}

生成的乳胶列表有时会在顶部显示以下不需要的行,有时则不显示:

[语言=Solidity,标签={lst:Etahinter1}]

请指导我如何去掉上面的那行。祖尔菲。

答案1

可选参数需要紧跟其后,\begin{listing}否则它将被逐字读取为列表的一部分。

这在下面的第二个块中显示,但我得到了

! Package Listings Error: Couldn't load requested language.

See the Listings package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.20 ...language=Solidity, label={lst:Etahinter2}]
                                                  
? 

! Package Listings Error: language solidity undefined.

See the Listings package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.20 ...language=Solidity, label={lst:Etahinter2}]
                                                  
? 

但也许您有一个定义此列表配置的本地扩展。

在此处输入图片描述

\documentclass{article}

\usepackage{listings}

\begin{document}
\begin{figure}
  \caption{Example of Information Flow Rules}
\begin{lstlisting}
[language=Solidity, label={lst:Etahinter1}]
contract IFR{
function initOwner(address _owner) public { owner = _owner;}
function EasyTokill() public {
   if (msg.sender == owner)
   { /* sensitive code like selfdestruct or Ether transfer statement */ ... }}
}
\end{lstlisting}

\bigskip \hrule \bigskip

\begin{lstlisting}[language=Solidity, label={lst:Etahinter2}]
contract IFR{
function initOwner(address _owner) public { owner = _owner;}
function EasyTokill() public {
   if (msg.sender == owner)
   { /* sensitive code like selfdestruct or Ether transfer statement */ ... }}
}
\end{lstlisting}
\end{figure}
\end{document}

相关内容