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?
5 Answers
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.
-
4Just 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.)– kgrJun 18, 2012 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. Jun 18, 2012 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?– udayJun 18, 2012 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?– udayJun 19, 2012 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 Jun 19, 2012 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, makeslatexmk
to add-output-directory=./build
to thepdflatex
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?– DanielMar 18, 2013 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.
-
-
Only if you like the LaTeXTools but your answer shows how to create the "build system", it's interesting too. Jun 18, 2012 at 8:48
-
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.
-
1Welcome 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.) Apr 6, 2015 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:
###################Makefile###########
NOMBRE_LATEX = TeXiS
FICHEROS_GLOSARIO = acronimos.gdf
pdflatex:
pdflatex $(NOMBRE_LATEX)
-bibtex $(NOMBRE_LATEX)
-glosstex $(NOMBRE_LATEX) $(FICHEROS_GLOSARIO)
-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)
-glosstex $(NOMBRE_LATEX) $(FICHEROS_GLOSARIO)
-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
NOMBRE_LATEX = TeXiS
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.
TeXWorks
? What exactly is the big advantage of using ST2 overTeXWorks
?