I am using titleps because I need chapters, sections, and subsections in the header, and titleps makes this easy. In the document I am working on, I wish for chapters, sections, and subsections to begin invisibly. That is, I wish the declaration of a new chapter, section, or subsection to affect the headers and the table of contents, but not the body of text.
\documentclass[openany]{book}
\usepackage{titleps}
\settitlemarks{chapter,section,subsection}
\newpagestyle{main}{
\sethead[\thepage][][{\scshape\chaptertitle} \hspace{1em} \sectiontitle \hspace{1em} {\itshape\subsectiontitle}] % even
{{\scshape\chaptertitle} \hspace{1em} \sectiontitle \hspace{1em} {\itshape\subsectiontitle}}{}{\thepage} % odd
}%
\pagestyle{main}
\begin{document}
\tableofcontents
\chapter{Chap}
\section{Sec}
\subsection{Subsec}
Words
\newpage
Words
\newpage
Words
\newpage
\section{SecTwo}
Words
\end{document}
titlesec(which plays well together withtitleps). – campa Oct 06 '23 at 17:00