LaTeX、biblatex、计数文献参考文献

LaTeX、biblatex、计数文献参考文献

抱歉我的英语不好。我正在biblatex-gost (+biber)我的项目中使用它。我需要计算文档中引用文献的数量。我可以使用什么命令来执行此操作?

该文件的结构如下:

% !TEX encoding = UTF-8
% !TEX program = lualatex
% !TEX TS-program = lualatex

\documentclass[a4paper,14pt, oneside]{extarticle}
\input{style/NIRS_3_1.sty}

\makeatletter 
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}} 
\makeatother

\setcounter{page}{4}

\usepackage[xindy={glsnumbers=false}, nonumberlist, nopostdot, nogroupskip, toc, translate=babel, acronym, automake]{glossaries}
\usepackage{glossaries-extra, glossary-longbooktabs}

\makeglossaries

\addto\captionsrussian{%
    \renewcommand*{\glossaryname}{ТЕРМИНЫ И ОПРЕДЕЛЕНИЯ}%
}
\begin{document}
\input{parts/Referat.tex} % This file contains general information about the document: an abstract, how many tables, figures, and how many references

\renewcommand{\contentsname}{\normalsize\bfseries\centering СОДЕРЖАНИЕ}

\tableofcontents
\normalsize
\newpage
    
\input{parts/Glossary.tex}
\input{parts/Acronims.tex}
\input{parts/01_Intro.tex}
\input{parts/02_Bio_sys.tex}
\input{parts/03_Bio_devices.tex}
\input{parts/04_Bio_atak.tex}
\input{parts/05_Outro.tex}

\newpage
\makeatletter

\addcontentsline{toc}{section}{СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ} 
\makeatother

\printbibliography[title={СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ}]


\end{document}

以下是摘要的示例内容,其中“????”应计算文献来源的数量:

\section*{РЕФЕРАТ}
%\thispagestyle{empty}
        \begin{center}
            Отчёт на \pageref{LastPage} с., \totalfigures\ рис., \totaltables\ табл., ??????? ист., Х прил.\\
            
            \textbf{ИНФОРМАЦИОННАЯ БЕЗОПАСНОСТЬ},\\
            \textbf{БИОМЕТРИЯ}, \textbf{БИОМЕТРИЧЕСКОЕ ПРЕДЪЯВЛЕНИЕ},\\
            \textbf{ИНСТРУМЕНТ АТАКИ}, \textbf{АРТЕФАКТ}
     \end{center}       
\pagebreak

使用 BibTeX 时,我使用了以下构造:

%%%%%%%%%%%%%%%% Подсчёт количества источников  литературы для реферата %%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{numrefs}

\let\bibtemorig=\bibtem
\def\bibtem{\refstepcounter{numrefs}\bibtemorig}

\let\thebibliographyorig=\thebibliography
\let\endthebibliographyorig=\endthebibliography

\renewenvironment{thebibliography}{\thebibliographyorig}{\label{lastref}\endthebibliographyorig}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

并通过命令获取源的数量\ref{lastref}

本文件应提供 58 个来源:

答案1

如果您想计算摘要中的所有引用,可以执行以下操作。它实际上会计算所有引用,但如果您在摘要末尾打印该值,并且摘要之前没有引用,则会获得摘要中的引用次数。(如果摘要之前有引用,请在摘要开头重置计数器。)

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

\usepackage[backend=biber, style=gost-numeric, citetracker]{biblatex}

\newcounter{abstractcites}
\AtEveryCitekey{%
  \ifbool{citetracker}
    {\stepcounter{abstractcites}}
    {}%
}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{abstract}
Lorem \autocite{sigfridsson}
ipsum \autocite{nussbaum,sigfridsson}

\theabstractcites{} citation(s) in abstract
\end{abstract}

Ipsum dolor \autocite{worman}
sit \autocite{sigfridsson}

\printbibliography
\end{document}

如果您只想计算唯一引用,请添加\ifciteseen。同样,这假设摘要之前没有引用。

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

\usepackage[backend=biber, style=gost-numeric, citetracker]{biblatex}

\newcounter{abstractcites}
\AtEveryCitekey{%
  \ifbool{citetracker}
    {\ifciteseen{}{\stepcounter{abstractcites}}}
    {}%
}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{abstract}
Lorem \autocite{sigfridsson}
ipsum \autocite{nussbaum,sigfridsson}

\theabstractcites{} citation(s) in abstract
\end{abstract}

Ipsum dolor \autocite{worman}
sit \autocite{sigfridsson}

\printbibliography
\end{document}

相关内容