Skip to content
Richard Stein edited this page May 9, 2017 · 8 revisions

This page is meant to collect tips and tricks to improve your LaTeX work-flow. Feel free to add you own tips.

Change environment and restore selection

LaTeXTools adds a function to change the current environment bound to the keybinding C-l, C-Shift-n. This sets the selection to the surrounding environment, but you can not restore the cursor position.

If you additionally install MultiEditUtils and ChainOfCommand you can add the following to your keymap (adapt keys for OSX). Then you can press C-l, C-Shift-n to change the environment. Afterwards just press escape and the previous selection will be restored.

Demonstration

    {
        "keys": ["ctrl+l", "ctrl+shift+n"],
        "command": "chain",
        "args": {
            "commands": [
                ["toggle_setting", {"setting": "custom_change_env"}],
                ["selection_fields", {"mode": "add"}],
                ["latex_change_environment"],
            ]
        },
        "context":
        [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex"}
        ]
    },

    {
        "keys": ["escape"],
        "command": "chain",
        "args": {
            "commands": [
                ["toggle_setting", {"setting": "custom_change_env"}],
                ["selection_fields", {"mode": "pop", "only_other": true}]
            ]
        },
        "context":
        [
            { "key": "setting.custom_change_env" },
            { "key": "auto_complete_visible", "operator": "equal", "operand": false }
        ]
    },

Change color scheme

Sublime Text is mainly used and designed for programming languages and some highlighting may not be optimal for LaTeX. This section contains improvements in the color scheme. You can use PackageResourceViewer to edit the color scheme. It is a *.tmTheme file with xml content.

Highlight inside math environments

Sublime Text has released a new syntax file in build 3119. This file removes the highlighting of math environments as strings, because that had several disadvantages. If you nonetheless want to highlight math environments the recommended way is to use the scope text.tex.latex variable.other.math. Therefore add

        <dict>
            <key>name</key>
            <string>LaTeX: Math Variable</string>
            <key>scope</key>
            <string>text.tex.latex variable.other.math</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#ffff00</string>
            </dict>
        </dict>

at a reasonable position in the color scheme. Change the foreground to your preferred color. (Use meta.environment.math to change the background color.) If you don't use the default color scheme, you could create a pull request at the color scheme.