Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
I assume references, say you refer three time to the same thing, does this count as one or as three? –  CommuSoft Mar 3 at 14:02
    

3 Answers 3

an alternative with biblatex for simply counting the number of entries in a bibliography is to use \AtEveryBibitem.

\usepackage{totcount}
\newtotcounter{citenum}
\AtEveryBibitem{\stepcounter{citenum}}

for multiple \printbibliography calls the counter can be reset with \AtNextBibliography.

share|improve this answer

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.

share|improve this answer
1  
Does this work for a BibTeX bibliography as well? –  Torbjørn T. Mar 3 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 3 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 3 at 15:36

If you are allowed to perform a shell-escape, when LaTeX uses bibliography, a document.blg file is produced. In this file the following line appears:

...
You've used 8 entries,
...

So you can run

grep -P "You've used [0-9]+ entries," -m 1 "Document.blg" | grep -P "[0-9]+" -o

By using the following document, this number will be printed:

\documentclass{article}
\usepackage{bashful}
\begin{document}
Foo...

\bash[script,stdout]
grep -P "You've used [0-9]+ entries," -m 1 "Document.blg" | grep -P "[0-9]+" -o
\END
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
http://tex.stackexchange.com/questions/163451/total-number-of-citations?answertab=active
tex.stackexchange.com
crawl=CC-MAIN-2014-52
80199
application/http; msgtype=response
sha1:Q42RSHUFTMR4WVZG2FUG64XDH42KOKMH
<urn:uuid:9955aa2c-17f4-4925-9bba-43ef0f9eb789>
2014-12-21T11:42:35Z
198.252.206.140
sha1:CVARIWLTAY4ZJDLP3GY7QSO453K374R7
<urn:uuid:c67f3c5d-105e-457f-9eab-aaf5b48b5361>
http://tex.stackexchange.com/questions/163451/total-number-of-citations?answertab=active
response
<urn:uuid:c3a09969-3bd4-4336-b771-8e5236e66968>
robots: classic
hostname: ip-10-231-17-201.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2014-52
operator: CommonCrawl Admin
description: Wide crawl of the web with URLs provided by Blekko for December 2014
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf