Text Formattingciteasnoun highlighting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Captain Lightning
Posts: 2
Joined: Mon Nov 29, 2010 7:33 pm

citeasnoun highlighting

Post by Captain Lightning »

Hello all,

I am a very new user sorry, here goes....

I am using latex on vim in linux (actually gvim), and I have a syntax highlighting problem:

when write \citeasnoun{thecitation} only the portion of it 'cite' is highlighted.

whereas I would like it to behave the same way as \cite{thecitation} where the entire term is highlighted.

Has anyone come across this before?

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

citeasnoun highlighting

Post by frabjous »

This is based largely on guesswork but seems to work for me. (I should note that I'm not using the vim-LaTeX suite plugin, so I hope that isn't involved here.)

First, make a personal copy of the tex.vim syntax highlighting file. For me, this involved the following commands from the terminal.

Code: Select all

mkdir -p $HOME/.vim/syntax
cp /usr/share/vim/vim73/syntax/tex.vim $HOME/.vim/syntax/tex.vim
You may need to check the exact path to tex.vim, which may vary by distribution, and certainly varies by vim version. (I'm using 7.3 on Arch Linux.)

Now edit the file you just created ($HOME/.vim/syntax/tex.vim) and look for the line:

Code: Select all

syn match  texRefZone		'\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
And a line just under it, just like it but with \\citeasnoun in place of \\cite

Code: Select all

syn match  texRefZone		'\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
syn match  texRefZone		'\\citeasnoun\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
(I'm sure there's a way to do it on a single like with vim's regex patterns, but I'm too lazy to figure it out right now.)

Save and you should be all set. (Fingers crossed.)
Captain Lightning
Posts: 2
Joined: Mon Nov 29, 2010 7:33 pm

Re: citeasnoun highlighting

Post by Captain Lightning »

Perfect thanks, I was previously attempting a similar process in the latex-suite without any luck.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

citeasnoun highlighting

Post by localghost »

Now that the problem is solved, please be so kind and mark the topic (not the last post) accordingly as clearly written in the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminder will not be necessary.


Best regards and welcome to the board
Thorsten
Post Reply