
Это продолжение моего предыдущего вопроса.Правильный способ включения ненумерованных глав в поглавную библиографию с использованием biblatex.
Решение, предложенное Одри, ломается, когда я использую titlesec
пакет для изменения заголовков глав. Вот 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}
Результат в библиографии таков:
Как вы видите, ссылки на главы исчезли. Даже нет никаких вопросительных знаков. Полагаю, это означает, что часть \csuse{subbib:\therefsection}}
решения Одри указывает в никуда после того, как я вставил переопределение формата главы с помощью titlesec
's \titleformat
.
Кроме того, размещение \titleformat{...}
переопределения заголовков глав перед патчем biblatex приводит к следующей ошибке argument of \csdef has an extra }
.
Есть идеи, как это обойти?
решение1
Проблема, скорее всего, в добавлении макросов глав. Вы можете переместить определения управляющей последовательности для заголовков сразу после biblatex
's prepending patch.
\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}}}}