vimlatexctagstagbar

use regex vim with tagbar to get filename of graphic in latex


I'm using vim and tagbar to write my latex files. In the latex source, the input for a graphic look like this:

\includegraphics[width=0.70\textwidth]{../../figures/mechanical_diffusion/plate_hole/plate_hole_fem_elas_cd_map}

I would like to get in tagbar only the filename, in this case, "plate_hole_fem_elas_cd_map". I created a .ctags in my home, which has the following line (modified from the original line found in tagbar documentation):

--regex-latex=/^[\t]*\\includegraphics[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{[\.{2}\/]*[[a-zA-Z0-9_]+\/]*([^}]+)\}/\3/g,graphic+listing/

But I cannot get only the file name. I tried other things, but sometimes I only remove the "../", sometimes I get only "plate_hole".. What did I do wrong ?

Thanks


Solution

  • Your regular expression is incorrect, you can't use character classes like that. This one worked for me:

    --regex-latex=/^[\t]*\\includegraphics[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+\/)?([^}\/]+)\}/\4/g,graphic+listing/