xref: /vim-8.2.3635/runtime/syntax/tex.vim (revision 17fb0e89)
1" Vim syntax file
2" Language:	TeX
3" Maintainer:	Dr. Charles E. Campbell, Jr. <[email protected]>
4" Last Change:	Dec 07, 2010
5" Version:	64
6" URL:		http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
7"
8" Notes: {{{1
9"
10" 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
11"    use %stopzone.
12"
13" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
14"    by suitable use of %stopzone.
15"
16" 3. If you have a slow computer, you may wish to modify
17"
18"	syn sync maxlines=200
19"	syn sync minlines=50
20"
21"    to values that are more to your liking.
22"
23" 4. There is no match-syncing for $...$ and $$...$$; hence large
24"    equation blocks constructed that way may exhibit syncing problems.
25"    (there's no difference between begin/end patterns)
26"
27" 5. If you have the variable "g:tex_no_error" defined then none of the
28"    lexical error-checking will be done.
29"
30"    ie. let g:tex_no_error=1
31
32" Version Clears: {{{1
33" For version 5.x: Clear all syntax items
34" For version 6.x: Quit when a syntax file was already loaded
35if version < 600
36  syntax clear
37elseif exists("b:current_syntax")
38  finish
39endif
40scriptencoding utf-8
41
42" Define the default highlighting. {{{1
43" For version 5.7 and earlier: only when not done already
44" For version 5.8 and later: only when an item doesn't have highlighting yet
45if version >= 508 || !exists("did_tex_syntax_inits")
46 let did_tex_syntax_inits = 1
47 if version < 508
48  command -nargs=+ HiLink hi link <args>
49 else
50  command -nargs=+ HiLink hi def link <args>
51 endif
52endif
53if exists("g:tex_tex") && !exists("g:tex_no_error")
54 let g:tex_no_error= 1
55endif
56
57" let user determine which classes of concealment will be supported
58"   a=accents/ligatures d=delimiters m=math symbols  g=Greek  s=superscripts/subscripts
59if !exists("g:tex_conceal")
60 let s:tex_conceal= 'admgs'
61else
62 let s:tex_conceal= g:tex_conceal
63endif
64
65" Determine whether or not to use "*.sty" mode {{{1
66" The user may override the normal determination by setting
67"   g:tex_stylish to 1      (for    "*.sty" mode)
68"    or to           0 else (normal "*.tex" mode)
69" or on a buffer-by-buffer basis with b:tex_stylish
70let s:extfname=expand("%:e")
71if exists("g:tex_stylish")
72 let b:tex_stylish= g:tex_stylish
73elseif !exists("b:tex_stylish")
74 if s:extfname == "sty" || s:extfname == "cls" || s:extfname == "clo" || s:extfname == "dtx" || s:extfname == "ltx"
75  let b:tex_stylish= 1
76 else
77  let b:tex_stylish= 0
78 endif
79endif
80
81" handle folding {{{1
82if !exists("g:tex_fold_enabled")
83 let g:tex_fold_enabled= 0
84elseif g:tex_fold_enabled && !has("folding")
85 let g:tex_fold_enabled= 0
86 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
87endif
88if g:tex_fold_enabled && &fdm == "manual"
89 setl fdm=syntax
90endif
91
92" (La)TeX keywords: uses the characters 0-9,a-z,A-Z,192-255 only... {{{1
93" but _ is the only one that causes problems.
94" One may override this iskeyword setting by providing
95" g:tex_isk
96if exists("g:tex_isk")
97 exe "setlocal isk=".g:tex_isk
98else
99 setlocal isk=48-57,a-z,A-Z,192-255
100endif
101if b:tex_stylish
102  setlocal isk+=@-@
103endif
104
105" Clusters: {{{1
106" --------
107syn cluster texCmdGroup		contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
108if !exists("g:tex_no_error")
109 syn cluster texCmdGroup	add=texMathError
110endif
111syn cluster texEnvGroup		contains=texMatcher,texMathDelim,texSpecialChar,texStatement
112syn 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,texSectionMarker,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract
113syn 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,@Spell
114syn 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,@Spell,texStyleMatcher
115syn cluster texRefGroup		contains=texMatcher,texComment,texDelimiter
116if !exists("tex_no_math")
117 syn cluster texMathZones	contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
118 syn cluster texMatchGroup	add=@texMathZones
119 syn cluster texMathDelimGroup	contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
120 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
121 syn cluster texMathZoneGroup	contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
122 if !exists("g:tex_no_error")
123  syn cluster texMathMatchGroup	add=texMathError
124  syn cluster texMathZoneGroup	add=texMathError
125 endif
126 syn cluster texMathZoneGroup add=@NoSpell
127 " following used in the \part \chapter \section \subsection \subsubsection
128 " \paragraph \subparagraph \author \title highlighting
129 syn cluster texDocGroup		contains=texPartZone,@texPartGroup
130 syn cluster texPartGroup		contains=texChapterZone,texSectionZone,texParaZone
131 syn cluster texChapterGroup		contains=texSectionZone,texParaZone
132 syn cluster texSectionGroup		contains=texSubSectionZone,texParaZone
133 syn cluster texSubSectionGroup		contains=texSubSubSectionZone,texParaZone
134 syn cluster texSubSubSectionGroup	contains=texParaZone
135 syn cluster texParaGroup		contains=texSubParaZone
136 if has("conceal") && &enc == 'utf-8'
137  syn cluster texMathZoneGroup	add=texGreek,texSuperscript,texSubscript,texMathSymbol
138  syn cluster texMathMatchGroup	add=texGreek,texSuperscript,texSubscript,texMathSymbol
139 endif
140endif
141
142" Try to flag {} and () mismatches: {{{1
143if !exists("g:tex_no_error")
144 syn region texMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texMatchGroup,texError
145 syn region texMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texMatchGroup,texError
146else
147 syn region texMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texMatchGroup
148 syn region texMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texMatchGroup
149endif
150syn region texParen		start="("						end=")"		contains=@texMatchGroup,@Spell
151if !exists("g:tex_no_error")
152 syn match  texError		"[}\])]"
153endif
154if !exists("tex_no_math")
155 if !exists("g:tex_no_error")
156  syn match  texMathError	"}"	contained
157 endif
158 syn region texMathMatcher	matchgroup=Delimiter start="{"  skip="\\\\\|\\}"  end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
159endif
160
161" TeX/LaTeX keywords: {{{1
162" Instead of trying to be All Knowing, I just match \..alphameric..
163" Note that *.tex files may not have "@" in their \commands
164if exists("g:tex_tex") || b:tex_stylish
165  syn match texStatement	"\\[a-zA-Z@]\+"
166else
167  syn match texStatement	"\\\a\+"
168  if !exists("g:tex_no_error")
169   syn match texError		"\\\a*@[a-zA-Z@]*"
170  endif
171endif
172
173" TeX/LaTeX delimiters: {{{1
174syn match texDelimiter		"&"
175syn match texDelimiter		"\\\\"
176
177" Tex/Latex Options: {{{1
178syn match texOption	"[^\\]\zs#\d\+\|^#\d\+"
179
180" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
181if b:tex_stylish
182  syn match texAccent		"\\[bcdvuH][^a-zA-Z@]"me=e-1
183  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
184else
185  syn match texAccent		"\\[bcdvuH]\A"me=e-1
186  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
187endif
188syn match texAccent		"\\[bcdvuH]$"
189syn match texAccent		+\\[=^.\~"`']+
190syn match texAccent		+\\['=t'.c^ud"vb~Hr]{\a}+
191syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
192
193" \begin{}/\end{} section markers: {{{1
194syn match  texSectionMarker	"\\begin\>\|\\end\>" nextgroup=texSectionName
195syn region texSectionName	matchgroup=Delimiter start="{" end="}"  contained	nextgroup=texSectionModifier	contains=texComment
196syn region texSectionModifier	matchgroup=Delimiter start="\[" end="]" contained	contains=texComment
197
198" \documentclass, \documentstyle, \usepackage: {{{1
199syn match  texDocType		"\\documentclass\>\|\\documentstyle\>\|\\usepackage\>"	nextgroup=texSectionName,texDocTypeArgs
200syn region texDocTypeArgs	matchgroup=Delimiter start="\[" end="]"			contained	nextgroup=texSectionName	contains=texComment
201
202" Preamble syntax-based folding support: {{{1
203if g:tex_fold_enabled && has("folding")
204 syn region texPreamble	transparent fold	start='\zs\\documentclass\>' end='\ze\\begin{document}'	contains=texStyle,@texMatchGroup
205endif
206
207" TeX input: {{{1
208syn match texInput		"\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7				contains=texStatement
209syn match texInputFile		"\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}"	contains=texStatement,texInputCurlies,texInputFileOpt
210syn match texInputFile		"\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}"		contains=texStatement,texInputCurlies,texInputFileOpt
211syn match texInputCurlies	"[{}]"								contained
212syn region texInputFileOpt	matchgroup=Delimiter start="\[" end="\]"			contained	contains=texComment
213
214" Type Styles (LaTeX 2.09): {{{1
215syn match texTypeStyle		"\\rm\>"
216syn match texTypeStyle		"\\em\>"
217syn match texTypeStyle		"\\bf\>"
218syn match texTypeStyle		"\\it\>"
219syn match texTypeStyle		"\\sl\>"
220syn match texTypeStyle		"\\sf\>"
221syn match texTypeStyle		"\\sc\>"
222syn match texTypeStyle		"\\tt\>"
223
224" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
225syn match texTypeStyle		"\\textbf\>"
226syn match texTypeStyle		"\\textit\>"
227syn match texTypeStyle		"\\textmd\>"
228syn match texTypeStyle		"\\textrm\>"
229syn match texTypeStyle		"\\textsc\>"
230syn match texTypeStyle		"\\textsf\>"
231syn match texTypeStyle		"\\textsl\>"
232syn match texTypeStyle		"\\texttt\>"
233syn match texTypeStyle		"\\textup\>"
234syn match texTypeStyle		"\\emph\>"
235
236syn match texTypeStyle		"\\mathbb\>"
237syn match texTypeStyle		"\\mathbf\>"
238syn match texTypeStyle		"\\mathcal\>"
239syn match texTypeStyle		"\\mathfrak\>"
240syn match texTypeStyle		"\\mathit\>"
241syn match texTypeStyle		"\\mathnormal\>"
242syn match texTypeStyle		"\\mathrm\>"
243syn match texTypeStyle		"\\mathsf\>"
244syn match texTypeStyle		"\\mathtt\>"
245
246syn match texTypeStyle		"\\rmfamily\>"
247syn match texTypeStyle		"\\sffamily\>"
248syn match texTypeStyle		"\\ttfamily\>"
249
250syn match texTypeStyle		"\\itshape\>"
251syn match texTypeStyle		"\\scshape\>"
252syn match texTypeStyle		"\\slshape\>"
253syn match texTypeStyle		"\\upshape\>"
254
255syn match texTypeStyle		"\\bfseries\>"
256syn match texTypeStyle		"\\mdseries\>"
257
258" Some type sizes: {{{1
259syn match texTypeSize		"\\tiny\>"
260syn match texTypeSize		"\\scriptsize\>"
261syn match texTypeSize		"\\footnotesize\>"
262syn match texTypeSize		"\\small\>"
263syn match texTypeSize		"\\normalsize\>"
264syn match texTypeSize		"\\large\>"
265syn match texTypeSize		"\\Large\>"
266syn match texTypeSize		"\\LARGE\>"
267syn match texTypeSize		"\\huge\>"
268syn match texTypeSize		"\\Huge\>"
269
270" Spacecodes (TeX'isms): {{{1
271" \mathcode`\^^@="2201  \delcode`\(="028300  \sfcode`\)=0 \uccode`X=`X  \lccode`x=`x
272syn match texSpaceCode		"\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
273syn match texSpaceCodeChar    "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)"	contained
274
275" Sections, subsections, etc: {{{1
276if g:tex_fold_enabled && has("folding")
277 syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											fold contains=@texFoldGroup,@texDocGroup,@Spell
278 syn region texPartZone			matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								fold contains=@texFoldGroup,@texPartGroup,@Spell
279 syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							fold contains=@texFoldGroup,@texChapterGroup,@Spell
280 syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					fold contains=@texFoldGroup,@texSectionGroup,@Spell
281 syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
282 syn region texSubSubSectionZone	matchgroup=texSection start='\\subsubsection\>'		 end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				fold contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
283 syn region texParaZone			matchgroup=texSection start='\\paragraph\>'		 end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'			fold contains=@texFoldGroup,@texParaGroup,@Spell
284 syn region texSubParaZone		matchgroup=texSection start='\\subparagraph\>'		 end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'	fold contains=@texFoldGroup,@Spell
285 syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													fold contains=@texFoldGroup,@Spell
286 syn region texAbstract			matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											fold contains=@texFoldGroup,@Spell
287else
288 syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											contains=@texFoldGroup,@texDocGroup,@Spell
289 syn region texPartZone			matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								contains=@texFoldGroup,@texPartGroup,@Spell
290 syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							contains=@texFoldGroup,@texChapterGroup,@Spell
291 syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					contains=@texFoldGroup,@texSectionGroup,@Spell
292 syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSectionGroup,@Spell
293 syn region texSubSubSectionZone	matchgroup=texSection start='\\subsubsection\>'		 end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
294 syn region texParaZone			matchgroup=texSection start='\\paragraph\>'		 end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'			contains=@texFoldGroup,@texParaGroup,@Spell
295 syn region texSubParaZone		matchgroup=texSection start='\\subparagraph\>'		 end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'	contains=@texFoldGroup,@Spell
296 syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													contains=@texFoldGroup,@Spell
297 syn region texAbstract			matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											contains=@texFoldGroup,@Spell
298endif
299
300" Bad Math (mismatched): {{{1
301if !exists("tex_no_math")
302 syn match texBadMath		"\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|smallmatrix\|xxalignat\)\s*}"
303 syn match texBadMath		"\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
304 syn match texBadMath		"\\[\])]"
305endif
306
307" Math Zones: {{{1
308if !exists("tex_no_math")
309 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
310 "                 Starred forms are created if starform is true.  Starred
311 "                 forms have syntax group and synchronization groups with a
312 "                 "S" appended.  Handles: cluster, syntax, sync, and HiLink.
313 fun! TexNewMathZone(sfx,mathzone,starform)
314   let grpname  = "texMathZone".a:sfx
315   let syncname = "texSyncMathZone".a:sfx
316   if g:tex_fold_enabled
317    let foldcmd= " fold"
318   else
319    let foldcmd= ""
320   endif
321   exe "syn cluster texMathZones add=".grpname
322   exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
323   exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
324   exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
325   exe 'hi def link '.grpname.' texMath'
326   if a:starform
327    let grpname  = "texMathZone".a:sfx.'S'
328    let syncname = "texSyncMathZone".a:sfx.'S'
329    exe "syn cluster texMathZones add=".grpname
330    exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
331    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
332    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
333    exe 'hi def link '.grpname.' texMath'
334   endif
335 endfun
336
337 " Standard Math Zones: {{{2
338 call TexNewMathZone("A","align",1)
339 call TexNewMathZone("B","alignat",1)
340 call TexNewMathZone("C","displaymath",1)
341 call TexNewMathZone("D","eqnarray",1)
342 call TexNewMathZone("E","equation",1)
343 call TexNewMathZone("F","flalign",1)
344 call TexNewMathZone("G","gather",1)
345 call TexNewMathZone("H","math",1)
346 call TexNewMathZone("I","multline",1)
347 call TexNewMathZone("K","xalignat",1)
348 call TexNewMathZone("L","xxalignat",0)
349
350 " Inline Math Zones: {{{2
351 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'd'
352  syn region texMathZoneV	matchgroup=Delimiter start="\\("			matchgroup=Delimiter end="\\)\|%stopzone\>"	keepend concealends contains=@texMathZoneGroup
353  syn region texMathZoneW	matchgroup=Delimiter start="\\\["			matchgroup=Delimiter end="\\]\|%stopzone\>"	keepend concealends contains=@texMathZoneGroup
354  syn region texMathZoneX	matchgroup=Delimiter start="\$" skip="\\\\\|\\\$"	matchgroup=Delimiter end="\$" end="%stopzone\>"		concealends contains=@texMathZoneGroup
355  syn region texMathZoneY	matchgroup=Delimiter start="\$\$" 			matchgroup=Delimiter end="\$\$" end="%stopzone\>"	concealends keepend		contains=@texMathZoneGroup
356 else
357  syn region texMathZoneV	matchgroup=Delimiter start="\\("			matchgroup=Delimiter end="\\)\|%stopzone\>"	keepend contains=@texMathZoneGroup
358  syn region texMathZoneW	matchgroup=Delimiter start="\\\["			matchgroup=Delimiter end="\\]\|%stopzone\>"	keepend contains=@texMathZoneGroup
359  syn region texMathZoneX	matchgroup=Delimiter start="\$" skip="\\\\\|\\\$"	matchgroup=Delimiter end="\$" end="%stopzone\>"	contains=@texMathZoneGroup
360  syn region texMathZoneY	matchgroup=Delimiter start="\$\$" 			matchgroup=Delimiter end="\$\$" end="%stopzone\>"	keepend		contains=@texMathZoneGroup
361 endif
362 syn region texMathZoneZ	matchgroup=texStatement start="\\ensuremath\s*{"	matchgroup=texStatement end="}" end="%stopzone\>"	contains=@texMathZoneGroup
363
364 syn match texMathOper		"[_^=]" contained
365
366 " Text Inside Math Zones: {{{2
367 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{'	end='}'	contains=@texFoldGroup,@Spell
368
369 " \left..something.. and \right..something.. support: {{{2
370 syn match   texMathDelimBad	contained		"\S"
371 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm'
372  syn match   texMathDelim	contained		"\\left\\{\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
373  syn match   texMathDelim	contained		"\\right\\}\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
374  let s:texMathDelimList=[
375     \ ['<'            , '<'] ,
376     \ ['>'            , '>'] ,
377     \ ['('            , '('] ,
378     \ [')'            , ')'] ,
379     \ ['\['           , '['] ,
380     \ [']'            , ']'] ,
381     \ ['\\{'          , '{'] ,
382     \ ['\\}'          , '}'] ,
383     \ ['|'            , '|'] ,
384     \ ['\\|'          , '‖'] ,
385     \ ['\\backslash'  , '\'] ,
386     \ ['\\downarrow'  , '↓'] ,
387     \ ['\\Downarrow'  , '⇓'] ,
388     \ ['\\langle'     , '<'] ,
389     \ ['\\lbrace'     , '['] ,
390     \ ['\\lceil'      , '⌈'] ,
391     \ ['\\lfloor'     , '⌊'] ,
392     \ ['\\lgroup'     , '⌊'] ,
393     \ ['\\lmoustache' , '⎛'] ,
394     \ ['\\rangle'     , '>'] ,
395     \ ['\\rbrace'     , ']'] ,
396     \ ['\\rceil'      , '⌉'] ,
397     \ ['\\rfloor'     , '⌋'] ,
398     \ ['\\rgroup'     , '⌋'] ,
399     \ ['\\rmoustache' , '⎞'] ,
400     \ ['\\uparrow'    , '↑'] ,
401     \ ['\\Uparrow'    , '↑'] ,
402     \ ['\\updownarrow', '↕'] ,
403     \ ['\\Updownarrow', '⇕']]
404  syn match texMathDelim	'\\[bB]igg\=[lr]' contained nextgroup=texMathDelimBad
405  for texmath in s:texMathDelimList
406   exe "syn match texMathDelim	'\\\\[bB]igg\\=[lr]\\=".texmath[0]."'	contained conceal cchar=".texmath[1]
407  endfor
408
409 else
410  syn match   texMathDelim	contained		"\\\(left\|right\)\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
411  syn match   texMathDelim	contained		"\\[bB]igg\=[lr]\=\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
412  syn match   texMathDelimSet2	contained	"\\"		nextgroup=texMathDelimKey,texMathDelimBad
413  syn match   texMathDelimSet1	contained	"[<>()[\]|/.]\|\\[{}|]"
414  syn keyword texMathDelimKey	contained	backslash       lceil           lVert           rgroup          uparrow
415  syn keyword texMathDelimKey	contained	downarrow       lfloor          rangle          rmoustache      Uparrow
416  syn keyword texMathDelimKey	contained	Downarrow       lgroup          rbrace          rvert           updownarrow
417  syn keyword texMathDelimKey	contained	langle          lmoustache      rceil           rVert           Updownarrow
418  syn keyword texMathDelimKey	contained	lbrace          lvert           rfloor
419 endif
420 syn match   texMathDelim	contained		"\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
421 syn match   texMathDelim	contained		"\\lefteqn\>"
422endif
423
424" Special TeX characters  ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
425syn match texSpecialChar	"\\[$&%#{}_]"
426if b:tex_stylish
427  syn match texSpecialChar	"\\[SP@][^a-zA-Z@]"me=e-1
428else
429  syn match texSpecialChar	"\\[SP@]\A"me=e-1
430endif
431syn match texSpecialChar	"\\\\"
432if !exists("tex_no_math")
433 syn match texOnlyMath		"[_^]"
434endif
435syn match texSpecialChar	"\^\^[0-9a-f]\{2}\|\^\^\S"
436
437" Comments: {{{1
438"    Normal TeX LaTeX     :   %....
439"    Documented TeX Format:  ^^A...	-and-	leading %s (only)
440if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
441 syn cluster texCommentGroup	contains=texTodo,@Spell
442else
443 syn cluster texCommentGroup	contains=texTodo,@NoSpell
444endif
445syn case ignore
446syn keyword texTodo		contained		combak	fixme	todo	xxx
447syn case match
448if s:extfname == "dtx"
449  syn match texComment		"\^\^A.*$"	contains=@texCommentGroup
450  syn match texComment		"^%\+"		contains=@texCommentGroup
451else
452  if g:tex_fold_enabled
453   " allows syntax-folding of 2 or more contiguous comment lines
454   " single-line comments are not folded
455   syn match  texComment	"%.*$"		contains=@texCommentGroup
456   syn region texComment	start="^\zs\s*%.*\_s*%"	skip="^\s*%"	end='^\ze\s*[^%]' fold
457  else
458   syn match texComment		"%.*$"		contains=@texCommentGroup
459  endif
460endif
461
462" Separate lines used for verb` and verb# so that the end conditions {{{1
463" will appropriately terminate.
464" If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
465if exists("g:tex_verbspell") && g:tex_verbspell
466 syn region texZone		start="\\begin{[vV]erbatim}"		end="\\end{[vV]erbatim}\|%stopzone\>"	contains=@Spell
467 " listings package:
468 syn region texZone		start="\\begin{lstlisting}"		end="\\end{lstlisting}\|%stopzone\>"	contains=@Spell
469 " moreverb package:
470 syn region texZone		start="\\begin{verbatimtab}"		end="\\end{verbatimtab}\|%stopzone\>"	contains=@Spell
471 syn region texZone		start="\\begin{verbatimwrite}"		end="\\end{verbatimwrite}\|%stopzone\>"	contains=@Spell
472 syn region texZone		start="\\begin{boxedverbatim}"		end="\\end{boxedverbatim}\|%stopzone\>"	contains=@Spell
473 if version < 600
474  syn region texZone		start="\\verb\*\=`"			end="`\|%stopzone\>"			contains=@Spell
475  syn region texZone		start="\\verb\*\=#"			end="#\|%stopzone\>"			contains=@Spell
476 else
477   if b:tex_stylish
478    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z@]\)"	end="\z1\|%stopzone\>"			contains=@Spell
479   else
480    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z]\)"	end="\z1\|%stopzone\>"			contains=@Spell
481   endif
482 endif
483else
484 syn region texZone		start="\\begin{[vV]erbatim}"		end="\\end{[vV]erbatim}\|%stopzone\>"
485 " listings package:
486 syn region texZone		start="\\begin{lstlisting}"		end="\\end{lstlisting}\|%stopzone\>"
487 " moreverb package:
488 syn region texZone		start="\\begin{verbatimtab}"		end="\\end{verbatimtab}\|%stopzone\>"
489 syn region texZone		start="\\begin{verbatimwrite}"		end="\\end{verbatimwrite}\|%stopzone\>"
490 syn region texZone		start="\\begin{boxedverbatim}"		end="\\end{boxedverbatim}\|%stopzone\>"
491 if version < 600
492  syn region texZone		start="\\verb\*\=`"			end="`\|%stopzone\>"
493  syn region texZone		start="\\verb\*\=#"			end="#\|%stopzone\>"
494 else
495   if b:tex_stylish
496     syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z@]\)"	end="\z1\|%stopzone\>"
497   else
498     syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z]\)"	end="\z1\|%stopzone\>"
499   endif
500 endif
501endif
502
503" Tex Reference Zones: {{{1
504syn match texRefZone		'\\@samp\>'		skipwhite	nextgroup=texRefLabel
505syn match texRefZone		'\\nocite\>'		skipwhite	nextgroup=texRefLabel
506syn match texRefZone		'\\bibliography\>'	skipwhite	nextgroup=texRefLabel
507syn match texRefZone		'\\label\>'		skipwhite	nextgroup=texRefLabel
508syn match texRefZone		'\\\(page\|eq\)ref\>'	skipwhite	nextgroup=texRefLabel
509syn match texRefZone		'\\v\=ref'		skipwhite	nextgroup=texRefLabel
510syn match texRefZone		'\\cite\%([tp]\*\=\)\='	skipwhite	nextgroup=texCiteOption,texCite
511syn region texRefLabel		contained matchgroup=Delimiter start='{'	end='}'	contains=@texRefGroup
512syn region texCiteOption	contained matchgroup=Delimiter start='\['	end=']'	contains=@Spell,@texRefGroup,@texMathZones,texRefZone	nextgroup=texCiteOption,texCite
513syn region texCite		contained matchgroup=Delimiter start='{'	end='}'	contains=@texRefGroup,texCite
514
515" Handle newcommand, newenvironment : {{{1
516syn match  texNewCmd				"\\newcommand\>"			nextgroup=texCmdName skipwhite skipnl
517syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
518syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]"		nextgroup=texCmdBody skipwhite skipnl
519syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]"	matchgroup=Delimiter end="}" contains=@texCmdGroup
520syn match  texNewEnv				"\\newenvironment\>"			nextgroup=texEnvName skipwhite skipnl
521syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texEnvBgn skipwhite skipnl
522syn region texEnvBgn  contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
523syn region texEnvEnd  contained matchgroup=Delimiter start="{"rs=s+1  end="}"		skipwhite skipnl contains=@texEnvGroup
524
525" Definitions/Commands: {{{1
526syn match texDefCmd				"\\def\>"				nextgroup=texDefName skipwhite skipnl
527if b:tex_stylish
528  syn match texDefName contained		"\\[a-zA-Z@]\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
529  syn match texDefName contained		"\\[^a-zA-Z@]"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
530else
531  syn match texDefName contained		"\\\a\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
532  syn match texDefName contained		"\\\A"					nextgroup=texDefParms,texCmdBody skipwhite skipnl
533endif
534syn match texDefParms  contained		"#[^{]*"	contains=texDefParm	nextgroup=texCmdBody skipwhite skipnl
535syn match  texDefParm  contained		"#\d\+"
536
537" TeX Lengths: {{{1
538syn match  texLength		"\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
539
540" TeX String Delimiters: {{{1
541syn match texString		"\(``\|''\|,,\)"
542
543" makeatletter -- makeatother sections
544if !exists("g:tex_no_error")
545 syn region texStyle			matchgroup=texStatement start='\\makeatletter' end='\\makeatother'	contains=@texStyleGroup contained
546 syn match  texStyleStatement		"\\[a-zA-Z@]\+"	contained
547 syn region texStyleMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texStyleGroup,texError	contained
548 syn region texStyleMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texStyleGroup,texError	contained
549endif
550
551" Conceal mode support (supports set cole=2) {{{1
552if has("conceal") && &enc == 'utf-8'
553
554 " Math Symbols {{{2
555 " (many of these symbols were contributed by Björn Winckler)
556 if s:tex_conceal =~ 'm'
557  let s:texMathList=[
558    \ ['|'		, '‖'],
559    \ ['angle'		, '∠'],
560    \ ['approx'		, '≈'],
561    \ ['ast'		, '∗'],
562    \ ['asymp'		, '≍'],
563    \ ['backepsilon'	, '∍'],
564    \ ['backsimeq'	, '≃'],
565    \ ['barwedge'	, '⊼'],
566    \ ['because'	, '∵'],
567    \ ['between'	, '≬'],
568    \ ['bigcap'		, '∩'],
569    \ ['bigcup'		, '∪'],
570    \ ['bigodot'	, '⊙'],
571    \ ['bigoplus'	, '⊕'],
572    \ ['bigotimes'	, '⊗'],
573    \ ['bigsqcup'	, '⊔'],
574    \ ['bigtriangledown', '∇'],
575    \ ['bigvee'		, '⋁'],
576    \ ['bigwedge'	, '⋀'],
577    \ ['blacksquare'	, '∎'],
578    \ ['bot'		, '⊥'],
579    \ ['boxdot'		, '⊡'],
580    \ ['boxminus'	, '⊟'],
581    \ ['boxplus'	, '⊞'],
582    \ ['boxtimes'	, '⊠'],
583    \ ['bumpeq'		, '≏'],
584    \ ['Bumpeq'		, '≎'],
585    \ ['cap'		, '∩'],
586    \ ['Cap'		, '⋒'],
587    \ ['cdot'		, '·'],
588    \ ['cdots'		, '⋯'],
589    \ ['circ'		, '∘'],
590    \ ['circeq'		, '≗'],
591    \ ['circlearrowleft', '↺'],
592    \ ['circlearrowright', '↻'],
593    \ ['circledast'	, '⊛'],
594    \ ['circledcirc'	, '⊚'],
595    \ ['complement'	, '∁'],
596    \ ['cong'		, '≅'],
597    \ ['coprod'		, '∐'],
598    \ ['cup'		, '∪'],
599    \ ['Cup'		, '⋓'],
600    \ ['curlyeqprec'	, '⋞'],
601    \ ['curlyeqsucc'	, '⋟'],
602    \ ['curlyvee'	, '⋎'],
603    \ ['curlywedge'	, '⋏'],
604    \ ['dashv'		, '⊣'],
605    \ ['diamond'	, '⋄'],
606    \ ['div'		, '÷'],
607    \ ['doteq'		, '≐'],
608    \ ['doteqdot'	, '≑'],
609    \ ['dotplus'	, '∔'],
610    \ ['dotsb'		, '⋯'],
611    \ ['dotsc'		, '…'],
612    \ ['dots'		, '…'],
613    \ ['dotsi'		, '⋯'],
614    \ ['dotso'		, '…'],
615    \ ['doublebarwedge'	, '⩞'],
616    \ ['downarrow'	, '↓'],
617    \ ['Downarrow'	, '⇓'],
618    \ ['emptyset'	, '∅'],
619    \ ['eqcirc'		, '≖'],
620    \ ['eqsim'		, '≂'],
621    \ ['eqslantgtr'	, '⪖'],
622    \ ['eqslantless'	, '⪕'],
623    \ ['equiv'		, '≡'],
624    \ ['exists'		, '∃'],
625    \ ['fallingdotseq'	, '≒'],
626    \ ['forall'		, '∀'],
627    \ ['ge'		, '≥'],
628    \ ['geq'		, '≥'],
629    \ ['geqq'		, '≧'],
630    \ ['gets'		, '←'],
631    \ ['gneqq'		, '≩'],
632    \ ['gtrdot'		, '⋗'],
633    \ ['gtreqless'	, '⋛'],
634    \ ['gtrless'	, '≷'],
635    \ ['gtrsim'		, '≳'],
636    \ ['hookleftarrow'	, '↩'],
637    \ ['hookrightarrow'	, '↪'],
638    \ ['iiint'		, '∭'],
639    \ ['iint'		, '∬'],
640    \ ['Im'		, 'ℑ'],
641    \ ['in'		, '∈'],
642    \ ['infty'		, '∞'],
643    \ ['int'		, '∫'],
644    \ ['lceil'		, '⌈'],
645    \ ['ldots'		, '…'],
646    \ ['le'		, '≤'],
647    \ ['leftarrow'	, '⟵'],
648    \ ['Leftarrow'	, '⟸'],
649    \ ['leftarrowtail'	, '↢'],
650    \ ['left('		, '('],
651    \ ['left\['		, '['],
652    \ ['left\\{'	, '{'],
653    \ ['Leftrightarrow'	, '⇔'],
654    \ ['leftrightsquigarrow', '↭'],
655    \ ['leftthreetimes'	, '⋋'],
656    \ ['leq'		, '≤'],
657    \ ['leqq'		, '≦'],
658    \ ['lessdot'	, '⋖'],
659    \ ['lesseqgtr'	, '⋚'],
660    \ ['lesssim'	, '≲'],
661    \ ['lfloor'		, '⌊'],
662    \ ['lmoustache'     , '╭'],
663    \ ['lneqq'		, '≨'],
664    \ ['ltimes'		, '⋉'],
665    \ ['mapsto'		, '↦'],
666    \ ['measuredangle'	, '∡'],
667    \ ['mid'		, '∣'],
668    \ ['mp'		, '∓'],
669    \ ['nabla'		, '∇'],
670    \ ['ncong'		, '≇'],
671    \ ['nearrow'	, '↗'],
672    \ ['ne'		, '≠'],
673    \ ['neg'		, '¬'],
674    \ ['neq'		, '≠'],
675    \ ['nexists'	, '∄'],
676    \ ['ngeq'		, '≱'],
677    \ ['ngeqq'		, '≱'],
678    \ ['ngtr'		, '≯'],
679    \ ['ni'		, '∋'],
680    \ ['nleftarrow'	, '↚'],
681    \ ['nLeftarrow'	, '⇍'],
682    \ ['nLeftrightarrow', '⇎'],
683    \ ['nleq'		, '≰'],
684    \ ['nleqq'		, '≰'],
685    \ ['nless'		, '≮'],
686    \ ['nmid'		, '∤'],
687    \ ['notin'		, '∉'],
688    \ ['nprec'		, '⊀'],
689    \ ['nrightarrow'	, '↛'],
690    \ ['nRightarrow'	, '⇏'],
691    \ ['nsim'		, '≁'],
692    \ ['nsucc'		, '⊁'],
693    \ ['ntriangleleft'	, '⋪'],
694    \ ['ntrianglelefteq', '⋬'],
695    \ ['ntriangleright'	, '⋫'],
696    \ ['ntrianglerighteq', '⋭'],
697    \ ['nvdash'		, '⊬'],
698    \ ['nvDash'		, '⊭'],
699    \ ['nVdash'		, '⊮'],
700    \ ['nwarrow'	, '↖'],
701    \ ['odot'		, '⊙'],
702    \ ['oint'		, '∮'],
703    \ ['ominus'		, '⊖'],
704    \ ['oplus'		, '⊕'],
705    \ ['oslash'		, '⊘'],
706    \ ['otimes'		, '⊗'],
707    \ ['owns'		, '∋'],
708    \ ['partial'	, '∂'],
709    \ ['perp'		, '⊥'],
710    \ ['pitchfork'	, '⋔'],
711    \ ['pm'		, '±'],
712    \ ['precapprox'	, '⪷'],
713    \ ['prec'		, '≺'],
714    \ ['preccurlyeq'	, '≼'],
715    \ ['preceq'		, '⪯'],
716    \ ['precnapprox'	, '⪹'],
717    \ ['precneqq'	, '⪵'],
718    \ ['precsim'	, '≾'],
719    \ ['prod'		, '∏'],
720    \ ['propto'		, '∝'],
721    \ ['rceil'		, '⌉'],
722    \ ['Re'		, 'ℜ'],
723    \ ['rfloor'		, '⌋'],
724    \ ['rightarrow'	, '⟶'],
725    \ ['Rightarrow'	, '⟹'],
726    \ ['rightarrowtail'	, '↣'],
727    \ ['right)'		, ')'],
728    \ ['right]'		, ']'],
729    \ ['right\\}'	, '}'],
730    \ ['rightsquigarrow', '↝'],
731    \ ['rightthreetimes', '⋌'],
732    \ ['risingdotseq'	, '≓'],
733    \ ['rmoustache'     , '╮'],
734    \ ['rtimes'		, '⋊'],
735    \ ['searrow'	, '↘'],
736    \ ['setminus'	, '∖'],
737    \ ['sim'		, '∼'],
738    \ ['sphericalangle'	, '∢'],
739    \ ['sqcap'		, '⊓'],
740    \ ['sqcup'		, '⊔'],
741    \ ['sqsubset'	, '⊏'],
742    \ ['sqsubseteq'	, '⊑'],
743    \ ['sqsupset'	, '⊐'],
744    \ ['sqsupseteq'	, '⊒'],
745    \ ['subset'		, '⊂'],
746    \ ['Subset'		, '⋐'],
747    \ ['subseteq'	, '⊆'],
748    \ ['subseteqq'	, '⫅'],
749    \ ['subsetneq'	, '⊊'],
750    \ ['subsetneqq'	, '⫋'],
751    \ ['succapprox'	, '⪸'],
752    \ ['succ'		, '≻'],
753    \ ['succcurlyeq'	, '≽'],
754    \ ['succeq'		, '⪰'],
755    \ ['succnapprox'	, '⪺'],
756    \ ['succneqq'	, '⪶'],
757    \ ['succsim'	, '≿'],
758    \ ['sum'		, '∑'],
759    \ ['Supset'		, '⋑'],
760    \ ['supseteq'	, '⊇'],
761    \ ['supseteqq'	, '⫆'],
762    \ ['supsetneq'	, '⊋'],
763    \ ['supsetneqq'	, '⫌'],
764    \ ['surd'		, '√'],
765    \ ['swarrow'	, '↙'],
766    \ ['therefore'	, '∴'],
767    \ ['times'		, '×'],
768    \ ['to'		, '→'],
769    \ ['top'		, '⊤'],
770    \ ['triangleleft'	, '⊲'],
771    \ ['trianglelefteq'	, '⊴'],
772    \ ['triangleq'	, '≜'],
773    \ ['triangleright'	, '⊳'],
774    \ ['trianglerighteq', '⊵'],
775    \ ['twoheadleftarrow', '↞'],
776    \ ['twoheadrightarrow', '↠'],
777    \ ['uparrow'	, '↑'],
778    \ ['Uparrow'	, '⇑'],
779    \ ['updownarrow'	, '↕'],
780    \ ['Updownarrow'	, '⇕'],
781    \ ['varnothing'	, '∅'],
782    \ ['vartriangle'	, '∆'],
783    \ ['vdash'		, '⊢'],
784    \ ['vDash'		, '⊨'],
785    \ ['Vdash'		, '⊩'],
786    \ ['vdots'		, '⋮'],
787    \ ['veebar'		, '⊻'],
788    \ ['vee'		, '∨'],
789    \ ['Vvdash'		, '⊪'],
790    \ ['wedge'		, '∧'],
791    \ ['wr'		, '≀']]
792  for texmath in s:texMathList
793   if texmath[0] =~ '\w$'
794    exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
795   else
796    exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
797   endif
798  endfor
799
800  if &ambw == "double"
801   syn match texMathSymbol '\\gg\>'			contained conceal cchar=≫
802   syn match texMathSymbol '\\ll\>'			contained conceal cchar=≪
803  else
804   syn match texMathSymbol '\\gg\>'			contained conceal cchar=⟫
805   syn match texMathSymbol '\\ll\>'			contained conceal cchar=⟪
806  endif
807 endif
808
809 " Greek {{{2
810 if s:tex_conceal =~ 'g'
811  fun! s:Greek(group,pat,cchar)
812    exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
813  endfun
814  call s:Greek('texGreek','\\alpha\>'		,'α')
815  call s:Greek('texGreek','\\beta\>'		,'β')
816  call s:Greek('texGreek','\\gamma\>'		,'γ')
817  call s:Greek('texGreek','\\delta\>'		,'δ')
818  call s:Greek('texGreek','\\epsilon\>'		,'ϵ')
819  call s:Greek('texGreek','\\varepsilon\>'	,'ε')
820  call s:Greek('texGreek','\\zeta\>'		,'ζ')
821  call s:Greek('texGreek','\\eta\>'		,'η')
822  call s:Greek('texGreek','\\theta\>'		,'θ')
823  call s:Greek('texGreek','\\vartheta\>'		,'ϑ')
824  call s:Greek('texGreek','\\kappa\>'		,'κ')
825  call s:Greek('texGreek','\\lambda\>'		,'λ')
826  call s:Greek('texGreek','\\mu\>'		,'μ')
827  call s:Greek('texGreek','\\nu\>'		,'ν')
828  call s:Greek('texGreek','\\xi\>'		,'ξ')
829  call s:Greek('texGreek','\\pi\>'		,'π')
830  call s:Greek('texGreek','\\varpi\>'		,'ϖ')
831  call s:Greek('texGreek','\\rho\>'		,'ρ')
832  call s:Greek('texGreek','\\varrho\>'		,'ϱ')
833  call s:Greek('texGreek','\\sigma\>'		,'σ')
834  call s:Greek('texGreek','\\varsigma\>'		,'ς')
835  call s:Greek('texGreek','\\tau\>'		,'τ')
836  call s:Greek('texGreek','\\upsilon\>'		,'υ')
837  call s:Greek('texGreek','\\phi\>'		,'φ')
838  call s:Greek('texGreek','\\varphi\>'		,'ϕ')
839  call s:Greek('texGreek','\\chi\>'		,'χ')
840  call s:Greek('texGreek','\\psi\>'		,'ψ')
841  call s:Greek('texGreek','\\omega\>'		,'ω')
842  call s:Greek('texGreek','\\Gamma\>'		,'Γ')
843  call s:Greek('texGreek','\\Delta\>'		,'Δ')
844  call s:Greek('texGreek','\\Theta\>'		,'Θ')
845  call s:Greek('texGreek','\\Lambda\>'		,'Λ')
846  call s:Greek('texGreek','\\Xi\>'		,'Χ')
847  call s:Greek('texGreek','\\Pi\>'		,'Π')
848  call s:Greek('texGreek','\\Sigma\>'		,'Σ')
849  call s:Greek('texGreek','\\Upsilon\>'		,'Υ')
850  call s:Greek('texGreek','\\Phi\>'		,'Φ')
851  call s:Greek('texGreek','\\Psi\>'		,'Ψ')
852  call s:Greek('texGreek','\\Omega\>'		,'Ω')
853  delfun s:Greek
854 endif
855
856 " Superscripts/Subscripts {{{2
857 if s:tex_conceal =~ 's'
858  syn region texSuperscript	matchgroup=Delimiter start='\^{'	end='}'	contained concealends contains=texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
859  syn region texSubscript	matchgroup=Delimiter start='_{'		end='}'	contained concealends contains=texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
860  fun! s:SuperSub(group,leader,pat,cchar)
861    exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
862    exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
863  endfun
864  call s:SuperSub('texSuperscript','\^','0','⁰')
865  call s:SuperSub('texSuperscript','\^','1','¹')
866  call s:SuperSub('texSuperscript','\^','2','²')
867  call s:SuperSub('texSuperscript','\^','3','³')
868  call s:SuperSub('texSuperscript','\^','4','⁴')
869  call s:SuperSub('texSuperscript','\^','5','⁵')
870  call s:SuperSub('texSuperscript','\^','6','⁶')
871  call s:SuperSub('texSuperscript','\^','7','⁷')
872  call s:SuperSub('texSuperscript','\^','8','⁸')
873  call s:SuperSub('texSuperscript','\^','9','⁹')
874  call s:SuperSub('texSuperscript','\^','a','ᵃ')
875  call s:SuperSub('texSuperscript','\^','b','ᵇ')
876  call s:SuperSub('texSuperscript','\^','c','ᶜ')
877  call s:SuperSub('texSuperscript','\^','d','ᵈ')
878  call s:SuperSub('texSuperscript','\^','e','ᵉ')
879  call s:SuperSub('texSuperscript','\^','f','ᶠ')
880  call s:SuperSub('texSuperscript','\^','g','ᵍ')
881  call s:SuperSub('texSuperscript','\^','h','ʰ')
882  call s:SuperSub('texSuperscript','\^','i','ⁱ')
883  call s:SuperSub('texSuperscript','\^','j','ʲ')
884  call s:SuperSub('texSuperscript','\^','k','ᵏ')
885  call s:SuperSub('texSuperscript','\^','l','ˡ')
886  call s:SuperSub('texSuperscript','\^','m','ᵐ')
887  call s:SuperSub('texSuperscript','\^','n','ⁿ')
888  call s:SuperSub('texSuperscript','\^','o','ᵒ')
889  call s:SuperSub('texSuperscript','\^','p','ᵖ')
890  call s:SuperSub('texSuperscript','\^','r','ʳ')
891  call s:SuperSub('texSuperscript','\^','s','ˢ')
892  call s:SuperSub('texSuperscript','\^','t','ᵗ')
893  call s:SuperSub('texSuperscript','\^','u','ᵘ')
894  call s:SuperSub('texSuperscript','\^','v','ᵛ')
895  call s:SuperSub('texSuperscript','\^','w','ʷ')
896  call s:SuperSub('texSuperscript','\^','x','ˣ')
897  call s:SuperSub('texSuperscript','\^','y','ʸ')
898  call s:SuperSub('texSuperscript','\^','z','ᶻ')
899  call s:SuperSub('texSuperscript','\^','A','ᴬ')
900  call s:SuperSub('texSuperscript','\^','B','ᴮ')
901  call s:SuperSub('texSuperscript','\^','D','ᴰ')
902  call s:SuperSub('texSuperscript','\^','E','ᴱ')
903  call s:SuperSub('texSuperscript','\^','G','ᴳ')
904  call s:SuperSub('texSuperscript','\^','H','ᴴ')
905  call s:SuperSub('texSuperscript','\^','I','ᴵ')
906  call s:SuperSub('texSuperscript','\^','J','ᴶ')
907  call s:SuperSub('texSuperscript','\^','K','ᴷ')
908  call s:SuperSub('texSuperscript','\^','L','ᴸ')
909  call s:SuperSub('texSuperscript','\^','M','ᴹ')
910  call s:SuperSub('texSuperscript','\^','N','ᴺ')
911  call s:SuperSub('texSuperscript','\^','O','ᴼ')
912  call s:SuperSub('texSuperscript','\^','P','ᴾ')
913  call s:SuperSub('texSuperscript','\^','R','ᴿ')
914  call s:SuperSub('texSuperscript','\^','T','ᵀ')
915  call s:SuperSub('texSuperscript','\^','U','ᵁ')
916  call s:SuperSub('texSuperscript','\^','W','ᵂ')
917  call s:SuperSub('texSuperscript','\^','+','⁺')
918  call s:SuperSub('texSuperscript','\^','-','⁻')
919  call s:SuperSub('texSuperscript','\^','<','˂')
920  call s:SuperSub('texSuperscript','\^','>','˃')
921  call s:SuperSub('texSuperscript','\^','/','ˊ')
922  call s:SuperSub('texSuperscript','\^','(','⁽')
923  call s:SuperSub('texSuperscript','\^',')','⁾')
924  call s:SuperSub('texSuperscript','\^','\.','˙')
925  call s:SuperSub('texSuperscript','\^','=','˭')
926  call s:SuperSub('texSubscript','_','0','₀')
927  call s:SuperSub('texSubscript','_','1','₁')
928  call s:SuperSub('texSubscript','_','2','₂')
929  call s:SuperSub('texSubscript','_','3','₃')
930  call s:SuperSub('texSubscript','_','4','₄')
931  call s:SuperSub('texSubscript','_','5','₅')
932  call s:SuperSub('texSubscript','_','6','₆')
933  call s:SuperSub('texSubscript','_','7','₇')
934  call s:SuperSub('texSubscript','_','8','₈')
935  call s:SuperSub('texSubscript','_','9','₉')
936  call s:SuperSub('texSubscript','_','a','ₐ')
937  call s:SuperSub('texSubscript','_','e','ₑ')
938  call s:SuperSub('texSubscript','_','i','ᵢ')
939  call s:SuperSub('texSubscript','_','o','ₒ')
940  call s:SuperSub('texSubscript','_','u','ᵤ')
941  call s:SuperSub('texSubscript','_','+','₊')
942  call s:SuperSub('texSubscript','_','-','₋')
943  call s:SuperSub('texSubscript','_','/','ˏ')
944  call s:SuperSub('texSubscript','_','(','₍')
945  call s:SuperSub('texSubscript','_',')','₎')
946  call s:SuperSub('texSubscript','_','\.','‸')
947  call s:SuperSub('texSubscript','_','r','ᵣ')
948  call s:SuperSub('texSubscript','_','v','ᵥ')
949  call s:SuperSub('texSubscript','_','x','ₓ')
950  call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
951  call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
952  call s:SuperSub('texSubscript','_','\\phi\>'  ,'ᵩ')
953  call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
954  call s:SuperSub('texSubscript','_','\\chi\>'  ,'ᵪ')
955  delfun s:SuperSub
956 endif
957
958 " Accented characters: {{{2
959 if s:tex_conceal =~ 'a'
960  if b:tex_stylish
961   syn match texAccent		"\\[bcdvuH][^a-zA-Z@]"me=e-1
962   syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
963  else
964   fun! s:Accents(chr,...)
965     let i= 1
966     for accent in ["`","\\'","^",'"','\~','\.',"c","H","k","r","u","v"]
967      if i > a:0
968       break
969      endif
970      if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
971       let i= i + 1
972       continue
973      endif
974      if accent =~ '\a'
975       exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
976      else
977       exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
978      endif
979      let i= i + 1
980     endfor
981   endfun
982   "                  \`  \'  \^  \"  \~  \.  \c  \H  \k  \r  \u  \v
983   call s:Accents('a','à','á','â','ä','ã',' ',' ',' ','ą','å','ă','ă')
984   call s:Accents('A','À','Á','Â','Ä','Ã',' ',' ',' ','Ą','Å','Ă','Ă')
985   call s:Accents('c',' ','ć','ĉ',' ',' ','ċ','ç',' ',' ',' ',' ','č')
986   call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ','Ç',' ',' ',' ',' ','Č')
987   call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
988   call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
989   call s:Accents('e','è','é','ê','ë','ẽ','ė','ȩ',' ','ę',' ','ĕ','ě')
990   call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ȩ',' ','Ę',' ','Ĕ','Ě')
991   call s:Accents('g',' ',' ',' ',' ',' ','ġ','ģ',' ',' ',' ','ğ',' ')
992   call s:Accents('G',' ',' ',' ',' ',' ','Ġ','Ģ',' ',' ',' ','Ğ',' ')
993   call s:Accents('i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
994   call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ',' ',' ',' ',' ','Ĭ',' ')
995   call s:Accents('l',' ','ĺ','ľ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
996   call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
997   call s:Accents('n',' ','ń',' ',' ','ñ',' ','ņ',' ',' ',' ',' ','ň')
998   call s:Accents('N',' ','Ń',' ',' ','Ñ',' ','Ņ',' ',' ',' ',' ','Ň')
999   call s:Accents('o','ò','ó','ô','ö','õ','ȯ',' ','ő','ǫ',' ','ŏ',' ')
1000   call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ',' ','Ő','Ǫ',' ','Ŏ',' ')
1001   call s:Accents('r',' ','ŕ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
1002   call s:Accents('R',' ','Ŕ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
1003   call s:Accents('s',' ','ś','ŝ',' ',' ',' ','ş',' ',' ',' ',' ','š')
1004   call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
1005   call s:Accents('t',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
1006   call s:Accents('T',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
1007   call s:Accents('u','ù','ú','û','ü','ũ',' ',' ','ű',' ','ů','ŭ',' ')
1008   call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ',' ','Ű',' ','Ů','Ŭ',' ')
1009   call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1010   call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1011   call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ')
1012   call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ')
1013   call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ','ž')
1014   call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ','Ž')
1015   call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
1016   "                  \`  \'  \^  \"  \~  \.  \c  \H  \k  \r  \u  \v
1017   delfun s:Accents
1018   syn match texAccent   '\\aa\>'	conceal cchar=å
1019   syn match texAccent   '\\AA\>'	conceal cchar=Å
1020   syn match texAccent	'\\o\>'		conceal cchar=ø
1021   syn match texAccent	'\\O\>'		conceal cchar=Ø
1022   syn match texLigature	'\\AE\>'	conceal cchar=Æ
1023   syn match texLigature	'\\ae\>'	conceal cchar=æ
1024   syn match texLigature	'\\oe\>'	conceal cchar=œ
1025   syn match texLigature	'\\OE\>'	conceal cchar=Œ
1026   syn match texLigature	'\\ss\>'	conceal cchar=ß
1027  endif
1028 endif
1029endif
1030
1031" ---------------------------------------------------------------------
1032" LaTeX synchronization: {{{1
1033syn sync maxlines=200
1034syn sync minlines=50
1035
1036syn  sync match texSyncStop			groupthere NONE		"%stopzone\>"
1037
1038" Synchronization: {{{1
1039" The $..$ and $$..$$ make for impossible sync patterns
1040" (one can't tell if a "$$" starts or stops a math zone by itself)
1041" The following grouptheres coupled with minlines above
1042" help improve the odds of good syncing.
1043if !exists("tex_no_math")
1044 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{abstract}"
1045 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{center}"
1046 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{description}"
1047 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{enumerate}"
1048 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{itemize}"
1049 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{table}"
1050 syn sync match texSyncMathZoneA		groupthere NONE		"\\end{tabular}"
1051 syn sync match texSyncMathZoneA		groupthere NONE		"\\\(sub\)*section\>"
1052endif
1053
1054" ---------------------------------------------------------------------
1055" Highlighting: {{{1
1056if did_tex_syntax_inits == 1
1057 let did_tex_syntax_inits= 2
1058  " TeX highlighting groups which should share similar highlighting
1059  if !exists("g:tex_no_error")
1060   if !exists("tex_no_math")
1061    HiLink texBadMath		texError
1062    HiLink texMathDelimBad	texError
1063    HiLink texMathError		texError
1064    if !b:tex_stylish
1065      HiLink texOnlyMath	texError
1066    endif
1067   endif
1068   HiLink texError		Error
1069  endif
1070
1071  HiLink texDefCmd		texDef
1072  HiLink texDefName		texDef
1073  HiLink texDocType		texCmdName
1074  HiLink texDocTypeArgs		texCmdArgs
1075  HiLink texInputFileOpt	texCmdArgs
1076  HiLink texInputCurlies	texDelimiter
1077  HiLink texLigature		texSpecialChar
1078  if !exists("tex_no_math")
1079   HiLink texMathDelimSet1	texMathDelim
1080   HiLink texMathDelimSet2	texMathDelim
1081   HiLink texMathDelimKey	texMathDelim
1082   HiLink texMathMatcher	texMath
1083   HiLink texAccent		texStatement
1084   HiLink texGreek		texStatement
1085   HiLink texSuperscript	texStatement
1086   HiLink texSubscript		texStatement
1087   HiLink texMathSymbol		texStatement
1088   HiLink texMathZoneV		texMath
1089   HiLink texMathZoneW		texMath
1090   HiLink texMathZoneX		texMath
1091   HiLink texMathZoneY		texMath
1092   HiLink texMathZoneV		texMath
1093   HiLink texMathZoneZ		texMath
1094  endif
1095  HiLink texRefZone		Identifier
1096  HiLink texSectionMarker	texCmdName
1097  HiLink texSectionName		texSection
1098  HiLink texSpaceCode		texStatement
1099  HiLink texStyleStatement	texStatement
1100  HiLink texTypeSize		texType
1101  HiLink texTypeStyle		texType
1102
1103   " Basic TeX highlighting groups
1104  HiLink texCite		Special
1105  HiLink texCmdArgs		Number
1106  HiLink texCmdName		Statement
1107  HiLink texComment		Comment
1108  HiLink texDef			Statement
1109  HiLink texDefParm		Special
1110  HiLink texDelimiter		Delimiter
1111  HiLink texInput		Special
1112  HiLink texInputFile		Special
1113  HiLink texLength		Number
1114  HiLink texMath		Special
1115  HiLink texMathDelim		Statement
1116  HiLink texMathOper		Operator
1117  HiLink texNewCmd		Statement
1118  HiLink texNewEnv		Statement
1119  HiLink texOption		Number
1120  HiLink texRefLabel		Special
1121  HiLink texSection		PreCondit
1122  HiLink texSpaceCodeChar	Special
1123  HiLink texSpecialChar		SpecialChar
1124  HiLink texStatement		Statement
1125  HiLink texString		String
1126  HiLink texTodo		Todo
1127  HiLink texType		Type
1128  HiLink texZone		PreCondit
1129
1130  delcommand HiLink
1131endif
1132
1133" Current Syntax: {{{1
1134unlet s:extfname
1135let   b:current_syntax = "tex"
1136" vim: ts=8 fdm=marker
1137