# Section number appears instead of book title (memoir + titlesec)

I'm using the memoir package to write a non-fiction book. I see that creating a section makes the header on the right page read the section number instead of the book title.

Here's what I desire: The verso header should have the chapter name, and the recto header should have the book name.

I referred to the question, Headers with chapter titles only, but it doesn't seem to fix my issue. Here's the MWE:

% universal settings
\documentclass[a5paper,11pt,twoside,onecolumn,openright,extrafontsizes]{memoir}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}
\usepackage[tracking=true,letterspace=50]{microtype}
\usepackage{setspace}
\usepackage{titlesec}

\usepackage{lipsum} % to generate Lorem Ipsum

\setlength{\parskip}{0em}
\SetTracking{encoding=*,shape=sc}{100}

% tracking adjustments for small caps
\DeclareMicrotypeSet*[tracking]{alegreyasc}
{font = */AlegreyaSC-TLF/*/*/*}

% defining the title and the author
\title{My Title}

% chapter title manipulation
\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}

\setcounter{secnumdepth}{0}
\titleformat{\section}[block]{\large\bfseries}{}{1em}{}

% for normal pages
\makeatletter
}
\makepagestyle{mystyle}
\clearmark{section}
\makepsmarks{mystyle}{%
\createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
% for pages where chapters begin
\makepagestyle{plain}
\makeevenfoot{plain}{}{}{}
\makeoddfoot{plain}{}{}{}
\pagestyle{mystyle}

% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}
\pagestyle{mystyle}
% preface
\chapter{Chapter One}
\lipsum[1]

\section*{Section One}
\lipsum[2-10]

\end{document}


The output is like this (notice the header):

• Your example doesn't produce any section numbers so I don't really understand the problem. – cfr Sep 17 '16 at 22:38
• Insert \pagestyle{mystyle} to use your new pagestyle in your document. Note that your code does not compile because\textsl and \thetitle are undefined. – esdd Sep 17 '16 at 22:38
• @esdd \thetitle is not a problem. Note that the OP's class is not the standard book. – cfr Sep 17 '16 at 22:54
• Sorry, guys. Changed the MWE. – Ram Iyer Sep 18 '16 at 14:49

EDIT: This is an answer to the revised question. For the original version, see below.

Memoir offers similar functionality to that provided by titlesec (p. 339). If you use both, you have two things trying to control the format of sectional divisions, the contents of marks and the format of headers. If you want to use titlesec, use titleps to configure headers, footers and marks. If you want to use Memoir, don't load titlesec. Instead, use the facilities provided by Memoir.

Your \titleformat for \section is essentially equivalent to

\setsecheadstyle{\large\bfseries}


because the indentation between label and title is irrelevant if you aren't numbering the sections or printing the label anyway and block is pretty much the default look. So the only thing the \titleformat command is really doing is substituting \large for \Large. Fair enough, but you can easily do that using Memoir's \setsecheadstyle, as explained on p. 95. This section also explains how to configure the other sectional divisions, including adjustments to vertical spacing before and after the heading, indentation and so on. If you use these commands, then your customisation of marks and headers using Memoir will be effective in your document. Otherwise, you need to redo that code to take account of the changes made by titlesec.

\documentclass[a5paper,11pt,twoside,onecolumn,openright,extrafontsizes]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}
\usepackage[tracking=true,letterspace=50]{microtype}
% setspace is emulated - see p. 339 - so loading the package is blocked, but the emulation is not complete
\makeatletter
\newcommand{\setstretch}[1]{% from setspace.sty
\def\baselinestretch{#1}%
\@currsize
}
\makeatother
% see p. 339 of Memoir's docs re. titlesec - you can use it, but you'll lose Memoir's equivalent functionality which cooperates with headers, marks etc.
\usepackage{lipsum} % to generate Lorem Ipsum

% \parskip is 0 by default
\setstretch{1.15}% see setspace.sty for details
\SetTracking{encoding=*,shape=sc}{100}

% tracking adjustments for small caps
\DeclareMicrotypeSet*[tracking]{alegreyasc}
{font = */AlegreyaSC-TLF/*/*/*}

% defining the title and the author
\title{My Title}

% chapter title manipulation
\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}

\setcounter{secnumdepth}{0}
% for normal pages
\makeatletter
}
\makepagestyle{mystyle}
\clearmark{section}
\makepsmarks{mystyle}{%
\createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
% for pages where chapters begin
\makepagestyle{plain}
\makeevenfoot{plain}{}{}{}
\makeoddfoot{plain}{}{}{}
\pagestyle{mystyle}

% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}
\pagestyle{mystyle}
% preface
\chapter{Chapter One}
\lipsum[1]

\section*{Section One}
\lipsum[2-10]

\end{document}


NOTE: This is an answer to the original question which has been rendered more-or-less meaningless by an update to the question. In particular, my answer assumed that Memoir's facilities were being used to format the page layout, including headers, marks and so on. But the updated question uses titlesec which obviously undermines these key assumptions. (Probably I should delete this answer for that reason ...?)

Currently, you do not ever apply the style you define. Adding \pagestyle{mystyle} will resolve this. You also need to add a title, of course, for it to be available in headers.

I altered your font settings for the headers and footers because \textls is not defined in your example. In doing this, I created a command \headerfont{} which can be configured in one place. Right now, the headers and footers use \scshape. To use small small-caps add

\headerfont{\small\scshape}


Here's the result

Complete code:

\documentclass[a5paper,11pt,twoside,onecolumn,openright]{memoir}
\usepackage{lipsum}
\makeatletter
}
\makepagestyle{mystyle}
\clearmark{section}
\makepsmarks{mystyle}{%
\createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
\pagestyle{mystyle}
\begin{document}
\title{My Book}
\author{Me}
\date{Now}
\maketitle
\chapter{Chapter title}
\lipsum[1]
\section*{section}
\lipsum[2-10]
\end{document}

• Thank you! I tried the code, and just your code gives the right output, but having the same in my document it gives me this. I've modified the MWE to be complete. I'm missing something obvious. And I'm going to feel embarrassed the moment someone points it out. I'm unable to figure it out, though. – Ram Iyer Sep 18 '16 at 14:40
• @ram7489 Sorry, but it is a totally different question now because you are using titlesec which you did not mention before. You are trying to control the header in 2 conflicting ways: with Memoir and with titlesec. Probably you should decide what you want to do and use titleps if you keep with titlesec or drop titlesec if you want to use Memoir for this. – cfr Sep 18 '16 at 17:00
• I'll keep with titlesec coz there are other places that use the package. I'll try out titleps for this purpose. – Ram Iyer Sep 18 '16 at 17:30
• @ram7489 Please see edit anyway. Memoir provides equivalent functionality according to the manual. If you use Memoir's facilities when you can, things are likely to work better overall. Otherwise, it is better to start with a standard class like book. – cfr Sep 18 '16 at 17:44
• @ram7489 It's OK. It can be hard to know what affects what. It is just that titlesec redefines a lot of stuff and has its own little world: titlesec + titletoc + titleps. Usually if you use a class like Memoir or one of the Koma classes, it is best not to use packages which also want to redefine basic document elements as they are just going to fight each other, as they did in this case. But probably somebody will provide you a titlesec/titleps answer if you hold on. You might want to highlight the use of titlesec in your question, though. – cfr Sep 18 '16 at 18:32