Biblatex citecounter 不计算图片标题中的参考文献

Biblatex citecounter 不计算图片标题中的参考文献

我在用着答案是打印参考文献被引用的次数。Biblatex“看到”该参考文献在图片标题中被引用,但它不会增加引用计数器。

以下 MWE 将打印在第 1、2 页被引用 1 次

有人知道这是为什么吗?我很感激任何帮助。

\documentclass{report}

\usepackage{filecontents}
\begin{filecontents}{references.bib}
@book{Knuth,
    author = {Knuth, Donald E.},
    title = {The Art of Computer Programming, Volume 1: Fundamental Algorithms},
    year = {1997},
    publisher = {Addison Wesley Longman Publishing Co., Inc.},
} 
\end{filecontents}

\usepackage[english]{babel}

\usepackage[backref=true,backend=biber,citecounter=true]{biblatex}
\addbibresource{references.bib}

\renewbibmacro*{pageref}
{%
    \iflistundef{pageref}
    {\printtext{\autocap{n}o citation in the text.}}
    {
        \printtext{\autocap{c}ited \arabic{citecounter} time\ifnumgreater{\value{citecounter}}{1}{s}{}}%
        \setunit{\addspace}%
        \ifnumgreater{\value{pageref}}{1}
            {\bibstring{backrefpages}\ppspace}
            {\bibstring{backrefpage}\ppspace}%
        \printlist[pageref][-\value{listtotal}]{pageref}
    }
}

\DefineBibliographyStrings{english}
{
    backrefpage  = {on page},
    backrefpages = {on pages},
}

\begin{document}
\cite{Knuth}
\newpage
\begin{figure}
    \caption{\cite{Knuth}}
\end{figure}
\printbibliography
\end{document}

答案1

引用跟踪器(以及引用计数器)在浮动内被禁用,因为浮动存在于正常文本流之外。

biblatex可以通过删除适用于的补丁来重新启用此功能\@floatboxreset

\documentclass{report}
\usepackage[english]{babel}
\usepackage[backref=true,backend=biber,citecounter=true]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\AtBeginDocument{%
  \patchcmd\@floatboxreset
    {\boolfalse{citetracker}%
     \boolfalse{pagetracker}}
    {}
    {}
    {\blx@err@patch{float}}}
\makeatother

\renewbibmacro*{pageref}
{%
    \iflistundef{pageref}
    {\printtext{\autocap{n}o citation in the text.}}
    {
        \printtext{\autocap{c}ited \arabic{citecounter} time\ifnumgreater{\value{citecounter}}{1}{s}{}}%
        \setunit{\addspace}%
        \ifnumgreater{\value{pageref}}{1}
            {\bibstring{backrefpages}\ppspace}
            {\bibstring{backrefpage}\ppspace}%
        \printlist[pageref][-\value{listtotal}]{pageref}
    }
}

\DefineBibliographyStrings{english}{
  backrefpage  = {on page},
  backrefpages = {on pages},
}

\begin{document}
\cite{sigfridsson}
\newpage
\begin{figure}
    \caption{\cite{sigfridsson}}
\end{figure}
\printbibliography
\end{document}

在第 1、2 页被引用 2 次。


由于行为有点令人困惑,我打开了https://github.com/plk/biblatex/issues/916

相关内容