Sublime Forum

LaTeX editing

#1

Hi all,

I am a longtime Textmate user on the Mac who likes to keep some ties with the Windows world… I have been looking for a decent counterpart to Textmate on Windows, but quite frankly the best there is right now is Emacs, which is, well, Emacs :smile:

I was shocked to find out about Sublime Text, almost by accident (from an off-hand remark in an e-texteditor forum, no less). Anyway, it’s simply BEAUTIFUL: I love the themes, the syntax highlighting, the snippets, AND the Python extendability of course.

BOTTOM LINE: what is the status of LaTeX support? I have tried out the snippets; some are OK, many need fixing (easy: e.g. the “” is missing for some snippets, because it is not escaped correctly in the corresponding xml file).

I think I can start working on a more complete set of plugins/snippets/commands to provide a good LaTeX environment. There are many easy things that can be done—e.g. provide a build command (using texify), a command to launch a previewer (I like SumatraPDF, which gives you inverse and forward search with PDF files), fix the existing snippets and maybe add a few more simple commands. These I could do relatively easily. More long-term stuff (but essential IMHO to provide a competitive alternative to the wonderful Textmate Latex bundle) would include e.g. insertion of citations and references.

I’d like to try to work on some of these things in my spare time. However, if somebody else has already started working on a Latex package, I’d be just as happy to help out.

Thanks,
Marciano

0 Likes

#2

Hi Marciano - welcome to the forums!

As far as I know, no one is working on anything for LaTeX. I use the existing package occasionally, but as you mention, it’s fairly bare bones. Any contributions would be more than welcome.

0 Likes

#3

OK, here are my first steps in the world of Sublime Text plugins :smile:

I am attaching two files. The first contains “sanitized” snippets (I only fixed the “”'s that needed to become “\” in the xml file), as well as two new snippets: Emphasize and Boldface.

The second contains two plugins (WindowCommands to be precise). “texify” invokes MiKTeX’s texify command to compile the TeX file in the current buffer; viewPDF invokes a PDF viewer on the PDF file corresponding to the TeX file in the current buffer. These are very preliminary, there is very little error checking (just the bare minimum), and the style is also probably not very Pythonic…

The “cool” thing is that I am using the SumatraPDF previewer, which supports forward and inverse search (via the SyncTeX protocol) for PDF files. Inverse search means that you double-click somewhere in the PDF file, and the editor jumps to the corresponding point in the TeX source file. Forward search is basically the reverse (I have not implemented it yet because I need to learn how to send DDE commands from Python—I know it’s doable, but I’m tired now!) This is, in my opinion, what makes LaTeXing so cool on the Mac, where TextMate and various previewers have long supported SyncTeX (or its predecessor, pdfsync).

The commands ensure that SumatraPDF is invoked with the correct inverse-search command. And, BTW—thanks for making Sublime Text do the right thing when invoked on an already-open file. And, also, for having a super-sane syntax for jumping to a given line and column in a file.

I’m really impressed with Sublime Text!
LaTeX snippets.zip (7.49 KB)
LaTex compile and view.zip (1.43 KB)

0 Likes

#4

Here is a more complete package. It includes:

  1. cleaned-up snippets

  2. the “emphasize” and “boldface” snippets mentioned in the previous spot

  3. an INITIAL implementation of a feature in TextMate: quick entry of LaTeX macros. E.g. a + ctrl-\ yields \alpha, etc. See the sublime-keymap and texMacro.py files for details and for a complete list of macros currently available.

  4. The “texify” command now lists errors in a quick panel, with TeX’s usual “helpful” messages… The user can click on any line that contains a line number, and the cursor moves to the corresponding point in the file. The “viewPDF” command is as per the previous post. In particular, inverse search works (with SumatraPDF).

  5. the “texRef” and “texCite” commands insert, respectively, a reference (e.g \ref{lem:result}, corresponding to \label{lem:result}) and a citation from a .bib file. For references, I use the completion drop-down menu; for citations, I use a quick-panel that shows the title of the article or book cited. These are definitely rough, but functional.

Overall, things could be greatly improved / cleaned up. However, the basics are in place, and I hope somebody will be willing to help out :smile:
LaTeX.zip (42.7 KB)

0 Likes

#5

Thanks! I have just commited the package, and will henceforth update it there. M

0 Likes

#6

In 20090922, I’ve changed the snippet parser to be more compatible with TextMate - using a backslash where it isn’t required (as was happening in the LaTeX snippets) will now result in the backslash being included verbatim, rather than getting dropped.

This should mean the LaTeX snippets are working a bit better out of the box, but they’ll also continue to work fine when properly escaped.

0 Likes