biblatex 每章參考書目和標題sec

biblatex 每章參考書目和標題sec

這是我之前問題的後續使用 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}

參考書目中的結果是這樣的:

在此輸入影像描述

正如您所看到的,章節的引用已經消失。連問號都沒有。我想這意味著在我使用's\csuse{subbib:\therefsection}}插入章節格式的重新定義後,奧黛麗的解決方案部分沒有指向任何內容。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}}}}

相關內容