# Using AUCTeX

Before I started using Org-mode for most of my writing, I typeset everything using groff. I occasionally used TeX but very little LaTeX. One of my New Year Resolutions is to learn more LaTeX.

My recent post on Piotr Kaźmierczak's use of AUCTeX had me itching to try out AUCTeX. So I loaded AUCTeX from ELPA and started working through this 3 hour introduction to LaTeX. I also had the Not So Short Introduction to LaTeX and the AMS LaTeX Reference Card at hand.

My first pleasant surprise was how easy the installation and use of AUCTeX was. I simply loaded it with ELPA, opened a new .tex file, and started using it. There was no configuration needed. I haven't bothered reading the manual yet. The menus show the necessary key shortcuts so I learned and was using the shortcuts in no time at all.

Opening a file with the .tex extension automatically invokes AUCTeX. The two most useful things to know are that 【Ctrl+c Ctrl+c】 will compile the document. If there are any errors, AUCTeX will instruct you to type 【Ctrl+c 】 to pop up a buffer with the errors.

If the compilation was successful, you can type 【Ctrl+c Ctrl+v】 to see the paper. On OS X this invokes Preview. Other systems presumably do something similar.

If you're familiar at all with LaTeX, you know that almost all special formatting is done in an “environment.” For example, to typeset a bullet list, you would use the itemize environment:

\begin{itemize}  % ⟵ the itemize environment
\item first bullet
\item second bullet
\item and so forth
\end{itemize}


AUCTeX makes it easy to enter environments by typing 【Ctrl+c Ctrl+e】 and then the name of the environment you want. AUCTeX will insert the \begin{...} and \end{...} commands and put the point between them. There are other labor saving features that I haven't used yet but perhaps I'll write about them later if I find them useful.

Two other useful commands are the ones that Kaźmierczak wrote about. You can format your input by section, region, environment, or paragraph. You do that by typing 【Ctrl+c Ctrl+q Ctrl+X】 where X is s, r, e, or p depending on what you want to format.

If you have a long paper, you may not want to typeset the whole paper every time you want to check some formatting. Instead, you can preview the code at point, environment, section, region, buffer, or document. You do that by typing 【Ctrl+c Ctrl+p Ctrl+X】 where X is p, e, s, r, b, d.

The great thing about AUCTeX is how easy it is to learn and use. Often complicated environments like AUCTeX are difficult to learn and may or may not be easy to use when you do learn them. AUCTeX is easy right out of the box. Use the menus the first few times you invoke a command and after a very short time you will have learned the key shortcuts. I love this package.

Meanwhile, abo-abo over at (or emacs has a post on an enhancement that he calls latex-wrap-region. The idea is that you have some highlighted text that you want to wrap in an environment. You simply call latex-wrap-region` and select the environment you want. See abo-abo's post for the details.

This entry was posted in General and tagged , . Bookmark the permalink.
• AucTex was the reason I got into emacs. It is, without a doubt, the best latex editor ever conceived by mankind (and I've tried a lot of them).

You should check out latex-extra. It implements a few org-like navigation commands such as C-c C-n and section folding with TAB.

• > It is, without a doubt, the best latex editor ever conceived by mankind
No argument here. The more I use it, the more I like it.

>You should check out latex-extra...
I will definitely check it out. Thanks for the pointer.

• Loaded latex-extra and played around a bit. Very nice.

• Jorge Alfaro-Murillo

AUCTeX already has the wrapping behavior by default. Just select the region and do C-c C-e. Moreover in any environment you can do C-u C-c C-e to change the environment.

• Hmmm. I didn't know that. Thanks for the info.

• Jarvis Schultz

Using reftex with AUCTeX is one my favorite parts. I love being able to jump to crossrefs "C-c &", viewing a browsable TOC "C-c =", inserting references "C-c )", and inserting citations "C-c [".

• More good tips. I may have to break down and actually read the documentation.

• Phil

I've never used TeX and family directly for anything, but this inspired me to install the auctex package and try your example. I created an itemize environment (and found that M-RET populates the next item for me), compiled the file, was told that I needed a document environment, added that in the same way (with auctex giving me several completion-enabled options along the way), recompiled without errors and viewed the result. As a total newbie I can only concur -- that was pretty darned easy to do! Very good to know :) Thanks!