# How to use biblatex with a nested bibliography/toc and the proper definined pagestyle

I used the solution given here How to use biblatex to have a nested bibliography with a nested toc? to implemented the nested bibliography/toc using biblatex, however the created pages have their own headers/footers even if the last selected pagestyle was user-configured with titlesec. I suspected biblatex defines its own pagestyle when creating bibliographies pages but I don't know how to tweak it in order to use my defined pagestyle. Any clues? Reading the titleeps documentation it says:

Therefore, using directly the marking commands is discouraged (seetitlesec.pdf), but if you needthem, you may write:

\chapter*{My Chapter}
\chaptermark{My Chapter}


I tried this code then unsuccessfully:

% Bibliography
\chapter*{Bibliography}
\chaptermark{Bibliography}


My own defined pagestyle code is:

\usepackage[pagestyles]{titlesec}
\newpagestyle{thesis}[\small]{
[\chaptertitle]%   even-center
[]%                 even-right
{}%                 odd-left
{\sectiontitle}%   odd-center
{\thepage}%        odd-right
}


According to the titlesec documentation (§4.2) one is not supposed to play around with starred sectioning commands, \addcontentsline and \mark... commands. Instead the documentation suggests locally modifying the secnumdepth counter to achieve the same effect.

The examples in the documentation define an environment for that, but it appears to be easier to use to have a dedicated command \addchap that generates the desired section heading. \addchap could be defined as follows

\newcommand*{\addchap}{\@dblarg\addchap@i}
\begingroup
\c@secnumdepth\m@ne
\chapter[#1]{#2}%
\endgroup
}


Essentially this definition locally changes the counter secnumdepth (that is responsible for the section numbering) to -1 (with \c@secnumdepth\m@ne), which causes the command to produce an unnumbered sectioning. The setup with the auxiliary command and \@dblarg is just to handle the optional argument correctly.

In the code below this definition is done automatically with \MkAddSectioningCMD to avoid having to repeat the same construction several times.

So we change the bibintoc and subbibintoc heading definition to use a local version of \addchap and \addsec that suppress chapter and section numbers by changing secnumdepth.

\documentclass[british]{book}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{lipsum}

\usepackage[pagestyles]{titlesec}
\newpagestyle{thesis}[\small]{%
[\chaptertitle]%   even-center
[]%                 even-right
{}%                 odd-left
{\sectiontitle}%   odd-center
{\thepage}%        odd-right
}

\makeatletter
\expandafter\newcommand\expandafter*\expandafter{\csname #1\endcsname}{%
\expandafter\@dblarg\expandafter{\csname #1@i\endcsname}}%
\expandafter\newcommand\expandafter*\expandafter{\csname #1@i\endcsname}[2][]{%
\begingroup
\c@secnumdepth\m@ne
#2[##1]{##2}%
\endgroup}%
}
\makeatother

\begin{document}
\pagestyle{thesis}
\tableofcontents

\chapter{Lorem}
\section{Florem}
Lorem \autocite{sigfridsson,worman,geer}
\lipsum[1-12]
\nocite{*}

\end{document}


If you prefer LaTeX3 the definition of \addchap can be changed to

\NewDocumentCommand{\addchap}{om}{%
\begingroup
\c@secnumdepth\m@ne
\IfNoValueTF{#1}
{\chapter{#2}}
{\chapter[#1]{#2}}%
\endgroup}


in which case we'd change \MkAddSectioningCMD to

\makeatletter
\NewDocumentCommand{#1}{om}{%
\begingroup
\c@secnumdepth\m@ne
\IfNoValueTF{##1}
{#2{##2}}
{#2[##1]{##2}}%
\endgroup}%
}
\makeatother


and use it as

\MkAddSectioningCMD{\addchap}{\chapter}


(You will need a current version of the LaTeX kernel when you want to use this without \usepackage{xparse}.)

• Can you elaborate more the way you defined the addchap and addsec commands? they are different from the documentation where they use \newenviroment etc.
– Luca
May 13, 2021 at 7:55
• Also I would like to have a "tweaked starred chapter" named bibliography and then the subsections with the article references, book references etc, all in the tocs and with my own defined pagestyle (odd pages with chapter name (bibliography) and even pages with sections names (articles, book, etc).
– Luca
May 13, 2021 at 7:56
• \the\value{secnumdepth} is for debugging?
– Luca
May 13, 2021 at 7:57
• @Luca Have a look at the edit. Yes, the \the\value{secnumdepth} was just for testing. I have removed it. May 13, 2021 at 9:27
• Thank you very much for the code, it seems to work as I expected, the toc, the headers and the bibliography is like I wanted. Just a note: the way you defined the new commands: I'm a simply user, I have never fixed latex this way (it seems a low level), so I would to debate about the simpler "definition" you provided: I am not able to understand what it is actually doing, sadly. Thank you very much again
– Luca
May 13, 2021 at 12:46