0

I would like to be able to print a Section Title in a Running Header. I have a Chapter Title and a Subtitle for a chapter start page in a scrbook format. The Subtitle is formatted as an unnumbered Section. Using the following code, the running header remains blank. Could someone show me how to include a section title in a running header? Many thanks. Mike

My mystyles.sty is:

\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}

My main.tex is:

\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
    Please provide your code in the form of a compilable MWE we can use to reproduce the problem. Your code is neither minimal nor complete: it almost certainly contains irrelevant stuff and it certainly doesn't provide enough for us to compile it. – cfr May 15 '16 at 19:59
  • There is neither a \section nor an \addsec command in your code. – esdd May 15 '16 at 21:17
  • How to write and format a MWE You can always join chat if you have questions concerning that matter. – Johannes_B May 16 '16 at 7:45
  • I guess you used an unnumbered section to prevent it from being included in the toc, but that also prevents it fro putting something into the header. – Johannes_B May 16 '16 at 7:52
2

With a KOMA-Script class you can use \addsec to get an unnumbered section with entry in the header and the TOC. The scrlayer-scrpage option automark defines \sectionmark to set the right mark for a twosided report or book. So there is no need to redefine \sectionmark manually.

\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}

enter image description here

  • Hi esdd, Absolutely brilliant! Thank you very much indeed. I had a feeling it was something to do with the calls to the chapter files but it never occured to me \addsec is appropriate. Apologies for the day's delay replying to you - been away. Mike – Mike May 17 '16 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.