I recently (2 days back) started using LaTeX, I use Sublime Text 2 (ST2) for most of the programming. I found that ST2 has LaTeX package. So what I am doing is write the document with ST2 and run it with TeXWorks to see any errors/debugging. Is there a way I can run/debug the tex file directly from ST2? Is there any better practice than what I am doing currently?

  • 1
    Welcome to TeX.SE. Why not just work directly in TeXWorks? What exactly is the big advantage of using ST2 over TeXWorks? – Peter Grill Jun 18 '12 at 4:59
  • 9
    @PeterGrill I am also using ST2 and I'd hardly change to a different editor just for my Tex work. Having a different keyboard interface is annoying to say the least. (But I can't answer the original question though - I open the log file in another tab and see it there.) – topskip Jun 18 '12 at 5:04
  • @PatrickGundlach: Ok, that makes sense. Will have to take a look at ST2. – Peter Grill Jun 18 '12 at 5:52
  • @PeterGrill, thanks for welcome, ST2 awesomely highlights the syntax where as TeXworks doesnt & its so messy! – uday Jun 18 '12 at 6:37
  • @uDaY What is your operating system ? – Alain Matthes Jun 18 '12 at 8:51

It's not easy to work with ST2 the first time . You need to install some tools.

Firstly, you can read this readme Readme LaTeXTools then you can download the archive .zip here LaTeXTools.

The readme explains how to install the package. You get something like TextMate after that (Personally I prefer TextMate on OS X) but this editor is really fine tool.

idea from kgr

A good thing, it's to add the package control, with this package you can LaTeXTools directly and very important this will keep it up to date. It's the better way. You need to read carefully the explanations to install the package control.

  • 4
    Just to expand on this a bit, first you need to add package control, instructions here: wbond.net/sublime_packages/package_control . Then you should add LaTeXTools directly in package control; this will keep it up to date. (As opposed to downloading the zip file manually.) – kgr Jun 18 '12 at 13:26
  • @kgr Yes you are right and it was my method to install the package but I forgot it. I will update my answer. I forgot because I work only with TextMate, I made only an attempt with Sublime Text 2. – Alain Matthes Jun 18 '12 at 14:09
  • @kgr, I already looked that site. But I have noticed that without adding the package control too the LaTeX package was available in ST2, So we need to add package control to have a build system to debug/run the LaTeX file created? – uday Jun 18 '12 at 17:14
  • @Altermundus, Ok I followed and installed the LaTeX tools package & have built the system, but after I compile the document without errors, ST2 prompts it Cannot launch Viewer, make sure its in PATH Is it talking about the Adobe Acrobat is not in path? – uday Jun 19 '12 at 0:08
  • 1
    @kgr I'm not a great expert with Windows but I think Sumatra is a great viewer. You can read this link jbdeaton.com/2012/…. About the PATH, perhaps via Start/ . . . /System/Extended/Enviroment variables – Alain Matthes Jun 19 '12 at 5:38

I'm the developer of the LaTeXTools plugin. Ctrl-B (-B on OS X) launches a specially modified build system that:

  • collects errors and warnings, and displays them in Sublime Text's output panel; you can then click on the errors to jump to the corresponding line in your source text file;

  • sets up forward and inverse search

  • upon completion, invokes forward search in your PDF previewer (Skim on Mac, SumatraPDF on Windows, Linux not there yet) so you get to see the current page

Take a look at the README file in the plugin's directory (which you can open in Sublime Text using the "Browse Packages..." menu item).

  • Hm... tried it a while a go and it didn't work. Now, after your answer I tried it again and found the culprit: Apparently, the plugin does not support the $out_dir=./build setting in my .latexmkrc, which, among other things, makes latexmk to add -output-directory=./build to the pdflatex command line. I really do love this setting, as it keeps my source folders clean. Any easy option to enable this? If not, any chance that it will be supported? – Daniel Mar 18 '13 at 22:13

There is no default functionality for that, but you can easily create your own. in ST2 you can add build systems in Tools -> Build System -> New Build System... and if you want to run your file with PDFTeX, your build system definition file would look like:

    "cmd": ["pdflatex","$file_name"],
        "selector": "text.tex.latex"


Another way is to set up latexmk for your project, which can be as simple as creating a project file like this (name that latexmkrc):

$pdf_mode = 1;
@default_files = ('myfile');

and have a build project with latexmk:

    "cmd": ["latexmk"],
    "selector": "text.tex.latex"

If you now select select that build system in the same menu you can now press command-b or ctrl-b the TeX file will get compiled. You can manually switch to the log file and see what is in there.

  • Altermundus' answer is much better than mine! – topskip Jun 18 '12 at 6:58
  • Only if you like the LaTeXTools but your answer shows how to create the "build system", it's interesting too. – Alain Matthes Jun 18 '12 at 8:48
  • well, LaTeXTools includes an already created build system for latex. – kgr Jun 18 '12 at 13:27

I've personally found the following to work just fine for me:

"cmd": ["pdflatex", "$file"]

Here's an explanation as requested.

This is the build file code that I use in Sublime Text 3 (this works fine in ST2 as well) to compile my LaTeX (I use MikTex). If you go to Tools -> Build System -> New Build System you can use what I have to build your .tex file. I've used this successfully on Linux (Ubuntu) and on Windows 8.1. You might have to check your PATH to ensure that MikTeX is there. I've explored LaTeXTools, but have found it much simpler to use this instead of the package; there's virtually no setup. However, if you're looking for something a bit more complicated, LaTeXTools is the way to go.

  • 1
    Welcome to TeX.SX! Could you please add some kind of explanation to clarify the code you posted? (You can have a look at our starter guide to familiarize yourself further with our format.) – Pier Paolo Apr 6 '15 at 18:15

If you want to compile more options, for example:

  • pdflatex #or latex
  • bibtex
  • glosstex
  • makeindex #or more

you can write a Makefile with content:

FICHEROS_GLOSARIO = acronimos.gdf

    pdflatex $(NOMBRE_LATEX)
    -bibtex $(NOMBRE_LATEX)
    -makeindex $(NOMBRE_LATEX).gxs -o $(NOMBRE_LATEX).glx -s glosstex.ist
    -makeindex $(NOMBRE_LATEX)
    pdflatex $(NOMBRE_LATEX)
    pdflatex $(NOMBRE_LATEX)

latex: imagenesbitmap imagenesvectoriales
    latex $(NOMBRE_LATEX)
    -bibtex $(NOMBRE_LATEX)
    -makeindex $(NOMBRE_LATEX).gxs -o $(NOMBRE_LATEX).glx -s glosstex.ist
    latex $(NOMBRE_LATEX)
    latex $(NOMBRE_LATEX)
    dvips $(NOMBRE_LATEX).dvi
    ps2pdf $(NOMBRE_LATEX).ps

and make a new sublime build for example: makeThesis.sublime-build with content:

"cmd": ["make -C ~/Tesis/TeXiS"],
"shell": true

The path "~/Tesis/TeXiS" content your all project of latex and "make -C" is to compile from anywhere (Ctrl+b)

Well only go to: Tools > Build Systems > makeThesis for compile

PD: in Makefile

 FICHEROS_GLOSARIO = acronimos.gdf

TeXiS es your master latex file (ie: TeSiS.tex) and acronimos.gdf content you glossary words. Keep in mind that the makefile is in linux SO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.