1

In a current project involving multiple other people working on the same latex base, I am using a custom biblatex bibliography style based on the standard style. Within it, I want to have

\ExecuteBibliographyOptions[article]{eprint=false}

This works as intended e.g. on MiKTex 21.1 or texlive2020. Unfortunately, it doesn't work with texlive2017, which is installed on computers used by several other people (and atm I cannot update the version there). I figured I could get the same behaviour with these older versions by also adding

\DeclareTypeOption[boolean]{eprint}[true]{\settoggle{bbx:eprint}{#1}}

Unfortunately, this breaks with the newer versions, as the option eprint is already defined.

Can I build in a switch that either checks for the existence of the (type) option or the biblatex version? If so, how? I would prefer to keep using the standard style and not having to c&p everything from there. I currently need to provide this backward compatibility.

1 Answer 1

1

biblatex type options are generated via keyval with set name blx@opt@typ. So we just need a test to see if the keyval option with the name eprint is defined in that set.

The test \blx@kv@ifkeyundef we use here is defined in newer versions of biblatex (see https://github.com/plk/biblatex/pull/991), but might not be available in older versions, so we copy its definition explicitly.

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

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

\makeatletter
\providecommand*{\blx@kv@ifkeyundef}[2]{%
  \ifcsundef{KV@#1@#2}}

% {<scope>}{<option name>}
\newcommand*{\IfBiblatexOptionUndef}[2]{%
  \blx@kv@ifkeyundef{blx@opt@#1}{#2}}

\IfBiblatexOptionUndef{typ}{eprint}
  {\DeclareTypeOption[boolean]{eprint}[true]{\settoggle{bbx:eprint}{#1}}}
  {}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}

\printbibliography
\end{document}

The set names are as follows

Option scope Scope name
Load-time ldt
Global pre
Type typ
Entry ent
Namelist namelist
Name name
Namepart namepart

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.