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