1

This may seem like an odd question but I believe there absolutely should be a standard or most common way to use LaTeX on emacs, and that this community would benefit from owning a complete answer to this question, so here goes.

This is my first Google hit for "emacs latex mac", which seems to imply AucTeX is the way to go.

AucTex lives here and it is covered in the GNU wiki here.

I'm trying installing it now but I'm not sure how out-of-the-box it is. The wiki says:

C-c C-c to run LaTeX over your document, then, once it has compiled correctly, C-c C-c again to view it, or if it failed to compile correctly, C-c ` to see the errors.

But C-c C-c doesn't do this (it brings up a prompt).

  • 2
    C-c C-c would bring up a prompt with different LaTeX programs you could select for the document life-cycle (type TAB or ? when you get the prompt to see the options, which is a generally useful technique for Emacs commands). You can also do C-h k and then answer the prompt with the key combination, eg. C-c C-c to see what command it is bound to and to read the description of that command. – wvxvw May 17 '15 at 22:09
  • 1
    There are two (2) common approaches -- there is the built-in solution using tex-mode.el; and, there is the non-built-in solution using AUCTeX. There is a complete 118-page manual written about AUCTeX -- gnu.org/software/auctex/manual/auctex.index.html And, of course, there are different options for installing the tex sources -- e.g., MacTeX -- tug.org/mactex There are issues with the $PATH that many users need to adjust; e.g., (setenv "PATH" (concat (getenv "PATH") ":/usr/texbin")). A good answer would be the equivalent of a small book. :) – lawlist May 17 '15 at 22:42
  • 1
    Can you successfully compile a LaTeX document in Terminal.app without using Emacs? If the answer to that question is "no", then figure out how to do that correctly first. If the answer to that question is "yes", then did you install AUCTeX using M-x list-packages and did it install correctly? If AUCTeX installed correctly, did you try restarting Emacs? Do you have your (package-initialize) statement in your .emacs file. The $PATH in Emacs is different than in the terminal, so did you check that to see if :/usr/texbin is set correctly? Are there any error *Messages*? – lawlist May 17 '15 at 22:57
  • 3
    The problem with addressing this question is that readers do not know whether the original poster has the necessary ingredients to create a LaTeX document without using Emacs. Those raw ingredients are generally beyond the scope of using Emacs, and the original poster will never get it to work correctly in Emacs without it. Forum participators will spin their wheels trying to find out what's wrong with the Emacs aspect, because they will assume the original poster has already set up the base tex installation correctly. There are a few threads where upgrades to OSX break symlinks and so on. – lawlist May 18 '15 at 4:16
  • 1
    For obtaining latex/tex have a look at tex.ac.uk/cgi-bin/texfaq2html?introduction=yes first. There is also useful information on tex.stackexchange.com . AUCTeX needs a tex distribution to be present on the system in order to compile the files. – Andrew Swann May 18 '15 at 10:44
4

Emacs comes with a built-in mode to edit (La)TeX documents. You can install AUCTeX as an additional package, either via your operating system's package manager if it's available there, or via Emacs's own package manager ELPA.

You can tell whether you're using AUCTeX by bringing up the major mode documentation with C-h m (describe-mode). If the first paragraph of the description mentions AUCTeX, you're using AUCTeX, otherwise you're using the built-in support. If you have AUCTeX installed, .tex and other TeX documents will open in AUCTeX.

In both the built-in mode and AUCTeX, the key binding C-c C-c invokes an Emacs command which prompts you to ask what TeX-related command you want to run. The sentence you quote from the wiki is misleading: you need to press C-c C-c RET to invoke the default TeX-related command. With the built-in mode, this runs (PDF)(La)TeX. With AUCTeX, this command is more intelligent and defaults to (PDF)(La)TeX if it looks like your document needs recompiling, or to launching a DVI/PDF viewer if your document looks up to date, or to launching one of a few other commands such as BibTeX if it looks like this is needed. As everywhere in Emacs, press Tab to invoke completion, which will show the possible/predefined commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.