#37 \citeauthor and \citeyear not recognised as citation command

v1.0 (example)
closed-invalid
nobody
5
2013-10-09
2012-04-26
Anonymous
No

This is mostly a problem with the tex ftplugin, I think: if I type \citeyear{citation_99}, then only the first five characters are correctly hilighted - the remainder are not hilighted, and the underscores in the citation key show up with error hilighting.

Discussion

  • Ted Pavlic

    Ted Pavlic - 2012-04-26

    I agree that that bug is annoying. However, it is a problem with the syntax/tex.vim that comes bundled with vim. The macros that you refer to are generally associated with natbib, and the syntax file that comes bundled with vim is coloring the bare minimum of macros (so \cite, \citet, and \citep).

    You should try your request with the folks who maintain the Vim distribution.

     
  • Jose Christian

    Jose Christian - 2012-08-11

    I added

    syn match texRefZone '\\citeauthor\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
    syn match texRefZone '\\citeyear\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite

    to the usr/share/vim/.../syntax/tex.vim file. It is a problem with the vim bundle rather than vim-latex

     
  • Ted Pavlic

    Ted Pavlic - 2012-08-11

    @jose187 -- That would catch weird things like \citeauthort and \citeauthorp as well. And your changes will be blown away if you ever update your Vim.

    A better(?) solution is to add:

    " For natbib and others
    syn match texRefZone '\\shortcite\%(\*\=\)\=' nextgroup=texRefOption,texCite
    syn match texRefZone '\\citeauthor\%(\*\=\)\=' nextgroup=texRefOption,texCite
    syn match texRefZone '\\citeyear\%(\*\=\)\=' nextgroup=texRefOption,texCite
    syn match texRefZone '\\citeyearpar\%(\*\=\)\=' nextgroup=texRefOption,texCite

    to your own

    ~/.vim/after/syntax/tex.vim

    where ~ is your home directory. In general, if you can find your *personal* entry of your runtimepath, then you can add (or augment) to a file "after/syntax/tex.vim" (without the quotes) under that folder. To find your personal rtp, try (in vim):

    :set rtp?

    The first entry is likely the one you want.

     
  • naught101

    naught101 - 2012-09-17

    Hrm... I tried as you suggested, tpavlic, but I get this:

    Error detected while processing /home/naught101/.vim/after/syntax/tex.vim:
    line 3:
    E492: Not an editor command: nextgroup=texRefOption,texCite
    line 5:
    E492: Not an editor command: nextgroup=texRefOption,texCite
    line 7:
    E492: Not an editor command: nextgroup=texRefOption,texCite
    line 9:
    E492: Not an editor command: nextgroup=texRefOption,texCite

     
  • Ted Pavlic

    Ted Pavlic - 2012-09-17

    @naught101 - That's because you wrapped the lines incorrectly. Each nextgroup is supposed to be on the end of the line before it, separated with a space instead of a new line. So the syntax addition should have four non-commented lines total.

     
  • Till Maas

    Till Maas - 2013-10-09
    • status: open --> closed-invalid
    • Group: --> v1.0 (example)
     

Log in to post a comment.