## I'd like to make a LaTeX output, script

### I'd like to make a LaTeX output, script

No idea where to start - it is quite simple, just needs to run texify or something (from miktex). I know a little bit of python, but I wouldn't know where to begin.

Posts: 5
Joined: Sun Sep 20, 2009 6:18 pm

### Re: I'd like to make a LaTeX output, script

Indeed, the LaTeX package is quite functional right now: take a look at the Sublimetextwiki page:

http://sublimetextwiki.com/pages/LaTeX.html

You can read the docs and download the package file from there. Or, as the previous poster suggested, take a look at the code on Google Code.

The current version provides:

* texification, with convenient error navigation
* inverse and forward search with SumatraPDF
* insertion of references and citations from BibTeX
* insertion of tex macros
* environment closers, and other niceties to work with TeX/LaTeX commands and environments

Take a look at the documentation; I have tried to be as comprehensive as possible. Your feedback would be much appreciated!

I have drawn inspiration from the TextMate LaTeX bundle (although the code is original). However, a few features are missing. In particular, one day I'd like to add:

* support for multi-file tex documents (a biggie, as it impacts various commands)
* insertion of citations from \bibitem commands (right now I handle bibtex bibliographies only). This should be easy to implement
* more font commands (easy). E.g. TextMate has a nice "italics" command that gives you \emph{} in normal text and \mathit{} in math mode. That would be nice to have.
* More tex macros (easy, as it's just a matter of adding to a dictionary).

M
Marciano

Posts: 146
Joined: Fri Sep 18, 2009 2:55 am

### Re: I'd like to make a LaTeX output, script

Hi -- not much time for a full reply, but this may help. Jon has a walkthrough for creating a basic TextCommand plugin (<http://www.sublimetext.com/docs/plugin-examples>), and this is code for running latex from miktex 2.7. Between the two, you should have all the pieces, but you'll need to do some blending. Call the compileLatex() method below.

Here's some code I use for running a LaTeX compiler;

Code: Select all
# you may need to import any of these;import sublime, sublimeplugin, re, os, datetime, shutil, popen2, string, subprocess, time# the driving code itself;def compileLatex(latexFile):  miktexExe = miktexCommandPath("latex")  commandLine = " --interaction=nonstopmode --aux-directory c:\\temp\\ \"" + latexFile + "\""  # two compiles, to make sure contents etc are up-to-date  for i in range(2):          result = runSysCommand(miktexExe, commandLine)     if (result != 0):      return result  return 0# call this on a command line to run it.def runSysCommand(commandText, arguments=None):  """executes the commands"""  print "running \"%s\" %s" % (commandText, arguments)  if arguments == None:    result = os.spawnl(os.P_WAIT, commandText)  else:    result = os.spawnl(os.P_WAIT, commandText, arguments)  if result != 0:    print "failed to execute \"%s\" %s" % (commandText, arguments)  return result# get the program files directorydef programFiles():  prog32 = "c:\\program files"  prog64 = "c:\\program files (x86)"  if os.path.exists(prog64):    return prog64  elif os.path.exists(prog32):    return prog32  else:    raise Exception("can't find a program files")    # get the miktex command; eg miktexCommandPath("texify") def miktexCommandPath(commandName):  return os.path.join(programFiles(), "MiKTeX 2.7\\miktex\\bin", commandName + ".exe")
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg

Posts: 193
Joined: Thu Mar 20, 2008 9:53 am