[Tex/LaTex] Excessive fields in biblatex could not be removed if using \fullcite

biblatexchicago-style

Combination of biblatex-chicago and Zotero produces many excessive fileds in the bibliography. This problem could be solved by adding to the preambule caveats like this:

\AtEveryBibitem{%
\ifentrytype{online}
{}
{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}}

(Described in detail in the answer to my previous question: Excessive fields in biblatex chicago author-date style.)

This solution worked well for me, but now I have to produce a syllabus using \fullcite command. Unfortunately, this solution does not solve the problem for full bibliographic entries outside of the bibliography itself.

Here is the code with bibliography inside (to get the author's first and last name in the right order I use the following solution: Biblatex-chicago: \fullcite flips first and last name):

\begin{filecontents*}{database.bib}
    @book{dalton_apartisan_2012,
        title = {The Apartisan American: Dealignment and Changing Electoral Politics},
        isbn = {9781452216942},
        url = {http://books.google.com/books?id=eYkczUyX5wMC},
        shorttitle = {The Apartisan American},
        pagetotal = {241},
        publisher = {{CQ} Press},
        author = {Dalton, Russell J.},
        urldate = {2014-04-03},
        date = {2012-02-22},
        langid = {english},
        keywords = {Political Science / Political Process / Elections, Political Science / Public Policy / General}
    }
\end{filecontents*}
\documentclass[11pt]{article}
\usepackage[hmargin=3cm,vmargin=3cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{booktabs,graphicx}
\usepackage{paralist}
\usepackage{cancel,soul}
\usepackage{enumitem}
\usepackage[authordate,backend=biber,bibencoding=utf8,bookpages=false,doi=only,isbn=false,footmarkoff]{biblatex-chicago}
\usepackage[colorlinks, pdfstartview={XYZ null null 1.25},bookmarksopen=true,bookmarksopenlevel=\maxdimen,citecolor={blue},urlcolor={blue}]{hyperref}
\addbibresource{database.bib}
\DeclareCiteCommand{\fullcite}
{\usebibmacro{prenote}}
{\usedriver
    {}
    {\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\AtEveryBibitem{%
    \ifthenelse{\ifentrytype{article}\OR\ifentrytype{book}\OR\ifentrytype{collection}\OR\ifentrytype{incollection}\OR\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR\ifentrytype{mvincollection}}
    {\clearfield{month}\clearfield{url}\clearfield{doi}\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}}


\begin{document}
\begin{center}
{\huge Partisanship in Old, New and Non-Democracies}\\
\end{center}

\vspace{30pt}
\noindent\textbf{Instructor: }  \hfill
\textbf{Time and Location:} TBA\\
\textbf{Contact:} 
\hfill
\hfil \textbf{Office Hours:} TBA\\

\vspace{-20pt}



\subsection*{Partisanship in the United States}


\begin{enumerate}
    \item \parencite{dalton_apartisan_2012}
    \item \fullcite{dalton_apartisan_2012}
\end{enumerate}

\printbibliography[heading=bibintoc]

\end{document} 

Here is the output. Note the excessive fileds in the in-text full citation (they are absent in the References):

enter image description here

Any help, especially simple acessible solutions would be greatlly apreciated.

Best Answer

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 @articles and @books. 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

enter image description here

Below is the output without any source-mapping for comparison

enter image description here

Related Question