# Refsegment with numbered appendix problem

The following MWE prints a cumulative bibliography, subdivided by chapter, using biblatex. Since there is a reference in the appendix the corresponding heading in the bibliography should read "References Appendix A" but I'm getting "References Chapter A". If I change \chaptername for \appendixname in the bibheading definition I get chapters headings in the bibliography as "References Appendix 1" which is also incorrect.

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

\usepackage{hyperref}
\begin{document}

\mainmatter
\chapter{Bar}
\nocite{cms}

\appendix
\chapter{Fooo}
\nocite{glashow}

\backmatter

\end{document}


Edit: I tried using \chaptertitlename instead of \chaptername but that also didn't work.

-

You can hook code into \appendix to save the current reference segment number:

\newcounter{lastmainsegment}
\setcounter{lastmainsegment}{1000}
\appto{\appendix}{\setcounter{lastmainsegment}{\value{refsegment}}}


\ifnumgreater{\therefsegment}{\value{lastmainsegment}}{\appendixname}{\chaptername}

@petobens Initialize the new counter with a large value. For example: \setcounter{lastmainsegment}{1000}. –  Audrey Jun 5 at 21:02