   }
   alignMathEnvironment: {
     comment: 'Matches align environment'
-    contentName: 'support.environment.math.align.latex'
-    begin: '(\\\\)(begin)(\\{)(align(\\*)?)(\\})'
-    beginCaptures:
-      1:
-        name: 'punctuation.definition.function.latex'
-      2:
+    contentName: 'meta.environment.math.align.latex'
+    begin: '\\\\begin(\\{)(align(\\*)?)(\\})'
+    beginCaptures:
+      0:
         name: 'support.function.environment.begin.latex'
-      3:
-        name: 'punctuation.definition.argument.begin.latex'
+      1:
+        name: 'punctuation.definition.argument.begin.latex'
+      2:
+        name: 'variable.parameter.argument.latex'
       4:
+        name: 'punctuation.definition.argument.end.latex'
+    end: '\\\\end(\\{)(\\2)(\\})'
+    endCaptures:
+      0:
+        name: 'support.function.environment.end.latex'
+      1:
+        name: 'punctuation.definition.argument.begin.latex'
+      2:
         name: 'variable.parameter.argument.latex'
-      6:
-        name: 'punctuation.definition.argument.end.latex'
-    end: '(\\\\)(end)(\\{)(\\4)(\\})'
-    endCaptures:
-      1:
-        name: 'punctuation.definition.function.latex'
-      2:
-        name: 'support.function.environment.end.latex'
-      3:
-        name: 'punctuation.definition.argument.begin.latex'
-      4:
-        name: 'variable.parameter.argument.latex'
-      5:
+      3:
         name: 'punctuation.definition.argument.end.latex'
     patterns: [
       {

  }
  figureEnvironment: {
    comment: 'Matches the common figure environment'
    contentName: 'support.environment.figure.latex'
    begin: '(\\\\)(begin)(\\{)(figure)(\\})((\\[)(\\w*)(\\]))?'
    beginCaptures:
      1:
        name: 'punctuation.definition.function.latex'
      2:
        name: 'support.function.environment.begin.latex'
      3:
        name: 'punctuation.definition.argument.begin.latex'
      4:
        name: 'variable.parameter.argument.latex'
      5:
        name: 'punctuation.definition.argument.end.latex'
      7:
        name: 'punctuation.definition.optional.begin.latex'
      8:
        name: 'variable.parameter.optional.latex'
      9:
        name: 'punctuation.definition.optional.end.latex'
    end: '(\\\\)(end)(\\{)(\\4)(\\})'
    endCaptures:
      1:
        name: 'punctuation.definition.function.latex'
      2:
        name: 'support.function.environment.end.latex'
      3:
        name: 'punctuation.definition.argument.begin.latex'
      4:
        name: 'variable.parameter.argument.latex'
      5:
        name: 'punctuation.definition.argument.end.latex'
    patterns: [
      {

  escapedCharacter: {
    comment: 'Finds escaped characters like \$ and \%. Uses this regex so unique capture groups can be used.'
    name: 'constant.character.latex'
    match: '\\\\(\\&|\\%|\\$|\\#|\\_|\\{|\\}|(textascii(tilde|circum)|textbackslash)(?=[^a-zA-Z@]))'
  }
  accents: {
    comment: 'For standard latex accent macros such as \^ or \`'
    name: 'constant.character.accent.latex'
    match: '''\\\\([\\`\\'\\^\\"\\~\\=\\.](\\w|\\{\\w?\\})|[Hcklbdruv]\\{\\w?\\})'''
  }
  hypersetup: {
    comment: 'Recongnises hypersetup environment. Can be extended to be a general key-option scoper, but this (potentially) allows custom colours for known keys.'
    name: 'meta.preamble.latex'
    begin: '\\\\hypersetup(?=[^a-zA-Z@])'
    beginCaptures:
      0:
        name: 'keyword.control.preamble.hypersetup.latex'
    end: '(?<=\\})|(^\\s*$)'
    endCaptures:
      1:
