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]{%
\headrule
\sethead
[\thepage][][\chaptertitlename\space\thechapter. \chaptertitle]
{\ifthesection{\thesection\space\,\sectiontitle}
{\chaptertitlename\space\thechapter. \chaptertitle}}{}{\thepage}
}
\newpagestyle{special}[\scshape]{%
\headrule
\sethead
[\thepage][][\chaptertitle]
{\ifthesection{\sectiontitle}{\chaptertitle}}{}{\thepage}
}
\usepackage{etoolbox}
\appto{\mainmatter}{\pagestyle{main}}
\appto{\backmatter}{\pagestyle{special}}
\usepackage[refsegment=chapter,backend=bibtex]{biblatex}
\defbibheading{bibbook}[\bibname]{\chapter{#1}}
\defbibheading{subbib}[\refname\space\chaptername\space
\ref*{refsegment:\therefsection\therefsegment}]{%
\setcounter{secnumdepth}{0}%
\section{#1}}
\addbibresource{biblatex-examples.bib}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\mainmatter
\chapter{Foo}
\lipsum
\section{Baz}
\lipsum
\nocite{*}
\chapter{Bar}
\nocite{*}
\backmatter
\printbibheading[heading=bibbook]
\bibbysegment[heading=subbib]
\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]{%
\headrule
\sethead
[\thepage][][\chaptertitle]
{\sectiontitle}{}{\thepage}
}
\appto{\backmatter}{\pagestyle{bibatend}}
However I would like to use the pagestyle special in the backmatter (because I have also and 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?
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]{%
\headrule
\sethead
[\thepage][][\chaptertitlename\space\thechapter. \chaptertitle]
{\ifthesection{\thesection\space\,\sectiontitle}
{\chaptertitlename\space\thechapter. \chaptertitle}}{}{\thepage}
}
\newpagestyle{special}[\scshape]{%
\headrule
\sethead
[\thepage][][\chaptertitle]
{\ifthesection{\sectiontitle}{\chaptertitle}}{}{\thepage}
}
\usepackage{etoolbox}
\appto{\mainmatter}{\pagestyle{main}}
\appto{\backmatter}{\pagestyle{special}}
\usepackage[refsegment=chapter,backend=bibtex]{biblatex}
\defbibheading{bibbook}[\bibname]{\chapter{#1}}
\defbibheading{subbib}[\refname\space\chaptername\space
\ref*{refsegment:\therefsection\therefsegment}]{%
\setcounter{secnumdepth}{0}%
\section{#1}}
\addbibresource{biblatex-examples.bib}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\mainmatter
\chapter{Foo}
\lipsum
\section{Baz}
\lipsum
\nocite{*}
\chapter{Bar}
\nocite{*}
\backmatter
\printbibheading[heading=bibbook]
\bibbysegment[heading=subbib]
\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]{%
\headrule
\sethead
[\thepage][][\chaptertitle]
{\sectiontitle}{}{\thepage}
}
\appto{\backmatter}{\pagestyle{bibatend}}
However I would like to use the pagestyle special in the backmatter (because I have also and 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?
No comments:
Post a Comment