bibliografia biblatex por capítulo e titlesec

bibliografia biblatex por capítulo e titlesec

Esta é uma continuação da minha pergunta anteriorManeira correta de incluir capítulos não numerados em uma bibliografia por capítulo usando biblatex.

A solução proposta por Audrey falha quando utilizo o titlesecpacote para modificar os títulos dos capítulos. Aqui está um MWE:

\documentclass{book}


\usepackage{titlesec}           
\usepackage{titletoc}

\setcounter{tocdepth}{3}

\usepackage[style = phys,%
            sorting=none,%
            backend=biber,%
            style=numeric,%
            hyperref=auto,%
            backref = true,%
            refsection=chapter,%
%           citereset=chapter,%
            dateabbrev=false,%
            urldate=comp]{biblatex}

\usepackage{nameref}

\makeatletter
% Extend biblatex's \chapter patch to \chapter*
\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1}{}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1}{}{\blx@err@patch{\string\@makeschapterhead}}}}
% Save data for bibliography titles
\apptocmd\@makechapterhead
  {\csdef{subbib:\therefsection}{%
     Chapter~\ref{refsection:\therefsection} - \nameref{refsection:\therefsection}}}{}{}
\apptocmd\@makeschapterhead
  {\csdef{subbib:\therefsection}{%
     \nameref{refsection:\therefsection}}}{}{}

\makeatother

\defbibheading{subbibliography}{%
  \section*{References for \csuse{subbib:\therefsection}}}

\titleformat{\chapter}[hang]
{\bfseries \LARGE \bfseries }{ \thechapter}{0.75em}{}[\vspace{2ex}\titlerule]
\titlespacing*{\chapter}{0cm}{0cm}{0.6cm}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\chapter*{Introduction}
\begin{refsegment}
\cite{A01}
\end{refsegment}
\chapter{Chapter 1}

\cite{A01,B02}

\chapter*{Conclusion}
\begin{refsegment}
\cite{C03}
\end{refsegment}

\backmatter

\printbibheading[heading=bibintoc]
\bibbysection[heading = subbibliography]

\end{document}

O resultado na bibliografia é este:

insira a descrição da imagem aqui

Como você pode ver, as referências aos capítulos desapareceram. Não há sequer pontos de interrogação. Acho que isso significa que a \csuse{subbib:\therefsection}}parte da solução de Audrey não aponta para nada depois de inserir a redefinição do formato do capítulo usando titlesec's \titleformat.

Além disso, colocar a \titleformat{...}redefinição dos títulos dos capítulos antes que o patch do biblatex termine no seguinte erro argument of \csdef has an extra }.

Alguma idéia de como contornar isso?

Responder1

Anexar as macros do capítulo é provavelmente o problema. Você pode mover as definições de sequência de controle para os títulos logo após biblatexo patch precedente.

\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\pretocmd\@makechapterhead
       {#1\csdef{subbib:\therefsection}{Chapter~\ref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makechapterhead}}%
     \pretocmd\@makeschapterhead
       {#1\csdef{subbib:\therefsection}{\nameref{refsection:\therefsection}}}
       {}{\blx@err@patch{\string\@makeschapterhead}}}}

informação relacionada