I want to insert a header in the book
class such that:
- Odd pages show only the book title on the left header:
- Even pages show either the section name, or the subsection (if this exists) on the right header
MWE:
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{lipsum}
\fancyhf{}
\fancyhead[LO]{Book title}\fancyfoot[CO]{\thepage}
\fancyhead[RE]{\nouppercase{\rightmark}}\fancyfoot[CE]{\thepage} %this should be defined in some other way
\pagestyle{fancy}
\author{Author}
\title{Test book}
\begin{document}
\maketitle
\tableofcontents
\chapter[Test chapter]{Test chapter}
\section{First section}
\lipsum[4-11]
\markedsection{Short section title}{Long section title}
\lipsum[1-6]
\end{document}
However, even pages do not show the section name, while they show the subsection name when that is already "initialized". How can I define a command that changes the section name into the subsection name of the header?
\markedsection
from?