Variable expanding inside BibLaTeX addbibresource











up vote
3
down vote

favorite












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

LoadClass[letterpaper,12pt]{book}
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,
}

addbibresource{g_fichiers_references_tl}


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
l.21 addbibresource{g_fichiers_references_tl}









share|improve this question


















  • 1




    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 expandafteraddbibresourceexpandafter{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
    2 days ago








  • 1




    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
    2 days ago










  • Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
    – moewe
    2 days ago















up vote
3
down vote

favorite












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

LoadClass[letterpaper,12pt]{book}
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,
}

addbibresource{g_fichiers_references_tl}


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
l.21 addbibresource{g_fichiers_references_tl}









share|improve this question


















  • 1




    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 expandafteraddbibresourceexpandafter{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
    2 days ago








  • 1




    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
    2 days ago










  • Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
    – moewe
    2 days ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











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

LoadClass[letterpaper,12pt]{book}
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,
}

addbibresource{g_fichiers_references_tl}


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
l.21 addbibresource{g_fichiers_references_tl}









share|improve this question













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

LoadClass[letterpaper,12pt]{book}
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,
}

addbibresource{g_fichiers_references_tl}


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
l.21 addbibresource{g_fichiers_references_tl}






biblatex arguments variable






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









le petit prince

10817




10817








  • 1




    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 expandafteraddbibresourceexpandafter{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
    2 days ago








  • 1




    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
    2 days ago










  • Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
    – moewe
    2 days ago














  • 1




    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 expandafteraddbibresourceexpandafter{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
    2 days ago








  • 1




    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
    2 days ago










  • Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
    – moewe
    2 days ago








1




1




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 expandafteraddbibresourceexpandafter{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
2 days ago






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 expandafteraddbibresourceexpandafter{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
2 days ago






1




1




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
2 days ago




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
2 days ago












Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
– moewe
2 days ago




Maybe you can avoid the expandafteraddbibresourceexpandafter{g_fichiers_references_tl} by defining an expl3 wrapper for addbibresource and using the V/v version of that command.
– moewe
2 days ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










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

LoadClass[letterpaper,12pt]{book}
RequirePackage{xparse}
RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

DeclareDocumentCommand ConfigurationDocument { m }
{
keys_set:nn { udes-genie-these } { #1 }
clist_map_function:NN g_fichiers_references_clist addbibresource
}

keys_define:nn {udes-genie-these}
{
fichiers-references .clist_gset:N = g_fichiers_references_clist,
fichiers-references .value_required:n = true,
}





share|improve this answer























  • Thanks for the answer! And the bonus feature is awesome!
    – le petit prince
    2 days ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460201%2fvariable-expanding-inside-biblatex-addbibresource%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










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

LoadClass[letterpaper,12pt]{book}
RequirePackage{xparse}
RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

DeclareDocumentCommand ConfigurationDocument { m }
{
keys_set:nn { udes-genie-these } { #1 }
clist_map_function:NN g_fichiers_references_clist addbibresource
}

keys_define:nn {udes-genie-these}
{
fichiers-references .clist_gset:N = g_fichiers_references_clist,
fichiers-references .value_required:n = true,
}





share|improve this answer























  • Thanks for the answer! And the bonus feature is awesome!
    – le petit prince
    2 days ago















up vote
3
down vote



accepted










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

LoadClass[letterpaper,12pt]{book}
RequirePackage{xparse}
RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

DeclareDocumentCommand ConfigurationDocument { m }
{
keys_set:nn { udes-genie-these } { #1 }
clist_map_function:NN g_fichiers_references_clist addbibresource
}

keys_define:nn {udes-genie-these}
{
fichiers-references .clist_gset:N = g_fichiers_references_clist,
fichiers-references .value_required:n = true,
}





share|improve this answer























  • Thanks for the answer! And the bonus feature is awesome!
    – le petit prince
    2 days ago













up vote
3
down vote



accepted







up vote
3
down vote



accepted






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

LoadClass[letterpaper,12pt]{book}
RequirePackage{xparse}
RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

DeclareDocumentCommand ConfigurationDocument { m }
{
keys_set:nn { udes-genie-these } { #1 }
clist_map_function:NN g_fichiers_references_clist addbibresource
}

keys_define:nn {udes-genie-these}
{
fichiers-references .clist_gset:N = g_fichiers_references_clist,
fichiers-references .value_required:n = true,
}





share|improve this answer














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

LoadClass[letterpaper,12pt]{book}
RequirePackage{xparse}
RequirePackage[backend=biber, style=ieee, citestyle=ieee, url=false]{biblatex}

DeclareDocumentCommand ConfigurationDocument { m }
{
keys_set:nn { udes-genie-these } { #1 }
clist_map_function:NN g_fichiers_references_clist addbibresource
}

keys_define:nn {udes-genie-these}
{
fichiers-references .clist_gset:N = g_fichiers_references_clist,
fichiers-references .value_required:n = true,
}






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









David Purton

8,0791834




8,0791834












  • Thanks for the answer! And the bonus feature is awesome!
    – le petit prince
    2 days ago


















  • Thanks for the answer! And the bonus feature is awesome!
    – le petit prince
    2 days ago
















Thanks for the answer! And the bonus feature is awesome!
– le petit prince
2 days ago




Thanks for the answer! And the bonus feature is awesome!
– le petit prince
2 days ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460201%2fvariable-expanding-inside-biblatex-addbibresource%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Entries order in /etc/network/interfaces

新発田市

Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)