某些页面出现奇怪的垂直偏移

某些页面出现奇怪的垂直偏移

不幸的是,我还无法创建完整的 MWE,因为我的文档的真实内容受版权保护,并且使用盲文不会产生奇怪的错误。

我的问题:我有一个包含许多表格等的大型文档。

在某些页面上,页眉和页脚在垂直方向上略有偏移。滚动文档时,某些页面会“跳动”一点点(最多几毫米)。

显示几何包的框架表明,边框没有改变,但是页眉/页脚的内容会改变。

在没有 MWE 的情况下,是否有任何方法可以确定为什么某些页面会偏移?

我认为它可能与这些页面上的“太多内容”有关,因为页眉在向上方向偏移,而页脚向下偏移......


编辑 1:我添加了完整的序言以提供更多信息。附加说明:移位与章节或小节的开头无关。

\documentclass[english,footsepline,listof=totoc]{scrartcl}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{float}

\makeatletter

%% Open a read-channel for later use
\newread\tempfile
\newread\file
\newcommand{\getnextline}

%% Packages for pagelayout and borders/margins of the whole document
\usepackage{geometry}
\geometry{a4paper,verbose=true,tmargin=4.5cm,bmargin=3.5cm,lmargin=2.5cm,rmargin=2.5cm,headheight=3cm,footskip=1.5cm,showframe}
\savegeometry{a4standard}
%\setlength{\footheight}{1cm}

%% Package for nice vertical spacings between the lines
\usepackage{setspace}

%% Begin of magic to indent all body but no headings
\newcommand\LeftMargin{.5cm}
\renewcommand*\sectionlinesformat[4]{ \ifstr{#3}{}{}{\hspace*{-\LeftMargin}}#3#4}
\usepackage[  headwidth=\the\textwidth+\LeftMargin:-\LeftMargin:    \LeftMargin,footwidth=\the\textwidth+\LeftMargin:-\LeftMargin:\LeftMargin]{scrlayer-scrpage}
%% End of magic

%% Define how deep the numeration in the document should be.
\setcounter{secnumdepth}{5}
%% Define how deep the numeration in the table of contents should be.
\setcounter{tocdepth}{3}
%% Print paragraphs and subparagraphs not in bold
\setkomafont{paragraph}{\normalfont \underline}
\setkomafont{subparagraph}{\normalfont \underline}

\usepackage{tabularx} %package for table on 1st page
\usepackage{longtable} %package for table that is longer than one page
\usepackage{tabu}

%% Using .eps-images
\usepackage[pdftex]{graphicx}
\usepackage[outdir=./]{epstopdf}

%% Define new columntype for centered output in tabularx/tabu environments
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{pgfplotstable} %package for automated csv-table-creation
\usepackage{pgfplots} %see above
\usepackage{colortbl} %allows coloring in tables
\usepackage{color} %allows creation of custom colors
\definecolor{lightergray}{RGB}{242,242,242} % define a color for later use
\definecolor{mediumgray}{RGB}{191,191,191} % define a color for later use
\usepackage{booktabs} %enables some nice formatting options in tables
\usepackage{hhline} %% Alternative horizontal line for tables

%% Standard typeset settings
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

%% Package for using external pdf pages
\usepackage{pdfpages}

%% allows better page layouts
\pagestyle{scrheadings} %same as above

%% Use of standard units
\usepackage{siunitx}

%% Define customized pagenumbering, might be obsolete
\newcommand{\custompagenumbers}{%
\break%
\pagenumbering{arabic}%
\renewcommand{\thepage}{\arabic{section}\-\arabic{page}}%
}
%% Let each section start on a new page
\let\stdsection\section
\renewcommand\section{%
\setcounter{page}{1}%
\clearpage%
\stdsection%
}

%% Creation of header/footer
\clearscrheadfoot    % footer/header layout happens below here
\chead{\raisebox{5mm}{\includegraphics[height=2cm]{logo.png}}}  
\ofoot{\raisebox{-5mm}{\thesection-\thepage}} 
\cfoot{\raisebox{-5mm}{Title}} 
\setkomafont{pageheadfoot}{\normalfont}

\usepackage{tikz} %needed for some magic
\usepackage{forloop} %needed to create multiple looped outputs
\usepackage{xparse} %needed to be able to calculate with integer values

\usepackage{sansmath} %load font for math without serifs
\sansmath %set all mathfont to the sansmath font

%% Create variable for later use
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\eval}{m}{\int_eval:n {#1}}
\ExplSyntaxOff

%% This should be the last entry
\usepackage[]{hyperref}

%Define a default counter for forloops and pgfmarks
\newcounter{forloopcount}
\newcounter{linespgf}

\makeatother

\usepackage{babel}

答案1

好的,我刚刚解决了这个问题。

和往常一样,错误是由粗心的编程引起的。在我的文档中的某些位置 - 在表格中实现自定义垂直间距之前 - 我使用了该\setstretch{}命令。此命令显然也会影响页眉/页脚中的垂直间距,因此始终存在问题。删除它并在整个文档中使用恒定的垂直间距解决了该问题。

感谢所有提供帮助的人。

相关内容