我有一份大文档,它由几个部分组成,每个部分又包含几个章节。文档开头有一个公共目录,只显示各个部分,然后每个部分都有自己的目录。当我将参考书目与 放在一起时\printbibliography
,参考书目会作为一章放在一起,因此它会显示在最后一部分的目录中,我希望将它放在第一个目录中,包含所有部分。
这是我的 MWE,正如我所说,它展示了最后一部分的参考书目:
\documentclass[toc=bibliography]{scrbook}
\usepackage[backend=biber,style=ieee,bibliography=totoc,dashed=false]{biblatex}
\urlstyle{same}
\addbibresource{bibliography.bib}
\usepackage[final]{pdfpages}
\usepackage{xpatch}
\usepackage{xparse}
% Partial TOC
\makeatletter
\newif\ifuseparttoc
\newcommand*{\parttoc}[1][\thepart]{% new command to generate and show a chapter toc
\useparttoctrue% switch on part-toc-entries
\edef\ext@parttoc{tcp#1}% extension of the part-toc-file, e.g., tcpI
\DeclareNewTOC[
listname=Table of Contents,
%unset=onecolumn% if the part toc should use twocolumn
]{\ext@parttoc}% declare a new toc file
\begingroup
\value{tocdepth}=\paragraphtocdepth% we want entries down to chapter
\listoftoc{\ext@parttoc}% show the toc with header
\endgroup
}
\xapptocmd\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator
\ifuseparttoc% if part toc entries should be generated
\expandafter\tocbasic@addxcontentsline\expandafter{\ext@parttoc}{#1}{#2}{#3}% do it
\fi
}{}{}
\xpretocmd\part{\useparttocfalse}{}{}% entries in part toc are automatically switched off at start of \part
\newif\ifusechaptertoc% Switch to tell \addtocentrydefault to not only make entries to the toc-file but also to the current section-toc-file
\xapptocmd\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator
\ifusechaptertoc% if chapter toc entries should be generated
\Ifstr{#1}{chapter}{}
{\expandafter\tocbasic@addxcontentsline\expandafter{\ext@chaptoc}{#1}{#2}{#3}}% do it
\fi
}{}{}
\xpretocmd\part{\usechaptertocfalse}{}{}% entries in part toc are automatically switched off at start of \part
\makeatother
\setcounter{tocdepth}{\partnumdepth}% depth of TOC
\begin{document}
\tableofcontents
\part{PART 1}
\parttoc
\chapter{smth}
something on new chapter \autocite{Ambit2019-rj}
\part{PART 2}
\parttoc
\chapter{somethung}
New chapter.
\printbibliography
\end{document}
答案1
biblatex
的默认参考书目标题通常以\chapter
/\section
为基础。如果您希望参考书目成为,\part
则可能必须使用 重新定义标题定义\defbibheading
。
在 KOMA-Script 类中,您可能希望使用\addpart
带有 ToC 条目的未编号部分。
\documentclass[toc=bibliography]{scrbook}
\usepackage[backend=biber,style=ieee,bibliography=totoc,dashed=false]{biblatex}
\urlstyle{same}
\usepackage{xpatch}
\defbibheading{bibliography}[\bibname]{\addpart{#1}}
% Partial TOC
\makeatletter
\newif\ifuseparttoc
\newcommand*{\parttoc}[1][\thepart]{% new command to generate and show a chapter toc
\useparttoctrue% switch on part-toc-entries
\edef\ext@parttoc{tcp#1}% extension of the part-toc-file, e.g., tcpI
\DeclareNewTOC[
listname=Table of Contents,
%unset=onecolumn% if the part toc should use twocolumn
]{\ext@parttoc}% declare a new toc file
\begingroup
\value{tocdepth}=\paragraphtocdepth% we want entries down to chapter
\listoftoc{\ext@parttoc}% show the toc with header
\endgroup
}
\xapptocmd\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator
\ifuseparttoc% if part toc entries should be generated
\expandafter\tocbasic@addxcontentsline\expandafter{\ext@parttoc}{#1}{#2}{#3}% do it
\fi
}{}{}
\xpretocmd\part{\useparttocfalse}{}{}% entries in part toc are automatically switched off at start of \part
\newif\ifusechaptertoc% Switch to tell \addtocentrydefault to not only make entries to the toc-file but also to the current section-toc-file
\xapptocmd\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator
\ifusechaptertoc% if chapter toc entries should be generated
\Ifstr{#1}{chapter}{}
{\expandafter\tocbasic@addxcontentsline\expandafter{\ext@chaptoc}{#1}{#2}{#3}}% do it
\fi
}{}{}
\xpretocmd\part{\usechaptertocfalse}{}{}% entries in part toc are automatically switched off at start of \part
\makeatother
\setcounter{tocdepth}{\partnumdepth}% depth of TOC
\addbibresource{biblatex-examples.bib}
\begin{document}
\tableofcontents
\part{PART 1}
\parttoc
\chapter{smth}
something on new chapter \autocite{sigfridsson}
\part{PART 2}
\parttoc
\chapter{somethung}
New chapter.
\printbibliography
\end{document}