Sublime Forum

LaTeX plugin for ST2

#1

I am porting my LaTeX plugin to ST2. Here’s how to get it: go to

github.com/SublimeText/LaTeXTools

and hit Download. For installation and setup instructions, and very preliminary documentation, see my blog:

tekonomist.wordpress.com/2011/03 … -text-2-4/

WARNING: it’s alpha quality, but I’ve been using it as my sole LaTeX editor for the past two weeks, on both Mac and Windows. Lots of work left to do, but it’s a start.

Comments welcome!

[EDITED 3/26 with new GitHub URL]

0 Likes

#2

Hi,

First of all, thanks a lot for taking your time for developing this plugin. I’ve been using it a lot (As well has a friend from the university also using Sublime Text) :smile:

I’m using it with linux (Ubuntu 11.04) and a build produces an error after running pdflatex. I’ve solved this by commenting the default pdf_previewer line and adding:

"-e", "\\$pdf_previewer = qq{evince %S}",

Evince (default pdf viewer) stays on the correct page, and it also allows pdflatex to update the pdf without having to close it, so the most basic functionality is there. No reverse lookup etc though but i can survive without that.

Thanks again :smile:

0 Likes

#3

Seconded (about this being a great plugin).

After some problems finding latexmk on my Mac (in case anyone else has this problem you have to put your PATH variable in a plist file called ~/.MacOSX/environment.plist which is read on login: see here), this works wonderfully. I’m using Preview.app as my previewer and did the same sort of thing as fjolle by appending:

"\\$pdf_previewer = qq{open -a Preview %O %S}"

rather than the default preview code. Preview updates the document preview when you refocus the window. Again no reverse lookup but I’m not a huge fan of Skim, so I decided I could do without this.

0 Likes

#4

Thanks guys!

Just a couple of comments. First, unfortunately there is no Linux-specific customization yet, the reason being that I don’t have enough room to install an Ubuntu VM on my laptop. I don’t like this state of affairs, and would be delighted if someone would contribute proper Linux support. I am not sure Evince has support for inverse search, but I think Okular does (or used to). It’s been a while…

Second, regarding the previewer in OSX (and other platforms, too, for that matter): my medium-term goal is to make such things user-configurable. Preview does not support forward/inverse search, and for me this is a non-starter; however, that’s a matter of taste.

However, I am about to merge patches that implement better interaction with the PDF viewer and, more importantly, proper error handling. This redefines the build command entirely, but in light of your comments, I’ll leave the current build system unmodified (or provide an easy way to switch back to it).

Keep the comments coming!
M

0 Likes

#5

Hi Marciano

I think the most useful bit of customisation at the moment would to be able to select the tex engine used to compile documents. I’m using xelatex a lot (because I hate the default LaTeX fonts and want to use Gentium for a lot of my documents), and although you can just change the build file, it would be nice to have a way of setting this on a per-document basis (like TeXShop’s %!TEX commands). I’m not sure how easy this would be to do though…

BTW, if anyone else wants to use xelatex rather than pdflatex, just stick the following in the build command in the LaTeX.sublime-build file:

"-e", "\\$pdflatex = 'xelatex %O %S'"
0 Likes

#6

[quote=“jesse.robertson”]Seconded (about this being a great plugin).

After some problems finding latexmk on my Mac (in case anyone else has this problem you have to put your PATH variable in a plist file called ~/.MacOSX/environment.plist which is read on login: see here), this works wonderfully.[/quote]

Hi,

thanks Marciano for the plugin, and thank you Jon for bringing us ST2. Coming here from the TextMate mailing list (where, btw, while TM2 is still sorely missed, ST2 indeed makes some waves) I am eager to try out ST2 in a LaTeX workflow. (I’m using TM and Skim for my LaTeX needs right now.)

However, to be honest, I’m not that proficient with regards to .plists, hidden path variables, and the like. So I would kindly ask Jesse to be a bit more specific about how to tell ST2 where latexmk lives.
For now, whenever I try to build some LaTeX, I get:

“[Errno 2] No such file or directory
[Finished]”

I managed to create the file ~/.MacOSX/environment.plist, but how to put the information about latexmk’s path into it? Excuse my illiteracy.

Thanks for your help, and great work.

–Georg

Update: I think I found crucial help (haven’t checked it out yet because I cannot log out/re-log in right now):

http://tekonomist.wordpress.com/2011/04/22/google-chrome-favicons-are-back-on-my-mac/#comment-189

Thx again, Marciano!

0 Likes

#7

You’re welcome :smile:

BTW, a way to specify paths within ST2, and possibly auto-discover them, is high on my list. I’ve been super-busy lately, but do plan to get back to coding ASAP.

0 Likes

#8

Hi
Many thanks for your work, it works great.
I do however have a simple question (probably the most stupid question I could ask)… but what is meant by:

So far I have specified the full path in viewPDF.py. It works, but I guess it is not what is meant??
Thanks
Thels

0 Likes

#9

Hi driple

Apologies for how long it has taken me to reply to your post!

The issue is that Macs don’t make environment variables (for example your PATH variable, which tells the operating system where to find some important UNIX programs on your computer, including LaTeX or other Python installs) available to every application by default. The way around this is to write a property list file (plist) called “environment.plist” and put it in the “~/.MaxOSX folder” - the system will look for this file on login and make the variables defined in it available to your applications.

The way to do this is as follows:

  1. Open a terminal window

  2. Run the following mkdir ~/.MacOSX; cd ~/.MaxOSX (If you already have this folder the OS will complain but won’t overwrite it). You should now be in the ~/.MacOSX folder, although it won’t appear in the Finder (since folders or files beginning with a period are hidden).

  3. Now you need a copy of your path. The easiest thing to do is run echo $PATH in the terminal and copy the result.

  4. Next you need to make the plist file. The easiest thing to do is touch environment.plist; open -a "Sublime Text 2" environment.plistwhich should open the file in Sublime Text. Copy the following in:

[code]<?xml version="1.0" encoding="UTF-8"?>

ROOT PATH YOUR_PATH_HERE [/code] replacing YOUR_PATH_HERE with whatever was printed from the echo command at step 3.
  1. Save the file, log out and log back in and everything should work.

You can generate plist files using the developer tools which come with Xcode but they’ve changed everything in Lion so it’s just easier to modify the files in Sublime Text. It’d probably be pretty easy to stick this all in a shell script but I’m too lazy to sort this out at the moment.

Hope this helps! I’ll keep an eye on this thread if you have any problems. :smile:

0 Likes

#10

Driple and jesse.robertson — since sometime in late July (can’t remember when exactly) it is no longer necessary to configure paths on Mac OS X. If you pull the current version from GitHub, you will be good to go without creating the .MacOS/environment.plist file.

Also, there is now a semi-legible README file with an explanation of the installation procedure (not much to do on the Mac) and features.

0 Likes

#11

First of all, thanks for this plugin, it makes my life a lot easier. I just installed it and enjoying it already. I just have one question, when i have SumatraPDF closed and the plugin tries to open it I get the error: “Cannot launch Viewer. Make sure it is on your PATH”. Of course I’m not that much of a moron that I didn’t understand the error, but what I can’t figure out is what the error message means by “PATH”. Where can I change it? (Or where is it set so I can change SumatraPDF’s location?).

Thanks for all the hard work and if anyone could help me i would be grateful!

0 Likes

#12

I do plan to remove this limitation at some point soon, but right now, you need to add the SumatraPDF executable to your “path”. This is the list of directories where Windows looks for programs (EXE files) to run when e.g. you invoke them from the command line. See e.g. here:

geekswithblogs.net/renso/archive … ows-7.aspx

Sumatra should be installed in

C:\Program Files\SumatraPDF\SumatraPDF.exe

unless you have put it somewhere else.

Hope this helps—M

0 Likes

#13

Worked perfectly! Thank you very much.
If you ever need help (testing or something), you just need to ask!

0 Likes

#14

Hey Marciano - should the LaTeXTools plugin be able to find all my *tex executables on a Mac? I still had to mod the environment.plist file when I did a clean install on a new Mac in Lion to get everything to work.

0 Likes

#15

Er… yes, it should. I have no environment.plist file on the machine I’m working on right now, and I am using LaTeXTools with no trouble at all. Are you sure you have a current version of the plugin?

0 Likes

#16

Hmm, maybe I’ll try a clean install with the new plugin and see whether it works. The old one might have come across when I shifted to the new machine. I’ll let you know how I get on.

0 Likes

#17

Ok, that fixed it! Thanks for sorting that our Marciano. :smile:

0 Likes

#18

Hi.

I’ve just buy a license of this text editor and I’ve followed your instructions and it works.

Now, I’d like to know to use my toolchain for compiling tex files. Considering that I use PSTricks and bibtex, che toolchain that I use in texmaker is the following:

latex -interaction=nonstopmode %.tex|bibtex %.aux|latex -interaction=nonstopmode %.tex|latex -interaction=nonstopmode %.tex|dvips -o %.ps %.dvi|ps2pdf %.ps

As you can see, I invoke the latex-bibtex-latex-latex chain for bibtex, giving the .dvi, and then the dvips-ps2pdf chain to create the pdf from the .dvi.
How can I invoke the same toolchain using your plugin?

0 Likes

#19

I don’t have direct experience with that, but LaTeXTools uses the latexmk script to actually drive tex & friends, and you can customize the way latexmk is invoked.

Take a look at the documentation for latexmk:

phys.psu.edu/~collins/softwa … k-427a.txt

There is an option -pdfps that instructs latexmk to generate a pdf file from a ps file, via ps2pdf. Look in the relevant (“osx”, I assume) section of the LaTeX.sublime-build file (it’s best if you first copy to the User directory, so it doesn’t get clobbered by subsequent updates). Check the “cmd” keyword and try modifying the options passed to latexmk.

Please report back your findings. Thanks!

0 Likes

#20

What do I need to change to run this on Linux Ubuntu?

I have pdflatex installed and can compile .tex files with it on the command line. I also installed this plugin, but when I hit Ctrl+B it doesn’t do anything except echoing this at this console like window:

It would be so great if I could run this on Linux. :smile:

0 Likes