Excessive fields in biblatex could not be removed if using \fullcite
If you want to control the urldate
in bibliography and citations independently, \AtEveryBibitem
and \AtEveryCitekey
are the way to go.
\AtEveryBibitem
performs its actions at every item in the bibliography, while \AtEveryCitekey
performs its actions at every item cited. (See pp. 228-229 of the biblatex
documentation).
So to get rid of, say, the title
only in citations, you would go with \AtEveryCitekey{\clearfield{title}}
- the title
is then ignored in citations, but still printed in the bibliography. Analogously, \AtEveryBibitem{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
gets rid of the URL date only on the bibliography, not in the citations.
In order to get rid of the URL date everywhere, you could therefore issue
\AtEveryBibitem{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
\AtEveryCitekey{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
Type restrictions can be applied by \ifentrytype
or even more complex constructs like so
\AtEveryBibitem{%
\ifentrytype{online}
{}
{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}}
\AtEveryCitekey{%
\ifboolexpr{test {\ifentrytype{article}} or test {\ifentrytype{book}}}
{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
{}}
The first example deletes the URL date for all but @online
entries, while the second deletes them only for @article
and @book
.
For technical reasons (I could think of possible label date creation) it is better though to get rid of the URL date as early as possible, if you don't want to use it at all. Here Biber's sourcemapping comes in (see §4.5.2 Dynamic Modification of Data, pp. 148-156 of the doc).
We want to get rid of the urldate
field in your .bib
file, so we just set it to null
.
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldset=urldate, null]
}
}
}
With sourcemapping, type restrictions can be imposed by \pertype
like so
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\pertype{article}
\pertype{book}
\step[fieldset=urldate, null]
}
}
}
This map now only applies to @article
s and @book
s.
Sadly, with \pertype
one cannot use negations as we did above (as in "only apply this to entries that are not @online
"), maybe that's worth a feature request (- it was worth one and our wish has been granted).
Since the date field is a bit special in how it's handled by biblatex
. In the document it is available as three fields year
, month
and day
(so one could use \AtEveryCitekey{\clearfield{month}}
without any trouble), for source-mapping purposes (remember, source-mapping is one of the first steps Biber takes with a file, at this point nothing has been interpreted or read from the file) often the date is input as date = {YYYY-MM-DD}
, that is why just deleting the month
field in source-mapping will only help those who input the date as year = {2014}, month = {03}, day={04}
(which is possible, but slightly less comfortable).
What we can do though is, we can make the date year-only with RegEx
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldset=month, null]
\step[fieldsource=date,
match=\regexp{([0-9]{4})-[0-9]{2}(-[0-9]{2})*},
replace=\regexp{$1}]
}
}
}
We look for a string of the form "YYYY-MM-DD" or possibly just "YYYY-MM-DD" and just retain the "YYYY" part, thus retaining only the year.
We also set the month to null
for those who prefer to input the date more verbosely.
MWE
\documentclass{article}
\usepackage[style=authoryear,backend=biber,mergedate=false]{biblatex}
\addbibresource{biblatex-examples.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\pertype{online}
\step[fieldset=urldate, null]
}
\map{
\step[fieldset=month, null]
\step[fieldsource=date,
match=\regexp{([0-9]{4})-[0-9]{2}(-[0-9]{2})*},
replace=\regexp{$1}]
}
}
}
\begin{document}
\cite{baez/online,itzhaki,markey}
\printbibliography
\end{document}
Gives
Below is the output without any source-mapping for comparison