1

I need two different header formats for two chapters. In chapter one, the header should show the chapter (number and title) on even pages, and the section (number and title) on odd pages. In chapter two, it should show the section (number and title) on even pages, and the subsection (number and title) on odd pages. To implement this, I used titlesec to define two pagestyles, one for each chapter. My code produces the desired output for chapter one, and for the even pages of chapter two. However, for odd pages, the header displays only the subsection number but not the subsection title -- as if the \subsectiontitle command is not active. How can I get the subsection title to show up? Here is a MWE (including some lines which I must use to format titles and the toc):

\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}

  \titlecontents{chapter}[9mm]    
    {\vspace{9pt}\normalsize\normalfont\bfseries}  
    {\contentslabel{9mm}}{}   
    {\hfill\thecontentspage}   

  \titlecontents{section}[20.7mm]   
    {\vspace{0pt}\normalsize\normalfont} 
    {\contentslabel[\thecontentslabel]{11.7mm}}{}
    {\titlerule*[.75em]{.}\thecontentspage}   

\newpagestyle{mystandardpagestyle}{
\sethead
    [\thepage][\thechapter\hspace{1em}\chaptertitle][]
    {}{\thesection\hspace{1em}\sectiontitle}{\thepage}
} 

\newpagestyle{myproblempagestyle}{
\sethead
    [\thepage][\thesection\hspace{1em}\sectiontitle][]
    {}{\thesubsection\hspace{1em}\subsectiontitle}{\thepage}
} 

\titleformat{\chapter}{\LARGE}{\thechapter}{1em}{}
\titleformat{\section}{\Large}{\thesection}{1em}{}
\titleformat{\subsection}{\large}{}{0em}{}  


\setcounter{tocdepth}{1}        
\setcounter{secnumdepth}{3}        

\begin{document}

\tableofcontents 

\pagestyle{mystandardpagestyle}
  \chapter{Chapter One} 
\lipsum
  \section{Section One}  
\lipsum
  \subsection{Subsection one} 
\lipsum[1-6]
\clearpage

\pagestyle{myproblempagestyle}
  \chapter{Chapter Two} 
\lipsum
  \section{Section One}  
\lipsum
  \subsection{Subsection one} 
\lipsum[1-6]

\end{document} 
2

You need to enable the mark-mechanism for subsection with

 \settitlemarks{chapter,section,subsection}

See the documentation titleps.pdf

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.