4

The format of my thesis is as follows:

\documentclass[oneside,11pt,english]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}

\usepackage{titlesec}

\setlength{\headheight}{26pt} 
\fancypagestyle{anfang}{% 
\fancyhead{\test}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhf{}% 
\fancyhead[L]{\rightmark}
\fancyfoot[C]{\thepage}
\lhead{\nouppercase{\leftmark}}
} 

\fancypagestyle{rest}{
\fancyhf{}
\fancyhead[L,R]{ \rightmark}
\fancyhead[L,R]{ \leftmark}
\fancyfoot[C]{\thepage}
\rhead{\nouppercase{\rightmark}}
\lhead{\nouppercase{\leftmark}}
}

\titleformat{\part}[display]
{\normalfont\center}{\huge\scshape\partname\ \thepart\\*[-15pt]\hrulefill}    {-13pt}{\huge\scshape\bfseries}[\vspace{-25pt}\hrulefill]

\titleformat{\chapter}[display]
{\normalfont\filleft}{\LARGE\scshape\chaptertitlename\ \thechapter\\*[-15pt]\hrulefill}{-13pt}{\scshape\LARGE\bfseries}[\vspace{-25pt}\hrulefill]
\titlespacing*{ \chapter}{0pt}{65pt}{40pt}

\titleformat{name=\chapter,numberless}[display]
{\normalfont\filleft}{\vspace{-15pt} \hrulefill}{-13pt}    {\scshape\LARGE\bfseries}[\vspace{-25pt}\hrulefill]
\titlespacing*{\chapter}{0pt}{65pt}{40pt}

\begin{document}
\pagestyle{rest}
\chapter[chapter title for the toc]{Title of the chapter as displayed in the thesis\chaptermark{chapter title as in the header}}
\chaptermark{chapter title as in the header}
\lipsum \lipsum

\section[section title for the toc]{section title as displayed in the  thesis\sectionmark{section title as in the header}}
\sectionmark{section title as in the header}
\lipsum

\subsection[subsection title for the toc]{subsection title as displayed in the thesis}
\subsectionmark{subsection title as in the header}
\lipsum

\part{here we have a part}

\end{document}

The problem occurs because the titlesec package that I am using to produce the layout of the beginning of the chapters and parts clashes somehow with the use of sectionmark so that the title of the section in the header on the first page on which the section occurs is the one that is supposed to be in the toc. In fact, the sectionmark does not really do anything for this first page, on the second page everything is as it should. The header on my second page looks like:

enter image description here

instead of the one on page 3:

enter image description here

What I want is to have the "section title for the header" to appear in the header of every page instead of the "section title for the toc".

Does anyone know how I can solve this issue?

warsaga
  • 305
  • 1
  • 3
  • 6
  • Let's recap: You want to remove the section mark in the header on the first page that the section occurs in, but the section mark should be there on subsequent pages? – Werner Sep 05 '13 at 17:37
  • No, I do not want to remove it but I want to have "section title for the header" instead of "section title for the toc" to appear in the header. – warsaga Sep 05 '13 at 17:46
  • So, potentially, you want a TitleA for the section in display, TitleB in the header and TitleC in the ToC? – Werner Sep 05 '13 at 17:48
  • Yes, that's correct! However, the use of sectionmark seems to clash with the general format I have used in my thesis because this uses titlesec. If I remove the titlesec package, everything is fine. See also the edit of my question above. – warsaga Sep 05 '13 at 17:50
  • Note that typically you're only given the option of supplying two different titles for sectioning commands. One for the display (mandatory), and one for the header/ToC (optional). So you're looking at adding another (perhaps optional) choice to distinguish between 3 possible inputs. I assume you're fixed on using titlesec, so you want something that works with it rather than abandoning it altogether. – Werner Sep 05 '13 at 18:39
  • Ulrike Fischer suggested a little hack that works with fancyhdr at my identical question: http://tex.stackexchange.com/questions/241286/toc-and-header-versions-of-section-titles-titlesec-interferes-with-fancyhdr/241299#241299. – sibilant Apr 30 '15 at 01:00

1 Answers1

2

What you want to do is quite easy with the corresponding class from »KOMA-Script«.

\documentclass[
  headings=optiontohead
]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{blindtext}  % only for the dummy text

\begin{document}
  \tableofcontents

  \chapter[head=Chapter head entry,tocentry=Chapter ToC entry]{Chapter title}
    \blindtext[5]  % creates the dummy text
\end{document}

For details please have a look at the »KOMA-Script« user guide.

Note that the »blindtext« package is only used here to create the dummy text, thus is not part of the solution.