使用 biblatex 时,如何在参考书目中显示第 ... 页上的未引用和被引用 i 次?

使用 biblatex 时,如何在参考书目中显示第 ... 页上的未引用和被引用 i 次?

关于这个问题格式化参考书目中的反向引用 [BibTeX]我学习了如何使用以下包对 bibtex 进行此操作backref

\usepackage[pagebackref=true]{hyperref}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]
{
    \ifcase #1
        No citation in the text.
    \or
        Cited on page #2.
    \else
        Cited #1 times on pages #2.
    \fi
}

例子:

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex
\RequirePackage{filecontents}

\begin{filecontents*}{references.bib}
@mvbook{assis08,
    author = {Machado de Assis},
    title = {Obra completa em quatro volumes},
    year = {2008},
    editor = {Aluizio Leite and Ana Lima Cecilio and Heloisa Jahn},
    editortype = {organizer},
    edition = {2},
    volumes = {4},
    publisher = {Nova Fronteira},
    location = {Rio de Janeiro},
    series = {Biblioteca luso-brasileira. Série brasileira}
}

@book{koma-scrguien,
  author = {Markus Kohm},
  edition = {2017-04-13},
  howpublished = {\url{http://mirrors.ibiblio.org/CTAN/.../scrguien.pdf}},
  publisher = {Online Material; \url{https://www.ctan.org/pkg/koma-script}},
  title = {The Guide KOMA -Script},
  urlaccessdate = {2017-08-28},
  year = {2017}
}
\end{filecontents*}


% How to make \PassOptionsToPackage add the option as the last option?
% https://tex.stackexchange.com/questions/385895/how-to-make
\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass{abntex2}

% An alternative to utf8 and arabtex under memoir documentclass
% https://tex.stackexchange.com/questions/42566/an-alternative-to-utf8-and-arabtex
\makeatletter
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\makeatother

% backreferencing in classicthesis package does not work
% https://tex.stackexchange.com/questions/115828/backreferencing-in-classicthesis
\usepackage[english,hyperpageref]{backref}

% Citação alfabética por autor-data [alf]
\usepackage[alf]{abntex2cite}

% Package hyperref Warning: Token not allowed in a PDF string?
% https://tex.stackexchange.com/questions/384885/package-hyperref
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% Package biblatex Warning: 'babel/polyglossia' detected but 'csquotes' missing
% https://tex.stackexchange.com/questions/229638/package-biblatex-warning
\usepackage{csquotes}

% Default text before page number
\renewcommand{\backref}{}
\renewcommand{\backrefpagesname}{Cited on page(s):~}

% Sets the text of the citation
\renewcommand*{\backrefalt}[4]
{
    \ifcase #1
        No citation in the text.
    \or
        Cited on page #2.
    \else
        Cited #1 times on pages #2.
    \fi
}

\begin{document}

    Citing \cite{koma-scrguien}, \newpage Citing again \cite{koma-scrguien},

    % \nocite{*}
    \bibliography{references}

\end{document}

在此处输入图片描述

然而现在我开始biblatex寻找最先进的书目包,但我不知道该怎么做。现在的问题格式化参考书目中的反向引用我可以做到:

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

但是当没有引用参考书目时,我得不到任何文字说明Not cited或说明Cited #1 times on pages #2

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex
\RequirePackage{filecontents}

\begin{filecontents*}{references.bib}
@mvbook{assis08,
    author = {Machado de Assis},
    title = {Obra completa em quatro volumes},
    year = {2008},
    editor = {Aluizio Leite and Ana Lima Cecilio and Heloisa Jahn},
    editortype = {organizer},
    edition = {2},
    volumes = {4},
    publisher = {Nova Fronteira},
    location = {Rio de Janeiro},
    series = {Biblioteca luso-brasileira. Série brasileira}
}

@book{koma-scrguien,
  author = {Markus Kohm},
  edition = {2017-04-13},
  howpublished = {\url{http://mirrors.ibiblio.org/CTAN/.../scrguien.pdf}},
  publisher = {Online Material; \url{https://www.ctan.org/pkg/koma-script}},
  title = {The Guide KOMA -Script},
  urlaccessdate = {2017-08-28},
  year = {2017}
}
\end{filecontents*}


% How to make \PassOptionsToPackage add the option as the last option?
% https://tex.stackexchange.com/questions/385895/how-to-make
\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass{abntex2}

% Package hyperref Warning: Token not allowed in a PDF string?
% https://tex.stackexchange.com/questions/384885/package-hyperref
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[style=abnt,language=english,backref=true,backend=biber]{biblatex}
\addbibresource{references.bib}

% Package biblatex Warning: 'babel/polyglossia' detected but 'csquotes' missing
% https://tex.stackexchange.com/questions/229638/package-biblatex-warning
\usepackage{csquotes}

% Sets the text of the citation
% \renewcommand*{\backrefalt}[4]
% {
%     \ifcase #1
%         No citation in the text.
%     \or
%         Cited on page #2.
%     \else
%         Cited #1 times on pages #2.
%     \fi
% }

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

\begin{document}

    Citing \cite{koma-scrguien}, \newpage Citing again \cite{koma-scrguien},

    \nocite{*}
    \printbibliography

\end{document}

在此处输入图片描述

答案1

通过该citecounter选项,我们可以查看某个条目被引用的次数,请参阅我可以计算每篇参考文献被引用的次数吗?。我们可以重新定义反向引用的宏以包含此信息

\renewbibmacro*{pageref}{%
  \iflistundef{pageref}
    {\printtext{\autocap{n}ot cited}}
    {\printtext{\autocap{c}ited \arabic{citecounter}~time\ifnumequal{\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},
}

答案2

发布基于的最小示例@moewe答案,注意我们需要将选项传递citecounter=truebiblatex包,否则引用计数器将始终显示0 times cited on pages ...

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex
\RequirePackage{filecontents}

\begin{filecontents*}{references.bib}
@mvbook{assis08,
    author = {Machado de Assis},
    title = {Obra completa em quatro volumes},
    year = {2008},
    editor = {Aluizio Leite and Ana Lima Cecilio and Heloisa Jahn},
    editortype = {organizer},
    edition = {2},
    volumes = {4},
    publisher = {Nova Fronteira},
    location = {Rio de Janeiro},
    series = {Biblioteca luso-brasileira. Série brasileira}
}

@book{koma-scrguien,
  author = {Markus Kohm},
  edition = {2017-04-13},
  howpublished = {\url{http://mirrors.ibiblio.org/CTAN/.../scrguien.pdf}},
  publisher = {Online Material; \url{https://www.ctan.org/pkg/koma-script}},
  title = {The Guide KOMA -Script},
  urlaccessdate = {2017-08-28},
  year = {2017}
}

\end{filecontents*}


% How to make \PassOptionsToPackage add the option as the last option?
% https://tex.stackexchange.com/questions/385895/how-to-make
\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass[10pt,a5paper,twoside,chapter=TITLE,section=TITLE]{abntex2}

% Package hyperref Warning: Token not allowed in a PDF string?
% https://tex.stackexchange.com/questions/384885/package-hyperref
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

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

% Package biblatex Warning: 'babel/polyglossia' detected but 'csquotes' missing
% https://tex.stackexchange.com/questions/229638/package-biblatex-warning
\usepackage{csquotes}

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

    Citing \textcite[p. 47-52 e 135]{koma-scrguien}

    \newpage

    Citing again \cite{koma-scrguien}

    \nocite{*}
    \printbibliography

\end{document}

在此处输入图片描述

相关内容