It happens quite frequently, that I keep hopping around in my LaTeX file to find the correct label for the \ref I want to use. That is especially annoying if the figure/section/equation that ought to be referenced is far up. And yes, I normally try to use sensible names for the labels, but the 'guess-try-fix' way gets rather annoying if doing it more than once per hour. But since I anyway use a Makefile to do the latex/bibtexing for me, there should be fancy way to just add a new target that will show me the correct tag, right?
Right! And it only took me ten minutes to come up with the right combination of tools to do what I want. I actually settled for getting a list of all labels. So for further reference, this does it:
showlabels:
@grep -n -e ' *\\label' ahf.content.tex \
| sed -e 's/\([0-9]*\):.*\\label{\([a-z]\+\):\([a-z|_|A-Z|0-9]*\)}.*/\2 (\1) \2:\3/' \
| sort -k1,1 -s | awk '{print $$2"\t"$$3}'
That will first grep for every \label occurence (and give the line number) and my tex file. Then the grep output is parsed and out in compressed form. Namely I don't want the whole line in which the label occurs, I just want the label name. Finally it needs to go through a sorting step (five minutes spent on the -k1,1) before doing the final output formatting. And it produces a list like this (just showing a few lines):
...
(611) fig:scaling_refref
(43) sec:introduction
(63) sec:halo_finding
(170) sec:testing
..
(194) tab:simulations
...
The first column gives the line number of the \label thing. Turned out to be a useful information to have. Oh, and this works because I use the structure \label{TYPE:NAME} for my labels, so I can order by TYPE and suborder by line number.
Neat. Really neat. And now tell me that this is horribly complicated and this should be done completely different :)
PS: And one fine day I will figure out how to make s9y do proper formatting of entries. Slightly annoying, actually, but not annoying enough yet.