Currently the section commands are coloured blue (using the Monokai theme). I would like to add more emphasis to sectioning commands in the source code when open in Sublime Text 3, similar to the effect illustrated in the Emacs answer.
I installed the PackageResourceViewer
plugin and opened LaTeX.sublime-syntax
resource. I see:
sections:
- match: |-
(?x)
(
(\\)
(?:
(?:sub){0,2}section
| (?:sub)?paragraph
| chapter|part|addpart
| addchap|addsec|minisec
)
(?:\*)?
)
(?:
(\[)([^\[]*?)(\]) # optional Title
)?
(\{)
captures:
1: support.function.section.latex
2: punctuation.definition.backslash.latex
3: punctuation.definition.group.brace.begin.latex
4: entity.name.section.latex
5: punctuation.definition.group.brace.end.latex
6: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.section.latex
- meta_content_scope: entity.name.section.latex
- match: '\}'
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: main
But I don't know how to proceed.
Best Answer
Overview
The way Sublime Text styles files is to separate the semantic meaning and the actual rendering. This is similar to LaTeX: you have a command
\section{...}
—indicating the intent—versus the actual rendering, perhaps\textbf{\huge ...}
for a very simple example.A
.sublime-syntax
file is only supposed to attach semantic meaning to parts of a document ("this is a section"), whilst the job of deciding how to render things ("this is bold") on screen belongs to colour scheme.tmThemes
files. (Of course in practice things are not so clean, and you'll see a mix of the two in.sublime-syntax
files. In a perfect world this wouldn't happen.)So you have two options:
tweak the syntax file, analogous to replacing every instance of
\section{...}
with\textbf{\huge ...}
to get bold sections. Not recommended, but I'll talk about how you could do it here.tweak the colour scheme file, analogous to changing the definition of
\section
to embolden sections.Tweak the syntax
Here we simply change the relevant parts of
LaTeX.sublime-syntax
to e.g.markup.bold.latex
(see this link for a discussion about scope names in Sublime Text). The altered lines are the ones with comments# ...
after them.(I kept the old scope
entity.name.section.latex
around in-case things rely on it, but puttingmarkup.bold.latex
after it means that the bold has priority over it.)Results may (will) vary across different colour schemes, for example some don't understand what
markup.bold
means. You mention Monokai, the default version doesn't handlemarkup.bold
, but e.g. Monokai Extended understands does.Tweak the colour scheme
The other option is to tweak the colour scheme itself. Colour schemes in Sublime Text are
.tmTheme
files, basically xml files. They have this sort of structure:Taking a look at the contents of the default
Monokai.tmTheme
, the relevant part for us is this entry in thearray
:This is what controls the style our
entity.name.section.latex
scope gets. What we can do is put in a new rule specifically targeting LaTeX sections:I don't know whether order matters here, to be safe I would put this in the
<array> ... </array>
list before the "Entity name" entry. Also, I don't know whether it's possible to change the font size; if it can be done, then this would surely be the place to do it.