Sign up ×
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 now have a 200 page document and have used \ref and \label very frequently. I was wondering if it is possible to use LaTeX to create a table at the start of the document with the "top ten" most internally referenced sections/figures/tables/pages of the document? This would be interesting for me as author but also hopefully interesting for the reader also - e.g. identifying the key parts of the document to read.

No idea if LaTeX is able to do this or not?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

I don't think there is an already made solution with LaTeX for this. If you are using linux, usual command line utilities can be used for that. For example:


sort the output of the pipe:

  grep -o ref\{[[:graph:]]*\} file.tex | sort |uniq -c | sort -nr

Original answer

  grep -o ref\{[[:graph:]]*\} file.tex | sort |uniq -c

gives the following output in a small tex file:

      2 ref{fig:constant-equipartition}
      1 ref{fig:current-match}
      1 ref{fig:hoffman-currents}
      1 ref{fig:hoffman-ratios}
      2 ref{fig:phase-advance}
      1 ref{fig:phase-law}
share|improve this answer
any answer that gets a grep pipeline onto must be worth a vote or two:-) (you could add another (numeric) sort to the end to make the list be in order of most used first.) – David Carlisle Nov 13 '12 at 12:55
Thanks for this, i'd still love to see it done in tex though ;) – GreyCloud Nov 28 '12 at 13:56

Your Answer


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.