减少/消除页眉和自定义章节标题之间的间隙

减少/消除页眉和自定义章节标题之间的间隙

我正在编写一个投资组合/报告pdflatex,在尝试获取页眉和页脚时,我遇到了一种情况,即页眉和章节标题之间存在明显的间隙,而其他页面上没有间隙。

我用来设置页眉、页脚和标题样式的代码是:

% Header/Footer 
\fancypagestyle{plain}{
  \fancyhf{}
  \fancyhead[L]{Name \texttt{<email@address>}}
  \fancyhead[R]{\leftmark}
  \fancyfoot[L]{Subject Name}
  \fancyfoot[R]{\thepage}
  \setlength{\headheight}{15.2pt}
  \setlength{\headsep}{6pt}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.4pt}
}

% Chapter Title formatting

\titleformat{\chapter}[display]
  {\normalfont\Huge \scshape}{\titlerule}{-28pt}{\thechapter\ \ \Huge}[\vspace{-2pt}\titlerule]
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\Huge \scshape}{\titlerule}{-28pt}{\Huge}[\vspace{-2pt}\titlerule]
\titlespacing*{\chapter}{0pt}{50pt}{*2}
\begin{document}

% Article top matter ...
\maketitle

\pagestyle{plain}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}

答案1

使用第二个强制参数减少间距\titlespacing(当前您正在声明间距50pt);将第二个参数设置为的完整示例0pt(请注意,过多地减少此空间可能并不可取,因为来自标题的规则和来自章节标题的规则可能太接近):

\documentclass{report}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{lipsum}

% Header/Footer 
\fancypagestyle{plain}{
  \fancyhf{}
  \fancyhead[L]{Name \texttt{<email@address>}}
  \fancyhead[R]{\leftmark}
  \fancyfoot[L]{Subject Name}
  \fancyfoot[R]{\thepage}
  \setlength{\headheight}{15.2pt}
  \setlength{\headsep}{6pt}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.4pt}
}

% Chapter Title formatting

\titleformat{\chapter}[display]
  {\normalfont\Huge \scshape}{\titlerule}{-28pt}{\thechapter\ \ \Huge}[\vspace{-2pt}\titlerule]
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\Huge \scshape}{\titlerule}{-28pt}{\Huge}[\vspace{-2pt}\titlerule]
\titlespacing*{\chapter}{0pt}{0pt}{*2}

\pagestyle{plain}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}

\begin{document}

\chapter{Test Chapter}
\lipsum[1-30]

\end{document}

在此处输入图片描述

相关内容