1

I am trying to customize a template initially designed for novels. I have added to it sections and I would like to see, as headers, on the left page, the title of the book, at the center of the page, and, on the right page and at the center of the page, the title of the chapter. I'd like especially to see all the subsections numbered in my toc. How could I do that?

This is my mwe:

\documentclass[smalldemyvopaper,10pt,twoside,onecolumn,openright,extrafontsizes]{memoir}
\usepackage[utf8]{inputenc}
\usepackage [frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}


\usepackage{lipsum}

% PACKAGE DEFINITION
% typographical packages
\usepackage{microtype} % for micro-typographical adjustments
\usepackage{setspace} % for line spacing
\usepackage{lettrine} % for drop caps and awesome chapter beginnings
\usepackage{titlesec} % for manipulation of chapter titles

% for placeholder text
\usepackage{lipsum} % to generate Lorem Ipsum




% other
\usepackage{calc}
\usepackage{hologo}
\usepackage[hidelinks]{hyperref}
%\usepackage{showframe}
% PHYSICAL DOCUMENT SETUP
% media settings
\setstocksize{8.5in}{5.675in}
\settrimmedsize{8.5in}{5.5in}{*}
\setbinding{0.175in}
\setlrmarginsandblock{0.611in}{1.222in}{*}
\setulmarginsandblock{0.722in}{1.545in}{*}

% defining the title and the author
%\title{\LaTeX{} ePub Template}
%\title{\textsc{How I Started to Love {\fontfamily{cmr}\selectfont\LaTeX{}}}}
\title{A title}

\author{My name}
\newcommand{\ISBN}{0-000-00000-2}
\newcommand{\press}{Nom de l'éditeur}

% custom second title page
\makeatletter
\newcommand*\halftitlepage{\begingroup % Misericords, T&H p 153
  \setlength\drop{0.1\textheight}
  \begin{center}
  \vspace*{\drop}
  \rule{\textwidth}{0in}\par
  {\Large\textsc\thetitle\par}
  \rule{\textwidth}{0in}\par
  \vfill
  \end{center}
\endgroup}
\makeatother

% custom title page
\thispagestyle{empty}
\makeatletter
\newlength\drop
\newcommand*\titleM{\begingroup % Misericords, T&H p 153
  \setlength\drop{0.15\textheight}
  \begin{center}
  \vspace*{\drop}
  \rule{\textwidth}{0in}\par
  {\HUGE\textsc\thetitle\par}
  \rule{\textwidth}{0in}\par
  {\Large\textit\theauthor\par}
  \vfill
  {\Large\scshape\press}
  \end{center}
\endgroup}
\makeatother

% chapter title manipulation
% padding with zero
%\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}
% chapter title display
\titleformat
{\chapter}
[display]
{\normalfont\scshape\LARGE}
{\huge\thechapter\centering}
{0pt}
{\vspace{18pt}\centering}[\vspace{22pt}]

% typographical settings for the body text
\setlength{\parskip}{0em}
\linespread{1.09}

% HEADER AND FOOTER MANIPULATION
  % for normal pages
  \nouppercaseheads
  \headsep = 0.16in
  \makepagestyle{mystyle} 
  \setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
  \makerunningwidth{mystyle}{\headwidth}
  \makeevenhead{mystyle}{}{\textsf{\scriptsize\scshape\thetitle}}{}
  \makeoddhead{mystyle}{}{\textsf{\scriptsize\scshape\leftmark}}{}
  \makeevenfoot{mystyle}{}{\textsf{\scriptsize\thepage}}{}
  \makeoddfoot{mystyle}{}{\textsf{\scriptsize\thepage}}{}
  \makeatletter
  \makepsmarks{mystyle}{%
  \createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
  \makeatother
  % for pages where chapters begin
  \makepagestyle{plain}
  \makerunningwidth{plain}{\headwidth}
  \makeevenfoot{plain}{}{}{}
  \makeoddfoot{plain}{}{}{}
  \pagestyle{mystyle}
% END HEADER AND FOOTER MANIPULATION

% table of contents customisation
\renewcommand\contentsname{\normalfont\scshape Contents}
\renewcommand\cftchapterfont{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}
\renewcommand{\printtoctitle}{\centering\Huge}



% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}
\pagestyle{empty}
% the half title page
%\halftitlepage
\cleardoublepage
% the title page
\titleM

% begin front matter
\frontmatter
\pagestyle{mystyle}

\chapter{Introduction}

\mainmatter
\part{A part}

\chapter{A chapter}

\section{A section}
\lipsum



\end{document}
1
  • off-topic: (i) it is sufficient to load each package once (ii) lettrine is integrated to memoir, so it is no need to load again, (iii) memoir provide similar facilities as titlesec, so i would rather exploit memoir ... (iv) for your problem see 7.3.1 Example pagestyles on page 111 in memoir manual.
    – Zarko
    Commented Feb 24, 2019 at 16:57

1 Answer 1

1
  1. First of all I highly recommend to take into account @Zarko remarks as the problem you are facing is largely due to some incompatibilities between the memoir class and the titlesec package.

  2. The \thetitle command defined by the memoir class is redifined by the titlesec package so we need to store its value before. So we define a new macro with edef\TheTitle{\thetitle} and use it to set the headers

    \makeevenhead{mystyle}{}{\textsf{\scriptsize\scshape\TheTitle}}{}
    \makeoddhead{mystyle}{}{\textsf{\scriptsize\scshape\leftmark}}{}
    
  3. To number the subsections and see them in the toc:

%

 \maxsecnumdepth{subsection}
 \maxtocdepth{subsection}

The complete code

\documentclass[smalldemyvopaper, 10pt, twoside, onecolumn, openright, extrafontsizes]{memoir}
\usepackage[utf8]{inputenc}
\usepackage [frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}

\usepackage{lipsum}

% PACKAGE DEFINITION
% typographical packages
\usepackage{microtype} % for micro-typographical adjustments
\usepackage{setspace} % for line spacing
\usepackage{lettrine} % for drop caps and awesome chapter beginnings
\usepackage{titlesec} % for manipulation of chapter titles

% for placeholder text
\usepackage{lipsum} % to generate Lorem Ipsum

% other
\usepackage{calc}
\usepackage{hologo}
\usepackage[hidelinks]{hyperref}
%\usepackage{showframe}
% PHYSICAL DOCUMENT SETUP
% media settings
\setstocksize{8.5in}{5.675in}
\settrimmedsize{8.5in}{5.5in}{*}
\setbinding{0.175in}
\setlrmarginsandblock{0.611in}{1.222in}{*}
\setulmarginsandblock{0.722in}{1.545in}{*}

% defining the title and the author
%\title{\LaTeX{} ePub Template}
%\title{\textsc{How I Started to Love {\fontfamily{cmr}\selectfont\LaTeX{}}}}
\title{The book title}

\author{My name}
\newcommand{\ISBN}{0-000-00000-2}
\newcommand{\press}{Nom de l'éditeur}

\edef\TheTitle{\thetitle}

% custom second title page
\makeatletter
\newcommand*\halftitlepage{\begingroup % Misericords, T&H p 153
  \setlength\drop{0.1\textheight}
  \begin{center}
  \vspace*{\drop}
  \rule{\textwidth}{0in}\par
  {\Large\textsc\thetitle\par}
  \rule{\textwidth}{0in}\par
  \vfill
  \end{center}
\endgroup}
\makeatother

% custom title page
\thispagestyle{empty}
\makeatletter
\newlength\drop
\newcommand*\titleM{\begingroup % Misericords, T&H p 153
  \setlength\drop{0.15\textheight}
  \begin{center}
  \vspace*{\drop}
  \rule{\textwidth}{0in}\par
  {\HUGE\textsc\thetitle\par}
  \rule{\textwidth}{0in}\par
  {\Large\textit\theauthor\par}
  \vfill
  {\Large\scshape\press}
  \end{center}
\endgroup}
\makeatother

% chapter title manipulation
% padding with zero
%\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}
% chapter title display
\titleformat
{\chapter}
[display]
{\normalfont\scshape\LARGE}
{\huge\thechapter\centering}
{0pt}
{\vspace{18pt}\centering}[\vspace{22pt}]

% typographical settings for the body text
\setlength{\parskip}{0em}
\linespread{1.09}

% HEADER AND FOOTER MANIPULATION
  % for normal pages
  \nouppercaseheads
  \headsep = 0.16in
  \makepagestyle{mystyle} 
  \setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
  \makerunningwidth{mystyle}{\headwidth}
  \makeevenhead{mystyle}{}{\textsf{\scriptsize\scshape\TheTitle}}{}
  \makeoddhead{mystyle}{}{\textsf{\scriptsize\scshape\leftmark}}{}
  \makeevenfoot{mystyle}{}{\textsf{\scriptsize\thepage}}{}
  \makeoddfoot{mystyle}{}{\textsf{\scriptsize\thepage}}{}
  \makeatletter
  \makepsmarks{mystyle}{%
  \createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
  \makeatother
  % for pages where chapters begin
  \makepagestyle{plain}
  \makerunningwidth{plain}{\headwidth}
  \makeevenfoot{plain}{}{}{}
  \makeoddfoot{plain}{}{}{}
  \pagestyle{mystyle}
% END HEADER AND FOOTER MANIPULATION

% table of contents customisation
\renewcommand\contentsname{\normalfont\scshape Contents}
\renewcommand\cftchapterfont{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}
\renewcommand{\printtoctitle}{\centering\Huge}

% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}

\pagestyle{empty}
% the half title page
%\halftitlepage
\cleardoublepage
% the title page
\titleM

% begin front matter
\frontmatter
\pagestyle{mystyle}

\maxtocdepth{subsection}
\maxsecnumdepth{subsection}

\tableofcontents

\chapter{Introduction}

\mainmatter
\part{A part}

\chapter{A chapter}

\section{A section}

\subsection{A subsection}

\lipsum

\end{document}

enter image description here

enter image description here

7
  • It works, but for section only, not for subsections nor subsubsections. How could I dot that?
    – domi
    Commented Feb 26, 2019 at 13:17
  • @domi What do you want in the headers chapters, sections, subsections, subsubsections ,... ??? Commented Feb 26, 2019 at 16:19
  • On the left, the title of the book, on the right, the title of the chapter. But, I'd like especially to see all the subsections in my toc.
    – domi
    Commented Feb 26, 2019 at 16:26
  • 1
    @domi It seams to me that your question has changed so maybe you should update your post. Commented Feb 26, 2019 at 16:46
  • 1
    @domi see updates Commented Feb 27, 2019 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .