public
Last active — forked from dpo/BibTeX.sublime-build

Build files, keymap entries, and `run_latex_build.py` plugin for adding the option for running bibtex and cleaning up auxiliary files for LaTeX in Sublime Text 2. Added the ability to run bibtex, and changed key bindings.

  • Download Gist
Bibtex.sublime-build
1 2 3 4 5 6
{
"cmd": ["bibtex", "$file_base_name"],
"path": "$PATH:/usr/texbin:/usr/local/bin",
"file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
"selector": "text.tex.latex"
}
CleanLatexFiles.sublime-build
1 2 3 4 5 6
{
"cmd": ["latexmk", "-C", "$file"],
"path": "$PATH:/usr/texbin:/usr/local/bin",
"file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
"selector": "text.tex.latex"
}
Default (OSX).sublime-keymap
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[
// Run bibtex
{ "keys": ["super+shift+b"],
"command": "run_latex_build",
"args": {
"build_system": "Packages/User/Bibtex.sublime-build",
"reset_to": "Packages/LaTeXTools/LaTeX.sublime-build"
},
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex" }
]
},
// Clean up LaTeX auxiliary files.
{
"keys": ["super+shift+c"],
"command": "run_latex_build",
"args": {
"build_system": "Packages/User/CleanLatexFiles.sublime-build",
"reset_to": "Packages/LaTeXTools/LaTeX.sublime-build"
},
"context": [
{ "key": "selector", "operator": "equal", "operand": "text.tex.latex" }
]
}
]
run_latex_build.py
Python
1 2 3 4 5 6 7 8
import sublime
import sublime_plugin
 
class RunLatexBuildCommand(sublime_plugin.WindowCommand):
def run(self, build_system, reset_to):
self.window.run_command( "set_build_system", {"file": build_system } )
self.window.run_command( "build" )
self.window.run_command( "set_build_system", {"file": reset_to})

I just wonder why you add a BibTeX command. Latexmk will take care of that.

@dpo: I think it was a hangover from running separate LaTeX and BibTeX commands the "old-fashioned" way, but sometimes it's convenient to run just latex or bibtex without invoking the switch in focus to Skim, i.e. if you're essentially just "debugging" the LaTeX source.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.