0

Sorry for the bad English. I am using biblatex-gost (+biber) in my project. I need to count the number of references to literature in the document. What command can I use to do this?

Here is the structure of the document:

% !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}

Here is a sample content of the abstract, where "????" should count the number of literary sources:

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

When using BibTeX, I used the following construction:

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

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

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

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

And got the number of sources by the command \ref{lastref}.

This document should yield 58 sources:

1
0

If you want to count all citations in the abstract, you could do something like the following. It actually counts all citations, but if you print the value at the end of the abstract and there are no citations before the abstract, you get the number of cites in the abstract. (If there are citations before the abstract, reset the counter at the beginning of the abstract.)

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

If you only want to count unique citations, add an \ifciteseen. Again, this assumes that there were no citations before the abstract.

\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}
3
  • I explained incorrectly.The abstract is a separate file, which I import with the input command. I need to count references throughout the document to correctly generate information on the document: the number of pages, the number of figures and tables and the number of references.
    – Mr_B00k
    Sep 29 '21 at 4:49
  • @Mr_B00k Mhhh, I still don't understand. Maybe you can edit your question and explain what you need and your setup in more detail together with a short example document.
    – moewe
    Sep 29 '21 at 5:12
  • added information about the problem
    – Mr_B00k
    Sep 29 '21 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.