Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6596019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:01:03+00:00 2026-05-25T18:01:03+00:00

In LaTeX, a section looks like: \section{Section Title} I would like to highlight such

  • 0

In LaTeX, a section looks like:

\section{Section Title}

I would like to highlight such sections, or section titles. I tried to put the following in ~/.vim/bundle/latexrc/after/syntax/tex.vim:

syn match texSectioning "\\section\>" skipwhite nextgroup=texSectioningTitle
syn region texSectioningTitle       contained matchgroup=Delimiter start='{'    end='}' contains=@texSectioningGroup
syn cluster texSectioningGroup      contains=texMatcher,texComment,texDelimiter

(Note that this kind of syntax is not handled by the default tex.vim syntax file. It only defines “section zones”, which are pretty much worthless for me.)

I then define the following in my color scheme:

hi texSectioning gui=bold guifg=red

And nothing happens; that is, section titles do not appear in red in my LaTeX code (even after I reloaded the file completely).

I am totally confused as to how vim’s syntax work, and how to debug it.

Edit
Some more information: it sometimes works and sometimes not. Completely unpredictable. What could be the problem? Pathogen? Something else? I’m completely puzzled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:01:03+00:00Added an answer on May 25, 2026 at 6:01 pm

    Here is the answer: the tex.vim divides the text in zones, in which the syntax must be explicitly allowed. The key element is that command:

    syn cluster texChapterGroup contains=@texSectioningGroup
    

    This says to vim that inside a texChapterGroup, the syntax cluster texSectioningGroup is allowed. The next thing to do is simply to define that cluster as usual.

    Another detail is that the region texSectioningTitle must be contained, otherwise it will match arbitrary pairs of {} in LaTeX.

    So a complete solution goes like this:

    syn match texSectioningCommand '\\section\>' skipwhite     nextgroup=texSectioningTitle contains=@texSectioningGroup
    syn region texSectioningTitle        start='{'  end='}' contained
    syn cluster texSectioningGroup contains=texSectioningCommand
    syn cluster texChapterGroup contains=@texSectioningGroup
    

    Edit Here is why the behaviour was apparently unpredictable: vim does not read the entire file to figure out the syntax. So in a big enough chapter, my section syntax would work because vim did not go far enough to see it was in a chapter zone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title section of my LaTeX documents usually look like \title{Title} \author{Me} %\date{} %//
I'm trying to typeset something in LaTeX and I would like to know if
I have the following Latex environment: \newcounter{txtctr}[section] \setcounter{txtctr}{0} \newenvironment{textex}{% This is the begin code
I'm trying to change how section numbering is displayed in a Latex document I'm
The latex file is giving the following error: ! LaTeX Error: File `datetime.sty' not
the following latex input: \rule{1cm}{1cm}\\ \rule{1cm}{1cm} leaves a gap of about .35mm between the
I'm working through NerdDinner and I'm a bit confused about the following section... First
My repository looks like this: trunk doc src etc... I want to grab the
Assume I have some sections within my latex-beamer presentation. Some of these sections contain
I can't seem to find examples of how to fold LaTeX documents by section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.