这是我上一个问题的后续使用 biblatex 在每个章节的参考书目中包含未编号章节的正确方法。
titlesec
当我使用该包修改章节标题时,Audrey 提出的解决方案失效了。这是 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}
书目中的结果是这样的:
如您所见,对章节的引用已消失。甚至没有任何问号。我猜这意味着在我使用's\csuse{subbib:\therefsection}}
插入章节格式的重新定义后,Audrey 的解决方案部分指向了空无一物。titlesec
\titleformat
此外,\titleformat{...}
在 biblatex 补丁之前重新定义章节标题会导致以下错误argument of \csdef has an extra }
。
有什么想法可以解决这个问题吗?
答案1
附加章节宏可能是问题所在。您可以将标题的控制序列定义移动到biblatex
附加补丁之后。
\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}}}}