TeX and GNU Emacs: A simpleton’s journey

About four months ago, I asked this question on TeX-sx. Over the previous ten years, I had looked at GNU Emacs, as a programming editor, three or four times, and, each time, given up because I thought the learning and implementation curves too challenging.

But this time, encouraged by the helpful answers to my question, I decided to invest some time in learning Emacs and tweaking it to do what I wanted. And now, four months later, I’m really pleased with the journey so far.

Background

I’m a Windows 7 user, using TeX Live and Emacs 23.3 for Windows. As a specialised software developer, my main TeX products are proposals and design documentation (though I also use it for all my ‘domestic text processing’ tasks). I generally manage documentation source, and everything else in a project, with Git.

Editing documents with Emacs

Plain Emacs out-of-the-box does a wonderful job, but for TeX editing you need a bit more: AucTeX, which provides many useful tools for TeX editing, including a component, RefTeX, which presents you with an intelligent TOC right there in your editor, allowing you to navigate (across multiple input files, of course), and to create index entries, labels, and cross-references very easily. AucTeX also has an outlining component which allows you to fold up your section hierarchy.

Just to whet the appetite, here’s a screen shot of a (fully unfolded) piece of a RefTeX *toc*:

As well as using Emacs for TeX editing, for notes and brainstorms I can heartily recommend org-mode, which is (much more than) an outliner, with facilities for To-Do items and table manipulation, as well as the usual structural organising.

It took some time to get Emacs tailored exactly to my liking. It’s a bit like typography in that respect; there are always opportunities for ‘just one more tweak’, and a lot of self-control is needed. But you should expect to do some customization, perhaps with help from SO or TeX.se.

Things I have not been able to do

The main reason for these, I think, is that my perception of the effort and irritation needed to get `x` working exceeds the effort and irritation of ignoring it or inventing a work-around. Here are the principal ones:

  • Unicode support from the keyboard: I occasionally work in multiple languages, including Welsh and Turkish, which are not catered for by ISO-8859-1. I have a customised Windows keyboard layout which generates the right Unicode characters, but Emacs, despite hours of cutting and pasting tentative solutions from the Internet, still insists on shoehorning them into ISO-8859-1: ŵ becomes w, ğ becomes g, and so on. I’ll live with it.
  • I haven’t tried to get Emacs to run LaTeX and produce a preview for me — I use Texworks for that, editing a dummy file which simply points to my master document file. One day…
  • I can’t seem to get references to labels in other files of the same book to work. One day…
  • Doing anything to the *toc* (refreshing, for example) always seems to split the screen. Just grin and bear it.

Summing up

Emacs is a fantastic editing system, and I’m gradually moving all my editing over to it from Notepad++ (something I never imagined doing). I confess to feeling a bit dizzy with all the new key combinations (I sometimes try to close other things with Ctrl-X Ctrl-C), but I’m really overjoyed at having made the move. I know Emacs isn’t for everyone, but if you’re not completely satisfied with your current editor, you really should consider it.

3 thoughts

  1. With AUCTeX Ctrl-C Ctrl-C compiles the main document. If you have a master document you can declare in what you call dummy files using something like

    % Local Variables:
    % TeX-master: “master.tex”
    % End:

    You can instruct REFTeX to parse the whole document Ctrl-X reftex-parse-all (or from the menu) and then, if you have set the master file, Ctrl-C ) should give the references in any file related to the document.

  2. You should be able to set utf8 input from the menu

    Options/Mule/Set coding system/ for saving this buffer

    and/or

    Options/Mule/set input method

    I usually set the first to utf-8 so the file is in utf8 but set the input method to one of the ascii input ones eg selecting TeX means that \alpha inserts α (I find that confusing:-) but selecting Welsh turns on a input method such that w/ enters ẁ Of course if you are happy to type unicode characters from the keyboard you want to toggle the input method to off so that your characters are entered directly.

  3. I can’t seem to get references to labels in other files of the same book to work. One day…

    I think that you either need to use

    xr

    package (to cross-reference other unrelated files), or set up master file in Emacs / AUCTeX like in Guido answer.

Leave a Reply

Your email address will not be published. Required fields are marked *