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?


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}
  • 2
    any answer that gets a grep pipeline onto tex.sx 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.) 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 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.