为什么当清单代码写在两页上时,页码会稍微移动到最底行?

为什么当清单代码写在两页上时,页码会稍微移动到最底行?

我注意到,每当我将源代码添加到我的 latex 文件时,添加代码的页码看起来都会错位。我不知道列表配置中是否存在导致这种情况的原因,但这是一个包含我使用的所有包的可编译代码示例,以及页码的图片,它的位置略微移动到了应该保持在线下方的行。 在此处输入图片描述

\documentclass[ngerman,12pt,a4paper,oneside,listof=totoc,plainfootsepline]{scrbook}
\addtokomafont{disposition}{\rmfamily} 
\addtokomafont{captionlabel}{\bfseries}
\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection}
\usepackage[left=3cm,right=2.5cm,top=3cm,bottom=2.5cm,head=33pt,foot=18pt]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{amsfonts}
\usepackage{amssymb}
%\def\quad{\hskip1em\relax}
\usepackage[normalem]{ulem}
\usepackage[pdfborder={0 0 0}]{hyperref}
\pagenumbering{Roman}

\usepackage{float}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[numbers,square]{natbib}
\bibliographystyle{unsrtdin}
\usepackage[pdftex]{graphicx}
\usepackage{epstopdf}

\usepackage{microtype}

\RequirePackage{scrlfile}
\ReplacePackage{scrpage2}{scrlayer-scrpage}
\usepackage{subcaption}  
\usepackage{blindtext}
\usepackage{tabto}
\usepackage{enumitem} 
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[labelfont=bf]{caption}
%\usepackage[singlelinecheck=false]{caption}
\usepackage{makecell, tabularx}
\usepackage{babel,tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X} % suppress full justification
\usepackage[locale=DE]{siunitx} % for \qty macro; use commas as decimal markers
\usepackage{nameref}
\usepackage{amssymb}
\usepackage{pdflscape}
\usepackage{wrapfig}
\usepackage{ulem}
\usepackage{url}
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{tabularray}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\usepackage[fleqn]{amsmath} 
\setitemize{leftmargin=*,noitemsep}
\setenumerate{leftmargin=*,noitemsep} 
\newlist{Schritte}{enumerate}{1}
\setlist[Schritte, 1]{label = Schritt \arabic*:}
\usepackage{etoolbox}
\usepackage{booktabs}
\usepackage[printonlyused]{acronym}
\renewcommand*{\aclabelfont}[1]{{\textit{#1}\hfill}}
\usepackage[section]{placeins}

\captionsetup{justification=centering}

\usepackage[singlelinecheck=false]{caption}
\usepackage[headsepline,footsepline]{scrpage2}
\pagestyle{scrheadings}
\automark[section]{chapter}

\renewcommand{\chaptermark}[1]{\markright{#1}}
\renewcommand{\sectionmark}[1]{}
\renewcommand*\MakeUppercase[1]{#1}

\ihead{}
\chead{}
\ohead{\rightmark}

\ifoot{}
\cfoot[\thepage]{\thepage}
\ofoot{}
\usepackage{tocbibind}

\newcommand*{\formelentry}[1]{%
    \addcontentsline{for}{formel}{\protect\numberline{\theequation} #1}}%

\usepackage{bigstrut}
\setlength\bigstrutjot{3pt} 

\renewcommand*{\chapterheadstartvskip}{\vspace*{.1\baselineskip}}
\usepackage{notoccite}
\usepackage{listings}
\usepackage{color}


\usepackage{courier}

\lstdefinestyle{customc}{
    breaklines=true,
    language=C,
    showstringspaces=false,
    keywordstyle=\bfseries\color{blue},
    commentstyle={\color{green!40!black}},
    identifierstyle=\color{black},
}

\lstset{escapechar=@,style=customc}

\makeatletter
\newcommand\BeraMonottfamily{%
    \def\fvm@Scale{0.6}% scales the font down
    \fontfamily{fvm}\selectfont% selects the Bera Mono font
}
\makeatother

\lstset{
    basicstyle=\BeraMonottfamily,lineskip={-6pt}, 
}
\begin{document}
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
\begin{lstlisting}
    #define ENDCOMMAND             ":END"
    #define COM1                   "START:DO_THE_COMMAND" //
    #define COM2                   "START:GET_COM2" //
    #define COM3                   "START:GET_COM3_" //Anmeldung
    #define COM4                   "START:WRITE_" //
    #define COM5                   "START:READ_" //
    #define COM6                   "START:READ_MULTI_"//
    #define COM7                   "START:SET_PRO_PAGE_" //
    #define COM8                   "START:SET_PRO_PAGES_"//
    #define COM9                   "START:PW_INPUT_"//
   \end{lstlisting}
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXb TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT . TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT\\
\end{document}

非常感谢您的帮助!

答案1

这里的问题是

\lstset{
    basicstyle=\BeraMonottfamily,lineskip={-6pt}, 
}

如果你只想要lstlisting单倍行距,你可以使用

\usepackage{etoolbox}
\AtBeginEnvironment{lstlisting}{\singlespacing}

如果您使用的是最新的 LaTeX 内核,则可以etoolbox用内核中的新 env 钩子替换,但这也适用于较旧的 LaTeX。请注意,这不会影响\lstinputlisting

相关内容