我想在书目排版结束后执行某些命令。类似于\bibsetup
但旨在用于书目末尾的命令
\documentclass{article}
\usepackage[backend=biber, citecounter=true]{biblatex}
\bibliography{biblatex-examples.bib}
\begin{document}
Basmah
\cite{aksin}
\printbibliography[heading=subbibliography]
\end{document}
澄清一下。假设我们想在每章末尾提供一个表格来报告条目
\documentclass{book}
\usepackage[x11names]{xcolor}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage[backend=biber, citecounter=true, sorting=ydnt, refsection=chapter]{biblatex}
\bibliography{biblatex-examples.bib}
\newcounter{articlenum}
\newcounter{booknum}
\newcounter{lasttwoyears}
\newcounter{lastfiveyears}
\AtEveryBibitem{
%
\ifentrytype{article}{%
\stepcounter{articlenum}%
}{}%
%
\ifentrytype{book}{%
\stepcounter{booknum}%
}{}%
}
\AtEveryBibitem{%
%
\iffieldint{year}%
{%
\ifnumless{\thefield{year}}{2004}%
{%
\ifnumless{\thefield{year}}{2001}%
{}%
{\stepcounter{lastfiveyears}}%
}%
{\stepcounter{lasttwoyears}}%
}%
}
\begin{document}
\chapter{Chapter 1}
Basmah
\cite{jcg,sarfraz,kullback:related,matuz:doody,doody}
\printbibliography[heading=subbibliography]
\noindent%
\begin{NiceTabular}[cell-space-limits=1.1mm]{@{}r >{\color{IndianRed1}}l@{}}
Number of articles is & \thearticlenum
\\
Number of books is & \thebooknum
\\
\addlinespace
Number of references in the last two years is & \thelasttwoyears
\\
Number of references in the last five years is & \thelastfiveyears
\\
\end{NiceTabular}
\setcounter{articlenum}{0}
\setcounter{booknum}{0}
\setcounter{lasttwoyears}{0}
\setcounter{lastfiveyears}{0}
\begingroup
\renewcommand{\cleardoublepage}{\newpage}
\chapter{Chapter 2}
\endgroup
Basmah
\cite{jcg,sarfraz,kullback:related,matuz:doody,doody}
\printbibliography[heading=subbibliography]
\noindent%
\begin{NiceTabular}[cell-space-limits=1.1mm]{@{}r >{\color{IndianRed1}}l@{}}
Number of articles is & \thearticlenum
\\
Number of books is & \thebooknum
\\
\addlinespace
Number of references in the last two years is & \thelasttwoyears
\\
Number of references in the last five years is & \thelastfiveyears
\\
\end{NiceTabular}
\end{document}
这意味着我们必须重置所有章节的计数器并手动输入表格
答案1
一般来说,我\bibsetup
主要将其用于布局设置(惩罚、法语/法语间距等)。这些设置都是本地的。因此,直接等同\bibsetup
于后参考书目没有什么意义,因为不需要重置这些布局设置,并且后面的文本不会因分组而受到影响。(请注意,有一个专门用于字体设置的钩子,称为\bibfont
。当然,同样的想法也适用于这里。)
为了引入更多与字体和布局设置无关的任意代码,我将使用\AtBeginBibliography
。同样,这个想法是中的代码\AtBeginBibliography
大多是本地的,或者至少不是那么成问题,以至于其影响需要在参考书目之后直接抵消,因此没有相应的\AtEndBibliography
钩子。(另请参阅https://github.com/plk/biblatex/issues/335以及相关讨论。
如果确实需要最终代码,目前最简单的方法是将其构建到\defbibenvironment
\defbibenvironment{<name>}{<begin code>}{<end code>}{<item code>}
通常,<end code>
只包含类似 的内容\endlist
,但您也可以添加更多代码。例如,取authoryear.bbx
的\defbibenvironment{bibliography}
\defbibenvironment{bibliography}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
您可以轻松地\endlist
在参考书目列表之后添加更多内容来执行代码。
但是,如果我正确理解了您的示例,那么还有一种稍微简单的方法。biblatex
允许您向参考书目添加前注和后注。这些前注/后注应包含可排版的内容,可用于在参考书目之前或之后直接添加几个单词。与\AtBeginBibliography
重置计数器一起使用
\documentclass{book}
\usepackage[x11names]{xcolor}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage[backend=biber, citecounter=true, sorting=ydnt, refsection=chapter]{biblatex}
\bibliography{biblatex-examples.bib}
\newcounter{articlenum}
\newcounter{booknum}
\newcounter{lasttwoyears}
\newcounter{lastfiveyears}
\AtBeginBibliography{%
\setcounter{articlenum}{0}%
\setcounter{booknum}{0}%
\setcounter{lasttwoyears}{0}%
\setcounter{lastfiveyears}{0}}
\AtEveryBibitem{%
\ifentrytype{article}
{\stepcounter{articlenum}}
{}%
\ifentrytype{book}
{\stepcounter{booknum}}
{}%
}
\AtEveryBibitem{%
\iffieldint{year}%
{\ifnumless{\thefield{year}}{2004}
{\ifnumless{\thefield{year}}{2001}
{}
{\stepcounter{lastfiveyears}}}
{\stepcounter{lasttwoyears}}}
{}%
}
\newcommand*{\statstable}{%
\begin{NiceTabular}[cell-space-limits=1.1mm]{@{}r >{\color{IndianRed1}}l@{}}
Number of articles is & \thearticlenum \\
Number of books is & \thebooknum \\\addlinespace
Number of references in the last two years is & \thelasttwoyears \\
Number of references in the last five years is & \thelastfiveyears \\
\end{NiceTabular}
}
\defbibnote{statstable}{\statstable}
\begin{document}
\chapter{Chapter 1}
Basmah
\cite{jcg,sarfraz,kullback:related,matuz:doody,doody}
\printbibliography[heading=subbibliography, postnote=statstable]
\begingroup
\renewcommand{\cleardoublepage}{\newpage}
\chapter{Chapter 2}
\endgroup
Basmah
\cite{jcg,sarfraz,kullback:related,matuz:doody,doody}
\printbibliography[heading=subbibliography, postnote=statstable]
\end{document}