带有章节标题的页眉

带有章节标题的页眉

我希望我的论文中有一个类似于下图的标题。除了竖线之外,我还有章节标题。我该如何处理?我的文档类别是报告,我正在处理双面文档。(参见代码示例)

非常感谢您的帮助。在此处输入图片描述

\documentclass[11pt,a4paper,openright,twoside]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}                            
\usepackage{amsmath}

\RequirePackage[times]{quotchap}
\definecolor{chaptergrey}{rgb}{0.5,0.5,0.5}
\usepackage{fancyhdr}                               
\pagestyle{fancy}

\def\layout{2}  

\ifnum\layout=2 
    \fancyhf{}      
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
    \fancyhead[LE]{\nouppercase{\chaptername~ \thechapter~ |}}
    \fancyhead[RO]{\nouppercase{ \rightmark}}
    \fancyfoot[LE,RO]{\thepage}
    \fancypagestyle{plain}{         
    \fancyhf{}
    \fancyfoot[LE,RO]{\thepage}}    
 \else          
    \renewcommand{\headrulewidth}{0pt}
    \fancyhf{}                  
    \fancyhead[C]{\nouppercase{ \leftmark}}
    \fancyfoot[C]{\thepage}
\fi

\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}

答案1

这是非常简单来说titleps

\documentclass[11pt,a4paper,openright,twoside]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\RequirePackage[times]{quotchap}
\definecolor{chaptergrey}{rgb}{0.5,0.5,0.5}
\usepackage{titleps}
\newpagestyle{mine}{
\sethead[\chaptername~ \thechapter~|~\chaptertitle][][]{}{}{\thesection.~\sectiontitle}
\setfoot[\thepage][][]{}{}{\thepage}
}
\renewpagestyle{plain}{%
\setfoot[\thepage][][]{}{}{\thepage}
}
\pagestyle{mine}

\begin{document}

\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document} 

在此处输入图片描述

答案2

似乎添加\leftmark会给出您想要的输出:

\documentclass[11pt,a4paper,openright,twoside]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}                            
\usepackage{amsmath}

\RequirePackage[times]{quotchap}
\definecolor{chaptergrey}{rgb}{0.5,0.5,0.5}
\usepackage{fancyhdr}                               
\pagestyle{fancy}

\def\layout{2}  

\ifnum\layout=2 
    \fancyhf{}      
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
    \fancyhead[LE]{\nouppercase{\chaptername~ \thechapter~ |~ \leftmark}}
    \fancyhead[RO]{\nouppercase{ \rightmark}}
    \fancyfoot[LE,RO]{\thepage}
    \fancypagestyle{plain}{         
    \fancyhf{}
    \fancyfoot[LE,RO]{\thepage}}    
 \else          
    \renewcommand{\headrulewidth}{0pt}
    \fancyhf{}                  
    \fancyhead[C]{\nouppercase{ \leftmark}}
    \fancyfoot[C]{\thepage}
\fi

\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}

在此处输入图片描述

相关内容