如果使用 \fullcite 則無法刪除 biblatex 中過多的字段

如果使用 \fullcite 則無法刪除 biblatex 中過多的字段

與Zotero的結合biblatex-chicago在參考書目中產生了許多過多的字段。這個問題可以透過在序言中加入以下警告來解決:

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

(在我之前問題的回答中有詳細描述:biblatex Chicago 作者日期樣式中的過多字段.)

這個解決方案對我來說效果很好,但現在我必須使用\fullcite命令來產生教學大綱。不幸的是,這個解決方案並不能解決參考書目本身之外的完整書目條目的問題。

這是內部包含參考書目的代碼(為了以正確的順序獲取作者的名字和姓氏,我使用以下解決方案:Biblatex-chicago: \fullcite 翻轉名字和姓氏):

\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} 

這是輸出。請注意文中完整引用中的過度欄位(參考文獻中沒有它們):

在此輸入影像描述

任何幫助,特別是簡單可行的解決方案將不勝感激。

答案1

如果您想urldate獨立控制參考書目和引文,\AtEveryBibitem那麼 和\AtEveryCitekey是可行的方法。

\AtEveryBibitem對參考書目中的每個項目執行其操作,同時\AtEveryCitekey對引用的每個項目執行其操作。 (請參閱第 228-229 頁biblatex文件)。

因此,要擺脫,比如說,title引文中的唯一,您可以選擇\AtEveryCitekey{\clearfield{title}}-title然後在引文中忽略 the,但仍然打印在參考書目中。類似地,\AtEveryBibitem{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}僅刪除參考書目中的 URL 日期,而不刪除引文中的 URL 日期。

為了擺脫各處的 URL 日期,您可以發出

\AtEveryBibitem{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
\AtEveryCitekey{\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}

\ifentrytype類型限制可以透過更複雜的構造應用,如下所示

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

\AtEveryCitekey{%
  \ifboolexpr{test {\ifentrytype{article}} or test {\ifentrytype{book}}}
    {\clearfield{urlyear}\clearfield{urlmonth}\clearfield{urlday}}
    {}}

第一個範例刪除除條目之外的所有 URL 日期@online,而第二個範例僅刪除@article和 的URL 日期@book


出於技術原因(我可以想到可能會建立標籤日期),如果您根本不想使用 URL 日期,最好儘早刪除它。這裡 Biber 的源映射登場(參見§4.5.2資料的動態修改,第 148-156 頁醫生)。

我們想要刪除文件urldate中的字段.bib,因此我們只需將其設置為null.

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=urldate, null]
    }
  }
}

透過來源映射,可以\pertype像這樣施加類型限制

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{article}
      \pertype{book}
      \step[fieldset=urldate, null]
    }
  }
}

該映射現在僅適用於@articles 和@books。遺憾的是,\pertype人們不能像我們上面那樣使用否定(如“僅將其應用於不是@online”的條目),也許這值得一個功能請求(-它值得一個並且我們的願望已經實現)。

由於日期欄位的處理方式有點特殊biblatex。在文件中,它以三個字段的形式提供yearmonth並且day(因此可以\AtEveryCitekey{\clearfield{month}}毫無問題地使用)用於來源映射目的(請記住,來源映射是Biber 對文件執行的第一步,此時還沒有任何內容)解釋或從文件中讀取)通常日期輸入為date = {YYYY-MM-DD},這就是為什麼僅刪除month來源映射中的欄位只會幫助那些輸入日期為 的人 year = {2014}, month = {03}, day={04}(這是可能的,但稍微不太舒服)。但我們可以做的是,我們可以使用 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}]
    }
  }
}

我們尋找“YYYY-MM-DD”或可能只是“YYYY-MM-DD”形式的字串,並僅保留“YYYY”部分,從而僅保留年份。我們還null為那些喜歡更詳細地輸入日期的人設定了月份。

微量元素

\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}

給予

在此輸入影像描述

下面是沒有任何來源映射的輸出用於比較

在此輸入影像描述

答案2

@moewe 的第二個解決方案對我有用(甚至對\fullcite),但我發現這裡更短的解決方案:

\AtEveryCitekey{\UseBibitemHook}

相關內容