π 2013-Mar-14 ⬩ βοΈ Ashwin Nanjappa ⬩ π·οΈ ctags, latex, tagbar, vim ⬩ π Archive
Problem
Tagbar is a useful plugin for Vim that displays tags of a source file ordered by theirΒ scope in a split window. However, if you open a LaTeX file in Vim, the Tagbar shows its chapters, sections and paragraphs correctly but they are not ordered by scope. Instead, all the chapters appear together, all the sections together and so on.
Solution
This is not a problem with Tagbar, but with the ctags program which is used by Tagbar to generate the tags. As of this writing, the ctags that ships with Ubuntu 12.04 LTS is a really old version that does not generate scope information for the tags of a LaTeX file. Thankfully, the tag scope feature for LaTeX files has been added to the main branch of ctags in 2012. Getting Tagbar to use the new version of ctags is easy:
Uninstall the exuberant-ctags package from your Ubuntu system.
Get the latest source code of ctags from either their SVN repository or this Github mirror. (The other Github clones of ctags source code do not seem to have this LaTeX fix.)
Compile ctags by using these commands:
$ autoheader
$ autoconf
$ ./configure
$ make
$ sudo make install
Now open the LaTeX file in Ubuntu and its tags should be displayed with correct scoping in Tagbar.
Tried with: Ubuntu 12.04 LTS