![如何按出版年份细分和分组参考书目?](https://linux22.com/image/384948/%E5%A6%82%E4%BD%95%E6%8C%89%E5%87%BA%E7%89%88%E5%B9%B4%E4%BB%BD%E7%BB%86%E5%88%86%E5%92%8C%E5%88%86%E7%BB%84%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%EF%BC%9F.png)
考虑一下这个 MWE
\documentclass{article}
\usepackage[style=archaeologie]{biblatex}
\addbibresource{biblatex-examples.bib}
\newcounter{BIBnumberYEARcount}
\setcounter{BIBnumberYEARcount}{1}
\defbibenvironment{BIBnumberYEAR}
{\list
{\theBIBnumberYEARcount\thinspace\textbar\stepcounter{BIBnumberYEARcount}\relax}
{\setlength{\labelwidth}{\labwidthsameline}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{-\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{##1\hss}}}
{\endlist}
{\item}
\DeclareSortingTemplate{dnymdt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=ascending]{
\field{sortyear}
\field{year}
\literal{9999}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{99}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\field{pubstate}
}
\sort{
\field{sortshorthand}
\field{shorthand}
\field{sortname}
\field{author}
\field{editor}
\field{translator}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{9999}
}
}
\begin{document}
{\begin{refcontext}[sorting=dnymdt]
\nocite{*}
\printbibliography[env=BIBnumberYEAR,
heading = none]
\end{refcontext}}
\end{document}
我希望将出版年份打印在该年出版的第一条(多条)条目的上方一行。只有当年份与前一年不同时,才应将其打印在单独的行中。
例如
2004
1| A.作者,... 2004
2| B. Buther,.... 2004年
2005
3| C.作者,....2005
2006
4| A.作者,....2006年
5| D.杜瑟,....2006年
答案1
在枚举标签“上方”添加内容有点麻烦。一旦可以实现,实际代码只需使用\iffieldequals
和\savefield
(类似于dashed
选项的实现方式或引用样式中的压缩-comp
)。
\documentclass{article}
\usepackage[style=archaeologie]{biblatex}
\addbibresource{biblatex-examples.bib}
\newcounter{BIBnumberYEARcount}
\setcounter{BIBnumberYEARcount}{1}
\makeatletter
\defbibenvironment{BIBnumberYEAR}
{\list
{\iffieldequals{year}{\lcbbx@lastyear}
{}
{\makebox[0pt][l]{%
\parbox[b]{20pt}{\leavevmode
\printfield{year}\\}}%
\savefield{year}{\lcbbx@lastyear}}%
\theBIBnumberYEARcount\thinspace\textbar
\stepcounter{BIBnumberYEARcount}}
{\setlength{\labelwidth}{\labwidthsameline}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{-\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{##1\hss}}}
{\endlist}
{\item}
\makeatother
\DeclareSortingTemplate{dnymdt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=ascending]{
\field{sortyear}
\field{year}
\literal{9999}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{99}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\field{pubstate}
}
\sort{
\field{sortshorthand}
\field{shorthand}
\field{sortname}
\field{author}
\field{editor}
\field{translator}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort[direction=ascending]{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{9999}
}
}
\begin{document}
{\begin{refcontext}[sorting=dnymdt]
\nocite{*}
\printbibliography[env=BIBnumberYEAR,
heading = none]
\end{refcontext}}
\end{document}