# Pass option to each occurence of command (especially \printbibliography with biblatex)

In a large book with many sub-bibliographies, I want to ensure that crucial bibchecks are executed at every call to \printbibliography. Normally, one would simply call \printbibliography[check=...] each time, but this being a large multi-user project, I want to make absolutely sure that the check is present without reviewing each call. As far as I see, biblatex doesn't support setting default options.

From the biblatex manual, I think it could be done with \AtEveryBiblistitem{subbibliography}{<code>} (§4.10.6). But without usage examples I don't know what <code> I need here.

Taken generally, this is the problem of appending the optional argument of every occurence, so that every \printbibliograhy[options] is changed to \printbibliography[check=...,options]. So I guess I'm looking for an analogue to \PassOptionsToPackage, but I haven't come across one.

• Is it always the same check for all instances of \printbibliography? What is the purpose of this bibcheck? Wouldn't a sourcemap be able to substitute it (given it is applied to all bibliographies)? That said, your question would probably receive better answers in the presence of a MWE wich illustrates the problem at hand in a more concrete way. As it stands, even though I believe the question is clear, it does look very much like an XY question. – gusbrs Jan 10 at 13:40

## 1 Answer

There is no \PassOptionsToPackage equivalent for \printbibliography. If you sincerely think that this could be needed you can open a feature request at https://github.com/plk/biblatex/issues.

In this particular case it is possible to patch \printbibliography (or rather its internal implementation) in a way that there is a default check that is always applied if no other check is requested (since each \printbibliography can only call one bibcheck). Of course this relies heavily on all kinds of internals.

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

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

\addbibresource{biblatex-examples.bib}

\makeatletter
\pretocmd{\blx@printbibliography}
{\blx@key@bibcheck{onlyart}}
{}{}
\makeatother

\defbibcheck{onlyart}{%
\ifentrytype{article}
{}
{\skipentry}%
}

\defbibcheck{onlybook}{%
\ifentrytype{book}
{}
{\skipentry}%
}

\begin{document}
\cite{sigfridsson,worman,nussbaum,cicero}
\printbibliography

\printbibliography[check=onlybook]
\end{document}


I agree with gusbrs' comment: It is a bit odd that you would want to apply one check for all \printbibliographys. It seems that in that case there should be a more elegant solution like a sourcemap or dataonly.

• It's a clever (and patchy) approach. But what happened to the "best solution™"? – gusbrs Jan 10 at 15:00
• @gusbrs Couldn't afford the royalty payments, so patchy it is ... – moewe Jan 10 at 15:05
• Ah! I didn't mean the patches (those do fit in my "best solution™" bunch), but the XY problem. I still think the OP is trying to use the wrong tool for the problem, just can't be sure what, lacking further information. – gusbrs Jan 10 at 15:10
• Thank you!, Also for pointing out the source map approach. As far as I understood the biblatex documentation, some basic tests like \ifnumless were only available in checks, but not in filters or sourcemaps, and so I thought that checks give us more tools to filter entries than the other two. After your suggestion, I will re-read the doc and think about it again. – Felix Emanuel Jan 17 at 13:28
• @FelixEmanuel That is correct, checks let you use very complicated constructions, but the interface is quite low-level and at times even awkward compared to other (higher-level) solutions. (See for example tex.stackexchange.com/q/470035/35864). Sourcemaps work on a different level (they are executed by Biber 'before' the data is processed and not on the biblatex side when all data is fixed) and have quite different capabilities in principle (regular expressions). ... – moewe Jan 17 at 13:37