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.