7

My question is how I can group the bibliographic records using biblatex on per-year-basis. I have tried the approach

\newcounter{mycounter}
\setcounter{mycounter}{2013}
\defbibcheck{intheyear}{
  \iffieldint{year}
  {\ifnum \thefield{year} = \themycounter
    {\skipentry}
    {} }
  {\skipentry}}

and then using the command

\printbibliography[title=2013
,heading=subbibliography
,type=article
,check = intheyear
]

changing the counter value manually, but this yields a result only if the command is called once. In the second calling of \printbibliography, pdflatex announces

! Incomplete \ifnum; all text was ignored after line <i>xx</i>.
<inserted text> 
                \fi 
<*> \input lpublications.tex

! Emergency stop.
<*> \input lpublications.tex

What I want to achieve is that I will have structure of references as

2013

Braham, A., Edrich, B. ...

Ecilie, C., Ietrich, D. ...

2012

.....

If this was done automatically according to entries in .bib file. It would be fine. I have really no idea how to do that.

  • You might be able to use biblatex's concept of categories together with the \bibbycategory. – Andrew Swann Jun 27 '13 at 16:14
  • \ifnum requires \fi. You may use for example \ifnumequal{\thefield{year}}{\themycounter} – Oleg Domanov Jun 28 '13 at 6:26
5

In the code below the first \printbibliography composes a list of years which is then used in a loop to print other bibliographies. The sorting option is used to sort the list (thanks to user32884 for suggesting this).

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{a1,
 author = {Author},
 title = {Title},
 journaltitle = {Superjournal},
 year = {2003},
}
@ARTICLE{a2,
 author = {Buthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2000},
}
@ARTICLE{a3,
 author = {Duthor},
 title = {Ztitle},
 journaltitle = {Superjournal},
 year = {2002},
}
\end{filecontents*}
\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}

\usepackage[style=authoryear,]{biblatex}
\addbibresource{\jobname.bib}

\newcounter{mycounter}
\defbibcheck{intheyear}{
  \iffieldint{year}
    {\ifnumequal{\thefield{year}}{\themycounter}
      {}
      {\skipentry}}
    {\skipentry}}
\defbibenvironment{counting}
  {}
  {}
  {\xifinlist{\thefield{year}}{\yearlist}
    {}
    {\listxadd{\yearlist}{\thefield{year}}}}

\begin{document}
\nocite{*}
\gdef\yearlist{}%
\begingroup%
  \makeatletter%
  \def\blx@driver#1{}%
  \printbibliography[env=counting,heading=none,type=article,sorting=ydnt]%
  \makeatother%
\endgroup%
\renewcommand*{\do}[1]{%
  \setcounter{mycounter}{#1}%
  \printbibliography[title=#1
  ,heading=subbibliography
  ,type=article
  ,check = intheyear
  ]}
\dolistloop{\yearlist}
\end{document} 

enter image description here

| improve this answer | |
  • Thnak you, this helped. I just had to remove double braces {{ }} at my year fields of the bib file to work. I also could solve the sorting problem by declaring my sorting scheme by \DeclareSortingScheme{dyear}{ \sort[direction=descending]{\field{year}} \sort{\field{author}} \sort{ \field{journal} \field{title} } } and modifying the group \begingroup% \makeatletter% \def\blx@driver#1{}% \printbibliography[env=counting,heading=none,type=article,sorting=dyear]% \makeatother% \endgroup% – Ikarie XB 1 Jun 28 '13 at 12:34
  • Oh, yes, a simple solution, it didn't come to my mind. There is actually a standard sorting scheme ydnt which can be used for that. I added it to the answer. I also removed \AtEveryBibitem while modifying a little the counting environment. – Oleg Domanov Jun 28 '13 at 13:04
  • This works great for me, except the years of my publications are now sorted in ascending instead of descending order. I copied and pasted the code without modification. Not sure what went wrong. – Xiaoyu Lu Feb 25 '19 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.