我想减少所有行高(每行之间的空白区域)\lstinputlisting
,可以吗?
原始代码取自https://tex.stackexchange.com/a/660320/127048,仅\usepackage[scale=0.9]{zi4}
改变(较小比例):
\documentclass[10pt,journal,compsoc]{IEEEtran} \usepackage{amsmath,amssymb} \usepackage{lipsum} \usepackage[nott]{newtxtext} \usepackage{newtxmath} \usepackage[scale=0.9]{zi4} \usepackage{listings} \usepackage{lstautogobble} \lstdefinestyle{mystyle} { basicstyle=\ttfamily, frame=single, breaklines, columns=fullflexible, breakindent=1.2em, breakatwhitespace, escapeinside={(*}{*)}, } \begin{document} abc\texttt{abc} \begin{lstlisting}[style=mystyle,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt] function hello_world(*\,*)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool { uint256 amount = 100 return true; } \end{lstlisting} \lipsum*[2] \end{document}
可能与以下情况相关:减少 \lstinputlisting 中空行的高度
答案1
您可以将基线跳过指定为字体大小的一部分,因此
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage[nott]{newtxtext}
\usepackage{newtxmath}
\usepackage[scale=0.9]{zi4}
\usepackage{listings}
\usepackage{lstautogobble}
\lstdefinestyle{mystyle}
{
basicstyle=\fontsize{10}{10.5}\ttfamily,
frame=single,
breaklines,
columns=fullflexible,
breakindent=1.2em,
breakatwhitespace,
escapeinside={(*}{*)},
}
\begin{document}
abc\texttt{abc}
\begin{lstlisting}[style=mystyle,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt]
function hello_world(*\,*)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool {
uint256 amount = 100
return true;
}
\end{lstlisting}
\lipsum*[2]
\end{document}