TeX - LaTeX Asked by Oak Nelson on December 8, 2020
I am wondering if it is possible to turn off the effects of DeclareSourceMap
part way through a tex document. Any tips on how to do this?
Here is some more information on the situation I am in. I am trying to get a unique citation style to work, which is based around biblatex
:
usepackage[backend=biber,bibstyle=nature,citestyle=authoryear,maxcitenames=2,maxbibnames=99,uniquelist=false,sorting=ydnt]{biblatex}
I use the following to add the journal name to the authoryear
cite style:
% add journal name to inline citation
renewbibmacro*{cite}{%
iffieldundef{shorthand}
{ifthenelse{ifnameundef{labelname}ORiffieldundef{labelyear}}
{usebibmacro{cite:label}%
setunit{printdelim{nonameyeardelim}}}
{printnames{labelname}%
setunit{printdelim{nameyeardelim}}}%
setunit{addcommaspace}%
usebibmacro{journal}
setunit{addcommaspace}%
usebibmacro{cite:labeldate+extradate}}%
{usebibmacro{cite:shorthand}}}
Finally, I use DeclareSourceMap
to shorted journal titles in the text. The result is as desired, which is references showing up as [Doe RSI 2006] when cited in the text.
HOWEVER, I would like to turn off the shortening of journal titles when I actually print the bibliography at the end of the document using printbibliography
. At the moment, my bibliography looks like:
Doe, A. B. & Smith, J. S. A journal article with a cool title. RSI (2006).
I would like the bibliography to look like this:
Doe, A. B. & Smith, J. S. A journal article with a cool title. Review of Scientific Instruments (2006).
But I need to preserve the citation formatting in the text as explained above.
Is there a way to turn off the effects of DeclareSourceMap
directly before the printbibliography
call?
Thanks for your help.
A MWE is included below:
documentclass{article}
usepackage[backend=biber,bibstyle=nature,citestyle=authoryear,maxcitenames=2,maxbibnames=99,uniquelist=false,sorting=ydnt]{biblatex}
usepackage{filecontents}
begin{filecontents}{mybibfile.bib}
@article{file,
author = {Doe, A. B. and Smith, J. S. and Author, G. B.},
title = {A journal article with a cool title},
journal = {Review of Scientific Instruments},
year = {2006}
}
end{filecontents}
addbibresource{mybibfile.bib}
% add journal name to inline citation
renewbibmacro*{cite}{%
iffieldundef{shorthand}
{ifthenelse{ifnameundef{labelname}ORiffieldundef{labelyear}}
{usebibmacro{cite:label}%
setunit{printdelim{nonameyeardelim}}}
{printnames{labelname}%
setunit{printdelim{nameyeardelim}}}%
setunit{addcommaspace}%
usebibmacro{journal}
setunit{addcommaspace}%
usebibmacro{cite:labeldate+extradate}}%
{usebibmacro{cite:shorthand}}}
% abbreviate journal names
DeclareSourcemap{
maps[datatype=bibtex,overwrite=true]{
map{
step[fieldsource=journal,
match=regexp{ReviewsofsScientificsInstruments},
replace={RSI}]
}
}
}
begin{document}
This works as intended: parencite{file}
This does not work as intended:
printbibliography
end{document}
biblatex
ojffers the field shortjournal
(not used by standard style), so what you can do is to set the value of the shortjournal
and use shortjournal
in the citation. This can be achieved by using printfield{shortjournal}
instead of usebibmacro{journal}
in the definition of cite
renewbibmacro*{cite}{%
iffieldundef{shorthand}
{ifthenelse{ifnameundef{labelname}ORiffieldundef{labelyear}}
{usebibmacro{cite:label}%
setunit{printdelim{nonameyeardelim}}}
{printnames{labelname}%
setunit{printdelim{nameyeardelim}}}%
setunit{addcommaspace}%
printfield{shortjournal} % changed line
setunit{addcommaspace}%
usebibmacro{cite:labeldate+extradate}}%
{usebibmacro{cite:shorthand}}}
and a DeclareSourceMap
that add a value for shortjournal
DeclareSourcemap{
maps[datatype=bibtex,overwrite=true]{
map{
step[fieldsource=journal,
match=regexp{ReviewsofsScientificsInstruments},
fieldset=shortjournal,
fieldvalue={RSI}]
}
}
}
The two changes above yield:
Correct answer by Guido on December 8, 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