I would like to customize the headers of my report. These should contain chaptertitle and sectiontitle. From here:
Header not displaying correctly on chapter page due to subsection
I have made an working MWE using fancyhdr{}
\documentclass[10pt,twoside]{report}
\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
% Allows calling chapter and section names in headers and footers.
\renewcommand{\chaptermark}[1]{%
\markboth{#1}
{\noexpand\firstsectiontitle}}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\sectionmark}[1]{%
\markright{#1}\gdef\firstsectiontitle{#1}}
\newcommand\firstsectiontitle{}
% General Header and Footer
\fancyhf{}
\fancyhead[LE]{\leftmark \space - \space \rightmark}
\fancyhead[RO]{\rightmark \space - \space \leftmark}
\fancyfoot[LE]{\thepage}
\fancyfoot[RO]{\thepage}
% Chapter Header and Footer
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[LE]{\leftmark \space - \space \rightmark}
\fancyhead[RO]{\rightmark \space - \space \leftmark}
\fancyfoot[LE]{\thepage}
\fancyfoot[RO]{\thepage}
}
%DOCUMENT
\begin{document}
\chapter{First chapter}
\section{First section}
\blindtext[6]
\pagebreak
\section{Second section}
\blindtext[6]
\pagebreak
\chapter{Second chapter}
\section{First section}
\blindtext[4]
\pagebreak
\section{Second section}
\blindtext[4]
\end{document}
As I am using titlesec anyhow, I was wondering if I could achieve something similar. With great help from here: How do I make a subsection title visible in a header on page with chapter / section I have done this:
\documentclass[10pt,twoside]{report}
%\documentclass[10pt]{report}
\usepackage[a4paper]{geometry}
\usepackage{blindtext}
\usepackage{ifthen}
\usepackage[pagestyles,extramarks]{titlesec}
\settitlemarks*{chapter,section}
\newpagestyle{mystyle}{
\sethead
[\chaptertitle\ifthesection{\ --\ \firstextramarks{section}\sectiontitle}{}]
[][]
{}{}
{\chaptertitle\ifthesection{\ --\ \firstextramarks{section}\sectiontitle}{}}
\setfoot[\thepage][][]{}{}{\thepage}
}
\pagestyle{mystyle}
\assignpagestyle{\chapter}{mystyle}
\begin{document}
\chapter{First chapter}
\section{First section}
\blindtext[6]
\pagebreak
\section{Second section}
\blindtext[6]
\pagebreak
\chapter{Second chapter}
\section{First section}
\blindtext[4]
\pagebreak
\section{Second section}
\blindtext[4]
\end{document}
Using the default (onesided) layout works fine. When I move over to the twosided layout however, the section name is not displayed on the chapter page. I could not find anything in the titlesec documentations, so my questions are:
- Does it make sense trying to avoid fancyhdr{} for the sake of simplicity?
- If it does, how can I display the section name?
Thanks in advance!


outermarksin the manual. In fact, it is only mentioned once in the examples.In general, do you think makes sense to have as few packages as possible? My intention was to avoid errors caused by interference.
Anyhow, thank you for you plain and quick response! You are right, it looks so much simpler now!
– lactea Jun 20 '14 at 05:41botmarksdid the thing. – lactea Jun 21 '14 at 13:40outermarkstakes the first mark in even and the last mark on odd pages.botmarkson the other hand takes only the very last line of every page. Here, it does not really matter because of the page breaks. When posting my question, I did not know that there is a separate manual for titleps, I have only read titlesec. Sorry for that. – lactea Jun 21 '14 at 14:37