SublimeText Latex update

First, a few introductory remarks. When on Windows, I use the great Sublime Text text editor. It’s the next best thing after TextMate, which is only available on the Mac. Its greatest asset (besides its killer looks…) is a well thought-out, comprehensive, and easy-to-use python-based plugin system. I spent some time developing a LaTeX package that replicates many of the best features of the TextMate LaTeX bundle. I plan on maintaining it (in my spare time), as a sort of “insurance policy”—if I ever have to leave the Mac for whatever reason, I want to make sure that I can rely on a suitable LaTeX-friendly editor. The available alternatives (WinEdt, Emacs, vim, the “e” text editor…) do not quite fit my style, for several reasons; but that’s for another post.

OK, now for the actual “news.” I just committed a small patch that improves error reporting when running the texify command (analogous to latexmk). Previously, if, for instance, texify was not on the path, nothing happened. This is, of course, bad: per the Zen of Python, “Errors should never pass silently.”

The code that creates a pipe to the texify command now captures all output directed to STDERR. Now, the tricky thing is that there are three possible cases to take care of:

  1. texify runs successfully, and compilation goes through, in the sense that there are no TeX/LaTeX errors (although there may be warnings). In this case, there is no output to STDERR, and the plugin proceeds as before, displaying a quick panel that summarizes the results of compilation.

  2. texify runs successfully, but there are TeX/LaTeX errors. In this case, texify prints out a message to STDERR inviting the user to “see [the] log file”.

  3. the pipe to texify cannot be created, in which case there the Windows system prints out a message to STDERR.

To cover cases 2 and 3, I use the following logic. If the output to STDERR is non-empty, I look for the string “see log file”; if it’s there, I bring up the quick panel, which displays the information from the log file as before; otherwise, I bring up a message box that notifies the user of the Windows error message that was obtained.

Again, most of the times the problem is that texify is not on the path, which can easily be fixed by adding the Miktex binary directory to the user or system PATH environment variable. Remember to relaunch Sublime Text after you modify the path.

NOTE: Make sure you download the latest version of the LaTeX package (it’s r.688 on Google Code). There were a couple of bugs in the first fix I committed; now everything seems to be OK, but please let me know if you encounter any issues.

Memo to myself: I must improve error reporting. Right now errors from bibtex (e.g. misspelled bibliography file) are not shown.


2 responses to “SublimeText Latex update

  1. I’ve been surfing online more than 4 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did, the net will be a lot more useful than ever before.|
    I couldn’t resist commenting. Well written!
    planning to get one as soon as i get paid

  2. I live in Le Perreux-Sur-Marne, France and my job in fact deals with this matter.
    Actually doing what you like and writing about it in such
    a quality way is a great gift. Your enlightening article contains the perfect
    combo of passion and well-written, interesting material that I’ve come to
    love and respect.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s