Sublime Forum

LaTeX plugin for ST2

#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

#21

sorry for my ignorance and lack of knowledge, but… how can I install this in ST2?

Thanks a lot

0 Likes

#23

My guess would be that the whitespace in “program files” isn’t properly quoted by the plugin.

0 Likes

#24

I had this same issue.

As a work around I went into the viewPDF.py file that resides in the C:\Users\MyName\AppData\Roaming\Sublime Text 2\Packages\LatexTools\ directory and changed the windows viewercmd line to this:

viewercmd = “C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe”, “-reuse-instance”]

It seems to work.

0 Likes

#25

Hi!

I’m trying to use this plugin with Ubuntu 12.04, but so far I have not been able to compile.
I suspect it’s the same problem fjolle mentions in the second post of the thread. I would like to try the same solution, but I don’t know what file to edit and line to comment out.

Could I please ask for assistance on this point?

Second EDIT:
The problem is with the build system. However, here is a solution/workaround that works: http://elleestcrimi.me/2012/04/09/sublime-text-latex-build-system/.
It is to make a new build system: Tools > Build System > New Build System and insert the code below. This compiles using pdflatex and opens the file.
Not as fancy as the regulat LaTeXTools builder, but it compiles from within ST2.

{ "cmd": "pdflatex $file && gnome-open $file_base_name.pdf"], "file_regex": "^(...*?):([0-9]*):?([0-9]*)", "selector": "source.latex.tex", "shell": true }

0 Likes