tags for latex labels

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

tags for latex labels

Lukas Ruf
Dear all,

I've got to love 'ctags' and the way vim handles them!  That's why I
would like to make use of the analogous functionality for LaTeX files.

Is there any simple tool that I can just run over all my latex files
and the tool generates a tags file of '\label{}' definitions?

I'm using vim (VIM - Vi IMproved 6.3 (2004 June 7, compiled
Sep 1 2005 16:55:29)) on a Debian unstable system.

First, I hoped that ctags provides support for latex.  However, the
version installed (Exuberant Ctags 5.5.4, Copyright (C) 1996-2003
Darren Hiebert Compiled: Mar 30 2004, 11:26:12) doesn't.

Can anyone recommend an 'ltags' tool?

Thanks!

wbr,
Lukas
--
Lukas Ruf   <http://www.lpr.ch> | Ad Personam
rbacs      <http://wiki.lpr.ch> | Restaurants, Bars and Clubs
Raw IP   <http://www.rawip.org> | Low Level Network Programming
Style  <http://email.rawip.org> | How to write emails
Reply | Threaded
Open this post in threaded view
|

Re: tags for latex labels

Mikołaj Machowski
Dnia pi?tek, 16 wrze?nia 2005 13:03, Lukas Ruf napisa?:
> Dear all,
>
> I've got to love 'ctags' and the way vim handles them!  That's why I
> would like to make use of the analogous functionality for LaTeX files.
>
> Is there any simple tool that I can just run over all my latex files
> and the tool generates a tags file of '\label{}' definitions?
>
>
--regex-tex=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
--regex-tex=/\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/

m.

Reply | Threaded
Open this post in threaded view
|

Re: tags for latex labels

Michael Naumann
On Friday 16 September 2005 15:47, Mikolaj Machowski wrote:

> Dnia pi?tek, 16 wrze?nia 2005 13:03, Lukas Ruf napisa?:
> > Dear all,
> >
> > I've got to love 'ctags' and the way vim handles them!  That's why I
> > would like to make use of the analogous functionality for LaTeX files.
> >
> > Is there any simple tool that I can just run over all my latex files
> > and the tool generates a tags file of '\label{}' definitions?
> >
> >
> --regex-tex=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
> --regex-tex=/\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/
>
> m.
>
>

What Mikolaj refers to is ~/.ctags

Put his two lines in this file.

you probably also want the following two too:

--langdef=tex
--langmap=tex:.tex

Then run ctags over your .tex-files

HTH, Michael

Reply | Threaded
Open this post in threaded view
|

Re: tags for latex labels

Lukas Ruf
In reply to this post by Lukas Ruf
> Ajit Thakkar <[hidden email]> [2005-09-16 13:35]:
>
thanks for your answer!

> On 9/16/05, Lukas Ruf <[hidden email]> wrote:
> >
> >
> > Is there any simple tool that I can just run over all my latex
> > files and the tool generates a tags file of '\label{}'
> > definitions?
> >
> > Can anyone recommend an 'ltags' tool?
>
>
> See http://www.unb.ca/chem/ajit/vim.htm for a modified ctags that
> does what you want for both LaTeX and BibTeX files.
>
cool stuff!

I downloaded it and fixed a problem of the code which gcc
((GCC) 4.0.2 20050913) complained about with the regular expression
definition in latex.c at my site:

latex.c:22:2: warning: unknown escape sequence '\}'
latex.c:26:2: warning: unknown escape sequence '\}'
latex.c:29:2: warning: unknown escape sequence '\}'
latex.c:32:2: warning: unknown escape sequence '\}'

I adjusted the regexps accordingly in bibtex.c.

I checked my fixes with a large set of latex and bibtex files -- and
it seems to work perfectly!  If anyone finds improvements, please me
know.

Please find attached two diffs:

  a)ec554src_latex_bibtex.lpr.diff
  b)ctags-5.5.4_lpr.diff

a) fixes the problem mentioned above in your code
b) applies the fixed code in a patch/diff style to ctags-5.5.4.tar.gz

Thanks again for your cool code!

wbr,
Lukas
PS: if you would like to add my fixes to your web-site, they would
  make your code easier applicable to the ctags-5.5.4.tar.gz source
  code.... it took me about 5 minutes until I realized the logic of
  application (I've not read the readme.txt, sorry;).  I appreciate a
  link to my private web-site <http://www.lpr.ch>.
--
Lukas Ruf   <http://www.lpr.ch> | Ad Personam
rbacs      <http://wiki.lpr.ch> | Restaurants, Bars and Clubs
Raw IP   <http://www.rawip.org> | Low Level Network Programming
Style  <http://email.rawip.org> | How to write emails

ctags-5.5.4_lpr.diff (4K) Download Attachment
ec554src_latex_bibtex.lpr.diff (2K) Download Attachment
signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tags for latex labels

Lukas Ruf
In reply to this post by Mikołaj Machowski
> Mikolaj Machowski <[hidden email]> [2005-09-16 15:49]:
>
> --regex-tex=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/
> --regex-tex=/\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/
>

> Michael Naumann <[hidden email]> [2005-09-16 15:58]:
>
> What Mikolaj refers to is ~/.ctags
>
> Put his two lines in this file.
>
> you probably also want the following two too:
>
> --langdef=tex
> --langmap=tex:.tex
>

Mikolaj and Michael, thanks for your replies.  Did I see them
earlier.....

As sent a few seconds ag in <[hidden email]> to
this list, I downloaded the code from Ajit that provides now the
solution for me.

Thanks!

wbr,
Lukas
--
Lukas Ruf   <http://www.lpr.ch> | Ad Personam
rbacs      <http://wiki.lpr.ch> | Restaurants, Bars and Clubs
Raw IP   <http://www.rawip.org> | Low Level Network Programming
Style  <http://email.rawip.org> | How to write emails