# Biblatex - how to count entries in a .bib file without invoking \printbibliography

I have three .bib files with the bibliography of my CV split into "journals", "conferences" and "thesis". I count the amount of entries for each .bib file following this method for the three types:

\newtotcounter{no_journals}

\AtEveryBibitem{
\ifkeyword{journal}{\stepcounter{no_journals}}{}%
}



... and thenn I print the result in a specific section as follows:

\begin{refsection}[journals.bib]
\nocite{*}
\begin{refcontext}
\printbibliography
\end{refcontext}
\end{refsection}

\begin{itemize}
\item Number of International Journals: \total{no_journals}\
\end{itemize}


For my long CV it works fine; however for the résumé, I only want to put the total amount of journals, conferences and thesis WITHOUT printing the full bibliography. For this purpose, I have the following command:

\begin{refsection}[journals.bib]
\nocite{*}
\begin{refcontext}
\printbibliography
\end{refcontext}
\end{refsection}

\begin{itemize}
\item International Journals: \total{no_journals}\, International Conferences: \total{no_conferences}\, Thesis Conducted: \total{no_thesis}\
\end{itemize}


As you can see in the command itself, if I do not invoke "\printbibliography" for each of the types (journals, conferences and thesis), the entries in the bibliography files are not counted.

• Is there any way in which I can count them without invoking "\printbibliography"?
• If there is no other chance than having to invoke "\printbibliography" mandatory, can I make it not print the bibliography? Like a "dry-run" method?
• Without testing: \setbox0\vbox{\printbibliography} doesn't print anything and still evaluates \printbibliography. – Skillmon Dec 2 '17 at 23:00
• Please make your code snippets compilable ... – Mensch Dec 2 '17 at 23:03
• @Skillmon : that answer is correct, it works. Would you please post this as an answer, so that I can mark it right? – Ricardo Dec 2 '17 at 23:23

To execute some code without printing it you can execute it in a \setbox, this stores the result in the used box, so \setbox0 stores the results in box register 0 (which is a scratch register for temporary use). It also requires the type of box where we choose \vbox because this allows more stuff than \hbox to be its content. So to use \printbibliography without typesetting it, you can use:

\setbox0\vbox{\printbibliography}


If the entries are \nocite'd or \cite'd you can use \AtDataInput instead of \AtEveryBibitem

\documentclass{article}
\usepackage{biblatex}

\newcounter{no_journals}
\newcounter{no_conferences}
\newcounter{no_thesis}

\AtDataInput{%
\ifentrytype{article}
{\stepcounter{no_journals}}
{\ifentrytype{inproceedings}
{\stepcounter{no_conferences}}
{\ifentrytype{thesis}
{\stepcounter{no_thesis}}
{}}}}

\begin{document}
\nocite{sigfridsson,worman,baez/article,geer}

journals: \arabic{no_journals}, theses: \arabic{no_thesis}
\end{document}


\AtDataInput is executed once per refsection for every entry in the .bbl when the .bbl file is read. \AtEveryBibitem is executed for every item printed in \printbibliography.