Thursday, June 28, 2007

Mac OS X editors for writing LaTeX

Well, it's taken a bit longer for me to get back to writing than I'd expected. I do intend to follow up on the one million answers post, but for now I'll take a look at something else.

In short, I am fed up with the LaTeX mode for TextMate, and maybe TextMate in general. Writing text, instead of programming, really seems to highlight the worst aspects of TextMate. Besides the well known failings of its undo, TextMate has two other serious annoyances that are relevant here.

First, you can only use monospace fonts. I accept it as the reality for a lot of programming, even if I don't like it. For writing LaTeX, it's terrible. Literally headache inducing.

The second flaw is how words are selected using the mouse. Standard behavior for Mac OS X is that when you double-click on a word, it is selected. Extending this, if you "click and a half," (double click, but keep the mouse button held down on the second click) you can then drag and select text by words instead of characters. In most applications, this works very well, and is often simpler than character-based selection. However, in TextMate, this works poorly, because you can't select a sentence including the period at the end. You can get to the last word, and then the selection jumps to include the first word of the next sentence.

All three of these problems make writing text a little bit harder, but aren't that big of a deal for programming. Taken all together, they make writing LaTeX into a stressful experience, and formal writing is hard enough. These troubles all come from the use of a custom text view instead of the standard Cocoa NSTextView. The author of TextMate, Allan Odgaard, has written that it would be easier to write a replacement for NSTextView than to get NSTextView to do what he wanted. I'm not sure I believe him; for me, at least, behaving like the rest of the Mac OS X text system is pretty important. In this sense, he hasn't written a replacement for NSTextView.

TextMate does have a LaTeX mode, though. It has a lot of nice features, like integrating with PDF viewers through pdfsync, text completion for citations and cross references, assorted functions for project management, and various snippets for simplifying typing. Unfortunately, not all of that works very well -- I've never got citation completion to work reliably, and not for lack of trying. Text completions have some funny behavior. Showing an outline of the document fails if it includes a file that started with the letter 'x' (no, I'm not kidding).

Because of all this, I've downloaded the current version of SubEthaEdit and will give that a try for the next month. So far, I'm finding the basic editing to be much more pleasant. I'm using a proportional font, undos work sanely, and I can select by words using the mouse. The basic task of writing seems a lot more pleasant. I haven't used SubEthaEdit much since getting TextMate, and the last version I'd used was version 2.2. It's still the same elegant, minimalist editor, but things have changed a bit. There are now language modes with mode-dependent scripting, not just syntax highlighting. There are now tabs, and a quite elegant implementation at that (no projects, yet, though).

That said, the LaTeX mode just has syntax highlighting. No pdfsync support. No keystroke to compile the file into a PDF and send it to a viewer. No completion of citations. However, SubEthaEdit is extendable by scripting and, thanks to its reliance on Mac OS X standards, the editing features can be extended by input managers. Over the thirty-day trial period, I'll see what I can do to extend SubEthaEdit's LaTeX mode into something a little more capable.

No comments: