Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create tags file for latex for labels and bib items

Tags:

vim

latex

ctags

I'm using ctags to create a tags file for use in Vim, so that I can jump to definitions of labels and citations. However, I have two problems:

  1. ctags includes \ref in the tags file, so when I hit jump on a \ref label, I don't necessarily jump to the definition of the label, but might end up on another reference to that label.
  2. I'd like to be able to jump to the corresponding entry in a .bib file from a \cite command, but ctags doesn't generate entries for that (I'm using ctags *.tex *.bib).

I wanted to redefine ctags's definition for tex files, so that I could remove \ref entries, but that didn't work.

My ~/.ctags file:

--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
like image 558
daniel kullmann Avatar asked Nov 14 '11 09:11

daniel kullmann


1 Answers

I realised that I didn't use exuberant ctags, but another ctags program, so the content in ~/.ctags was never used.

I also managed to add another entry in ~/.ctags for bib entries:

--langdef=tex2
--langmap=tex2:.tex
--regex-tex2=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/

--langdef=bib
--langmap=bib:.bib
--regex-bib=/^@[A-Za-z]+\{([^,]*)/\1/b,bib/

ctags *.tex *.bib works now as I want it.

like image 164
daniel kullmann Avatar answered Oct 14 '22 18:10

daniel kullmann