# \printbibliography by variable years

This is the system I currently have:

\defbibcheck{yr2016}{
\iffieldint{year}
{\ifnumequal{\thefield{year}}{2016}
{\skipentry}
{}}
{\skipentry}
}


This should exclude anything except entries in 2016. I then use it with:

\printbibliography[check=yr2016]


I want to know if it is possible to make variables for the ranges of years I want to list, so I can change the ranges when needed. I wanted to do something in the preamble like:

\defbibcheck{{year-init},{year-final}}{
\iffieldint{year}
{\ifnumrange{\thefield{year}}{{year-init},{year-final}}
{\skipentry}
{}}
{\skipentry}
}


And then in the document have:

\printbibliography[check={year-init}={2012},{year-final}={2015}]


So if I want to change my range to:

\printbibliography[check={year-init}={2012},{year-final}={2018}]


I wouldn't have to change or update the code in the preamble.

Bibchecks are not designed to take an argument, even less so in an arbitrary format. You can work around this limitation by using placeholder macros in the definition of the bibcheck and setting these placeholders with a second macro before the application of the check.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\makeatletter
\def\mblx@yearfrom{-1000}
\def\mblx@yearto{3000}

\newrobustcmd*{\setcheckfromtorange}[2]{%
\def\mblx@yearfrom{#1}%
\def\mblx@yearto{#2}%
}

\defbibcheck{fromto}{%
\iffieldint{year}
{\ifnumless{\thefield{year}}{\mblx@yearfrom}
{\skipentry}
{\ifnumgreater{\thefield{year}}{\mblx@yearto}
{\skipentry}
{}}}
{\skipentry}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{appleby0,
author  = {Humphrey Appleby},
title   = {On the Importance of the Civil Service},
date    = {1980},
}
@book{appleby1,
author  = {Humphrey Appleby},
title   = {On the Ablative in Greek},
date    = {1981},
}
@book{appleby2,
author  = {Humphrey Appleby},
title   = {On Honours},
date    = {1982},
}
@book{appleby3,
author  = {Humphrey Appleby},
title   = {Theory on Brontosauruses},
date    = {1983},
}
\end{filecontents}

\nocite{*}

\begin{document}
\printbibliography[check=fromto,title={All}]

\setcheckfromtorange{1981}{1982}
\printbibliography[check=fromto,title={1981--1982}]
\end{document}


Remember that the fromto settings are not reset automatically, they are simple local assignments.

• I tried to create an author category (shown below) and then use a [check=byauthor] in the \printbibliography but it isn't recognized anymore. \newcommand*{\generateauthorcategory}[3]{% \DeclareBibliographyCategory{by#1}% \DeclareIndexNameFormat{cat#1}{% \ifboolexpr{test {\ifdefstring{\namepartfamily}{#2}} and test {\ifdefstring{\namepartgiven}{#3}}} {\addtocategory{by#1}{\thefield{entrykey}}} {}}% \AtDataInput{\indexnames[cat#1][1-999]{author}}} \printbibliography[check=fromto, catergory=byauthor, title={2014--2016}] – Michael Aug 1 '18 at 15:03
• @Michael If you are talking about the code from tex.stackexchange.com/q/406061/35864 the combination of the two works just fine for me. There is one tiny thing off in your comment: You have a typo in \printbibliography[check=fromto, catergory=byauthor, title={2014--2016}] it should be category not catergory. If it doesn't work when you fix that typo, please ask a new question with an MWE and an exact description of what does not work and how it does not work (with log output and pictures of the PDF). – moewe Aug 1 '18 at 15:26