# Titlesec: \ifthesection command issue with biblatex refsegment

I'm using titlesec to set my page style and biblatex to print a cumulative bibliography subdivided by chapter. There seems to be some problem with the \ifthesection command because in the following MWE the headers in the odd pages of the bibliography should say, for instance, "References Chapter 1" but I'me getting "Bibliography" instead.

\documentclass{book}

\usepackage[pagestyles]{titlesec}
\newpagestyle{main}[\scshape]{%
[\thepage][][\chaptertitlename\space\thechapter. \chaptertitle]
{\ifthesection{\thesection\space\,\sectiontitle}
{\chaptertitlename\space\thechapter. \chaptertitle}}{}{\thepage}
}
\newpagestyle{special}[\scshape]{%
[\thepage][][\chaptertitle]
{\ifthesection{\sectiontitle}{\chaptertitle}}{}{\thepage}
}

\usepackage{etoolbox}
\appto{\mainmatter}{\pagestyle{main}}
\appto{\backmatter}{\pagestyle{special}}

\usepackage[refsegment=chapter,backend=bibtex]{biblatex}
\ref*{refsegment:\therefsection\therefsegment}]{%
\setcounter{secnumdepth}{0}%
\section{#1}}

\usepackage{lipsum}
\usepackage{hyperref}

\begin{document}

\mainmatter
\chapter{Foo}
\lipsum
\section{Baz}
\lipsum
\nocite{*}
\chapter{Bar}
\nocite{*}

\backmatter

\end{document}


One workaround is to define a new pagestyle that doesn't use the \ifthesection command and do the following in the preamble:

\newpagestyle{bibatend}[\scshape]{%
[\thepage][][\chaptertitle]
{\sectiontitle}{}{\thepage}
}
\appto{\backmatter}{\pagestyle{bibatend}}


However I would like to use the pagestyle special in the backmatter (because I have also an index that doesn't have sections and therefore the heading should always be the chapter title). So my question is: why is the \ifthesection command not working properly?

• titlesec isn't compatible with refsegment=chapter. The option setting has biblatex patch low-level chapter commands. titlesec ignores these; it redefines the user-level \chapter command. – Audrey Jun 3 '13 at 1:01
• @Audrey Thanks, I didn't know that. Can you post your comment as an answer? – petobens Jun 3 '13 at 1:16

The titlesec package isn't compatible with any of the biblatex refsegment or refsection option settings. biblatex patches the low-level section/chapter commands. titlesec ignores all of these changes because it redefines the user-level section/chapter commands.
To workaround this you should omit the refsegment=chapter setting and create reference segments manually with:
\chapter{<title>}