With biblatex and Biber, how to create a loop on the years to print bibliography year after year in the following manner:
\section{2016}
\subsection{Article}
\printbibliography of all articles published in 2017
\subsection{inproceedings}
\printbibliography of all papers in proceedings published in 2017
\subsection{in Misc}
\printbibliography of all misc published in 2017
\section{2015}
etc. for all bib entries and all years.
Here is an example of the desired result: http://malti.fr/index.php/publications which was however obtained using a quite older package (bibunit) with multiple cites, multiple compilations, etc. (no more desired).
Some further enhancements could be:
- The starting year automatically set up to the older entry year of the bib file,
- The end year automatically set up to the most recent entry year of the bib file,
- In case there is no paper published corresponding to a given (sub-)section, then that (sub-)section does not appear, (i.e.) no (sub-)section appears empty.
Printing bibliography between two years was resolved here. Thanks.
EDITED. Here is a MWE borrowed and modified from here to answer @samcarter.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Article{a,
date = 2001,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{b,
date = 2003,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{c,
date = 2004,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{d,
date = 2007,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{e,
date = 2009,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{f,
date = 2011,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{g,
date = 2013,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{h,
date = 2015,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{i,
date = 2016,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@patent{l,
year = 2016,
author = {Author, Amy},
title = {Patent 1},
number = 4,
pages = {100-141}}
@inproceedings{j,
date = 2016,
author = {Author, Amy},
title = {Title 1},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@patent{o,
year = 2016,
author = {Author, Amy},
title = {Patent 1},
number = 4,
pages = {100-141}}
@patent{m,
year = 2016,
author = {Author, Amy},
title = {Patent 2},
number = 4,
pages = {100-141}}
@Article{n,
date = 2016,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=author,match=Amy,final]
\step[fieldset=keywords, fieldvalue={,}, append]
\step[fieldset=keywords, fieldvalue=own, append]
}}}
\defbibcheck{2016}{%There must be a better way to code "different from" 2016
\ifnumless{\thefield{year}}{2016}
{\skipentry}
{\ifnumgreater{\thefield{year}}{2016}
{\skipentry}
{}
}
}
\defbibcheck{2015}{%There must be a better way to code "different from" 2015
\ifnumless{\thefield{year}}{2015}
{\skipentry}
{\ifnumgreater{\thefield{year}}{2015}
{\skipentry}
{}
}
}
\begin{document}
\nocite{*}
\section*{2016}
\printbibliography[check=2016, keyword=own, resetnumbers=true, type=article, heading=subbibliography, title={Articles}]
\printbibliography[check=2016, keyword=own, resetnumbers=true, type=inproceedings, heading=subbibliography, title={Inproceedings}]
\printbibliography[check=2016, keyword=own, resetnumbers=true, type=patent, heading=subbibliography, title={Patent}]
\section*{2015}
\printbibliography[check=2015, keyword=own, resetnumbers=true, type=article, heading=subbibliography, title={Articles}]
\printbibliography[check=2015, keyword=own, resetnumbers=true, type=inproceedings, heading=subbibliography, title={Inproceedings}]
\printbibliography[check=2015, keyword=own, resetnumbers=true, type=patent, heading=subbibliography, title={Patent}]
\end{document}
However, I've got an undesired output with headings Inproceedings
and Patent
printed with an empty content in year 2015. I'd like not to have any heading if the content is empty.
Back to my request. How to create a loop from 2016 down to 2001 printing the bibliography year after year according to the types (Article, Inproceedings, Patent, Misc, ...)?
Another enhancement would be:
- to create an inner loop which loops around the different types (Article, Inproceedings, Patent, Misc, ...) for each year.
EDITED
Find below a MWE, with the proposed solutions, which however points out the compilation pb when using htlatex/biber/htlatex. See the comment below posted on Feb, 22nd, 2020.
RE-EDITED on March, 12th, 2020: a misc ref is added:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Article{b,
date = 2003,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@misc{ccc,
date = 2003,
author = {misc, LLL},
title = {MISC},
journaltitle = {Journal-misc},
volume = 10,
number = 4,
pages = {100-141}}
@Article{c,
date = 2003,
author = {Author, BBB},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{d,
date = 2003,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@Article{i,
date = 2016,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@patent{l,
year = 2016,
author = {Author, Amy},
title = {Patent 1},
number = 4,
pages = {100-141}}
@inproceedings{j,
date = 2016,
author = {Author, Amy},
title = {Title 1},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
@patent{o,
year = 2016,
author = {Author, Amy},
title = {Patent 1},
number = 4,
pages = {100-141}}
@patent{m,
year = 2016,
author = {Author, Amy},
title = {Patent 2},
number = 4,
pages = {100-141}}
@Article{n,
date = 2016,
author = {Author, Amy},
title = {Title},
journaltitle = {Journal},
volume = 10,
number = 4,
pages = {100-141}}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\pertype{article}
\step[fieldset=presort,fieldvalue=article]
}
\map{
\pertype{inproceedings}
\step[fieldset=presort,fieldvalue=inproceedings]
}
\map{
\pertype{patent}
\step[fieldset=presort,fieldvalue=patent]
}
}
}
\DeclareSortingTemplate{rasha}{
\sort[direction=ascending]{
\field{year}}
\sort{\field{presort}}
}
\defbibenvironment{bibliography}
{\begin{enumerate}}
{\end{enumerate}}
{}
\newcounter{myyear}
\setcounter{myyear}{0}
\renewbibmacro{begentry}{%
\ifnumgreater{\thefield{year}}{\value{myyear}}
{\section*{\hspace*{-\leftmargin}\printfield{year}}
\setcounter{myyear}{\thefield{year}}%
\setcounter{enumi}{0}%
\xdef\mylastentrytype{}%
}%
{}%
\iffieldequals{entrytype}{\mylastentrytype}
{}
{ \iffieldequalstr{entrytype}{article}
{\subsection*{\hspace*{-\leftmargin}Journal Articles}}
{ \iffieldequalstr{entrytype}{inproceedings}
{\subsection*{\hspace*{-\leftmargin}Conference Papers}
\setcounter{enumi}{0}%
}
{\iffieldequalstr{entrytype}{patent}
{\subsection*{\hspace*{-\leftmargin}Patents}
\setcounter{enumi}{0}
}
{}
}
}
\xdef\mylastentrytype{\thefield{entrytype}}
}
\item
}
\begin{document}
\nocite{*}
\begin{refcontext}[sorting=rasha]
\printbibliography[title={Publication list by year}]
\end{refcontext}
\end{document}