neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

tex.vim (69407B)


      1 " Vim syntax file
      2 " Language:	TeX
      3 " Maintainer:	This runtime file is looking for a new maintainer.
      4 " Former Maintainer: Charles E. Campbell
      5 " Last Change:	Apr 22, 2022
      6 "   2024 Feb 19 by Vim Project: announce adoption
      7 "   2025 Jan 18 by Vim Project: add texEmphStyle to texMatchGroup, #16228
      8 "   2025 Feb 08 by Vim Project: improve macro option, \providecommand, 
      9 "                               \newcommand and \newenvironment #16543
     10 "   2025 Sep 29 by Vim Project: add amsmath support #18433
     11 " Version:	121
     12 " Former URL:	http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
     13 "
     14 " Notes: {{{1
     15 "
     16 " 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
     17 "    use %stopzone.
     18 "
     19 " 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
     20 "    by suitable use of %stopzone.
     21 "
     22 " 3. If you have a slow computer, you may wish to modify
     23 "
     24 "	syn sync maxlines=200
     25 "	syn sync minlines=50
     26 "
     27 "    to values that are more to your liking.
     28 "
     29 " 4. There is no match-syncing for $...$ and $$...$$; hence large
     30 "    equation blocks constructed that way may exhibit syncing problems.
     31 "    (there's no difference between begin/end patterns)
     32 "
     33 " 5. If you have the variable "g:tex_no_error" defined then none of the
     34 "    lexical error-checking will be done.
     35 "
     36 "    ie. let g:tex_no_error=1
     37 "
     38 " 6. Please see  :help latex-syntax  for information on
     39 "      syntax folding           :help tex-folding
     40 "      spell checking           :help tex-nospell
     41 "      commands and mathzones   :help tex-runon
     42 "      new command highlighting :help tex-morecommands
     43 "      error highlighting       :help tex-error
     44 "      new math groups          :help tex-math
     45 "      new styles               :help tex-style
     46 "      using conceal mode       :help tex-conceal
     47 
     48 " Version Clears: {{{1
     49 " quit when a syntax file was already loaded
     50 if exists("b:current_syntax")
     51  finish
     52 endif
     53 let s:keepcpo= &cpo
     54 set cpo&vim
     55 scriptencoding utf-8
     56 
     57 " by default, enable all region-based highlighting
     58 let s:tex_fast= "bcmMprsSvV"
     59 if exists("g:tex_fast")
     60 if type(g:tex_fast) != 1
     61  " g:tex_fast exists and is not a string, so
     62  " turn off all optional region-based highighting
     63  let s:tex_fast= ""
     64 else
     65  let s:tex_fast= g:tex_fast
     66 endif
     67 endif
     68 
     69 " let user determine which classes of concealment will be supported
     70 "   a=accents/ligatures d=delimiters m=math symbols  g=Greek  s=superscripts/subscripts
     71 if !exists("g:tex_conceal")
     72 let s:tex_conceal= 'abdmgsS'
     73 else
     74 let s:tex_conceal= g:tex_conceal
     75 endif
     76 if !exists("g:tex_superscripts")
     77 let s:tex_superscripts= '[0-9a-zA-W.,:;+-<>/()=]'
     78 else
     79 let s:tex_superscripts= g:tex_superscripts
     80 endif
     81 if !exists("g:tex_subscripts")
     82 let s:tex_subscripts= '[0-9aehijklmnoprstuvx,+-/().]'
     83 else
     84 let s:tex_subscripts= g:tex_subscripts
     85 endif
     86 
     87 " Determine whether or not to use "*.sty" mode {{{1
     88 " The user may override the normal determination by setting
     89 "   g:tex_stylish to 1      (for    "*.sty" mode)
     90 "    or to           0 else (normal "*.tex" mode)
     91 " or on a buffer-by-buffer basis with b:tex_stylish
     92 let s:extfname=expand("%:e")
     93 if exists("g:tex_stylish")
     94 let b:tex_stylish= g:tex_stylish
     95 elseif !exists("b:tex_stylish")
     96 if s:extfname == "sty" || s:extfname == "cls" || s:extfname == "clo" || s:extfname == "dtx" || s:extfname == "ltx"
     97  let b:tex_stylish= 1
     98 else
     99  let b:tex_stylish= 0
    100 endif
    101 endif
    102 
    103 " handle folding {{{1
    104 if !exists("g:tex_fold_enabled")
    105 let s:tex_fold_enabled= 0
    106 elseif g:tex_fold_enabled && !has("folding")
    107 let s:tex_fold_enabled= 0
    108 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
    109 else
    110 let s:tex_fold_enabled= 1
    111 endif
    112 if s:tex_fold_enabled && &fdm == "manual"
    113 setl fdm=syntax
    114 endif
    115 if s:tex_fold_enabled && has("folding")
    116 com! -nargs=* TexFold <args> fold
    117 else
    118 com! -nargs=* TexFold <args>
    119 endif
    120 
    121 " (La)TeX keywords: uses the characters 0-9,a-z,A-Z,192-255 only... {{{1
    122 " but _ is the only one that causes problems.
    123 " One may override this iskeyword setting by providing
    124 " g:tex_isk
    125 if exists("g:tex_isk")
    126 if b:tex_stylish && g:tex_isk !~ '@'
    127  let b:tex_isk= '@,'.g:tex_isk
    128 else
    129  let b:tex_isk= g:tex_isk
    130 endif
    131 elseif b:tex_stylish
    132 let b:tex_isk="@,48-57,a-z,A-Z,192-255"
    133 else
    134 let b:tex_isk="48-57,a-z,A-Z,192-255"
    135 endif
    136 if (v:version == 704 && has("patch-7.4.1142")) || v:version > 704
    137 exe "syn iskeyword ".b:tex_isk
    138 else
    139 exe "setl isk=".b:tex_isk
    140 endif
    141 if exists("g:tex_no_error") && g:tex_no_error
    142 let s:tex_no_error= 1
    143 else
    144 let s:tex_no_error= 0
    145 endif
    146 if exists("g:tex_comment_nospell") && g:tex_comment_nospell
    147 let s:tex_comment_nospell= 1
    148 else
    149 let s:tex_comment_nospell= 0
    150 endif
    151 if exists("g:tex_nospell") && g:tex_nospell
    152 let s:tex_nospell = 1
    153 else
    154 let s:tex_nospell = 0
    155 endif
    156 if exists("g:tex_matchcheck")
    157 let s:tex_matchcheck= g:tex_matchcheck
    158 else
    159 let s:tex_matchcheck= '[({[]'
    160 endif
    161 if exists("g:tex_excludematcher")
    162 let s:tex_excludematcher= g:tex_excludematcher
    163 else
    164 let s:tex_excludematcher= 0
    165 endif
    166 
    167 " Clusters: {{{1
    168 " --------
    169 syn cluster texCmdGroup			contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texBeginEnd,texBeginEndName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,@texMathZones
    170 if !s:tex_no_error
    171 syn cluster texCmdGroup		add=texMathError
    172 endif
    173 syn cluster texEnvGroup			contains=texDefParm,texMatcher,texMathDelim,texSpecialChar,texStatement
    174 syn cluster texFoldGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texItalStyle,texEmphStyle,texNoSpell
    175 syn cluster texBoldGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texBoldItalStyle,texNoSpell
    176 syn cluster texItalGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texItalStyle,texEmphStyle,texItalBoldStyle,texNoSpell
    177 if !s:tex_excludematcher
    178 syn cluster texBoldGroup add=texMatcher
    179 syn cluster texItalGroup add=texMatcher
    180 endif
    181 if !s:tex_nospell
    182 if !s:tex_no_error
    183  syn cluster texMatchGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texEmphStyle,texZone,texInputFile,texOption,@Spell
    184  syn cluster texMatchNMGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
    185  syn cluster texStyleGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell
    186 else
    187  syn cluster texMatchGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texEmphStyle,texZone,texInputFile,texOption,@Spell
    188  syn cluster texMatchNMGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
    189  syn cluster texStyleGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell
    190 endif
    191 else
    192 if !s:tex_no_error
    193  syn cluster texMatchGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
    194  syn cluster texMatchNMGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
    195  syn cluster texStyleGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texError,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher
    196 else
    197  syn cluster texMatchGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
    198  syn cluster texMatchNMGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
    199  syn cluster texStyleGroup		contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher
    200 endif
    201 endif
    202 syn cluster texPreambleMatchGroup	contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
    203 syn cluster texRefGroup			contains=texMatcher,texComment,texDelimiter
    204 if !exists("g:tex_no_math")
    205 syn cluster texPreambleMatchGroup	contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
    206 syn cluster texMathZones		contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
    207 syn cluster texMatchGroup		add=@texMathZones
    208 syn cluster texMathDelimGroup		contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
    209 syn cluster texMathMatchGroup		contains=@texMathZones,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathMatcher,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone
    210 syn cluster texMathZoneGroup		contains=texBadPar,texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
    211 if !s:tex_no_error
    212  syn cluster texMathMatchGroup		add=texMathError
    213  syn cluster texMathZoneGroup		add=texMathError
    214 endif
    215 syn cluster texMathZoneGroup		add=@NoSpell
    216 " following used in the \part \chapter \section \subsection \subsubsection
    217 " \paragraph \subparagraph \author \title highlighting
    218 syn cluster texDocGroup		contains=texPartZone,@texPartGroup
    219 syn cluster texPartGroup		contains=texChapterZone,texSectionZone,texParaZone
    220 syn cluster texChapterGroup		contains=texSectionZone,texParaZone
    221 syn cluster texSectionGroup		contains=texSubSectionZone,texParaZone
    222 syn cluster texSubSectionGroup		contains=texSubSubSectionZone,texParaZone
    223 syn cluster texSubSubSectionGroup	contains=texParaZone
    224 syn cluster texParaGroup		contains=texSubParaZone
    225 if has("conceal") && &enc == 'utf-8'
    226  syn cluster texMathZoneGroup		add=texGreek,texSuperscript,texSubscript,texMathSymbol
    227  syn cluster texMathMatchGroup		add=texGreek,texSuperscript,texSubscript,texMathSymbol
    228 endif
    229 endif
    230 
    231 " Try to flag {}, [], and () mismatches: {{{1
    232 if s:tex_fast =~# 'm'
    233  if !s:tex_no_error
    234   if s:tex_matchcheck =~ '{'
    235    syn region texMatcher	matchgroup=texDelimiter start="{" skip="\\\\\|\\[{}]"	end="}"			transparent contains=@texMatchGroup,texError
    236    syn region texMatcherNM	matchgroup=texDelimiter start="{" skip="\\\\\|\\[{}]"	end="}"			transparent contains=@texMatchNMGroup,texError
    237   endif
    238   if s:tex_matchcheck =~ '\['
    239    syn region texMatcher	matchgroup=texDelimiter start="\["				end="]"			transparent contains=@texMatchGroup,texError,@NoSpell
    240    syn region texMatcherNM	matchgroup=texDelimiter start="\["				end="]"			transparent contains=@texMatchNMGroup,texError,@NoSpell
    241   endif
    242  else
    243   if s:tex_matchcheck =~ '{'
    244    syn region texMatcher	matchgroup=texDelimiter start="{" skip="\\\\\|\\[{}]"	end="}"			transparent contains=@texMatchGroup
    245    syn region texMatcherNM	matchgroup=texDelimiter start="{" skip="\\\\\|\\[{}]"	end="}"			transparent contains=@texMatchNMGroup
    246   endif
    247   if s:tex_matchcheck =~ '\['
    248    syn region texMatcher	matchgroup=texDelimiter start="\["				end="]"			transparent contains=@texMatchGroup
    249    syn region texMatcherNM	matchgroup=texDelimiter start="\["				end="]"			transparent contains=@texMatchNMGroup
    250   endif
    251  endif
    252  if s:tex_matchcheck =~ '('
    253   if !s:tex_nospell
    254    syn region texParen		start="("	end=")"								transparent contains=@texMatchGroup,@Spell
    255   else
    256    syn region texParen		start="("	end=")"								transparent contains=@texMatchGroup
    257   endif
    258  endif
    259 endif
    260 if !s:tex_no_error
    261 if s:tex_matchcheck =~ '('
    262  syn match  texError		"[}\]]"
    263 else
    264  syn match  texError		"[}\])]"
    265 endif
    266 endif
    267 if s:tex_fast =~# 'M'
    268  if !exists("g:tex_no_math")
    269   if !s:tex_no_error
    270    syn match  texMathError	"}"	contained
    271   endif
    272   syn region texMathMatcher	matchgroup=texDelimiter	start="{"          skip="\%(\\\\\)*\\}"     end="}" end="%stopzone\>"	contained contains=@texMathMatchGroup
    273  endif
    274 endif
    275 
    276 " TeX/LaTeX keywords: {{{1
    277 " Instead of trying to be All Knowing, I just match \..alphameric..
    278 " Note that *.tex files may not have "@" in their \commands
    279 if exists("g:tex_tex") || b:tex_stylish
    280  syn match texStatement	"\\[a-zA-Z@]\+"
    281 else
    282  syn match texStatement	"\\\a\+"
    283  if !s:tex_no_error
    284   syn match texError		"\\\a*@[a-zA-Z@]*"
    285  endif
    286 endif
    287 
    288 " TeX/LaTeX delimiters: {{{1
    289 syn match texDelimiter		"&"
    290 syn match texDelimiter		"\\\\"
    291 
    292 " Tex/Latex Options: {{{1
    293 syn match texOption		"[^\\]\zs#[1-9]\|^#[1-9]"
    294 
    295 " texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
    296 if b:tex_stylish
    297  syn match texAccent		"\\[bcdvuH][^a-zA-Z@]"me=e-1
    298  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
    299 else
    300  syn match texAccent		"\\[bcdvuH]\A"me=e-1
    301  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
    302 endif
    303 syn match texAccent		"\\[bcdvuH]$"
    304 syn match texAccent		+\\[=^.\~"`']+
    305 syn match texAccent		+\\['=t'.c^ud"vb~Hr]{\a}+
    306 syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
    307 
    308 
    309 " \begin{}/\end{} section markers: {{{1
    310 syn match  texBeginEnd		"\\begin\>\|\\end\>" nextgroup=texBeginEndName
    311 if s:tex_fast =~# 'm'
    312  syn region texBeginEndName		matchgroup=texDelimiter	start="{"		end="}"	contained	nextgroup=texBeginEndModifier	contains=texComment
    313  syn region texBeginEndModifier	matchgroup=texDelimiter	start="\["		end="]"	contained	contains=texComment,@texMathZones,@NoSpell
    314 endif
    315 
    316 " \documentclass, \documentstyle, \usepackage: {{{1
    317 syn match  texDocType		"\\documentclass\>\|\\documentstyle\>\|\\usepackage\>"	nextgroup=texBeginEndName,texDocTypeArgs
    318 if s:tex_fast =~# 'm'
    319  syn region texDocTypeArgs	matchgroup=texDelimiter start="\[" end="]"			contained	nextgroup=texBeginEndName	contains=texComment,@NoSpell
    320 endif
    321 
    322 " Preamble syntax-based folding support: {{{1
    323 if s:tex_fold_enabled && has("folding")
    324 syn region texPreamble	transparent fold	start='\zs\\documentclass\>' end='\ze\\begin{document}'	contains=texStyle,@texPreambleMatchGroup
    325 endif
    326 
    327 " TeX input: {{{1
    328 syn match texInput		"\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7				contains=texStatement
    329 syn match texInputFile		"\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}"	contains=texStatement,texInputCurlies,texInputFileOpt
    330 syn match texInputFile		"\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}"		contains=texStatement,texInputCurlies,texInputFileOpt
    331 syn match texInputCurlies	"[{}]"								contained
    332 if s:tex_fast =~# 'm'
    333 syn region texInputFileOpt	matchgroup=texDelimiter start="\[" end="\]"			contained	contains=texComment
    334 endif
    335 
    336 " Type Styles (LaTeX 2.09): {{{1
    337 syn match texTypeStyle		"\\rm\>"
    338 syn match texTypeStyle		"\\em\>"
    339 syn match texTypeStyle		"\\bf\>"
    340 syn match texTypeStyle		"\\it\>"
    341 syn match texTypeStyle		"\\sl\>"
    342 syn match texTypeStyle		"\\sf\>"
    343 syn match texTypeStyle		"\\sc\>"
    344 syn match texTypeStyle		"\\tt\>"
    345 
    346 " Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
    347 if s:tex_conceal !~# 'b'
    348 syn match texTypeStyle		"\\textbf\>"
    349 syn match texTypeStyle		"\\textit\>"
    350 syn match texTypeStyle		"\\emph\>"
    351 endif
    352 syn match texTypeStyle		"\\textmd\>"
    353 syn match texTypeStyle		"\\textrm\>"
    354 
    355 syn match texTypeStyle		"\\mathbf\>"
    356 syn match texTypeStyle		"\\mathcal\>"
    357 syn match texTypeStyle		"\\mathit\>"
    358 syn match texTypeStyle		"\\mathnormal\>"
    359 syn match texTypeStyle		"\\mathrm\>"
    360 syn match texTypeStyle		"\\mathsf\>"
    361 syn match texTypeStyle		"\\mathtt\>"
    362 
    363 syn match texTypeStyle		"\\rmfamily\>"
    364 syn match texTypeStyle		"\\sffamily\>"
    365 syn match texTypeStyle		"\\ttfamily\>"
    366 
    367 syn match texTypeStyle		"\\itshape\>"
    368 syn match texTypeStyle		"\\scshape\>"
    369 syn match texTypeStyle		"\\slshape\>"
    370 syn match texTypeStyle		"\\upshape\>"
    371 
    372 syn match texTypeStyle		"\\bfseries\>"
    373 syn match texTypeStyle		"\\mdseries\>"
    374 
    375 " Some type sizes: {{{1
    376 syn match texTypeSize		"\\tiny\>"
    377 syn match texTypeSize		"\\scriptsize\>"
    378 syn match texTypeSize		"\\footnotesize\>"
    379 syn match texTypeSize		"\\small\>"
    380 syn match texTypeSize		"\\normalsize\>"
    381 syn match texTypeSize		"\\large\>"
    382 syn match texTypeSize		"\\Large\>"
    383 syn match texTypeSize		"\\LARGE\>"
    384 syn match texTypeSize		"\\huge\>"
    385 syn match texTypeSize		"\\Huge\>"
    386 
    387 " Spacecodes (TeX'isms): {{{1
    388 " \mathcode`\^^@="2201  \delcode`\(="028300  \sfcode`\)=0 \uccode`X=`X  \lccode`x=`x
    389 syn match texSpaceCode		"\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
    390 syn match texSpaceCodeChar    "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)"	contained
    391 
    392 " Sections, subsections, etc: {{{1
    393 if s:tex_fast =~# 'p'
    394 if !s:tex_nospell
    395  TexFold syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											contains=@texFoldGroup,@texDocGroup,@Spell
    396  TexFold syn region texPartZone		matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								contains=@texFoldGroup,@texPartGroup,@Spell
    397  TexFold syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							contains=@texFoldGroup,@texChapterGroup,@Spell
    398  TexFold syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					contains=@texFoldGroup,@texSectionGroup,@Spell
    399  TexFold syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSectionGroup,@Spell
    400  TexFold syn region texSubSubSectionZone	matchgroup=texSection start='\\subsubsection\>'		 end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
    401  TexFold syn region texParaZone		matchgroup=texSection start='\\paragraph\>'		 end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'			contains=@texFoldGroup,@texParaGroup,@Spell
    402  TexFold syn region texSubParaZone		matchgroup=texSection start='\\subparagraph\>'		 end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'	contains=@texFoldGroup,@Spell
    403  TexFold syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													contains=@texFoldGroup,@Spell
    404  TexFold syn region texAbstract		matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											contains=@texFoldGroup,@Spell
    405 else
    406  TexFold syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											contains=@texFoldGroup,@texDocGroup
    407  TexFold syn region texPartZone		matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								contains=@texFoldGroup,@texPartGroup
    408  TexFold syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							contains=@texFoldGroup,@texChapterGroup
    409  TexFold syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					contains=@texFoldGroup,@texSectionGroup
    410  TexFold syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSectionGroup
    411  TexFold syn region texSubSubSectionZone	matchgroup=texSection start='\\subsubsection\>'		 end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSubSectionGroup
    412  TexFold syn region texParaZone		matchgroup=texSection start='\\paragraph\>'		 end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'			contains=@texFoldGroup,@texParaGroup
    413  TexFold syn region texSubParaZone		matchgroup=texSection start='\\subparagraph\>'		 end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'	contains=@texFoldGroup
    414  TexFold syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													contains=@texFoldGroup
    415  TexFold syn region texAbstract		matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											contains=@texFoldGroup
    416  endif
    417 endif
    418 
    419 " particular support for bold and italic {{{1
    420 if s:tex_fast =~# 'b'
    421  if s:tex_conceal =~# 'b'
    422   if !exists("g:tex_nospell") || !g:tex_nospell
    423    syn region texBoldStyle	matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup,@Spell
    424    syn region texBoldItalStyle	matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup,@Spell
    425    syn region texItalStyle	matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup,@Spell
    426    syn region texItalBoldStyle	matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup,@Spell
    427    syn region texEmphStyle	matchgroup=texTypeStyle start="\\emph\s*{"   matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup,@Spell
    428    syn region texEmphStyle	matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup,@Spell
    429    syn region texEmphStyle	matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup,@Spell
    430    syn region texEmphStyle	matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup,@Spell
    431   else
    432    syn region texBoldStyle	matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup
    433    syn region texBoldItalStyle	matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup
    434    syn region texItalStyle	matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup
    435    syn region texItalBoldStyle	matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texBoldGroup
    436    syn region texEmphStyle	matchgroup=texTypeStyle start="\\emph\s*{"   matchgroup=texTypeStyle  end="}" concealends contains=@texItalGroup
    437    syn region texEmphStyle	matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texEmphGroup
    438    syn region texEmphStyle	matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texEmphGroup
    439    syn region texEmphStyle	matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle  end="}" concealends contains=@texEmphGroup
    440   endif
    441  endif
    442 endif
    443 
    444 " Bad Math (mismatched): {{{1
    445 if !exists("g:tex_no_math") && !s:tex_no_error
    446 syn match texBadMath		"\\end\s*{\s*\(array\|[bBpvV]matrix\|split\|smallmatrix\)\s*}"
    447 syn match texBadMath		"\\end\s*{\s*\(align\|alignat\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\)\*\=\s*}"
    448 syn match texBadMath		"\\[\])]"
    449 syn match texBadPar	contained  "\%(\\par\>\|^\s*\n.\)"
    450 endif
    451 
    452 " Math Zones: {{{1
    453 if !exists("g:tex_no_math")
    454 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
    455 "                 Starred forms are created if starform is true.  Starred
    456 "                 forms have syntax group and synchronization groups with a
    457 "                 "S" appended.  Handles: cluster, syntax, sync, and highlighting.
    458 fun! TexNewMathZone(sfx,mathzone,starform)
    459   let grpname  = "texMathZone".a:sfx
    460   let syncname = "texSyncMathZone".a:sfx
    461   if s:tex_fold_enabled
    462    let foldcmd= " fold"
    463   else
    464    let foldcmd= ""
    465   endif
    466   exe "syn cluster texMathZones add=".grpname
    467   if s:tex_fast =~# 'M'
    468    exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
    469    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
    470    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
    471   endif
    472   exe 'hi def link '.grpname.' texMath'
    473   if a:starform
    474    let grpname  = "texMathZone".a:sfx.'S'
    475    let syncname = "texSyncMathZone".a:sfx.'S'
    476    exe "syn cluster texMathZones add=".grpname
    477    if s:tex_fast =~# 'M'
    478     exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
    479     exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
    480     exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
    481    endif
    482    exe 'hi def link '.grpname.' texMath'
    483   endif
    484 endfun
    485 
    486 " Standard Math Zones: {{{2
    487 call TexNewMathZone("A","displaymath",1)
    488 call TexNewMathZone("B","eqnarray",1)
    489 call TexNewMathZone("C","equation",1)
    490 call TexNewMathZone("D","math",1)
    491 call TexNewMathZone("E","align",1)
    492 call TexNewMathZone("F","alignat",1)
    493 call TexNewMathZone("G","flalign",1)
    494 call TexNewMathZone("H","gather",1)
    495 call TexNewMathZone("I","multline",1)
    496 
    497 " Inline Math Zones: {{{2
    498 if s:tex_fast =~# 'M'
    499  if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'd'
    500   syn region texMathZoneV	matchgroup=texDelimiter start="\\("			matchgroup=texDelimiter	end="\\)\|%stopzone\>"			keepend concealends contains=@texMathZoneGroup
    501   syn region texMathZoneW	matchgroup=texDelimiter start="\\\["			matchgroup=texDelimiter	end="\\]\|%stopzone\>"			keepend concealends contains=@texMathZoneGroup
    502   syn region texMathZoneX	matchgroup=texDelimiter start="\$" skip="\\\\\|\\\$"	matchgroup=texDelimiter	end="\$"	end="%stopzone\>"		concealends contains=@texMathZoneGroup
    503   syn region texMathZoneY	matchgroup=texDelimiter start="\$\$" 			matchgroup=texDelimiter	end="\$\$"	end="%stopzone\>"	keepend concealends contains=@texMathZoneGroup
    504  else
    505   syn region texMathZoneV	matchgroup=texDelimiter start="\\("			matchgroup=texDelimiter	end="\\)\|%stopzone\>"			keepend contains=@texMathZoneGroup
    506   syn region texMathZoneW	matchgroup=texDelimiter start="\\\["			matchgroup=texDelimiter	end="\\]\|%stopzone\>"			keepend contains=@texMathZoneGroup
    507   syn region texMathZoneX	matchgroup=texDelimiter start="\$" skip="\%(\\\\\)*\\\$"	matchgroup=texDelimiter	end="\$"	end="%stopzone\>"		contains=@texMathZoneGroup
    508   syn region texMathZoneY	matchgroup=texDelimiter start="\$\$" 			matchgroup=texDelimiter	end="\$\$"	end="%stopzone\>"	keepend	contains=@texMathZoneGroup
    509  endif
    510  syn region texMathZoneZ	matchgroup=texStatement start="\\ensuremath\s*{"	matchgroup=texStatement	end="}"		end="%stopzone\>"	contains=@texMathZoneGroup
    511 endif
    512 
    513 syn match texMathOper		"[_^=]" contained
    514 
    515 " Text Inside Math Zones: {{{2
    516 if s:tex_fast =~# 'M'
    517  if !exists("g:tex_nospell") || !g:tex_nospell
    518   syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{'	end='}'	contains=@texFoldGroup,@Spell
    519  else
    520   syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{'	end='}'	contains=@texFoldGroup
    521  endif
    522 endif
    523 
    524 " \left..something.. and \right..something.. support: {{{2
    525 syn match   texMathDelimBad	contained		"\S"
    526 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'm'
    527  syn match   texMathDelim	contained		"\\left\["
    528  syn match   texMathDelim	contained		"\\left\\{"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
    529  syn match   texMathDelim	contained		"\\right\\}"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
    530  let s:texMathDelimList=[
    531     \ ['<'            , '<'] ,
    532     \ ['>'            , '>'] ,
    533     \ ['('            , '('] ,
    534     \ [')'            , ')'] ,
    535     \ ['\['           , '['] ,
    536     \ [']'            , ']'] ,
    537     \ ['\\{'          , '{'] ,
    538     \ ['\\}'          , '}'] ,
    539     \ ['|'            , '|'] ,
    540     \ ['\\|'          , '‖'] ,
    541     \ ['\\backslash'  , '\'] ,
    542     \ ['\\downarrow'  , '↓'] ,
    543     \ ['\\Downarrow'  , '⇓'] ,
    544     \ ['\\lbrace'     , '['] ,
    545     \ ['\\lceil'      , '⌈'] ,
    546     \ ['\\lfloor'     , '⌊'] ,
    547     \ ['\\lgroup'     , '⌊'] ,
    548     \ ['\\lmoustache' , '⎛'] ,
    549     \ ['\\rbrace'     , ']'] ,
    550     \ ['\\rceil'      , '⌉'] ,
    551     \ ['\\rfloor'     , '⌋'] ,
    552     \ ['\\rgroup'     , '⌋'] ,
    553     \ ['\\rmoustache' , '⎞'] ,
    554     \ ['\\uparrow'    , '↑'] ,
    555     \ ['\\Uparrow'    , '↑'] ,
    556     \ ['\\updownarrow', '↕'] ,
    557     \ ['\\Updownarrow', '⇕']]
    558  if &ambw == "double" || exists("g:tex_usedblwidth")
    559    let s:texMathDelimList= s:texMathDelimList + [
    560     \ ['\\langle'     , '〈'] ,
    561     \ ['\\rangle'     , '〉']]
    562  else
    563    let s:texMathDelimList= s:texMathDelimList + [
    564     \ ['\\langle'     , '<'] ,
    565     \ ['\\rangle'     , '>']]
    566  endif
    567  syn match texMathDelim	'\\[bB]igg\=[lr]' contained nextgroup=texMathDelimBad
    568  for texmath in s:texMathDelimList
    569   exe "syn match texMathDelim	'\\\\[bB]igg\\=[lr]\\=".texmath[0]."'	contained conceal cchar=".texmath[1]
    570  endfor
    571 
    572 else
    573  syn match   texMathDelim	contained		"\\\(left\|right\)\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
    574  syn match   texMathDelim	contained		"\\[bB]igg\=[lr]\=\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
    575  syn match   texMathDelimSet2	contained	"\\"		nextgroup=texMathDelimKey,texMathDelimBad
    576  syn match   texMathDelimSet1	contained	"[<>()[\]|/.]\|\\[{}|]"
    577  syn keyword texMathDelimKey	contained	backslash       lceil           lVert           rgroup          uparrow
    578  syn keyword texMathDelimKey	contained	downarrow       lfloor          rangle          rmoustache      Uparrow
    579  syn keyword texMathDelimKey	contained	Downarrow       lgroup          rbrace          rvert           updownarrow
    580  syn keyword texMathDelimKey	contained	langle          lmoustache      rceil           rVert           Updownarrow
    581  syn keyword texMathDelimKey	contained	lbrace          lvert           rfloor
    582 endif
    583 syn match   texMathDelim	contained		"\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
    584 syn match   texMathDelim	contained		"\\lefteqn\>"
    585 endif
    586 
    587 " Special TeX characters  ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
    588 syn match texSpecialChar	"\\[$&%#{}_]"
    589 if b:tex_stylish
    590  syn match texSpecialChar	"\\[SP@][^a-zA-Z@]"me=e-1
    591 else
    592  syn match texSpecialChar	"\\[SP@]\A"me=e-1
    593 endif
    594 syn match texSpecialChar	"\\\\"
    595 if !exists("g:tex_no_math")
    596 syn match texOnlyMath		"[_^]"
    597 endif
    598 syn match texSpecialChar	"\^\^[0-9a-f]\{2}\|\^\^\S"
    599 if s:tex_conceal !~# 'S'
    600 syn match texSpecialChar	'\\glq\>'	contained conceal cchar=    601 syn match texSpecialChar	'\\grq\>'	contained conceal cchar=    602 syn match texSpecialChar	'\\glqq\>'	contained conceal cchar=    603 syn match texSpecialChar	'\\grqq\>'	contained conceal cchar=    604 syn match texSpecialChar	'\\hyp\>'	contained conceal cchar=-
    605 endif
    606 
    607 " Comments: {{{1
    608 "    Normal TeX LaTeX     :   %....
    609 "    Documented TeX Format:  ^^A...	-and-	leading %s (only)
    610 if !s:tex_comment_nospell
    611 syn cluster texCommentGroup	contains=texTodo,@Spell
    612 else
    613 syn cluster texCommentGroup	contains=texTodo,@NoSpell
    614 endif
    615 syn case ignore
    616 syn keyword texTodo		contained		combak	fixme	todo	xxx
    617 syn case match
    618 if s:extfname == "dtx"
    619 syn match texComment		"\^\^A.*$"	contains=@texCommentGroup
    620 syn match texComment		"^%\+"		contains=@texCommentGroup
    621 else
    622 if s:tex_fold_enabled
    623  " allows syntax-folding of 2 or more contiguous comment lines
    624  " single-line comments are not folded
    625  syn match  texComment	"%.*$"				contains=@texCommentGroup
    626  if s:tex_fast =~# 'c'
    627   TexFold syn region texComment						start="^\zs\s*%.*\_s*%"	skip="^\s*%"	end='^\ze\s*[^%]'	contains=@texCommentGroup
    628   TexFold syn region texNoSpell	contained	matchgroup=texComment	start="%\s*nospell\s*{"	end="%\s*nospell\s*}"			contains=@texFoldGroup,@NoSpell
    629  endif
    630 else
    631  syn match texComment		"%.*$"			contains=@texCommentGroup
    632  if s:tex_fast =~# 'c'
    633   syn region texNoSpell		contained	matchgroup=texComment start="%\s*nospell\s*{"	end="%\s*nospell\s*}"	contains=@texFoldGroup,@NoSpell
    634  endif
    635 endif
    636 endif
    637 
    638 " %begin-include ... %end-include acts like a texDocZone for \include'd files.  Permits spell checking, for example, in such files.
    639 if !s:tex_nospell
    640 TexFold syn region texDocZone			matchgroup=texSection start='^\s*%begin-include\>'	 end='^\s*%end-include\>'											contains=@texFoldGroup,@texDocGroup,@Spell
    641 else
    642 TexFold syn region texDocZone			matchgroup=texSection start='^\s*%begin-include\>'	 end='^\s*%end-include\>'											contains=@texFoldGroup,@texDocGroup
    643 endif
    644 
    645 " Separate lines used for verb` and verb# so that the end conditions {{{1
    646 " will appropriately terminate.
    647 " If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
    648 if s:tex_fast =~# 'v'
    649  if exists("g:tex_verbspell") && g:tex_verbspell
    650   syn region texZone		start="\\begin{[vV]erbatim}"		end="\\end{[vV]erbatim}\|%stopzone\>"	contains=@Spell
    651   " listings package:
    652   if b:tex_stylish
    653    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z@]\)"	end="\z1\|%stopzone\>"			contains=@Spell
    654   else
    655    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z]\)"	end="\z1\|%stopzone\>"			contains=@Spell
    656   endif
    657  else
    658   syn region texZone		start="\\begin{[vV]erbatim}"		end="\\end{[vV]erbatim}\|%stopzone\>"
    659   if b:tex_stylish
    660     syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z@]\)"	end="\z1\|%stopzone\>"
    661   else
    662     syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z]\)"	end="\z1\|%stopzone\>"
    663   endif
    664  endif
    665 endif
    666 
    667 " Tex Reference Zones: {{{1
    668 if s:tex_fast =~# 'r'
    669  syn region texZone		matchgroup=texStatement start="@samp{"			end="}\|%stopzone\>"	contains=@texRefGroup
    670  syn region texRefZone		matchgroup=texStatement start="\\nocite{"		end="}\|%stopzone\>"	contains=@texRefGroup
    671  syn region texRefZone		matchgroup=texStatement start="\\bibliography{"		end="}\|%stopzone\>"	contains=@texRefGroup
    672  syn region texRefZone		matchgroup=texStatement start="\\label{"		end="}\|%stopzone\>"	contains=@texRefGroup
    673  syn region texRefZone		matchgroup=texStatement start="\\\(page\|eq\)ref{"	end="}\|%stopzone\>"	contains=@texRefGroup
    674  syn region texRefZone		matchgroup=texStatement start="\\v\=ref{"		end="}\|%stopzone\>"	contains=@texRefGroup
    675  syn region texRefOption	contained	matchgroup=texDelimiter start='\[' end=']'		contains=@texRefGroup,texRefZone	nextgroup=texRefOption,texCite
    676  syn region texCite		contained	matchgroup=texDelimiter start='{' end='}'		contains=@texRefGroup,texRefZone,texCite
    677 endif
    678 syn match  texRefZone		'\\cite\%([tp]\*\=\)\=\>' nextgroup=texRefOption,texCite
    679 
    680 " Handle (re)newcommand, providecommand, (re)newenvironment : {{{1
    681 " EXAMPLE:
    682 "
    683 " The followings are valid (ignoring error due to redefinition):
    684 "
    685 " \newcommand{\foo}{body}
    686 " \newcommand{\foo}[1]{#1}
    687 " \newcommand{\foo}[1][def]{#1}
    688 "
    689 " The followings are ill-formed:
    690 "
    691 " \newcommand{\foo}{#1}		! Illegal parameter number in definition of \foo.
    692 " \newcommand{\foo}[x]{…}	! Missing number, treated as zero.
    693 " \newcommand{\foo}[10]{…}	! You already have nine parameters.
    694 syn match  texNewCmd				"\\\%(\%(re\)\=new\|provide\)command\>\*\?"	nextgroup=texCmdName skipwhite skipnl
    695 if s:tex_fast =~# 'V'
    696  syn region texCmdName contained matchgroup=texDelimiter start="{"rs=s+1  end="}"		nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
    697  syn region texCmdArgs contained matchgroup=texDelimiter start="\["rs=s+1 end="]"		nextgroup=texCmdDefaultPar,texCmdBody skipwhite skipnl
    698  syn region texCmdDefaultPar contained matchgroup=texDelimiter start="\["rs=s+1 end="]"	nextgroup=texCmdBody skipwhite skipnl
    699  syn region texCmdBody contained matchgroup=texDelimiter start="{"rs=s+1 skip="\\\\\|\\[{}]"	matchgroup=texDelimiter end="}" contains=@texCmdGroup
    700 endif
    701 " EXAMPLE:
    702 "
    703 " The followings are valid (ignoring error due to redefinition):
    704 "
    705 " \newenvironment{baz}{beg}{end}
    706 " \newenvironment{baz}[1]{beg #1}{end}
    707 " \newenvironment{baz}[1][default]{beg #1}{end}
    708 "
    709 " The followings are invalid:
    710 "
    711 " \newenvironment{baz}{#1}{…}		! Illegal parameter number in definition of \baz.
    712 " \newenvironment{baz}[x]{…}{…}		! Missing number, treated as zero.
    713 " \newenvironment{baz}[10]{…}{…}	! You already have nine parameters.
    714 " \newenvironment{baz}[1]{…}{#1}	! Illegal parameter number in definition of \endbaz.
    715 syn match  texNewEnv				"\\\%(re\)\=newenvironment\>\*\?"		nextgroup=texEnvName skipwhite skipnl
    716 if s:tex_fast =~# 'V'
    717  syn region texEnvName contained matchgroup=texDelimiter start="{"rs=s+1  end="}"		nextgroup=texEnvArgs,texEnvBgn skipwhite skipnl
    718  syn region texEnvArgs contained matchgroup=texDelimiter start="\["rs=s+1 end="]"		nextgroup=texEnvDefaultPar,texEnvBgn skipwhite skipnl
    719  syn region texEnvDefaultPar contained matchgroup=texDelimiter start="\["rs=s+1 end="]"	nextgroup=texEnvBgn skipwhite skipnl
    720  syn region texEnvBgn  contained matchgroup=texDelimiter start="{"rs=s+1  end="}"		nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
    721  syn region texEnvEnd  contained matchgroup=texDelimiter start="{"rs=s+1  end="}"		skipwhite skipnl contains=@texEnvGroup
    722 endif
    723 
    724 " Definitions/Commands: {{{1
    725 syn match texDefCmd				"\\def\>"				nextgroup=texDefName skipwhite skipnl
    726 if b:tex_stylish
    727  syn match texDefName contained		"\\[a-zA-Z@]\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
    728  syn match texDefName contained		"\\[^a-zA-Z@]"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
    729 else
    730  syn match texDefName contained		"\\\a\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
    731  syn match texDefName contained		"\\\A"					nextgroup=texDefParms,texCmdBody skipwhite skipnl
    732 endif
    733 syn match texDefParms  contained		"#[^{]*"	contains=texDefParm	nextgroup=texCmdBody skipwhite skipnl
    734 syn match  texDefParm  contained		"#[1-9]"
    735 
    736 " TeX Lengths: {{{1
    737 syn match  texLength		"\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
    738 
    739 " TeX String Delimiters: {{{1
    740 syn match texString		"\(``\|''\|,,\)"
    741 
    742 " makeatletter -- makeatother sections
    743 if !s:tex_no_error
    744 if s:tex_fast =~# 'S'
    745  syn region texStyle			matchgroup=texStatement start='\\makeatletter' end='\\makeatother'	contains=@texStyleGroup contained
    746 endif
    747 syn match  texStyleStatement		"\\[a-zA-Z@]\+"	contained
    748 if s:tex_fast =~# 'S'
    749  syn region texStyleMatcher		matchgroup=texDelimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texStyleGroup,texError	contained
    750  syn region texStyleMatcher		matchgroup=texDelimiter start="\["				end="]"		contains=@texStyleGroup,texError	contained
    751 endif
    752 endif
    753 
    754 " Conceal mode support (supports set cole=2) {{{1
    755 if has("conceal") && &enc == 'utf-8'
    756 
    757 " Math Symbols {{{2
    758 " (many of these symbols were contributed by Björn Winckler)
    759 if s:tex_conceal =~# 'm'
    760  let s:texMathList=[
    761    \ ['|'		, '‖'],
    762    \ ['aleph'		, 'ℵ'],
    763    \ ['amalg'		, '∐'],
    764    \ ['angle'		, '∠'],
    765    \ ['approx'		, '≈'],
    766    \ ['ast'		, '∗'],
    767    \ ['asymp'		, '≍'],
    768    \ ['backslash'	, '∖'],
    769    \ ['bigcap'		, '∩'],
    770    \ ['bigcirc'	, '○'],
    771    \ ['bigcup'		, '∪'],
    772    \ ['bigodot'	, '⊙'],
    773    \ ['bigoplus'	, '⊕'],
    774    \ ['bigotimes'	, '⊗'],
    775    \ ['bigsqcup'	, '⊔'],
    776    \ ['bigtriangledown', '∇'],
    777    \ ['bigtriangleup'	, '∆'],
    778    \ ['bigvee'		, '⋁'],
    779    \ ['bigwedge'	, '⋀'],
    780    \ ['bot'		, '⊥'],
    781    \ ['bowtie'	        , '⋈'],
    782    \ ['bullet'	        , '•'],
    783    \ ['cap'		, '∩'],
    784    \ ['cdot'		, '·'],
    785    \ ['cdots'		, '⋯'],
    786    \ ['circ'		, '∘'],
    787    \ ['clubsuit'	, '♣'],
    788    \ ['cong'		, '≅'],
    789    \ ['coprod'		, '∐'],
    790    \ ['copyright'	, '©'],
    791    \ ['cup'		, '∪'],
    792    \ ['dagger'	        , '†'],
    793    \ ['dashv'		, '⊣'],
    794    \ ['ddagger'	, '‡'],
    795    \ ['ddots'	        , '⋱'],
    796    \ ['diamond'	, '⋄'],
    797    \ ['diamondsuit'	, '♢'],
    798    \ ['div'		, '÷'],
    799    \ ['doteq'		, '≐'],
    800    \ ['dots'		, '…'],
    801    \ ['downarrow'	, '↓'],
    802    \ ['Downarrow'	, '⇓'],
    803    \ ['ell'		, 'ℓ'],
    804    \ ['emptyset'	, '∅'],
    805    \ ['equiv'		, '≡'],
    806    \ ['exists'		, '∃'],
    807    \ ['flat'		, '♭'],
    808    \ ['forall'		, '∀'],
    809    \ ['frown'		, '⁔'],
    810    \ ['ge'		, '≥'],
    811    \ ['geq'		, '≥'],
    812    \ ['gets'		, '←'],
    813    \ ['gg'		, '⟫'],
    814    \ ['hbar'		, 'ℏ'],
    815    \ ['heartsuit'	, '♡'],
    816    \ ['hookleftarrow'	, '↩'],
    817    \ ['hookrightarrow'	, '↪'],
    818    \ ['iff'            , '⇔'],
    819    \ ['Im'		, 'ℑ'],
    820    \ ['imath'		, 'ɩ'],
    821    \ ['in'		, '∈'],
    822    \ ['infty'		, '∞'],
    823    \ ['int'		, '∫'],
    824    \ ['jmath'		, '𝚥'],
    825    \ ['land'		, '∧'],
    826    \ ['lceil'		, '⌈'],
    827    \ ['ldots'		, '…'],
    828    \ ['le'		, '≤'],
    829    \ ['left|'		, '|'],
    830    \ ['left\\|'	, '‖'],
    831    \ ['left('		, '('],
    832    \ ['left\['		, '['],
    833    \ ['left\\{'	, '{'],
    834    \ ['leftarrow'	, '←'],
    835    \ ['Leftarrow'	, '⇐'],
    836    \ ['leftharpoondown', '↽'],
    837    \ ['leftharpoonup'	, '↼'],
    838    \ ['leftrightarrow'	, '↔'],
    839    \ ['Leftrightarrow'	, '⇔'],
    840    \ ['leq'		, '≤'],
    841    \ ['leq'		, '≤'],
    842    \ ['lfloor'		, '⌊'],
    843    \ ['ll'		, '≪'],
    844    \ ['lmoustache'     , '╭'],
    845    \ ['lor'		, '∨'],
    846    \ ['mapsto'		, '↦'],
    847    \ ['mid'		, '∣'],
    848    \ ['models'		, '╞'],
    849    \ ['mp'		, '∓'],
    850    \ ['nabla'		, '∇'],
    851    \ ['natural'	, '♮'],
    852    \ ['ne'		, '≠'],
    853    \ ['nearrow'	, '↗'],
    854    \ ['neg'		, '¬'],
    855    \ ['neq'		, '≠'],
    856    \ ['ni'		, '∋'],
    857    \ ['notin'		, '∉'],
    858    \ ['nwarrow'	, '↖'],
    859    \ ['odot'		, '⊙'],
    860    \ ['oint'		, '∮'],
    861    \ ['ominus'		, '⊖'],
    862    \ ['oplus'		, '⊕'],
    863    \ ['oslash'		, '⊘'],
    864    \ ['otimes'		, '⊗'],
    865    \ ['owns'		, '∋'],
    866    \ ['P'	        , '¶'],
    867    \ ['parallel'	, '║'],
    868    \ ['partial'	, '∂'],
    869    \ ['perp'		, '⊥'],
    870    \ ['pm'		, '±'],
    871    \ ['prec'		, '≺'],
    872    \ ['preceq'		, '⪯'],
    873    \ ['prime'		, '′'],
    874    \ ['prod'		, '∏'],
    875    \ ['propto'		, '∝'],
    876    \ ['rceil'		, '⌉'],
    877    \ ['Re'		, 'ℜ'],
    878    \ ['quad'		, ' '],
    879    \ ['qquad'		, ' '],
    880    \ ['rfloor'		, '⌋'],
    881    \ ['right|'		, '|'],
    882    \ ['right\\|'	, '‖'],
    883    \ ['right)'		, ')'],
    884    \ ['right]'		, ']'],
    885    \ ['right\\}'	, '}'],
    886    \ ['rightarrow'	, '→'],
    887    \ ['Rightarrow'	, '⇒'],
    888    \ ['rightleftharpoons', '⇌'],
    889    \ ['rmoustache'     , '╮'],
    890    \ ['S'	        , '§'],
    891    \ ['searrow'	, '↘'],
    892    \ ['setminus'	, '∖'],
    893    \ ['sharp'		, '♯'],
    894    \ ['sim'		, '∼'],
    895    \ ['simeq'		, '⋍'],
    896    \ ['smile'		, '‿'],
    897    \ ['spadesuit'	, '♠'],
    898    \ ['sqcap'		, '⊓'],
    899    \ ['sqcup'		, '⊔'],
    900    \ ['sqsubset'	, '⊏'],
    901    \ ['sqsubseteq'	, '⊑'],
    902    \ ['sqsupset'	, '⊐'],
    903    \ ['sqsupseteq'	, '⊒'],
    904    \ ['star'		, '✫'],
    905    \ ['subset'		, '⊂'],
    906    \ ['subseteq'	, '⊆'],
    907    \ ['succ'		, '≻'],
    908    \ ['succeq'		, '⪰'],
    909    \ ['sum'		, '∑'],
    910    \ ['supset'		, '⊃'],
    911    \ ['supseteq'	, '⊇'],
    912    \ ['surd'		, '√'],
    913    \ ['swarrow'	, '↙'],
    914    \ ['times'		, '×'],
    915    \ ['to'		, '→'],
    916    \ ['top'		, '⊤'],
    917    \ ['triangle'	, '∆'],
    918    \ ['triangleleft'	, '⊲'],
    919    \ ['triangleright'	, '⊳'],
    920    \ ['uparrow'	, '↑'],
    921    \ ['Uparrow'	, '⇑'],
    922    \ ['updownarrow'	, '↕'],
    923    \ ['Updownarrow'	, '⇕'],
    924    \ ['vdash'		, '⊢'],
    925    \ ['vdots'		, '⋮'],
    926    \ ['vee'		, '∨'],
    927    \ ['wedge'		, '∧'],
    928    \ ['wp'		, '℘'],
    929    \ ['wr'		, '≀']]
    930  if &ambw == "double" || exists("g:tex_usedblwidth")
    931    let s:texMathList= s:texMathList + [
    932    \ ['right\\rangle'	, '〉'],
    933    \ ['left\\langle'	, '〈']]
    934  else
    935    let s:texMathList= s:texMathList + [
    936    \ ['right\\rangle'	, '>'],
    937    \ ['left\\langle'	, '<']]
    938  endif
    939  for texmath in s:texMathList
    940   if texmath[0] =~# '\w$'
    941    exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
    942   else
    943    exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
    944   endif
    945  endfor
    946 
    947  if &ambw == "double"
    948   syn match texMathSymbol '\\gg\>'			contained conceal cchar=    949   syn match texMathSymbol '\\ll\>'			contained conceal cchar=    950  else
    951   syn match texMathSymbol '\\gg\>'			contained conceal cchar=    952   syn match texMathSymbol '\\ll\>'			contained conceal cchar=    953  endif
    954 
    955  syn match texMathSymbol '\\hat{a}' contained conceal cchar=â
    956  syn match texMathSymbol '\\hat{A}' contained conceal cchar=Â
    957  syn match texMathSymbol '\\hat{c}' contained conceal cchar=ĉ
    958  syn match texMathSymbol '\\hat{C}' contained conceal cchar=Ĉ
    959  syn match texMathSymbol '\\hat{e}' contained conceal cchar=ê
    960  syn match texMathSymbol '\\hat{E}' contained conceal cchar=Ê
    961  syn match texMathSymbol '\\hat{g}' contained conceal cchar=ĝ
    962  syn match texMathSymbol '\\hat{G}' contained conceal cchar=Ĝ
    963  syn match texMathSymbol '\\hat{i}' contained conceal cchar=î
    964  syn match texMathSymbol '\\hat{I}' contained conceal cchar=Î
    965  syn match texMathSymbol '\\hat{o}' contained conceal cchar=ô
    966  syn match texMathSymbol '\\hat{O}' contained conceal cchar=Ô
    967  syn match texMathSymbol '\\hat{s}' contained conceal cchar=ŝ
    968  syn match texMathSymbol '\\hat{S}' contained conceal cchar=Ŝ
    969  syn match texMathSymbol '\\hat{u}' contained conceal cchar=û
    970  syn match texMathSymbol '\\hat{U}' contained conceal cchar=Û
    971  syn match texMathSymbol '\\hat{w}' contained conceal cchar=ŵ
    972  syn match texMathSymbol '\\hat{W}' contained conceal cchar=Ŵ
    973  syn match texMathSymbol '\\hat{y}' contained conceal cchar=ŷ
    974  syn match texMathSymbol '\\hat{Y}' contained conceal cchar=Ŷ
    975 "  syn match texMathSymbol '\\bar{a}' contained conceal cchar=a̅
    976 
    977  syn match texMathSymbol '\\dot{B}' contained conceal cchar=    978  syn match texMathSymbol '\\dot{b}' contained conceal cchar=    979  syn match texMathSymbol '\\dot{D}' contained conceal cchar=    980  syn match texMathSymbol '\\dot{d}' contained conceal cchar=    981  syn match texMathSymbol '\\dot{F}' contained conceal cchar=    982  syn match texMathSymbol '\\dot{f}' contained conceal cchar=    983  syn match texMathSymbol '\\dot{H}' contained conceal cchar=    984  syn match texMathSymbol '\\dot{h}' contained conceal cchar=    985  syn match texMathSymbol '\\dot{M}' contained conceal cchar=    986  syn match texMathSymbol '\\dot{m}' contained conceal cchar=    987  syn match texMathSymbol '\\dot{N}' contained conceal cchar=    988  syn match texMathSymbol '\\dot{n}' contained conceal cchar=    989  syn match texMathSymbol '\\dot{P}' contained conceal cchar=    990  syn match texMathSymbol '\\dot{p}' contained conceal cchar=    991  syn match texMathSymbol '\\dot{R}' contained conceal cchar=    992  syn match texMathSymbol '\\dot{r}' contained conceal cchar=    993  syn match texMathSymbol '\\dot{S}' contained conceal cchar=    994  syn match texMathSymbol '\\dot{s}' contained conceal cchar=    995  syn match texMathSymbol '\\dot{T}' contained conceal cchar=    996  syn match texMathSymbol '\\dot{t}' contained conceal cchar=    997  syn match texMathSymbol '\\dot{W}' contained conceal cchar=    998  syn match texMathSymbol '\\dot{w}' contained conceal cchar=    999  syn match texMathSymbol '\\dot{X}' contained conceal cchar=   1000  syn match texMathSymbol '\\dot{x}' contained conceal cchar=   1001  syn match texMathSymbol '\\dot{Y}' contained conceal cchar=   1002  syn match texMathSymbol '\\dot{y}' contained conceal cchar=   1003  syn match texMathSymbol '\\dot{Z}' contained conceal cchar=Ż
   1004  syn match texMathSymbol '\\dot{z}' contained conceal cchar=ż
   1005 
   1006  syn match texMathSymbol '\\dot{C}' contained conceal cchar=Ċ
   1007  syn match texMathSymbol '\\dot{c}' contained conceal cchar=ċ
   1008  syn match texMathSymbol '\\dot{E}' contained conceal cchar=Ė
   1009  syn match texMathSymbol '\\dot{e}' contained conceal cchar=ė
   1010  syn match texMathSymbol '\\dot{G}' contained conceal cchar=Ġ
   1011  syn match texMathSymbol '\\dot{g}' contained conceal cchar=ġ
   1012  syn match texMathSymbol '\\dot{I}' contained conceal cchar=İ
   1013 
   1014  syn match texMathSymbol '\\dot{A}' contained conceal cchar=Ȧ
   1015  syn match texMathSymbol '\\dot{a}' contained conceal cchar=ȧ
   1016  syn match texMathSymbol '\\dot{O}' contained conceal cchar=Ȯ
   1017  syn match texMathSymbol '\\dot{o}' contained conceal cchar=ȯ
   1018 endif
   1019 
   1020 " Greek {{{2
   1021 if s:tex_conceal =~# 'g'
   1022  fun! s:Greek(group,pat,cchar)
   1023    exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
   1024  endfun
   1025  call s:Greek('texGreek','\\alpha\>'		,'α')
   1026  call s:Greek('texGreek','\\beta\>'		,'β')
   1027  call s:Greek('texGreek','\\gamma\>'		,'γ')
   1028  call s:Greek('texGreek','\\delta\>'		,'δ')
   1029  call s:Greek('texGreek','\\epsilon\>'		,'ϵ')
   1030  call s:Greek('texGreek','\\varepsilon\>'	,'ε')
   1031  call s:Greek('texGreek','\\zeta\>'		,'ζ')
   1032  call s:Greek('texGreek','\\eta\>'		,'η')
   1033  call s:Greek('texGreek','\\theta\>'		,'θ')
   1034  call s:Greek('texGreek','\\vartheta\>'	,'ϑ')
   1035  call s:Greek('texGreek','\\iota\>'            ,'ι')
   1036  call s:Greek('texGreek','\\kappa\>'		,'κ')
   1037  call s:Greek('texGreek','\\lambda\>'		,'λ')
   1038  call s:Greek('texGreek','\\mu\>'		,'μ')
   1039  call s:Greek('texGreek','\\nu\>'		,'ν')
   1040  call s:Greek('texGreek','\\xi\>'		,'ξ')
   1041  call s:Greek('texGreek','\\pi\>'		,'π')
   1042  call s:Greek('texGreek','\\varpi\>'		,'ϖ')
   1043  call s:Greek('texGreek','\\rho\>'		,'ρ')
   1044  call s:Greek('texGreek','\\varrho\>'		,'ϱ')
   1045  call s:Greek('texGreek','\\sigma\>'		,'σ')
   1046  call s:Greek('texGreek','\\varsigma\>'	,'ς')
   1047  call s:Greek('texGreek','\\tau\>'		,'τ')
   1048  call s:Greek('texGreek','\\upsilon\>'		,'υ')
   1049  call s:Greek('texGreek','\\phi\>'		,'ϕ')
   1050  call s:Greek('texGreek','\\varphi\>'		,'φ')
   1051  call s:Greek('texGreek','\\chi\>'		,'χ')
   1052  call s:Greek('texGreek','\\psi\>'		,'ψ')
   1053  call s:Greek('texGreek','\\omega\>'		,'ω')
   1054  call s:Greek('texGreek','\\Gamma\>'		,'Γ')
   1055  call s:Greek('texGreek','\\Delta\>'		,'Δ')
   1056  call s:Greek('texGreek','\\Theta\>'		,'Θ')
   1057  call s:Greek('texGreek','\\Lambda\>'		,'Λ')
   1058  call s:Greek('texGreek','\\Xi\>'              ,'Ξ')
   1059  call s:Greek('texGreek','\\Pi\>'		,'Π')
   1060  call s:Greek('texGreek','\\Sigma\>'		,'Σ')
   1061  call s:Greek('texGreek','\\Upsilon\>'		,'Υ')
   1062  call s:Greek('texGreek','\\Phi\>'		,'Φ')
   1063  call s:Greek('texGreek','\\Chi\>'		,'Χ')
   1064  call s:Greek('texGreek','\\Psi\>'		,'Ψ')
   1065  call s:Greek('texGreek','\\Omega\>'		,'Ω')
   1066  delfun s:Greek
   1067 endif
   1068 
   1069 " Superscripts/Subscripts {{{2
   1070 if s:tex_conceal =~# 's'
   1071  if s:tex_fast =~# 's'
   1072   syn region texSuperscript	matchgroup=texDelimiter start='\^{'	skip="\\\\\|\\[{}]" end='}'	contained concealends contains=texSpecialChar,texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
   1073   syn region texSubscript	matchgroup=texDelimiter start='_{'		skip="\\\\\|\\[{}]" end='}'	contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
   1074  endif
   1075  " s:SuperSub:
   1076  fun! s:SuperSub(group,leader,pat,cchar)
   1077    if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# s:tex_superscripts) || (a:leader == '_' && a:pat =~# s:tex_subscripts)
   1078 "     call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">")
   1079     exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
   1080     exe 'syn match '.a:group."s '".a:pat        ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
   1081    endif
   1082  endfun
   1083  call s:SuperSub('texSuperscript','\^','0','⁰')
   1084  call s:SuperSub('texSuperscript','\^','1','¹')
   1085  call s:SuperSub('texSuperscript','\^','2','²')
   1086  call s:SuperSub('texSuperscript','\^','3','³')
   1087  call s:SuperSub('texSuperscript','\^','4','⁴')
   1088  call s:SuperSub('texSuperscript','\^','5','⁵')
   1089  call s:SuperSub('texSuperscript','\^','6','⁶')
   1090  call s:SuperSub('texSuperscript','\^','7','⁷')
   1091  call s:SuperSub('texSuperscript','\^','8','⁸')
   1092  call s:SuperSub('texSuperscript','\^','9','⁹')
   1093  call s:SuperSub('texSuperscript','\^','a','ᵃ')
   1094  call s:SuperSub('texSuperscript','\^','b','ᵇ')
   1095  call s:SuperSub('texSuperscript','\^','c','ᶜ')
   1096  call s:SuperSub('texSuperscript','\^','d','ᵈ')
   1097  call s:SuperSub('texSuperscript','\^','e','ᵉ')
   1098  call s:SuperSub('texSuperscript','\^','f','ᶠ')
   1099  call s:SuperSub('texSuperscript','\^','g','ᵍ')
   1100  call s:SuperSub('texSuperscript','\^','h','ʰ')
   1101  call s:SuperSub('texSuperscript','\^','i','ⁱ')
   1102  call s:SuperSub('texSuperscript','\^','j','ʲ')
   1103  call s:SuperSub('texSuperscript','\^','k','ᵏ')
   1104  call s:SuperSub('texSuperscript','\^','l','ˡ')
   1105  call s:SuperSub('texSuperscript','\^','m','ᵐ')
   1106  call s:SuperSub('texSuperscript','\^','n','ⁿ')
   1107  call s:SuperSub('texSuperscript','\^','o','ᵒ')
   1108  call s:SuperSub('texSuperscript','\^','p','ᵖ')
   1109  call s:SuperSub('texSuperscript','\^','r','ʳ')
   1110  call s:SuperSub('texSuperscript','\^','s','ˢ')
   1111  call s:SuperSub('texSuperscript','\^','t','ᵗ')
   1112  call s:SuperSub('texSuperscript','\^','u','ᵘ')
   1113  call s:SuperSub('texSuperscript','\^','v','ᵛ')
   1114  call s:SuperSub('texSuperscript','\^','w','ʷ')
   1115  call s:SuperSub('texSuperscript','\^','x','ˣ')
   1116  call s:SuperSub('texSuperscript','\^','y','ʸ')
   1117  call s:SuperSub('texSuperscript','\^','z','ᶻ')
   1118  call s:SuperSub('texSuperscript','\^','A','ᴬ')
   1119  call s:SuperSub('texSuperscript','\^','B','ᴮ')
   1120  call s:SuperSub('texSuperscript','\^','D','ᴰ')
   1121  call s:SuperSub('texSuperscript','\^','E','ᴱ')
   1122  call s:SuperSub('texSuperscript','\^','G','ᴳ')
   1123  call s:SuperSub('texSuperscript','\^','H','ᴴ')
   1124  call s:SuperSub('texSuperscript','\^','I','ᴵ')
   1125  call s:SuperSub('texSuperscript','\^','J','ᴶ')
   1126  call s:SuperSub('texSuperscript','\^','K','ᴷ')
   1127  call s:SuperSub('texSuperscript','\^','L','ᴸ')
   1128  call s:SuperSub('texSuperscript','\^','M','ᴹ')
   1129  call s:SuperSub('texSuperscript','\^','N','ᴺ')
   1130  call s:SuperSub('texSuperscript','\^','O','ᴼ')
   1131  call s:SuperSub('texSuperscript','\^','P','ᴾ')
   1132  call s:SuperSub('texSuperscript','\^','R','ᴿ')
   1133  call s:SuperSub('texSuperscript','\^','T','ᵀ')
   1134  call s:SuperSub('texSuperscript','\^','U','ᵁ')
   1135  call s:SuperSub('texSuperscript','\^','V','ⱽ')
   1136  call s:SuperSub('texSuperscript','\^','W','ᵂ')
   1137  call s:SuperSub('texSuperscript','\^',',','︐')
   1138  call s:SuperSub('texSuperscript','\^',':','︓')
   1139  call s:SuperSub('texSuperscript','\^',';','︔')
   1140  call s:SuperSub('texSuperscript','\^','+','⁺')
   1141  call s:SuperSub('texSuperscript','\^','-','⁻')
   1142  call s:SuperSub('texSuperscript','\^','<','˂')
   1143  call s:SuperSub('texSuperscript','\^','>','˃')
   1144  call s:SuperSub('texSuperscript','\^','/','ˊ')
   1145  call s:SuperSub('texSuperscript','\^','(','⁽')
   1146  call s:SuperSub('texSuperscript','\^',')','⁾')
   1147  call s:SuperSub('texSuperscript','\^','\.','˙')
   1148  call s:SuperSub('texSuperscript','\^','=','˭')
   1149  call s:SuperSub('texSubscript','_','0','₀')
   1150  call s:SuperSub('texSubscript','_','1','₁')
   1151  call s:SuperSub('texSubscript','_','2','₂')
   1152  call s:SuperSub('texSubscript','_','3','₃')
   1153  call s:SuperSub('texSubscript','_','4','₄')
   1154  call s:SuperSub('texSubscript','_','5','₅')
   1155  call s:SuperSub('texSubscript','_','6','₆')
   1156  call s:SuperSub('texSubscript','_','7','₇')
   1157  call s:SuperSub('texSubscript','_','8','₈')
   1158  call s:SuperSub('texSubscript','_','9','₉')
   1159  call s:SuperSub('texSubscript','_','a','ₐ')
   1160  call s:SuperSub('texSubscript','_','e','ₑ')
   1161  call s:SuperSub('texSubscript','_','h','ₕ')
   1162  call s:SuperSub('texSubscript','_','i','ᵢ')
   1163  call s:SuperSub('texSubscript','_','j','ⱼ')
   1164  call s:SuperSub('texSubscript','_','k','ₖ')
   1165  call s:SuperSub('texSubscript','_','l','ₗ')
   1166  call s:SuperSub('texSubscript','_','m','ₘ')
   1167  call s:SuperSub('texSubscript','_','n','ₙ')
   1168  call s:SuperSub('texSubscript','_','o','ₒ')
   1169  call s:SuperSub('texSubscript','_','p','ₚ')
   1170  call s:SuperSub('texSubscript','_','r','ᵣ')
   1171  call s:SuperSub('texSubscript','_','s','ₛ')
   1172  call s:SuperSub('texSubscript','_','t','ₜ')
   1173  call s:SuperSub('texSubscript','_','u','ᵤ')
   1174  call s:SuperSub('texSubscript','_','v','ᵥ')
   1175  call s:SuperSub('texSubscript','_','x','ₓ')
   1176  call s:SuperSub('texSubscript','_',',','︐')
   1177  call s:SuperSub('texSubscript','_','+','₊')
   1178  call s:SuperSub('texSubscript','_','-','₋')
   1179  call s:SuperSub('texSubscript','_','/','ˏ')
   1180  call s:SuperSub('texSubscript','_','(','₍')
   1181  call s:SuperSub('texSubscript','_',')','₎')
   1182  call s:SuperSub('texSubscript','_','\.','‸')
   1183  call s:SuperSub('texSubscript','_','r','ᵣ')
   1184  call s:SuperSub('texSubscript','_','v','ᵥ')
   1185  call s:SuperSub('texSubscript','_','x','ₓ')
   1186  call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
   1187  call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
   1188  call s:SuperSub('texSubscript','_','\\phi\>'  ,'ᵩ')
   1189  call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
   1190  call s:SuperSub('texSubscript','_','\\chi\>'  ,'ᵪ')
   1191 
   1192  delfun s:SuperSub
   1193 endif
   1194 
   1195 " Accented characters and Ligatures: {{{2
   1196 if s:tex_conceal =~# 'a'
   1197  if b:tex_stylish
   1198   syn match texAccent		"\\[bcdvuH][^a-zA-Z@]"me=e-1
   1199   syn match texLigature	"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
   1200   syn match texLigature	'--'
   1201   syn match texLigature	'---'
   1202  else
   1203   fun! s:Accents(chr,...)
   1204     let i= 1
   1205     for accent in ["`","\\'","^",'"','\~','\.','=',"c","H","k","r","u","v"]
   1206      if i > a:0
   1207       break
   1208      endif
   1209      if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
   1210       let i= i + 1
   1211       continue
   1212      endif
   1213      if accent =~# '\a'
   1214       exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
   1215      else
   1216       exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
   1217      endif
   1218      let i= i + 1
   1219     endfor
   1220   endfun
   1221   "                  \`  \'  \^  \"  \~  \.  \=  \c  \H  \k  \r  \u  \v
   1222   call s:Accents('a','à','á','â','ä','ã','ȧ','ā',' ',' ','ą','å','ă','ǎ')
   1223   call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ','Ā',' ',' ','Ą','Å','Ă','Ǎ')
   1224   call s:Accents('c',' ','ć','ĉ',' ',' ','ċ',' ','ç',' ',' ',' ',' ','č')
   1225   call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ',' ','Ç',' ',' ',' ',' ','Č')
   1226   call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
   1227   call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
   1228   call s:Accents('e','è','é','ê','ë','ẽ','ė','ē','ȩ',' ','ę',' ','ĕ','ě')
   1229   call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ē','Ȩ',' ','Ę',' ','Ĕ','Ě')
   1230   call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ',' ','ģ',' ',' ',' ','ğ','ǧ')
   1231   call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ',' ','Ģ',' ',' ',' ','Ğ','Ǧ')
   1232   call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
   1233   call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
   1234   call s:Accents('i','ì','í','î','ï','ĩ','į','ī',' ',' ','į',' ','ĭ','ǐ')
   1235   call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ','Ī',' ',' ','Į',' ','Ĭ','Ǐ')
   1236   call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
   1237   call s:Accents('k',' ',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ','ǩ')
   1238   call s:Accents('K',' ',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ','Ǩ')
   1239   call s:Accents('l',' ','ĺ','ľ',' ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
   1240   call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
   1241   call s:Accents('n',' ','ń',' ',' ','ñ',' ',' ','ņ',' ',' ',' ',' ','ň')
   1242   call s:Accents('N',' ','Ń',' ',' ','Ñ',' ',' ','Ņ',' ',' ',' ',' ','Ň')
   1243   call s:Accents('o','ò','ó','ô','ö','õ','ȯ','ō',' ','ő','ǫ',' ','ŏ','ǒ')
   1244   call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ','Ō',' ','Ő','Ǫ',' ','Ŏ','Ǒ')
   1245   call s:Accents('r',' ','ŕ',' ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
   1246   call s:Accents('R',' ','Ŕ',' ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
   1247   call s:Accents('s',' ','ś','ŝ',' ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
   1248   call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
   1249   call s:Accents('t',' ',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
   1250   call s:Accents('T',' ',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
   1251   call s:Accents('u','ù','ú','û','ü','ũ',' ','ū',' ','ű','ų','ů','ŭ','ǔ')
   1252   call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ','Ū',' ','Ű','Ų','Ů','Ŭ','Ǔ')
   1253   call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
   1254   call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
   1255   call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
   1256   call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
   1257   call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ',' ','ž')
   1258   call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ',' ','Ž')
   1259   call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ',' ','ĭ',' ')
   1260   "                    \`  \'  \^  \"  \~  \.  \=  \c  \H  \k  \r  \u  \v
   1261   delfun s:Accents
   1262   syn match texAccent		'\\aa\>'	conceal cchar=å
   1263   syn match texAccent		'\\AA\>'	conceal cchar=Å
   1264   syn match texAccent		'\\o\>'		conceal cchar=ø
   1265   syn match texAccent		'\\O\>'		conceal cchar=Ø
   1266   syn match texLigature	'\\AE\>'	conceal cchar=Æ
   1267   syn match texLigature	'\\ae\>'	conceal cchar=æ
   1268   syn match texLigature	'\\oe\>'	conceal cchar=œ
   1269   syn match texLigature	'\\OE\>'	conceal cchar=Œ
   1270   syn match texLigature	'\\ss\>'	conceal cchar=ß
   1271   syn match texLigature	'--'		conceal cchar=   1272   syn match texLigature	'---'		conceal cchar=   1273  endif
   1274 endif
   1275 endif
   1276 
   1277 " ---------------------------------------------------------------------
   1278 " LaTeX synchronization: {{{1
   1279 syn sync maxlines=200
   1280 syn sync minlines=50
   1281 
   1282 syn  sync match texSyncStop			groupthere NONE		"%stopzone\>"
   1283 
   1284 " Synchronization: {{{1
   1285 " The $..$ and $$..$$ make for impossible sync patterns
   1286 " (one can't tell if a "$$" starts or stops a math zone by itself)
   1287 " The following grouptheres coupled with minlines above
   1288 " help improve the odds of good syncing.
   1289 if !exists("g:tex_no_math")
   1290 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{abstract}"
   1291 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{center}"
   1292 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{description}"
   1293 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{enumerate}"
   1294 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{itemize}"
   1295 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{table}"
   1296 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{tabular}"
   1297 syn sync match texSyncMathZoneA		groupthere NONE		"\\\(sub\)*section\>"
   1298 endif
   1299 
   1300 " ---------------------------------------------------------------------
   1301 " Highlighting: {{{1
   1302 
   1303 " Define the default highlighting. {{{1
   1304 if !exists("skip_tex_syntax_inits")
   1305 
   1306  " TeX highlighting groups which should share similar highlighting
   1307  if !exists("g:tex_no_error")
   1308   if !exists("g:tex_no_math")
   1309    hi def link texBadMath		texError
   1310    hi def link texBadPar		texBadMath
   1311    hi def link texMathDelimBad		texError
   1312    hi def link texMathError		texError
   1313    if !b:tex_stylish
   1314      hi def link texOnlyMath		texError
   1315    endif
   1316   endif
   1317   hi def link texError			Error
   1318  endif
   1319 
   1320  hi texBoldStyle		gui=bold	cterm=bold
   1321  hi texItalStyle		gui=italic	cterm=italic
   1322  hi texBoldItalStyle		gui=bold,italic cterm=bold,italic
   1323  hi texItalBoldStyle		gui=bold,italic cterm=bold,italic
   1324  hi def link texEmphStyle	texItalStyle
   1325  hi def link texCite		texRefZone
   1326  hi def link texDefCmd		texDef
   1327  hi def link texDefName	texDef
   1328  hi def link texDocType	texCmdName
   1329  hi def link texDocTypeArgs	texCmdArgs
   1330  hi def link texInputFileOpt	texCmdArgs
   1331  hi def link texInputCurlies	texDelimiter
   1332  hi def link texLigature	texSpecialChar
   1333  if !exists("g:tex_no_math")
   1334   hi def link texMathDelimSet1	texMathDelim
   1335   hi def link texMathDelimSet2	texMathDelim
   1336   hi def link texMathDelimKey	texMathDelim
   1337   hi def link texMathMatcher	texMath
   1338   hi def link texAccent	texStatement
   1339   hi def link texGreek		texStatement
   1340   hi def link texSuperscript	texStatement
   1341   hi def link texSubscript	texStatement
   1342   hi def link texSuperscripts 	texSuperscript
   1343   hi def link texSubscripts 	texSubscript
   1344   hi def link texMathSymbol	texStatement
   1345   hi def link texMathZoneV	texMath
   1346   hi def link texMathZoneW	texMath
   1347   hi def link texMathZoneX	texMath
   1348   hi def link texMathZoneY	texMath
   1349   hi def link texMathZoneV	texMath
   1350   hi def link texMathZoneZ	texMath
   1351  endif
   1352  hi def link texBeginEnd	texCmdName
   1353  hi def link texBeginEndName	texSection
   1354  hi def link texSpaceCode	texStatement
   1355  hi def link texStyleStatement	texStatement
   1356  hi def link texTypeSize	texType
   1357  hi def link texTypeStyle	texType
   1358 
   1359   " Basic TeX highlighting groups
   1360  hi def link texCmdArgs	Number
   1361  hi def link texCmdName	Statement
   1362  hi def link texComment	Comment
   1363  hi def link texDef		Statement
   1364  hi def link texDefParm	Special
   1365  hi def link texDelimiter	Delimiter
   1366  hi def link texEnvArgs	Number
   1367  hi def link texInput		Special
   1368  hi def link texInputFile	Special
   1369  hi def link texLength		Number
   1370  hi def link texMath		Special
   1371  hi def link texMathDelim	Statement
   1372  hi def link texMathOper	Operator
   1373  hi def link texNewCmd		Statement
   1374  hi def link texNewEnv		Statement
   1375  hi def link texOption		Number
   1376  hi def link texRefZone	Special
   1377  hi def link texSection	PreCondit
   1378  hi def link texSpaceCodeChar	Special
   1379  hi def link texSpecialChar	SpecialChar
   1380  hi def link texStatement	Statement
   1381  hi def link texString		String
   1382  hi def link texTodo		Todo
   1383  hi def link texType		Type
   1384  hi def link texZone		PreCondit
   1385 
   1386 endif
   1387 
   1388 " Cleanup: {{{1
   1389 delc TexFold
   1390 unlet s:extfname
   1391 let   b:current_syntax = "tex"
   1392 let &cpo               = s:keepcpo
   1393 unlet s:keepcpo
   1394 " vim: ts=8 fdm=marker