将章节标题添加到运行页眉

将章节标题添加到运行页眉

我希望能够在运行页眉中打印章节标题。我有一个章节标题和一个副标题,用于 scrbook 格式的章节起始页。副标题的格式为未编号的章节。使用以下代码,运行页眉保持空白。有人可以告诉我如何在运行页眉中包含章节标题吗?非常感谢。Mike

我的 mystyles.sty 是:

\ProvidesPackage{mystyles}
\usepackage{fontspec}
\setmainfont{Gill Sans}
\usepackage{lettrine}
\usepackage[automark,headsepline=.25pt]{scrlayer-scrpage}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{graphicx}
\graphicspath{ {../img/} }
\usepackage{wrapfig}
\usepackage[british]{babel}
\pagestyle{scrheadings}
\addtokomafont{pageheadfoot}{\scshape}%changed to small caps in headers
\addtokomafont{pagehead}{\small}
\addtokomafont{pagefoot}{\small}
\addtokomafont{disposition}{\rmfamily} %for headings
\chead{Ben Francis}
\ofoot{} %Author Name
\ifoot{} % Chapter Number
\lehead{\pagemark}
\rohead{\pagemark}
\cohead{\rightmark}
\renewcommand\thepart{\Alph{part}}
\linespread{1.05}
\usepackage{hyphenat}
\tolerance=1000
\hyphenpenalty=1000
\renewcommand*{\partpagestyle}{empty}
\usepackage{geometry}
\geometry{paperwidth=5.06in,paperheight=7.81in,
    verbose,
    tmargin=0.75in,
    bmargin=0.75in,
    inner=0.75in,
    outer=0.5in,
    headheight=0.1in,
    headsep=0.15in,
    footskip=0.45in,
    twoside}
\newcommand{\mytitle}{My Shorts} 
\newcommand{\emptx}[1]{\textit{#1}}
\renewcommand*\raggedsection{\centering}

\renewcommand{\sectionmark}[1]{ \markright{#1}{} }

\RedeclareSectionCommand[
font=\fontsize{45}{40}\selectfont\mdseries\mathilde
font=\fontsize{20}{15}
]{section}

\setkomafont{section}{\fontsize{35}{30}\selectfont\fontspec{mathilde}}
\setkomafont{subsection}{\normalsize}
\setkomafont{subsubsection}{\small}
\setkomafont{paragraph}{\normalsize}
\setkomafont{subparagraph}{\normalsize}
\widowpenalty=300
\clubpenalty=300

\setlength\parindent{8pt}

我的 main.tex 是:

\documentclass[12pt,english,british,twoside,openany,headings=small]{scrbook}
\usepackage{mystyles}%include file mystyles.sty in same directory which sets the styles for the book

%Begin content of book-------------------------------------------------

%First the title pages and copyright+++++++++++++++++++++++++++++++++++
\begin{document}
    \title{\mytitle}
    \author{}
    \date{}

    \frontmatter
    \maketitle
    \begin{titlepage}
        \begin{flushright}
            {\huge \mytitle}
            \par\end{flushright}{\huge \par}
    \end{titlepage}

    \begin{titlepage}
        \noindent\includegraphics[width=4in,height=1.5in]{./msbensig}
        \vspace*{0.5in}
        \begin{flushright}
            \Huge{My Shorts}
            \par\end{flushright}{\Huge \par}

        \clearpage
        \thispagestyle{empty}

        \begin{center}
            \emph{Copyright}
        \end{center}
        \begin{center}
            \textcopyright{ 2014 Ben Francis All rights reserved.}
        \end{center}
        \vspace*{0.5in}
        \begin{center}
            \begin{minipage}[t]{0.5\paperwidth}
                No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form, or by any means;
                mechanical, electrical, photocopying, scanning, recording or
                otherwise, without prior written consent from the publishers. Every
                effort has been made to contact all copyright holders. The author and
                publisher will gladly rectify any omissions.
            \end{minipage}
        \end{center}
        \vspace*{0.5in}
        \begin{center}
            ISBN:
        \end{center}
        \vspace*{0.2in}
        \begin{center}
            A CIP Record for this book is available from the British
            Library.
        \end{center}
        \vspace*{0.1in}
        \begin{center}
            Typeset in \LaTeXe
        \end{center}
    \end{titlepage}

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

%Include a Table of Contents, Preface and/or Introduction--------------

    %   \pagenumbering{gobble}% Remove page numbers (and reset to 1)
    %   \tableofcontents

    %   \addchap{PREFACE}
    %   \input{./BBB TITR Preface.tex}

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

%Include the chapters of the book----------------------------------------       
    \mainmatter
    \addchap{ONE}
    \input{./My_Shorts_01.tex}
    \addchap{TWO}
    \input{./My_Shorts_02.tex}
    \addchap{THREE}
    \input{./My_Shorts_03.tex}
    \addchap{FOUR}
    \input{./My_Shorts_04.tex}
    \addchap{FIVE}
    \input{./My_Shorts_05.tex}
    \addchap{SIX}
    \input{./My_Shorts_06.tex}
%The end of the book-----------------------------------------------------
\end{document}

答案1

使用 KOMA-Script 类,您可以用来\addsec获取未编号的部分,并在标题和目录中输入条目。该scrlayer-scrpage选项automark定义为双面或\sectionmark设置正确的标记。因此无需手动重新定义。reportbook\sectionmark

\documentclass[12pt,british,twoside,openany,headings=small]{scrbook}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{ragged2e}

\usepackage{babel}

\usepackage[automark,headsepline=.25pt]{scrlayer-scrpage}
\addtokomafont{pageheadfoot}{\scshape\small}%changed to small caps in headers
\clearpairofpagestyles% remove default header and footer content
\cehead{Ben Francis}
\cohead{\rightmark}% section in header
\ofoot{} %Author Name
\ifoot{} % Chapter Number
\ohead{\pagemark}

\usepackage{geometry}
\geometry{paperwidth=5.06in,paperheight=7.81in,
    verbose,
    margin=0.75in,
    headheight=0.1in,
    headsep=0.15in,
    footskip=0.45in,
    }
\renewcommand*\raggedsection{\centering}

\addtokomafont{disposition}{\rmfamily} %for headings
\setkomafont{section}{\fontsize{35}{30}\selectfont}
\setkomafont{subsubsection}{\small}

\linespread{1.05}

\usepackage{lipsum}% dummy text
\begin{document}
\addchap{ONE}
\addsec{First section}
\lipsum
\addchap{TWO}
\addsec{Second section}
\lipsum
\addchap{THREE}
\addsec{Third section}
\lipsum
\end{document}

在此处输入图片描述

相关内容