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