xref: /vim-8.2.3635/runtime/syntax/tex.vim (revision 00a927d6)
1071d4279SBram Moolenaar" Vim syntax file
2071d4279SBram Moolenaar" Language:	TeX
3488c6512SBram Moolenaar" Maintainer:	Dr. Charles E. Campbell, Jr. <[email protected]>
4*00a927d6SBram Moolenaar" Last Change:	Apr 14, 2010
5*00a927d6SBram Moolenaar" Version:	47
6488c6512SBram Moolenaar" URL:		http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
7071d4279SBram Moolenaar"
8071d4279SBram Moolenaar" Notes: {{{1
9071d4279SBram Moolenaar"
10071d4279SBram Moolenaar" 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
11071d4279SBram Moolenaar"    use %stopzone.
12071d4279SBram Moolenaar"
13071d4279SBram Moolenaar" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
14071d4279SBram Moolenaar"    by suitable use of %stopzone.
15071d4279SBram Moolenaar"
16071d4279SBram Moolenaar" 3. If you have a slow computer, you may wish to modify
17071d4279SBram Moolenaar"
18071d4279SBram Moolenaar"	syn sync maxlines=200
19071d4279SBram Moolenaar"	syn sync minlines=50
20071d4279SBram Moolenaar"
21071d4279SBram Moolenaar"    to values that are more to your liking.
22071d4279SBram Moolenaar"
23071d4279SBram Moolenaar" 4. There is no match-syncing for $...$ and $$...$$; hence large
24071d4279SBram Moolenaar"    equation blocks constructed that way may exhibit syncing problems.
25071d4279SBram Moolenaar"    (there's no difference between begin/end patterns)
26071d4279SBram Moolenaar"
27071d4279SBram Moolenaar" 5. If you have the variable "g:tex_no_error" defined then none of the
28071d4279SBram Moolenaar"    lexical error-checking will be done.
29071d4279SBram Moolenaar"
30071d4279SBram Moolenaar"    ie. let g:tex_no_error=1
31071d4279SBram Moolenaar
32071d4279SBram Moolenaar" Version Clears: {{{1
33071d4279SBram Moolenaar" For version 5.x: Clear all syntax items
34071d4279SBram Moolenaar" For version 6.x: Quit when a syntax file was already loaded
35071d4279SBram Moolenaarif version < 600
36071d4279SBram Moolenaar  syntax clear
37071d4279SBram Moolenaarelseif exists("b:current_syntax")
38071d4279SBram Moolenaar  finish
39071d4279SBram Moolenaarendif
40071d4279SBram Moolenaar
41071d4279SBram Moolenaar" Define the default highlighting. {{{1
42071d4279SBram Moolenaar" For version 5.7 and earlier: only when not done already
43071d4279SBram Moolenaar" For version 5.8 and later: only when an item doesn't have highlighting yet
44071d4279SBram Moolenaarif version >= 508 || !exists("did_tex_syntax_inits")
45071d4279SBram Moolenaar let did_tex_syntax_inits = 1
46071d4279SBram Moolenaar if version < 508
47071d4279SBram Moolenaar  command -nargs=+ HiLink hi link <args>
48071d4279SBram Moolenaar else
49071d4279SBram Moolenaar  command -nargs=+ HiLink hi def link <args>
50071d4279SBram Moolenaar endif
51071d4279SBram Moolenaarendif
52071d4279SBram Moolenaarif exists("g:tex_tex") && !exists("g:tex_no_error")
53071d4279SBram Moolenaar let g:tex_no_error= 1
54071d4279SBram Moolenaarendif
55071d4279SBram Moolenaar
56f1f8bc5bSBram Moolenaar" Determine whether or not to use "*.sty" mode {{{1
57071d4279SBram Moolenaar" The user may override the normal determination by setting
58071d4279SBram Moolenaar"   g:tex_stylish to 1      (for    "*.sty" mode)
59071d4279SBram Moolenaar"    or to           0 else (normal "*.tex" mode)
60071d4279SBram Moolenaar" or on a buffer-by-buffer basis with b:tex_stylish
61071d4279SBram Moolenaarlet b:extfname=expand("%:e")
62071d4279SBram Moolenaarif exists("g:tex_stylish")
63071d4279SBram Moolenaar let b:tex_stylish= g:tex_stylish
64071d4279SBram Moolenaarelseif !exists("b:tex_stylish")
65071d4279SBram Moolenaar if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx"
66071d4279SBram Moolenaar  let b:tex_stylish= 1
67071d4279SBram Moolenaar else
68071d4279SBram Moolenaar  let b:tex_stylish= 0
69071d4279SBram Moolenaar endif
70071d4279SBram Moolenaarendif
71071d4279SBram Moolenaar
72f1f8bc5bSBram Moolenaar" handle folding {{{1
73f1f8bc5bSBram Moolenaarif !exists("g:tex_fold_enabled")
74f1f8bc5bSBram Moolenaar let g:tex_fold_enabled= 0
75f1f8bc5bSBram Moolenaarelseif g:tex_fold_enabled && !has("folding")
76ab194816SBram Moolenaar let g:tex_fold_enabled= 0
77f1f8bc5bSBram Moolenaar echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
78f1f8bc5bSBram Moolenaarendif
79f1f8bc5bSBram Moolenaarif g:tex_fold_enabled && &fdm == "manual"
80*00a927d6SBram Moolenaar setl fdm=syntax
81f1f8bc5bSBram Moolenaarendif
82f1f8bc5bSBram Moolenaar
83071d4279SBram Moolenaar" (La)TeX keywords: only use the letters a-zA-Z {{{1
84071d4279SBram Moolenaar" but _ is the only one that causes problems.
85071d4279SBram Moolenaarif version < 600
86071d4279SBram Moolenaar  set isk-=_
87071d4279SBram Moolenaar  if b:tex_stylish
88071d4279SBram Moolenaar    set isk+=@
89071d4279SBram Moolenaar  endif
90071d4279SBram Moolenaarelse
91071d4279SBram Moolenaar  setlocal isk-=_
92071d4279SBram Moolenaar  if b:tex_stylish
93071d4279SBram Moolenaar    setlocal isk+=@
94071d4279SBram Moolenaar  endif
95071d4279SBram Moolenaarendif
96071d4279SBram Moolenaar
97071d4279SBram Moolenaar" Clusters: {{{1
98071d4279SBram Moolenaar" --------
99071d4279SBram Moolenaarsyn cluster texCmdGroup		contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
100071d4279SBram Moolenaarif !exists("g:tex_no_error")
101071d4279SBram Moolenaar syn cluster texCmdGroup	add=texMathError
102071d4279SBram Moolenaarendif
103071d4279SBram Moolenaarsyn cluster texEnvGroup		contains=texMatcher,texMathDelim,texSpecialChar,texStatement
104488c6512SBram Moolenaarsyn cluster texFoldGroup	contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texSectionMarker,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract
1055b8d8fdbSBram Moolenaarsyn 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
1065c73622aSBram Moolenaarsyn 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
107cfbc5ee4SBram Moolenaarsyn cluster texRefGroup		contains=texMatcher,texComment,texDelimiter
108071d4279SBram Moolenaarif !exists("tex_no_math")
109071d4279SBram Moolenaar syn cluster texMathZones	contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
110071d4279SBram Moolenaar syn cluster texMatchGroup	add=@texMathZones
111071d4279SBram Moolenaar syn cluster texMathDelimGroup	contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
112071d4279SBram Moolenaar 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
113071d4279SBram Moolenaar syn cluster texMathZoneGroup	contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
114071d4279SBram Moolenaar if !exists("g:tex_no_error")
115071d4279SBram Moolenaar  syn cluster texMathMatchGroup	add=texMathError
116071d4279SBram Moolenaar  syn cluster texMathZoneGroup	add=texMathError
117071d4279SBram Moolenaar endif
1185b8d8fdbSBram Moolenaar syn cluster texMathZoneGroup add=@NoSpell
1195b8d8fdbSBram Moolenaar " following used in the \part \chapter \section \subsection \subsubsection
1205b8d8fdbSBram Moolenaar " \paragraph \subparagraph \author \title highlighting
1215b8d8fdbSBram Moolenaar syn cluster texDocGroup		contains=texPartZone,@texPartGroup
1225b8d8fdbSBram Moolenaar syn cluster texPartGroup		contains=texChapterZone,texSectionZone,texParaZone
1235b8d8fdbSBram Moolenaar syn cluster texChapterGroup		contains=texSectionZone,texParaZone
1245b8d8fdbSBram Moolenaar syn cluster texSectionGroup		contains=texSubSectionZone,texParaZone
1255b8d8fdbSBram Moolenaar syn cluster texSubSectionGroup		contains=texSubSubSectionZone,texParaZone
1265b8d8fdbSBram Moolenaar syn cluster texSubSubSectionGroup	contains=texParaZone
1275b8d8fdbSBram Moolenaar syn cluster texParaGroup		contains=texSubParaZone
128071d4279SBram Moolenaarendif
129071d4279SBram Moolenaar
130071d4279SBram Moolenaar" Try to flag {} and () mismatches: {{{1
131071d4279SBram Moolenaarif !exists("g:tex_no_error")
132071d4279SBram Moolenaar syn region texMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texMatchGroup,texError
133071d4279SBram Moolenaar syn region texMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texMatchGroup,texError
134071d4279SBram Moolenaarelse
135071d4279SBram Moolenaar syn region texMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texMatchGroup
136071d4279SBram Moolenaar syn region texMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texMatchGroup
137071d4279SBram Moolenaarendif
138293ee4d4SBram Moolenaarsyn region texParen		start="("						end=")"		contains=@texMatchGroup,@Spell
139071d4279SBram Moolenaarif !exists("g:tex_no_error")
140071d4279SBram Moolenaar syn match  texError		"[}\])]"
141071d4279SBram Moolenaarendif
142071d4279SBram Moolenaarif !exists("tex_no_math")
143071d4279SBram Moolenaar if !exists("g:tex_no_error")
144071d4279SBram Moolenaar  syn match  texMathError	"}"	contained
145071d4279SBram Moolenaar endif
146071d4279SBram Moolenaar syn region texMathMatcher	matchgroup=Delimiter start="{"  skip="\\\\\|\\}"  end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
147071d4279SBram Moolenaarendif
148071d4279SBram Moolenaar
149071d4279SBram Moolenaar" TeX/LaTeX keywords: {{{1
150071d4279SBram Moolenaar" Instead of trying to be All Knowing, I just match \..alphameric..
151071d4279SBram Moolenaar" Note that *.tex files may not have "@" in their \commands
152071d4279SBram Moolenaarif exists("g:tex_tex") || b:tex_stylish
153071d4279SBram Moolenaar  syn match texStatement	"\\[a-zA-Z@]\+"
154071d4279SBram Moolenaarelse
155071d4279SBram Moolenaar  syn match texStatement	"\\\a\+"
156071d4279SBram Moolenaar  if !exists("g:tex_no_error")
157071d4279SBram Moolenaar   syn match texError		"\\\a*@[a-zA-Z@]*"
158071d4279SBram Moolenaar  endif
159071d4279SBram Moolenaarendif
160071d4279SBram Moolenaar
161071d4279SBram Moolenaar" TeX/LaTeX delimiters: {{{1
162071d4279SBram Moolenaarsyn match texDelimiter		"&"
163071d4279SBram Moolenaarsyn match texDelimiter		"\\\\"
164071d4279SBram Moolenaar
165071d4279SBram Moolenaar" Tex/Latex Options: {{{1
166071d4279SBram Moolenaarsyn match texOption	"[^\\]\zs#\d\+\|^#\d\+"
167071d4279SBram Moolenaar
168071d4279SBram Moolenaar" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
169071d4279SBram Moolenaarif b:tex_stylish
170071d4279SBram Moolenaar  syn match texAccent		"\\[bcdvuH][^a-zA-Z@]"me=e-1
171071d4279SBram Moolenaar  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
172071d4279SBram Moolenaarelse
173071d4279SBram Moolenaar  syn match texAccent		"\\[bcdvuH]\A"me=e-1
174071d4279SBram Moolenaar  syn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
175071d4279SBram Moolenaarendif
176071d4279SBram Moolenaarsyn match texAccent		"\\[bcdvuH]$"
177071d4279SBram Moolenaarsyn match texAccent		+\\[=^.\~"`']+
178071d4279SBram Moolenaarsyn match texAccent		+\\['=t'.c^ud"vb~Hr]{\a}+
179071d4279SBram Moolenaarsyn match texLigature		"\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
180071d4279SBram Moolenaar
181071d4279SBram Moolenaar" \begin{}/\end{} section markers: {{{1
182071d4279SBram Moolenaarsyn match  texSectionMarker	"\\begin\>\|\\end\>" nextgroup=texSectionName
1835c73622aSBram Moolenaarsyn region texSectionName	matchgroup=Delimiter start="{" end="}"  contained	nextgroup=texSectionModifier	contains=texComment
1845c73622aSBram Moolenaarsyn region texSectionModifier	matchgroup=Delimiter start="\[" end="]" contained	contains=texComment
185071d4279SBram Moolenaar
186071d4279SBram Moolenaar" \documentclass, \documentstyle, \usepackage: {{{1
187071d4279SBram Moolenaarsyn match  texDocType		"\\documentclass\>\|\\documentstyle\>\|\\usepackage\>"	nextgroup=texSectionName,texDocTypeArgs
1885c73622aSBram Moolenaarsyn region texDocTypeArgs	matchgroup=Delimiter start="\[" end="]"			contained	nextgroup=texSectionName	contains=texComment
189071d4279SBram Moolenaar
190a9a568caSBram Moolenaar" Preamble syntax-based folding support: {{{1
191a9a568caSBram Moolenaarif g:tex_fold_enabled && has("folding")
1925c73622aSBram Moolenaar syn region texPreamble	transparent fold	start='\zs\\documentclass\>' end='\ze\\begin{document}'	contains=texStyle,@texMatchGroup
193a9a568caSBram Moolenaarendif
194a9a568caSBram Moolenaar
195071d4279SBram Moolenaar" TeX input: {{{1
196071d4279SBram Moolenaarsyn match texInput		"\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7				contains=texStatement
1975c73622aSBram Moolenaarsyn match texInputFile		"\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}"	contains=texStatement,texInputCurlies,texInputFileOpt
198071d4279SBram Moolenaarsyn match texInputFile		"\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}"		contains=texStatement,texInputCurlies,texInputFileOpt
199071d4279SBram Moolenaarsyn match texInputCurlies	"[{}]"								contained
2005c73622aSBram Moolenaarsyn region texInputFileOpt	matchgroup=Delimiter start="\[" end="\]"			contained	contains=texComment
201071d4279SBram Moolenaar
202071d4279SBram Moolenaar" Type Styles (LaTeX 2.09): {{{1
203071d4279SBram Moolenaarsyn match texTypeStyle		"\\rm\>"
204071d4279SBram Moolenaarsyn match texTypeStyle		"\\em\>"
205071d4279SBram Moolenaarsyn match texTypeStyle		"\\bf\>"
206071d4279SBram Moolenaarsyn match texTypeStyle		"\\it\>"
207071d4279SBram Moolenaarsyn match texTypeStyle		"\\sl\>"
208071d4279SBram Moolenaarsyn match texTypeStyle		"\\sf\>"
209071d4279SBram Moolenaarsyn match texTypeStyle		"\\sc\>"
210071d4279SBram Moolenaarsyn match texTypeStyle		"\\tt\>"
211071d4279SBram Moolenaar
212071d4279SBram Moolenaar" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
213071d4279SBram Moolenaarsyn match texTypeStyle		"\\textbf\>"
214071d4279SBram Moolenaarsyn match texTypeStyle		"\\textit\>"
215071d4279SBram Moolenaarsyn match texTypeStyle		"\\textmd\>"
216071d4279SBram Moolenaarsyn match texTypeStyle		"\\textrm\>"
217071d4279SBram Moolenaarsyn match texTypeStyle		"\\textsc\>"
218071d4279SBram Moolenaarsyn match texTypeStyle		"\\textsf\>"
219071d4279SBram Moolenaarsyn match texTypeStyle		"\\textsl\>"
220071d4279SBram Moolenaarsyn match texTypeStyle		"\\texttt\>"
221071d4279SBram Moolenaarsyn match texTypeStyle		"\\textup\>"
222071d4279SBram Moolenaarsyn match texTypeStyle		"\\emph\>"
223071d4279SBram Moolenaar
224071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathbb\>"
225071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathbf\>"
226071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathcal\>"
227071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathfrak\>"
228071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathit\>"
229071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathnormal\>"
230071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathrm\>"
231071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathsf\>"
232071d4279SBram Moolenaarsyn match texTypeStyle		"\\mathtt\>"
233071d4279SBram Moolenaar
234071d4279SBram Moolenaarsyn match texTypeStyle		"\\rmfamily\>"
235071d4279SBram Moolenaarsyn match texTypeStyle		"\\sffamily\>"
236071d4279SBram Moolenaarsyn match texTypeStyle		"\\ttfamily\>"
237071d4279SBram Moolenaar
238071d4279SBram Moolenaarsyn match texTypeStyle		"\\itshape\>"
239071d4279SBram Moolenaarsyn match texTypeStyle		"\\scshape\>"
240071d4279SBram Moolenaarsyn match texTypeStyle		"\\slshape\>"
241071d4279SBram Moolenaarsyn match texTypeStyle		"\\upshape\>"
242071d4279SBram Moolenaar
243071d4279SBram Moolenaarsyn match texTypeStyle		"\\bfseries\>"
244071d4279SBram Moolenaarsyn match texTypeStyle		"\\mdseries\>"
245071d4279SBram Moolenaar
246071d4279SBram Moolenaar" Some type sizes: {{{1
247071d4279SBram Moolenaarsyn match texTypeSize		"\\tiny\>"
248071d4279SBram Moolenaarsyn match texTypeSize		"\\scriptsize\>"
249071d4279SBram Moolenaarsyn match texTypeSize		"\\footnotesize\>"
250071d4279SBram Moolenaarsyn match texTypeSize		"\\small\>"
251071d4279SBram Moolenaarsyn match texTypeSize		"\\normalsize\>"
252071d4279SBram Moolenaarsyn match texTypeSize		"\\large\>"
253071d4279SBram Moolenaarsyn match texTypeSize		"\\Large\>"
254071d4279SBram Moolenaarsyn match texTypeSize		"\\LARGE\>"
255071d4279SBram Moolenaarsyn match texTypeSize		"\\huge\>"
256071d4279SBram Moolenaarsyn match texTypeSize		"\\Huge\>"
257071d4279SBram Moolenaar
258071d4279SBram Moolenaar" Spacecodes (TeX'isms): {{{1
259071d4279SBram Moolenaar" \mathcode`\^^@="2201  \delcode`\(="028300  \sfcode`\)=0 \uccode`X=`X  \lccode`x=`x
260071d4279SBram Moolenaarsyn match texSpaceCode		"\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
261071d4279SBram Moolenaarsyn match texSpaceCodeChar    "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)"	contained
262071d4279SBram Moolenaar
263071d4279SBram Moolenaar" Sections, subsections, etc: {{{1
264f1f8bc5bSBram Moolenaarif g:tex_fold_enabled && has("folding")
2659964e468SBram Moolenaar syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											fold contains=@texFoldGroup,@texDocGroup,@Spell
2663577c6faSBram Moolenaar syn region texPartZone			matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								fold contains=@texFoldGroup,@texPartGroup,@Spell
2673577c6faSBram Moolenaar syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							fold contains=@texFoldGroup,@texChapterGroup,@Spell
2683577c6faSBram Moolenaar syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					fold contains=@texFoldGroup,@texSectionGroup,@Spell
2693577c6faSBram Moolenaar syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
2703577c6faSBram Moolenaar 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
2713577c6faSBram Moolenaar 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
2723577c6faSBram Moolenaar 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
2735b8d8fdbSBram Moolenaar syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													fold contains=@texFoldGroup,@Spell
2745b8d8fdbSBram Moolenaar syn region texAbstract			matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											fold contains=@texFoldGroup,@Spell
275293ee4d4SBram Moolenaarelse
2769964e468SBram Moolenaar syn region texDocZone			matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}'											contains=@texFoldGroup,@texDocGroup,@Spell
2773577c6faSBram Moolenaar syn region texPartZone			matchgroup=texSection start='\\part\>'			 end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)'								contains=@texFoldGroup,@texPartGroup,@Spell
2783577c6faSBram Moolenaar syn region texChapterZone		matchgroup=texSection start='\\chapter\>'		 end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)'							contains=@texFoldGroup,@texChapterGroup,@Spell
2793577c6faSBram Moolenaar syn region texSectionZone		matchgroup=texSection start='\\section\>'		 end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'					contains=@texFoldGroup,@texSectionGroup,@Spell
2803577c6faSBram Moolenaar syn region texSubSectionZone		matchgroup=texSection start='\\subsection\>'		 end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSectionGroup,@Spell
2813577c6faSBram Moolenaar syn region texSubSubSectionZone	matchgroup=texSection start='\\subsubsection\>'		 end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'				contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
2823577c6faSBram Moolenaar syn region texParaZone			matchgroup=texSection start='\\paragraph\>'		 end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'			contains=@texFoldGroup,@texParaGroup,@Spell
2833577c6faSBram Moolenaar syn region texSubParaZone		matchgroup=texSection start='\\subparagraph\>'		 end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)'	contains=@texFoldGroup,@Spell
2845b8d8fdbSBram Moolenaar syn region texTitle			matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}'													contains=@texFoldGroup,@Spell
2855b8d8fdbSBram Moolenaar syn region texAbstract			matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}'											contains=@texFoldGroup,@Spell
286293ee4d4SBram Moolenaarendif
287071d4279SBram Moolenaar
288071d4279SBram Moolenaar" Bad Math (mismatched): {{{1
289071d4279SBram Moolenaarif !exists("tex_no_math")
290071d4279SBram Moolenaar syn match texBadMath		"\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
291071d4279SBram Moolenaar syn match texBadMath		"\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
292071d4279SBram Moolenaar syn match texBadMath		"\\[\])]"
293071d4279SBram Moolenaarendif
294071d4279SBram Moolenaar
295071d4279SBram Moolenaar" Math Zones: {{{1
296071d4279SBram Moolenaarif !exists("tex_no_math")
297488c6512SBram Moolenaar " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
298071d4279SBram Moolenaar "                 Starred forms are created if starform is true.  Starred
299071d4279SBram Moolenaar "                 forms have syntax group and synchronization groups with a
300071d4279SBram Moolenaar "                 "S" appended.  Handles: cluster, syntax, sync, and HiLink.
301071d4279SBram Moolenaar fun! TexNewMathZone(sfx,mathzone,starform)
302071d4279SBram Moolenaar   let grpname  = "texMathZone".a:sfx
303071d4279SBram Moolenaar   let syncname = "texSyncMathZone".a:sfx
3043577c6faSBram Moolenaar   if g:tex_fold_enabled
3053577c6faSBram Moolenaar    let foldcmd= " fold"
3063577c6faSBram Moolenaar   else
3073577c6faSBram Moolenaar    let foldcmd= ""
3083577c6faSBram Moolenaar   endif
309071d4279SBram Moolenaar   exe "syn cluster texMathZones add=".grpname
3103577c6faSBram Moolenaar   exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
311071d4279SBram Moolenaar   exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
312071d4279SBram Moolenaar   exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
3135c73622aSBram Moolenaar   exe 'hi def link '.grpname.' texMath'
314071d4279SBram Moolenaar   if a:starform
315071d4279SBram Moolenaar    let grpname  = "texMathZone".a:sfx.'S'
316071d4279SBram Moolenaar    let syncname = "texSyncMathZone".a:sfx.'S'
317071d4279SBram Moolenaar    exe "syn cluster texMathZones add=".grpname
3183577c6faSBram Moolenaar    exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
319071d4279SBram Moolenaar    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
320071d4279SBram Moolenaar    exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
3215c73622aSBram Moolenaar    exe 'hi def link '.grpname.' texMath'
322071d4279SBram Moolenaar   endif
323071d4279SBram Moolenaar endfun
324071d4279SBram Moolenaar
325071d4279SBram Moolenaar " Standard Math Zones: {{{2
326071d4279SBram Moolenaar call TexNewMathZone("A","align",1)
327071d4279SBram Moolenaar call TexNewMathZone("B","alignat",1)
328071d4279SBram Moolenaar call TexNewMathZone("C","displaymath",1)
329071d4279SBram Moolenaar call TexNewMathZone("D","eqnarray",1)
330071d4279SBram Moolenaar call TexNewMathZone("E","equation",1)
331071d4279SBram Moolenaar call TexNewMathZone("F","flalign",1)
332071d4279SBram Moolenaar call TexNewMathZone("G","gather",1)
333071d4279SBram Moolenaar call TexNewMathZone("H","math",1)
334071d4279SBram Moolenaar call TexNewMathZone("I","multline",1)
335071d4279SBram Moolenaar call TexNewMathZone("J","subequations",0)
336071d4279SBram Moolenaar call TexNewMathZone("K","xalignat",1)
337071d4279SBram Moolenaar call TexNewMathZone("L","xxalignat",0)
338071d4279SBram Moolenaar
339071d4279SBram Moolenaar " Inline Math Zones: {{{2
340071d4279SBram Moolenaar syn region texMathZoneV	matchgroup=Delimiter start="\\("	matchgroup=Delimiter end="\\)\|%stopzone\>"	keepend contains=@texMathZoneGroup
341071d4279SBram Moolenaar syn region texMathZoneW	matchgroup=Delimiter start="\\\["	matchgroup=Delimiter end="\\]\|%stopzone\>"	keepend contains=@texMathZoneGroup
342071d4279SBram Moolenaar syn region texMathZoneX	matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>"	contains=@texMathZoneGroup
343071d4279SBram Moolenaar syn region texMathZoneY	matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>"	keepend		contains=@texMathZoneGroup
344071d4279SBram Moolenaar syn region texMathZoneZ	matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>"	contains=@texMathZoneGroup
345071d4279SBram Moolenaar
346071d4279SBram Moolenaar syn match texMathOper		"[_^=]" contained
347071d4279SBram Moolenaar
348071d4279SBram Moolenaar " \left..something.. and \right..something.. support: {{{2
349071d4279SBram Moolenaar syn match   texMathDelimBad	contained		"\S"
350071d4279SBram Moolenaar syn match   texMathDelim	contained		"\\\(left\|right\|[bB]igg\=[lr]\)\>"	skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
351071d4279SBram Moolenaar syn match   texMathDelim	contained		"\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
352071d4279SBram Moolenaar syn match   texMathDelim	contained		"\\lefteqn\>"
353071d4279SBram Moolenaar syn match   texMathDelimSet2	contained	"\\"		nextgroup=texMathDelimKey,texMathDelimBad
354071d4279SBram Moolenaar syn match   texMathDelimSet1	contained	"[<>()[\]|/.]\|\\[{}|]"
355071d4279SBram Moolenaar syn keyword texMathDelimKey	contained	backslash       lceil           lVert           rgroup          uparrow
356071d4279SBram Moolenaar syn keyword texMathDelimKey	contained	downarrow       lfloor          rangle          rmoustache      Uparrow
357071d4279SBram Moolenaar syn keyword texMathDelimKey	contained	Downarrow       lgroup          rbrace          rvert           updownarrow
358071d4279SBram Moolenaar syn keyword texMathDelimKey	contained	langle          lmoustache      rceil           rVert           Updownarrow
359071d4279SBram Moolenaar syn keyword texMathDelimKey	contained	lbrace          lvert           rfloor
360071d4279SBram Moolenaarendif
361071d4279SBram Moolenaar
362071d4279SBram Moolenaar" Special TeX characters  ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
363071d4279SBram Moolenaarsyn match texSpecialChar	"\\[$&%#{}_]"
364071d4279SBram Moolenaarif b:tex_stylish
365071d4279SBram Moolenaar  syn match texSpecialChar	"\\[SP@][^a-zA-Z@]"me=e-1
366071d4279SBram Moolenaarelse
367071d4279SBram Moolenaar  syn match texSpecialChar	"\\[SP@]\A"me=e-1
368071d4279SBram Moolenaarendif
369071d4279SBram Moolenaarsyn match texSpecialChar	"\\\\"
370071d4279SBram Moolenaarif !exists("tex_no_math")
371071d4279SBram Moolenaar syn match texOnlyMath		"[_^]"
372071d4279SBram Moolenaarendif
373071d4279SBram Moolenaarsyn match texSpecialChar	"\^\^[0-9a-f]\{2}\|\^\^\S"
374071d4279SBram Moolenaar
375071d4279SBram Moolenaar" Comments: {{{1
376071d4279SBram Moolenaar"    Normal TeX LaTeX     :   %....
377071d4279SBram Moolenaar"    Documented TeX Format:  ^^A...	-and-	leading %s (only)
3783577c6faSBram Moolenaarif !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
379071d4279SBram Moolenaar syn cluster texCommentGroup	contains=texTodo,@Spell
3803577c6faSBram Moolenaarelse
3813577c6faSBram Moolenaar syn cluster texCommentGroup	contains=texTodo,@NoSpell
3823577c6faSBram Moolenaarendif
383071d4279SBram Moolenaarsyn case ignore
38418144c84SBram Moolenaarsyn keyword texTodo		contained		combak	fixme	todo	xxx
385071d4279SBram Moolenaarsyn case match
386071d4279SBram Moolenaarif b:extfname == "dtx"
387071d4279SBram Moolenaar  syn match texComment		"\^\^A.*$"	contains=@texCommentGroup
388071d4279SBram Moolenaar  syn match texComment		"^%\+"		contains=@texCommentGroup
389071d4279SBram Moolenaarelse
390fd2ac767SBram Moolenaar  if g:tex_fold_enabled
391fd2ac767SBram Moolenaar   " allows syntax-folding of 2 or more contiguous comment lines
392fd2ac767SBram Moolenaar   " single-line comments are not folded
393071d4279SBram Moolenaar   syn match  texComment	"%.*$"		contains=@texCommentGroup
394fd2ac767SBram Moolenaar   syn region texComment	start="^\zs\s*%.*\_s*%"	skip="^\s*%"	end='^\ze\s*[^%]' fold
395fd2ac767SBram Moolenaar  else
396fd2ac767SBram Moolenaar   syn match texComment		"%.*$"		contains=@texCommentGroup
397fd2ac767SBram Moolenaar  endif
398071d4279SBram Moolenaarendif
399071d4279SBram Moolenaar
400071d4279SBram Moolenaar" Separate lines used for verb` and verb# so that the end conditions {{{1
401071d4279SBram Moolenaar" will appropriately terminate.  Ideally vim would let me save a
402071d4279SBram Moolenaar" character from the start pattern and re-use it in the end-pattern.
4035c73622aSBram Moolenaarsyn region texZone		start="\\begin{[vV]erbatim}"		end="\\end{[vV]erbatim}\|%stopzone\>"	contains=@Spell
404c1e37901SBram Moolenaar" listings package:
405c1e37901SBram Moolenaarsyn region texZone		start="\\begin{lstlisting}"		end="\\end{lstlisting}\|%stopzone\>"	contains=@Spell
406c1e37901SBram Moolenaar" moreverb package:
407c1e37901SBram Moolenaarsyn region texZone		start="\\begin{verbatimtab}"		end="\\end{verbatimtab}\|%stopzone\>"	contains=@Spell
408c1e37901SBram Moolenaarsyn region texZone		start="\\begin{verbatimwrite}"		end="\\end{verbatimwrite}\|%stopzone\>"	contains=@Spell
409c1e37901SBram Moolenaarsyn region texZone		start="\\begin{boxedverbatim}"		end="\\end{boxedverbatim}\|%stopzone\>"	contains=@Spell
410071d4279SBram Moolenaarif version < 600
411071d4279SBram Moolenaar syn region texZone		start="\\verb\*\=`"			end="`\|%stopzone\>"
412071d4279SBram Moolenaar syn region texZone		start="\\verb\*\=#"			end="#\|%stopzone\>"
413071d4279SBram Moolenaarelse
414071d4279SBram Moolenaar  if b:tex_stylish
415071d4279SBram Moolenaar    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z@]\)"	end="\z1\|%stopzone\>"
416071d4279SBram Moolenaar  else
417071d4279SBram Moolenaar    syn region texZone		start="\\verb\*\=\z([^\ta-zA-Z]\)"	end="\z1\|%stopzone\>"
418071d4279SBram Moolenaar  endif
419071d4279SBram Moolenaarendif
420071d4279SBram Moolenaar
421071d4279SBram Moolenaar" Tex Reference Zones: {{{1
422cfbc5ee4SBram Moolenaarsyn region texZone		matchgroup=texStatement start="@samp{"			end="}\|%stopzone\>"	contains=@texRefGroup
423cfbc5ee4SBram Moolenaarsyn region texRefZone		matchgroup=texStatement start="\\nocite{"		end="}\|%stopzone\>"	contains=@texRefGroup
424cfbc5ee4SBram Moolenaarsyn region texRefZone		matchgroup=texStatement start="\\bibliography{"		end="}\|%stopzone\>"	contains=@texRefGroup
425cfbc5ee4SBram Moolenaarsyn region texRefZone		matchgroup=texStatement start="\\label{"		end="}\|%stopzone\>"	contains=@texRefGroup
426cfbc5ee4SBram Moolenaarsyn region texRefZone		matchgroup=texStatement start="\\\(page\|eq\)ref{"	end="}\|%stopzone\>"	contains=@texRefGroup
427cfbc5ee4SBram Moolenaarsyn region texRefZone		matchgroup=texStatement start="\\v\=ref{"		end="}\|%stopzone\>"	contains=@texRefGroup
428cc016f54SBram Moolenaarsyn match  texRefZone		'\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
429cc016f54SBram Moolenaarsyn region texRefOption	contained	matchgroup=Delimiter start='\[' end=']'		contains=@texRefGroup	nextgroup=texRefOption,texCite
430cc016f54SBram Moolenaarsyn region texCite	contained	matchgroup=Delimiter start='{' end='}'		contains=@texRefGroup
431071d4279SBram Moolenaar
432071d4279SBram Moolenaar" Handle newcommand, newenvironment : {{{1
433071d4279SBram Moolenaarsyn match  texNewCmd				"\\newcommand\>"			nextgroup=texCmdName skipwhite skipnl
434071d4279SBram Moolenaarsyn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
435071d4279SBram Moolenaarsyn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]"		nextgroup=texCmdBody skipwhite skipnl
436071d4279SBram Moolenaarsyn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]"	matchgroup=Delimiter end="}" contains=@texCmdGroup
437071d4279SBram Moolenaarsyn match  texNewEnv				"\\newenvironment\>"			nextgroup=texEnvName skipwhite skipnl
438071d4279SBram Moolenaarsyn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texEnvBgn skipwhite skipnl
439071d4279SBram Moolenaarsyn region texEnvBgn  contained matchgroup=Delimiter start="{"rs=s+1  end="}"		nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
440071d4279SBram Moolenaarsyn region texEnvEnd  contained matchgroup=Delimiter start="{"rs=s+1  end="}"		skipwhite skipnl contains=@texEnvGroup
441071d4279SBram Moolenaar
442071d4279SBram Moolenaar" Definitions/Commands: {{{1
443071d4279SBram Moolenaarsyn match texDefCmd				"\\def\>"				nextgroup=texDefName skipwhite skipnl
444071d4279SBram Moolenaarif b:tex_stylish
445071d4279SBram Moolenaar  syn match texDefName contained		"\\[a-zA-Z@]\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
446071d4279SBram Moolenaar  syn match texDefName contained		"\\[^a-zA-Z@]"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
447071d4279SBram Moolenaarelse
448071d4279SBram Moolenaar  syn match texDefName contained		"\\\a\+"				nextgroup=texDefParms,texCmdBody skipwhite skipnl
449071d4279SBram Moolenaar  syn match texDefName contained		"\\\A"					nextgroup=texDefParms,texCmdBody skipwhite skipnl
450071d4279SBram Moolenaarendif
451071d4279SBram Moolenaarsyn match texDefParms  contained		"#[^{]*"	contains=texDefParm	nextgroup=texCmdBody skipwhite skipnl
452071d4279SBram Moolenaarsyn match  texDefParm  contained		"#\d\+"
453071d4279SBram Moolenaar
454071d4279SBram Moolenaar" TeX Lengths: {{{1
4559964e468SBram Moolenaarsyn match  texLength		"\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
456071d4279SBram Moolenaar
457071d4279SBram Moolenaar" TeX String Delimiters: {{{1
458071d4279SBram Moolenaarsyn match texString		"\(``\|''\|,,\)"
459071d4279SBram Moolenaar
4605c73622aSBram Moolenaar" makeatletter -- makeatother sections
4615c73622aSBram Moolenaarif !exists("g:tex_no_error")
4625c73622aSBram Moolenaar syn region texStyle			matchgroup=texStatement start='\\makeatletter' end='\\makeatother'	contains=@texStyleGroup contained
4635c73622aSBram Moolenaar syn match  texStyleStatement		"\\[a-zA-Z@]\+"	contained
4645c73622aSBram Moolenaar syn region texStyleMatcher		matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]"	end="}"		contains=@texStyleGroup,texError	contained
4655c73622aSBram Moolenaar syn region texStyleMatcher		matchgroup=Delimiter start="\["				end="]"		contains=@texStyleGroup,texError	contained
4665c73622aSBram Moolenaarendif
4675c73622aSBram Moolenaar
468071d4279SBram Moolenaar" LaTeX synchronization: {{{1
469071d4279SBram Moolenaarsyn sync maxlines=200
470071d4279SBram Moolenaarsyn sync minlines=50
471071d4279SBram Moolenaar
472071d4279SBram Moolenaarsyn  sync match texSyncStop			groupthere NONE		"%stopzone\>"
473071d4279SBram Moolenaar
474071d4279SBram Moolenaar" Synchronization: {{{1
475071d4279SBram Moolenaar" The $..$ and $$..$$ make for impossible sync patterns
476071d4279SBram Moolenaar" (one can't tell if a "$$" starts or stops a math zone by itself)
477071d4279SBram Moolenaar" The following grouptheres coupled with minlines above
478071d4279SBram Moolenaar" help improve the odds of good syncing.
479071d4279SBram Moolenaarif !exists("tex_no_math")
480071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{abstract}"
481071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{center}"
482071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{description}"
483071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{enumerate}"
484071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{itemize}"
485071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{table}"
486071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\end{tabular}"
487071d4279SBram Moolenaar syn sync match texSyncMathZoneA		groupthere NONE		"\\\(sub\)*section\>"
488071d4279SBram Moolenaarendif
489071d4279SBram Moolenaar
490071d4279SBram Moolenaar" Highlighting: {{{1
491071d4279SBram Moolenaarif did_tex_syntax_inits == 1
492071d4279SBram Moolenaar let did_tex_syntax_inits= 2
493071d4279SBram Moolenaar  " TeX highlighting groups which should share similar highlighting
494071d4279SBram Moolenaar  if !exists("g:tex_no_error")
495071d4279SBram Moolenaar   if !exists("tex_no_math")
496071d4279SBram Moolenaar    HiLink texBadMath		texError
497071d4279SBram Moolenaar    HiLink texMathDelimBad	texError
498071d4279SBram Moolenaar    HiLink texMathError		texError
499071d4279SBram Moolenaar    if !b:tex_stylish
500071d4279SBram Moolenaar      HiLink texOnlyMath	texError
501071d4279SBram Moolenaar    endif
502071d4279SBram Moolenaar   endif
503071d4279SBram Moolenaar   HiLink texError		Error
504071d4279SBram Moolenaar  endif
505071d4279SBram Moolenaar
506cc016f54SBram Moolenaar  HiLink texCite		texRefZone
507071d4279SBram Moolenaar  HiLink texDefCmd		texDef
508071d4279SBram Moolenaar  HiLink texDefName		texDef
509071d4279SBram Moolenaar  HiLink texDocType		texCmdName
510071d4279SBram Moolenaar  HiLink texDocTypeArgs		texCmdArgs
511071d4279SBram Moolenaar  HiLink texInputFileOpt	texCmdArgs
512071d4279SBram Moolenaar  HiLink texInputCurlies	texDelimiter
513071d4279SBram Moolenaar  HiLink texLigature		texSpecialChar
514071d4279SBram Moolenaar  if !exists("tex_no_math")
515071d4279SBram Moolenaar   HiLink texMathDelimSet1	texMathDelim
516071d4279SBram Moolenaar   HiLink texMathDelimSet2	texMathDelim
517071d4279SBram Moolenaar   HiLink texMathDelimKey	texMathDelim
518071d4279SBram Moolenaar   HiLink texMathMatcher	texMath
5195c73622aSBram Moolenaar   HiLink texMathZoneV		texMath
520071d4279SBram Moolenaar   HiLink texMathZoneW		texMath
521071d4279SBram Moolenaar   HiLink texMathZoneX		texMath
522071d4279SBram Moolenaar   HiLink texMathZoneY		texMath
5233577c6faSBram Moolenaar   HiLink texMathZoneV		texMath
524071d4279SBram Moolenaar   HiLink texMathZoneZ		texMath
525071d4279SBram Moolenaar  endif
526071d4279SBram Moolenaar  HiLink texSectionMarker	texCmdName
527071d4279SBram Moolenaar  HiLink texSectionName		texSection
528071d4279SBram Moolenaar  HiLink texSpaceCode		texStatement
5295c73622aSBram Moolenaar  HiLink texStyleStatement	texStatement
530071d4279SBram Moolenaar  HiLink texTypeSize		texType
531071d4279SBram Moolenaar  HiLink texTypeStyle		texType
532071d4279SBram Moolenaar
533071d4279SBram Moolenaar   " Basic TeX highlighting groups
534071d4279SBram Moolenaar  HiLink texCmdArgs		Number
535071d4279SBram Moolenaar  HiLink texCmdName		Statement
536071d4279SBram Moolenaar  HiLink texComment		Comment
537071d4279SBram Moolenaar  HiLink texDef			Statement
538071d4279SBram Moolenaar  HiLink texDefParm		Special
539071d4279SBram Moolenaar  HiLink texDelimiter		Delimiter
540071d4279SBram Moolenaar  HiLink texInput		Special
541071d4279SBram Moolenaar  HiLink texInputFile		Special
542071d4279SBram Moolenaar  HiLink texLength		Number
543071d4279SBram Moolenaar  HiLink texMath		Special
544071d4279SBram Moolenaar  HiLink texMathDelim		Statement
545071d4279SBram Moolenaar  HiLink texMathOper		Operator
546071d4279SBram Moolenaar  HiLink texNewCmd		Statement
547071d4279SBram Moolenaar  HiLink texNewEnv		Statement
548071d4279SBram Moolenaar  HiLink texOption		Number
549071d4279SBram Moolenaar  HiLink texRefZone		Special
550071d4279SBram Moolenaar  HiLink texSection		PreCondit
551071d4279SBram Moolenaar  HiLink texSpaceCodeChar	Special
552071d4279SBram Moolenaar  HiLink texSpecialChar		SpecialChar
553071d4279SBram Moolenaar  HiLink texStatement		Statement
554071d4279SBram Moolenaar  HiLink texString		String
555071d4279SBram Moolenaar  HiLink texTodo		Todo
556071d4279SBram Moolenaar  HiLink texType		Type
557071d4279SBram Moolenaar  HiLink texZone		PreCondit
558071d4279SBram Moolenaar
559071d4279SBram Moolenaar  delcommand HiLink
560071d4279SBram Moolenaarendif
561071d4279SBram Moolenaar
562071d4279SBram Moolenaar" Current Syntax: {{{1
563071d4279SBram Moolenaarunlet b:extfname
564071d4279SBram Moolenaarlet   b:current_syntax = "tex"
565071d4279SBram Moolenaar" vim: ts=8 fdm=marker
566