使用 biblatex 自定义 citecommand 后 \clearfield{url} 不再起作用

使用 biblatex 自定义 citecommand 后 \clearfield{url} 不再起作用

为了整理参考文献的脚注,我使用了这个帖子。之前我只是使用\footfullcite{}和另外\AtEveryCitekey{\clearfield{url}},因为我觉得 URL 有点混乱。

然而,添加上述代码后,这似乎不再有任何效果。

帖子中\AtEveryCitekey{\clearfield{url}}添加的示例代码:

\documentclass{article}
\usepackage[style=numeric-comp,sorting=none,citetracker,pagetracker=page]{biblatex}
\usepackage[colorlinks]{hyperref}

\makeatletter
% user-level citation command
\DeclareCiteCommand{\sfcite}[\cbx@superscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim\supercitedelim
   \iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:super:foot}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

% save instcount, save key and last inline instcount if seen first on page
\newbibmacro*{cite:super:foot}{%
  \xdef\cbx@key{\thefield{entrykey}}%
  \ifsamepage{\value{instcount}}{\csuse{cbx@instcount@\cbx@key}}{}{%
    \listxadd{\cbx@savelist}{\cbx@key}%
    \ifnumequal{\value{cbx@inst@lastonpage}}{0}{%
      \defcounter{cbx@inst@iter}{\value{instcount}}%
      \loop\ifnum\value{cbx@inst@iter}>0
        \ifsamepage{\value{instcount}}{\value{cbx@inst@iter}}
          {\ifcsundef{blx@fnpage@\number\numexpr\value{cbx@inst@iter}}
             {\setcounter{cbx@inst@lastonpage}{\value{cbx@inst@iter}}}{}%
           \stepcounter{cbx@inst@iter}}
          {\setcounter{cbx@inst@iter}{0}}%
      \repeat}{}}%
  \csnumgdef{cbx@instcount@\cbx@key}{\value{instcount}}}
\let\cbx@savelist\@empty
\newcounter{cbx@inst@iter}
\newcounter{cbx@inst@lastonpage}
\setcounter{cbx@inst@lastonpage}{0}

\newrobustcmd*{\cbx@superscript}[1]{%
  \global\toggletrue{cbx@sfcite}
  \mkbibsuperscript{#1}%
  \cbx@footnote%
  \global\togglefalse{cbx@sfcite}}
\newtoggle{cbx@sfcite}

\AtEveryCitekey{%
  \ifciteseen{}{\csnumgdef{cbx@instcount@\thefield{entrykey}}{-1}}%
  \iftoggle{cbx@sfcite}{}{\cbx@footnote}}
\AtEveryBibitem{\cbx@footnote}
\AtEveryLositem{\cbx@footnote}

% defer citation footnotes to last inline reference instance on page
\newrobustcmd*{\cbx@footnote}{%
  \ifboolexpr{ not test {\ifdefempty{\cbx@savelist}}
               and test {\ifnumequal{\value{instcount}}{\value{cbx@inst@lastonpage}}} }
    {\cbx@sortlist@init%
     \let\do\cbx@do
     \dolistloop{\cbx@sortlist}%
     \global\let\cbx@savelist\@empty
     \setcounter{cbx@inst@lastonpage}{0}}{}}

% print footnotes in 'sorting' order
\def\cbx@do#1{%
  \ifinlist{#1}{\cbx@savelist}
    {\begingroup
     \blx@resetdata
     \blx@getrefcontext{#1}%
     \blx@getdata@cite{#1}%
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \blx@execute
     \blx@beglang
     \iffieldundef{shorthand}
       {\gdef\@thefnmark{\printfield{labelprefix}\printfield{labelnumber}}}
       {\gdef\@thefnmark{\printfield{shorthand}}}%
     \gappto\@thefnmark{\blx@initunit}%
     \ifhyperref
       {\H@@footnotetext{\blx@driver\abx@field@entrytype}}
       {\@footnotetext{\blx@driver\abx@field@entrytype}}%
     \blx@endlang
     \endgroup}
    {}}

% access internal list of sorted entry keys
\def\cbx@sortlist@init{%
  \global\letcs{\cbx@sortlist}
    {blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}
\let\cbx@sortlist\@empty
\makeatother

\addbibresource{biblatex-examples.bib}
\AtEveryCitekey{\clearfield{url}}

\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
\null\vfill\noindent
New citation.\sfcite{companion}
New and recurrent citations.\sfcite{kant:ku,companion}
Vanilla footnote with citation.\footnote{Following \textcite{companion}...}
\clearpage
\null\vfill\noindent
New citation.\sfcite{ctan}
Recurrent citations from previous and current pages.\sfcite{companion,ctan}
\clearpage
\printbibliography
\end{document}

任何帮助都将不胜感激,因为我的论文截止日期不远了……

答案1

能够自己解决:

您必须添加以和之间\iffieldundef{url}{}{\clearfield{url}}开头的块。\def\cbx@do#1{\printfield{shorthand}}}\gappto\@thefnmark

工作区块:

% print footnotes in 'sorting' order
\def\cbx@do#1{%
  \ifinlist{#1}{\cbx@savelist}
    {\begingroup
     \blx@resetdata
     \blx@getrefcontext{#1}%
     \blx@getdata@cite{#1}%
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \blx@execute
     \blx@beglang
     \iffieldundef{shorthand}
       {\gdef\@thefnmark{\printfield{labelprefix}\printfield{labelnumber}}}
       {\gdef\@thefnmark{\printfield{shorthand}}}%
    \iffieldundef{url}{}{\clearfield{url}}%
    \iffieldundef{doi}{}{\clearfield{doi}}%
     \gappto\@thefnmark{\blx@initunit}%
     \ifhyperref
       {\H@@footnotetext{\blx@driver\abx@field@entrytype}}
       {\@footnotetext{\blx@driver\abx@field@entrytype}}%
     \blx@endlang
     \endgroup}
    {}}

相关内容