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}
biblatex arguments variable
add a comment |
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}
biblatex arguments variable
1
AFAICS there are several issues here: One is related to howbiblatextreats the argument ofaddbibresourceto sanitise potentially problematic file names, which means thatg_fichiers_references_tlis 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-yexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}. But then the second issue kicks in: Whenaddbibresourceis executed in your class file, the option has not been set and the variableg_fichiers_references_tlis empty.
– moewe
2 days ago
1
I suggest you just let your users useaddbibresourcethemselves. 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 theexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}by defining anexpl3wrapper foraddbibresourceand using theV/vversion of that command.
– moewe
2 days ago
add a comment |
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}
biblatex arguments variable
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
biblatex arguments variable
asked 2 days ago
le petit prince
10817
10817
1
AFAICS there are several issues here: One is related to howbiblatextreats the argument ofaddbibresourceto sanitise potentially problematic file names, which means thatg_fichiers_references_tlis 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-yexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}. But then the second issue kicks in: Whenaddbibresourceis executed in your class file, the option has not been set and the variableg_fichiers_references_tlis empty.
– moewe
2 days ago
1
I suggest you just let your users useaddbibresourcethemselves. 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 theexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}by defining anexpl3wrapper foraddbibresourceand using theV/vversion of that command.
– moewe
2 days ago
add a comment |
1
AFAICS there are several issues here: One is related to howbiblatextreats the argument ofaddbibresourceto sanitise potentially problematic file names, which means thatg_fichiers_references_tlis 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-yexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}. But then the second issue kicks in: Whenaddbibresourceis executed in your class file, the option has not been set and the variableg_fichiers_references_tlis empty.
– moewe
2 days ago
1
I suggest you just let your users useaddbibresourcethemselves. 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 theexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}by defining anexpl3wrapper foraddbibresourceand using theV/vversion 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
add a comment |
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,
}
Thanks for the answer! And the bonus feature is awesome!
– le petit prince
2 days ago
add a comment |
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,
}
Thanks for the answer! And the bonus feature is awesome!
– le petit prince
2 days ago
add a comment |
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,
}
Thanks for the answer! And the bonus feature is awesome!
– le petit prince
2 days ago
add a comment |
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,
}
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,
}
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
AFAICS there are several issues here: One is related to how
biblatextreats the argument ofaddbibresourceto sanitise potentially problematic file names, which means thatg_fichiers_references_tlis 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-yexpandafteraddbibresourceexpandafter{g_fichiers_references_tl}. But then the second issue kicks in: Whenaddbibresourceis executed in your class file, the option has not been set and the variableg_fichiers_references_tlis empty.– moewe
2 days ago
1
I suggest you just let your users use
addbibresourcethemselves. 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 anexpl3wrapper foraddbibresourceand using theV/vversion of that command.– moewe
2 days ago