9

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.

5
  • 4
    There's an \AtEveryCite as well as an \AtEveryCitekey in biblatex.
    – jon
    Feb 21, 2015 at 19:13
  • 2
    In addition to jon's suggestion, you could still map all these fields to null using sourcemapping.
    – moewe
    Feb 21, 2015 at 19:29
  • As @moewe says, the best way to do this is to do this as early as possible before biblatex even sees the data, using the biber sourcemapping feature. There are many examples of this on TSE.
    – PLK
    Feb 21, 2015 at 23:31
  • @jon: OK, so I tried to add to my \AtEveryBibitem code exactly the same code but starting with \AtEveryCitekey and it resolves the issue, but produces the following mess in front of every citation: "blx@hook@citekey@next" (like (blx@hook@citekey@nextDalton 2012). (Also I am curious why you have to include both? And you have to, because if only code starting with \AtEveryCitekeyis included, the thing doesn't compile at all. Here they also use both: [tex.stackexchange.com/questions/40097/…). Feb 22, 2015 at 8:27
  • @moewe and PLK, I looked up souremapping in biber manual and, unfortunately, it's beyond by proficiency level in biblatex. Feb 22, 2015 at 8:30

2 Answers 2

15

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

15
  • Thanks, your second solution worked! I just want to clarify for other users how to make it work for more complex purposes and also why I was not able to make your first solution work for my purposes. \AtEveryCitekey (unlike, \AtEveryBibitem) was not able to swallow \ifthenelse{\ifentrytype{...}}clauses. Since in most cases I need to delete particular fields for particular types of entries, this did not work for me. Feb 23, 2015 at 6:02
  • 1
    @homo_loquens Both \AtEveryCitekey and \AtEveryBibitem support \ifentrytype and even more complex conditional constructions, the error you mentioned in your other comments looks suspiciously like this.
    – moewe
    Feb 23, 2015 at 6:07
  • 1
    @homo_loquens That's due to the special format date fields have, for source-mapping purposes a date specified as date = {YYYY-MM-DD} is just a date field, while for biblatex styles the date splits into year, month and date, so you can only selectively get rid of months by dropping them later (or by using regex in the source-mapping).
    – moewe
    Feb 23, 2015 at 21:01
  • 1
    @homo_loquens Have a look at the modified answer, it now features a get-rid-of-all-date-parts-but-the-year-source-mapping.
    – moewe
    Feb 24, 2015 at 6:38
  • 1
    @homo_loquens Mhh, it shouldn't $1 is a place-holder for the first match, which in our case is going to be the year. Maybe you are using an older version of biblatex/Biber. Did you try the actual MWE above and did get this strange behaviour?
    – moewe
    Feb 25, 2015 at 6:43
0

The second solution from @moewe worked for me (even for \fullcite), but I found here a shorter solution:

\AtEveryCitekey{\UseBibitemHook}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .