Sublime Forum

Latex.tmLanguage meta variables

#1

I would like to further customize the syntax highlighting, in this case of LaTeX.

For this I need to know which meta variables are defined, and possibly I would like to include more meta variables. However the LaTeX.tmLanguage definition is closed source I believe?

  • Can I extract at least which meta variables are defined?
  • Can a definition for \footnote{...} be made under meta.footnote.latex ?
0 Likes

#2

@tdegeus Compare https://github.com/sublimehq/Packages (and subfolder ../Latex there). You can submit pull requests against that repo if need be.

0 Likes

#3

You can install PackageResourceViewer and open the file LaTeX/LaTeX.sublime-syntax. There you can for example search for textit to see how a new scope is applied. Just duplicate the entry and add your footnote there (not the best style). But be aware that you won’t get further syntax updates, unless you work them in manually (where OverrideAudit may be helpful) .

1 Like

#4

@r-stein @rppn These are great tips that have helped me to get done what I wanted. Currently however I have a Packages/User/LaTeX.sublime-settings with a slight extension to the existing one (as suggested). I am pretty sure however that instead I can include the shipped LaTeX.sublime-settings. My attempt (not working: \footnote{...} is ignored):

%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
scope: text.tex.latex

contexts:
  main:
    - match: ""
      push: "Packages/LaTeX/LaTeX.sublime-syntax"
      with_prototype:
        - match: '((\\)footnote)(\{)'
          push: footnote

  footnote:
    - meta_scope: meta.function.footnote.latex
    - match: '\}'
      scope: punctuation.definition.group.brace.end.latex
      pop: true

(see also Syntax Definitions: Including Other Files)

0 Likes