如何按出版年份细分和分组参考书目?

如何按出版年份细分和分组参考书目?

考虑一下这个 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}

MWE 首页截图

相关内容