将“urldate”添加到参考书目

将“urldate”添加到参考书目

我正在使用biblatex基于trad-standard风格:

\RequireBibliographyStyle{trad-standard}

urldate在我的自定义样式中,我重新定义了一些外观,如粗体文本等,但现在如果给出了 URL,我想将其添加到输出中。

例如,我有一个网站作为参考。Mendeley 将资源导出为 ,@misc这似乎是正确的,但访问日期(保存为urldate)没有显示。我现在搜索了 bibstyle 的代码trad-standard,但没有找到密钥,因此没有输出是很合乎逻辑的。如果给出了 URL 和,urldate我如何添加始终显示 的功能,无论我处于哪种条目类型?urldateurldate

我的猜测是更新doi+eprint+url宏,因为它负责输出 URL。因此,如果我可以将 附加urldate到输出,它应该可以满足我的要求。问题是,我不知道如何将 附加urldate到宏。


这是我的自定义.bbx文件:

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is a custom bibliography style based on the trad-abbrv style
% by Marco Daniel (2012--2015) and Moritz Wemheuer (2016--).
%
% This package is released under the terms of the
% LaTeX Project Public License v1.3c or later
% See http://www.latex-project.org/lppl.txt
%
% Copyright (c) 2012 -- 2015 Marco Daniel
%               2016 --      Moritz Wemheuer
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% %%%%%%%%%%%%%
% Declare Style
% %%%%%%%%%%%%%

\ProvidesFile{custom-abbrv.bbx}[2017/10/18 v1.0.0 Custom abbrv Bibliography Style]



% %%%%%%%%%%%%%%
% Require Styles
% %%%%%%%%%%%%%%

\RequireBibliographyStyle{trad-standard}



% %%%%%%%%%%%%%
% Basic Options
% %%%%%%%%%%%%%

\ExecuteBibliographyOptions{
    abbreviate      = false,
    arxiv           = false
    autolang        = hyphen,
    backref         = false,
    dateabbrev      = true,
    eprint          = false,
    hyperref        = true,
    labelnumber     = true,
    maxnames        = 3,
    minnames        = 3,
    sorting         = none,
}



% %%%%%%%%%%%%%%%%%%%
% trad-abbrv Settings
% %%%%%%%%%%%%%%%%%%%

\@ifpackagelater{biblatex}{2016/03/01}{%
    \@ifpackagelater{biblatex}{2016/05/14}{%
        \DeclareNameFormat{abbrv}{%
            \usebibmacro{name:given-family}%
            {\namepartfamily}%
            {\namepartgiveni}%
            {\namepartprefixi}%
            {\namepartsuffixi}%
            \usebibmacro{name:andothers}%
        }%
    }{%
        \DeclareNameFormat{abbrv}{%
            \nameparts{#1}%
            \usebibmacro{name:given-family}%
            {\namepartfamily}%
            {\namepartgiveni}%
            {\namepartprefixi}%
            {\namepartsuffixi}%
            \usebibmacro{name:andothers}%
        }%
    }%
}{%
    \DeclareNameFormat{abbrv}{%
        \usebibmacro{name:first-last}{#1}{#4}{#6}{#8}%
        \usebibmacro{name:andothers}%
    }%
}%
\DeclareNameAlias{default}{abbrv}


\DeclareFieldFormat{bibentrysetcount}{\mkbibparens{\mknumalph{#1}}}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}}


\@ifpackagelater{biblatex}{2016/05/14}{%
    \defbibenvironment{bibliography}%
        {%
            \list{%
                \printtext[labelnumberwidth]{%
                    \printfield{labelprefix}%
                    \printfield{labelnumber}%
                }%
            }{%
                \setlength{\labelwidth}{\labelnumberwidth}%
                \setlength{\leftmargin}{\labelwidth}%
                \setlength{\labelsep}{\biblabelsep}%
                \addtolength{\leftmargin}{\labelsep}%
                \setlength{\itemsep}{\bibitemsep}%
                \setlength{\parsep}{\bibparsep}%
            }%
            \renewcommand*{\makelabel}[1]{\hss##1}%
        }
        {\endlist}
        {\item}%
}{%
    \defbibenvironment{bibliography}%
        {%
            \list{%
                \printtext[labelnumberwidth]{%
                    \printfield{prefixnumber}%
                    \printfield{labelnumber}%
                }%
            }{%
                \setlength{\labelwidth}{\labelnumberwidth}%
                \setlength{\leftmargin}{\labelwidth}%
                \setlength{\labelsep}{\biblabelsep}%
                \addtolength{\leftmargin}{\labelsep}%
                \setlength{\itemsep}{\bibitemsep}%
                \setlength{\parsep}{\bibparsep}%
            }%
            \renewcommand*{\makelabel}[1]{\hss##1}%
        }%
        {\endlist}%
        {\item}%
}

\defbibenvironment{shorthands}%
    {%
        \list{%
            \printfield[shorthandwidth]{shorthand}%
        }{%
            \setlength{\labelwidth}{\shorthandwidth}%
            \setlength{\leftmargin}{\labelwidth}%
            \setlength{\labelsep}{\biblabelsep}%
            \addtolength{\leftmargin}{\labelsep}%
            \setlength{\itemsep}{\bibitemsep}%
            \setlength{\parsep}{\bibparsep}%
            \renewcommand*{\makelabel}[1]{\hss##1}%
        }%
    }%
    {\endlist}%
    {\item}%

\DeclareBibliographyDriver{set}%
    {%
        \entryset%
        {%
            \ifbool{bbx:subentry}%
                {%
                    \printfield[bibentrysetcount]{entrysetcount}%
                    \setunit*{\addnbspace}%
                }%
                {}%
        }%
        {}%
        \newunit\newblock%
        \usebibmacro{setpageref}%
        \finentry%
    }



% %%%%%%%%%%%%%%%%%
% Appearance Styles
% %%%%%%%%%%%%%%%%%

% Name
\renewcommand{\labelnamepunct}{\addcolon\space}

% Title
\DeclareFieldFormat*{title}{\enquote{#1}\isdot}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1},}

% Volume
\DeclareFieldFormat[article]{volume}{#1}

% Number
\DeclareFieldFormat*{number}{\mkbibparens{#1}}

% Pages
\DeclareFieldFormat*{pages}{\space#1\space}
\renewcommand*{\bibpagespunct}{\addspace}

% Year
\DeclareFieldFormat{date}{\textbf{#1}}

% URL
\DeclareFieldFormat{url}{URL:\space\url{#1}}

% ISSN / ISBN
\DeclareFieldFormat{issn}{ISSN:\space\url{#1}}
\DeclareFieldFormat{isbn}{ISBN:\space\url{#1}}

% DOI
\DeclareFieldFormat{doi}{%
    DOI\addcolon\space
    \ifhyperref
        {\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
        {\nolinkurl{#1}}%
}

% Item Separation
\setlength\bibitemsep{.5\baselineskip}

% Alignment
\AtBeginBibliography{\raggedright}



% %%%%%%%%%%%%%%%%%%%%%%%
% Changes in the position
% %%%%%%%%%%%%%%%%%%%%%%%

% Change the position of the year to be in front of the volume
\renewbibmacro*{journal+issuetitle}{%
    \usebibmacro{journal}%
    \usebibmacro{date}% Added the date, right after the journal
    \newcommaunit*%
    \iffieldundef{series}
    {}
    {%
        \newunit
        \printfield{series}%
        \setunit{\addcomma\space}%
    }%
    \usebibmacro{volume+number+pages+eid}%
    \newcommaunit
    % \setunit{\addspace}%
    \usebibmacro{issue+date-parens}%
    \setunit*{\addcolon\space}%
    \usebibmacro{issue}%
    \newunit%
}

% Remove the date after the volume
\renewbibmacro*{issue+date-parens}{%
    \iffieldundef{issue}%
    {%
        % \usebibmacro{date}
    }%
    {%
        \printfield{issue}%
        \newcommaunit*%
        % \usebibmacro{date}
    }%
    \newunit%
}

\endinput

答案1

正如评论中所说,问题实际上是urldateMendeley 导出的格式错误的字段。所有日期字段都必须以格式 (ISO 8601/EDTF)biblatex编写,这不是可接受的输入,并会生成警告:YYYY-MM-DDDD.MM.YYYY

Invalid format '30.04.2018' of date field 'urldate' - ignoring

您一定要就此事联系 Mendeley 开发人员。

与此同时,这里有一个 Biber 源映射的修复

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\begin{filecontents}{\jobname.bib}
@misc{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  date    = {1980},
  url     = {http://example.com/~sirhumphrey/cc.pdf},
  urldate = {30.04.2018},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=urldate, match=\regexp{\A(\d{2}).(\d{2}).(\d{4})\Z}, replace={$3-$2-$1}]
    }
  }
}

\begin{document}
\cite{sigfridsson,appleby}
\printbibliography
\end{document}

在此处输入图片描述

但不要只是使用它:向 Mendeley 的人投诉!

相关内容