# Variable expanding inside BibLaTeX \addbibresource

I am working with a custom class provided by my university for the typesetting of thesis. The class automatically includes BibTex references in the document. I want to modify the class to make it work with BibLaTex. In the class, the .bib file path is passed from the document to the class via a command. The problem is that BibLaTeX command \addbibresource{} cannot process a variable as its input. See the MWE below for more details.

Is there a command I can use to expand the variable before it is processed by \addbibresource{}?

# MWE

## Main document

\documentclass{test}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}

\ConfigurationDocument{fichiers-references = {references.bib}}

\begin{document}
\cite{franssila_introduction_2010}
\printbibliography
\end{document}


## test.cls

\RequirePackage{expl3}
\ProvidesExplClass{test}{2018/09/26}{2.0}{MWE}

\tl_new:N \g_fichiers_references_tl

\RequirePackage{xparse,etoolbox}
\RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

\DeclareDocumentCommand \ConfigurationDocument { m }
{ \keys_set:nn { udes-genie-these } { #1 } }

\keys_define:nn {udes-genie-these}
{
fichiers-references .tl_gset:N = \g_fichiers_references_tl,
fichiers-references .value_required:n = true,
}



## references.bib

@book{franssila_introduction_2010,
location = {Chichester, {UK}},
edition = {2e édition},
title = {Introduction to microfabrication},
publisher = {Wiley},
author = {Franssila, Sami},
date = {2010}
}


## Error message

! Undefined control sequence.
<argument> \g
_fichiers_references_tl

• AFAICS there are several issues here: One is related to how biblatex treats the argument of \addbibresource to sanitise potentially problematic file names, which means that \g_fichiers_references_tl is carried on and expanded in the wrong context (at least I think that is the problem) - I could get around that with the un-LaTeX3-y \expandafter\addbibresource\expandafter{\g_fichiers_references_tl}. But then the second issue kicks in: When \addbibresource is executed in your class file, the option has not been set and the variable \g_fichiers_references_tl is empty. – moewe Nov 15 '18 at 21:31
• I suggest you just let your users use \addbibresource themselves. If you are worried about compatibility or want to be able to switch between systems, define a higher-level replacement. – moewe Nov 15 '18 at 21:32
• Maybe you can avoid the \expandafter\addbibresource\expandafter{\g_fichiers_references_tl} by defining an expl3 wrapper for \addbibresource and using the V/v version of that command. – moewe Nov 15 '18 at 21:36

I suggest using a clist for your references instead of a tl variable.

Then you can use \clist_map_function:NN \g_fichiers_references_clist \addbibresource inside \ConfigurationDocument to add each bibliography resource.

This has the advantage that you can add multiple references in the same key:

\ConfigurationDocument{fichiers-references = {references.bib, biblatex-exmaples.bib}}


So test.cls becomes:

\RequirePackage{expl3}
\ProvidesExplClass{test}{2018/09/26}{2.0}{MWE}

\clist_new:N \g_fichiers_references_clist

\RequirePackage{xparse}
\RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

\DeclareDocumentCommand \ConfigurationDocument { m }
{
\keys_set:nn { udes-genie-these } { #1 }