20

I am trying find an easy way to get the total number of citations in my thesis (in the final document - not in my Libary.bib file!). I know that I can use \citenum{last_entry} to get the number of the last entry, but in case there is a new entry added later, this doesn't give me the total number of citations anymore. I found the package \usepackage{totcount} helpful, because it give you a super easy way to get the total number of figures, tables, etc.

My questions is: Is there a similar command for the total number of citations? I searched quite a bit, but didn't find anything helpful.

Just in case this info is needed - I use a numeric output such as:

[1] P. Drude, Physikal. Zeitschr. 1, 161 (1900)

Example of how I currently use the package totcount for the total number of figures, tables:

\documentclass{book}
\usepackage{totcount}
\newtotcounter{bibitems}
\newtotcounter{figure}
\regtotcounter{table}

\begin{document}
The total number of figures is \total{figure}, and the total number of tables is \total{table}.



\begin{figure}
[...]
\end{figure}

\begin{figure}
[...]
\end{figure}



\begin{table}
[...]
\end{end}

\begin{table}
[...]
\end{end}

\end{document}
Philipp
  • 463

3 Answers3

13

You can do this using the totcount package.

\documentclass{article}
\usepackage{totcount}

\newtotcounter{citnum} %From the package documentation
\def\oldbibitem{} \let\oldbibitem=\bibitem
\def\bibitem{\stepcounter{citnum}\oldbibitem}

\begin{document}
This document contains \total{citnum}\ references.

\cite{Martin06} \cite{Fortran2008}

\begin{thebibliography}{1}

\bibitem{Martin06}
P.~A. Martin.
\newblock {\em Multiple Scattering. {Interaction} of Time-Harmonic Waves with
  {$N$} Obstacles}.
\newblock Cambridge University Press, 2006.

\bibitem{Fortran2008}
Fortran standards technical~committee (J3).
\newblock Fortran 2008 language standard.
\newblock Technical Report J3/10-007, International Committee for Information
  Technology Standards (INCITS), 2010.

\end{thebibliography}
\end{document}

Note that this works for bibtex bibliographies as well; I included the bibliography environment to make the example as simple as possible.

Ian Thompson
  • 43,767
  • 1
    Does this work for a BibTeX bibliography as well? – Torbjørn T. Mar 03 '14 at 14:27
  • 1
    @TorbjørnT. --- Yes. I just included the bibliography environment to make the example as simple as possible. I'll edit the answer. – Ian Thompson Mar 03 '14 at 14:43
  • Aha! @IanThompson I was a that point already. But the number returned was always "0". Turned out that I adding \newtotcounter{citnum} etc. to the style file is not a good idea! Added to the header works great! Thx though! – Philipp Mar 03 '14 at 15:36
  • 1: the perfect solution!
  • – Leos313 Apr 14 '20 at 10:48