TeX - LaTeX Asked by SU3 on December 14, 2020
I don’t think I understand how the DeclareSourcemap
works in biblatex
.
I’m trying to define 3 rules:
issue
to number;number
for journals that start with "Phys. Rev.";volume
for journals that are "JHEP".Here’s what I have right now, but it seems to apply all transformations to all bibliography entries.
DeclareSourcemap{
maps[datatype=bibtex]{
map{
step[fieldsource=issue]
step[fieldset=number, origfieldval]
step[fieldset=issue, null]
%
step[fieldsource=journal, fieldtarget=journaltitle]
step[fieldsource=journaltitle, match=regexp{APhys.s+Rev.}]
step[fieldset=number, null]
%
step[fieldsource=journal, fieldtarget=journaltitle]
step[fieldsource=journaltitle, match=regexp{AJHEPZ}]
step[fieldset=volume, null]
}
}
}
Ideally, I would also like for issue
to be moved to number
only if number
is not defined.
Biber processes all step
s in a map
sequentially unless one of the step
s has the final
option, which tells Biber to stop at this step if it does not apply.
Since there are no final
s in the code shown in the question, all step
s get executed, which means that in the end both volume
and number
get removed.
You need to separate the different things you want to do into separate map
s and use final
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{csquotes}
usepackage[backend=biber, style=authoryear]{biblatex}
DeclareSourcemap{
maps[datatype=bibtex]{
% remap fields for all entries, but nothing will be overwritten
map{
step[fieldsource=issue, fieldtarget=number]
step[fieldsource=journal, fieldtarget=journaltitle]
}
% delete number only for Phys. Rev.
map{
step[fieldsource=journaltitle, match=regexp{APhys.s+Rev.}, final]
step[fieldset=number, null]
}
% delte volume only for JHEP
map{
step[fieldsource=journaltitle, match=regexp{AJHEPZ}, final]
step[fieldset=volume, null]
}
}
}
begin{filecontents}{jobname.bib}
@article{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
journal = {Phys. Rev.},
volume = {131},
issue = {5},
}
@article{belk,
author = {Anne Belk},
title = {A Theory on Brontosauruses},
year = {1971},
journal = {JHEP},
volume = {132},
issue = {6},
}
@article{celk,
author = {Anne Celk},
title = {A Theory on Brontosauruses},
year = {1974},
journal = {Lorem},
volume = {133},
issue = {7},
}
@article{delk,
author = {Anne Delk},
title = {A Theory on Brontosauruses},
year = {1975},
journal = {Lorem},
volume = {134},
number = {8},
}
@article{felk,
author = {Anne Felk},
title = {A Theory on Brontosauruses},
year = {1977},
journal = {Lorem},
volume = {135},
number = {9},
issue = {Michaelmas term},
}
end{filecontents}
addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}
begin{document}
Lorem autocite{sigfridsson,elk,belk,celk,delk,felk}
printbibliography
end{document}
Correct answer by moewe on December 14, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP