Open a .tex file in a stock GNU Emacs and you are already in a LaTeX mode, with no package installed at all — it ships in the box as lisp/textmodes/tex-mode.el. AUCTeX is what you install to replace that mode, and the two have been entangled from the start, because AUCTeX grew out of that very file. In 1986, at Aalborg University in Denmark, someone began adding functions to Emacs’s tex-mode.el for inserting font macros and Danish characters; the AUC in the name is Aalborg Universitetscenter, the university’s Danish name at the time. This page covers what AUCTeX adds to the built-in mode, why C-c C-c asks a different question every time you press it, RefTeX (which is not part of AUCTeX at all), preview-latex and the preview.sty you may already be using without knowing it, and YaTeX, the Japanese-community alternative.
The built-in LaTeX mode and AUCTeX: same keys, different commands
Even in a stock Emacs, opening a .tex file puts you in latex-mode, where C-c C-b typesets, C-c C-o inserts a \begin…\end pair, C-c C-e closes the innermost unclosed block, and C-c C-v opens the viewer. Which mode you land in is decided by reading the file: tex-mode looks for the first backslash that is not inside a comment and checks whether it is followed by one of documentclass, documentstyle, begin, section, chapter, newcommand, RequirePackage and a few others. If so, latex-mode; if not, plain-tex-mode. When nothing at all is found it falls back to the value of tex-default-mode, which defaults to latex-mode.
Install AUCTeX and the same keyboard is wired to a different instrument. The keys are largely the same and the commands behind them are not — which is exactly why people find the behaviour has changed under their fingers. In the built-in mode C-c C-f is tex-file, which typesets the whole file; in AUCTeX C-c C-f is TeX-font, which inserts a font-changing macro. The built-in C-c C-e is latex-close-block, which closes an open environment; AUCTeX’s C-c C-e is LaTeX-environment, which asks which environment to insert. Set those two side by side and the difference states itself: the built-in mode is an editing mode that can run TeX, while AUCTeX is an environment that knows the structure of the document.
How the two coexist was actually tidied up in 2024. AUCTeX 14.0.1 renamed its modes to the capitalised LaTeX-mode, plain-TeX-mode and docTeX-mode, precisely to stop colliding with the built-in names. Since then, which mode a .tex file lands in is decided, on Emacs 29 and later, by redirection through major-mode-remap-alist and major-mode-remap-defaults. AUCTeX’s own front door for this is the user option TeX-modes, which lets you hand, say, plain TeX back to the built-in mode while keeping LaTeX on AUCTeX. The manual advises customizing TeX-modes rather than touching major-mode-remap-* by hand. One trap: on Emacs 29 and later, typing M-x latex-mode directly gets you the built-in mode, not AUCTeX. Configuration code that calls the old lowercase names walks straight into this.
auctex install, and the manual that runs two years behind
AUCTeX is not bundled with GNU Emacs. It is a GNU project distributed as a package on GNU ELPA, under GPL v3. GNU ELPA has been enabled out of the box since Emacs 24.1, so installing it is M-x list-packages, mark auctex with i, press x — or the equivalent M-x package-install RET auctex RET. Two prerequisites. The first is that latexmk --version runs in a terminal, that is, that the TeX commands are on your PATH: the typesetting is done by the TeX Live, MacTeX or MiKTeX you installed, and Emacs merely spawns it as a child process. The second is the version of Emacs itself — current AUCTeX requires Emacs 28.1 or newer.
There is one discrepancy here that will eat your afternoon if you do not know about it. The AUCTeX that GNU ELPA distributes and the manual published at gnu.org are not the same version. Checked in August 2026, GNU ELPA’s newest was 14.1.2, dated 14 January 2026, while the online manual at gnu.org still opened by saying it documented version 13.3, from 14 January 2024. Two years apart. The website has no release-news page either. So when you want to know how a setting or a key actually behaves, read the Info manual of the version you installed, with C-h i. The page a search engine hands you is not necessarily describing your machine.
The first things to put in init.el (usually ~/.emacs.d/init.el) are TeX-PDF-mode to default to PDF output, TeX-parse-self and TeX-auto-save to make completion aware of your document, and TeX-source-correlate-mode to switch on the SyncTeX correspondence. TeX-parse-self and TeX-auto-save tell AUCTeX to read the document — pulling in the macros from the packages you \usepackage — and to cache the result in an auto/ directory. How SyncTeX itself works belongs to its own page; what follows is only the configuration.
;; package.el reads GNU ELPA, enabled by default since Emacs 24.1.
(require 'package)
(package-initialize)
(use-package tex
:ensure auctex
:hook ((LaTeX-mode . TeX-source-correlate-mode) ; SyncTeX
(LaTeX-mode . reftex-mode) ; cross-references
(LaTeX-mode . LaTeX-math-mode)) ; backquote math shortcuts
:config
(setq TeX-auto-save t ; cache parse data in the auto/ directory
TeX-parse-self t ; scan the file for \usepackage and friends
TeX-PDF-mode t) ; produce PDF, not DVI
;; Tie source lines to PDF positions and run a server for inverse search.
(setq TeX-source-correlate-method 'synctex
TeX-source-correlate-start-server t))C-c C-c asks a different question every time you press it
C-c C-c (TeX-command-master) is not an order to run something; it is a question about what to run next. The minibuffer asks, proposing a default based on the state of the document: LaTeX if you have not typeset yet, LaTeX again if the .aux file shows unresolved references, BibTeX if there is a bibliography, and View once everything has settled. Accepting with Enter and repeating is the basic loop, and it captures AUCTeX’s design well: you are not expected to remember the sequence; the state of the document decides the next step. When you would rather not watch the steps, C-c C-a (TeX-command-run-all) chains them automatically until an error or completion, and on success opens the viewer for you.
| Key | Command | What it does |
|---|---|---|
C-c C-c | TeX-command-master | Ask what to run next, proposing a default from the document’s state |
C-c C-a | TeX-command-run-all | Run the whole chain until it finishes or errors, then view |
C-c C-r | TeX-command-region | Typeset only the selected region — handy for trying one passage |
C-c C-z | LaTeX-command-section | Typeset just the current section |
C-c ` | TeX-next-error | Go to the next error (C-c followed by a backquote) |
M-g p | TeX-previous-error | Go back to the previous error; needs the whole log parsed (TeX-parse-all-errors) |
C-c C-l | TeX-recenter-output-buffer | Scroll the output buffer so its last line is visible |
C-c C-k | TeX-kill-job | Kill the running external process, be it TeX or the viewer |
C-c C-e | LaTeX-environment | Prompt for an environment and insert \begin…\end |
C-c C-s | LaTeX-section | Insert a sectioning command; with RefTeX it labels it at the same time |
C-c C-f | TeX-font | Insert a font macro; C-c C-f C-d deletes the innermost one |
C-c C-m | TeX-insert-macro | Complete a macro name and prompt for each argument (C-c RET too) |
C-c ~ | LaTeX-math-mode | Turn the backquote into a prefix for entering math symbols |
C-c C-o C-f | TeX-fold-mode | Toggle folding; C-c C-o C-b folds the whole buffer |
Two notes beyond the table. M-g n is not an AUCTeX binding but Emacs’s own next-error, which AUCTeX does not override. Going backwards with M-g p (TeX-previous-error) assumes the whole log has been parsed, and TeX-parse-all-errors is on by default. Second, if you want typing $ to insert a matched pair, set TeX-electric-math. The default is nil — a $ is just a $ — while ("$" . "$") gives the TeX-style inline formula and ("\\(" . "\\)") the LaTeX-style one.
latexmk needs no plugin any more: LaTeXMk is built into AUCTeX
LaTeXMk is already among the choices C-c C-c offers you. It was added to TeX-command-list in AUCTeX 14.0.5, released on 19 May 2024, and later releases tightened up its handling of the output directory and its XeTeX options. The external package that used to be the standard answer, auctex-latexmk, is no longer needed — and is better left alone. Its last upstream commit is from 2017, which stops its clock well before the mode renaming of AUCTeX 14. Before you copy (auctex-latexmk-setup) out of an old configuration you found, press C-c C-c and look at the list.
To make latexmk the default action, set TeX-command-default to "LaTeXMk" — mind the spelling, with a capital M and K. Because latexmk inspects dependencies and re-runs exactly as many times as needed, you never count passes for cross-references or the table of contents. Engine selection stays on the AUCTeX side, in TeX-engine, whose four built-in values are default, xetex, luatex and omega; the LaTeXMk entry reads that value and assembles the flags it hands to latexmk. Bibliography details and finer engine tuning are cleanest in a .latexmkrc at the project root, which also means the same PDF can be reproduced outside Emacs or in CI. latexmk configuration itself belongs to the automated-builds page.
;; AUCTeX 14.0.5 and later ship a LaTeXMk entry in TeX-command-list.
;; Note the spelling: capital M, capital K.
(setq-default TeX-command-default "LaTeXMk")
;; Engine selection stays on the AUCTeX side and is buffer-local.
;; M-x TeX-engine-set, or in a file-local variables block:
;; %%% TeX-engine: luatexRefTeX ships with Emacs, not with AUCTeX
The package that looks after \label, \ref and \cite is RefTeX, and it is not part of AUCTeX. It lives in the Emacs source tree, as reftex.el and a dozen companions under lisp/textmodes/, so there is nothing to install. It first appeared in Emacs 20.1 in 1997, and etc/NEWS.20, under “Changes in Emacs 20.1”, prints the key table of the day: C-c (, C-c ), C-c [, C-c &, C-c =. A quarter of a century later they are still the same keys. The author is Carsten Dominik — the email address in the header of reftex.el is the same one in the author line of org.el, which is to say the person who wrote Org mode. It is maintained today by the AUCTeX project.
What it actually buys you is that you never have to invent a label by hand. C-c ( (reftex-label) looks at whether you are in a figure, a table, an equation or a section and proposes a sensibly prefixed label — fig:, tab:, eq: — to insert. To refer back, C-c ) (reftex-reference) just lets you pick from the existing labels. For citations, C-c [ (reftex-citation) searches your .bib by regular expression and inserts \cite{...}. C-c = (reftex-toc) opens a table-of-contents buffer for the whole document in another window, and C-c & (reftex-view-crossref) shows you, in place, what the reference under the cursor points at. If your document has an index, C-c / turns the selected word into an index entry. Even across several files, RefTeX follows the master file to gather every label and every citation.
To mesh it tightly with AUCTeX, set reftex-plug-into-AUCTeX. It is a list of five booleans, switching independently whether RefTeX supplies labels for newly created sections and environments, and whether it supplies the argument for \label, for \ref, for \cite and for \index. Assigning t turns them all on and nil turns them all off. With it on, creating a section with C-c C-s prompts for its label at once, and inserting \ref with C-c C-m opens RefTeX’s selection buffer — this setting is why the two packages feel like one.
(use-package reftex
:ensure nil ; part of Emacs itself, nothing to fetch
:hook (LaTeX-mode . turn-on-reftex)
:config
(setq reftex-plug-into-AUCTeX t ; t turns all five flags on
reftex-cite-format 'natbib)) ; or 'biblatex, 'default, ...preview-latex, and the preview.sty you are probably already using
preview-latex actually typesets your formulas, figures and tikzpictures with LaTeX and then lays the result over the source buffer as an image, in place. It stopped being a separate download and became part of AUCTeX in version 11.81, so there is nothing extra to install. The source of a $…$, \[…\] or equation environment stays editable, yet appears as set mathematics whenever you want to check it — a WYSIWYG-like feel while the file remains plain text. The commands start with C-c C-p: C-c C-p C-p for the object at point, C-c C-p C-e for the environment, C-c C-p C-s for the section, C-c C-p C-r for the region, C-c C-p C-b for the buffer, C-c C-p C-d for the whole document. To clear them, insert C-c C-c in the middle — C-c C-p C-c C-p removes the preview at point. Clicking an image with mouse-2 toggles it as well.
;; The preview commands, by their Lisp names.
;; C-c C-p C-p preview-at-point C-c C-p C-c C-p preview-clearout-at-point
;; C-c C-p C-e preview-environment C-c C-p C-c C-s preview-clearout-section
;; C-c C-p C-s preview-section C-c C-p C-c C-b preview-clearout-buffer
;; C-c C-p C-r preview-region C-c C-p C-c C-d preview-clearout-document
;; C-c C-p C-b preview-buffer C-c C-p C-f preview-cache-preamble
;; C-c C-p C-d preview-document C-c C-p C-i preview-goto-info-pageHere is a fact that tends to surprise people. The preview.sty that preview-latex uses under the hood is the same file the standalone class loads to crop a picture. The preview.sty in this machine’s TeX Live 2024 is version 13.3, dated 17 January 2024; its header says it was developed as part of AUCTeX, and the identification string in its \ProvidesPackage line is literally (AUCTeX/preview-latex). Line 571 of standalone.cls is \RequirePackage{preview}, and since the preview option is true by default, writing \documentclass{standalone} runs it. If you have ever cropped a TikZ picture into its own file, you have used part of an Emacs package — even if you have never opened Emacs. LyX’s previews and pst-pdf stand on the same stone.
Two practical prerequisites. preview-latex needs Ghostscript (7.07 or newer) to make the images, in both the DVI and the PDF route. On the DVI route it additionally needs either Dvips or dvipng — dvipng is not an extra requirement but an alternative to Dvips, and the manual notes it is much faster than the Dvips-plus-Ghostscript combination. The other prerequisite is that your Emacs was built with image support. Where it pays off is a manuscript thick with long equations or commutative diagrams: being able to check the set result at a glance removes the whole round trip of compiling and going to look at the PDF.
AUCTeX already speaks Japanese: japanese-LaTeX-mode and the pTeX engines
Before you go looking for a different mode for Japanese, one thing is worth knowing. AUCTeX ships tex-jp.el in the box, providing japanese-LaTeX-mode and japanese-plain-TeX-mode. That file adds ptex, jtex and uptex to the list of engines, and japanese-TeX-engine-default — whose default is ptex — decides which one is used. More than that: with TeX-parse-self enabled, it picks the right engine automatically from the class name, looking at jbook, jsarticle or tjreport and deciding whether to call platex or uplatex. That is precisely why the manual recommends TeX-parse-self to Japanese LaTeX users. The default class comes from japanese-LaTeX-default-style, initially "jarticle".
The automatic choice can miss. The example the manual itself gives is j-article: AUCTeX picks NTT jLaTeX for it, while the writer meant ASCII pLaTeX. When that happens, override it explicitly in a local-variables block at the end of the file. If you want Japanese documents to be the default, set TeX-default-mode to japanese-LaTeX-mode. It is worth adding that the AUCTeX manual states plainly that none of its primary maintainers read Japanese — which is exactly why this corner of the package has been kept alive by reports from Japanese speakers.
%%% Local Variables:
%%% mode: japanese-LaTeX
%%% TeX-engine: uptex
%%% End:YaTeX (野鳥), and a whole flock of modes named after birds
YaTeX is a LaTeX major mode for Emacs by HIROSE Yuuji, its copyright line running from 1991 to the present. Its Japanese name, 野鳥, reads yachou and the manual translates it as Wild Bird, explaining that it is a pun in Japanese. And this is where it gets interesting, because the pun founded a family: LaiTeX (Thunder Bird) for the Vz editor, HackTeX (Swan) for Wz, HiTeX (Flying Bird) for xyzzy, and KaTeX, whose author called his the fj Wild Bird Society. In the Japanese TeX world of the 1990s, naming your editor support after a bird was practically a convention. The licence is the 2-clause BSD (since version 1.80, on 9 September 2017), and the latest release is 1.84.1 from August 2026, still updated by the author himself.
Its philosophy differs somewhat from AUCTeX, leaning on “type the first few letters, then complete” to insert macros and environments fast. The prefix is C-c by default. C-c b is begin-type completion (environments, \begin{...}...\end{...}), C-c s is section-type (\section and friends), C-c l is large-type (sizes and faces like \large), and C-c m is maketitle-type (argument-less macros such as \maketitle and \item). On top of that, C-c SPC is arbitrary completion: type \ and the start of any command name, press it, and YaTeX completes on the spot. Typesetting starts with C-c t — C-c t j typesets, C-c t p previews, C-c t b runs BibTeX, C-c t i makeindex, C-c t d the whole latex-to-dvipdfmx chain, C-c t r typesets a region only, and C-c t k interrupts. For navigation there is C-c g, which jumps to the corresponding object — \begin to \end, \label to \ref, \include to the file it names — and for rewriting, C-c c (change) and C-c k (kill).
One caution here. The t in C-c t j is a bare t, with no modifier. In Emacs the C-c letter space is reserved for the user, so some people dislike YaTeX taking it. Setting YaTeX-inhibit-prefix-letter to t moves every default C-c letter binding to C-c C-letter, giving the more Emacs-like C-c C-t j for typesetting. The region-based completions on capital letters survive; to drop those too, use 1 instead of t. The default is nil, so out of the box it really is C-c t j. When you find a configuration snippet online, this variable tells you which dialect it was written in.
A few variables anchor the Japanese side. YaTeX-kanji-code is the kanji encoding used on save: nil means “convert nothing, keep the file’s own coding system”, 0 is no-conversion, 1 is Shift JIS, 2 is JIS, 3 is EUC and 4 is UTF-8. nil and 0 are not the same thing — and the current source defaults to nil, which suits today’s habit of not wanting files silently re-encoded. tex-command is the typesetting command actually invoked, such as "latexmk", "uplatex" or "lualatex -synctex=1". Setting bibtex-command and makeindex-command to upbibtex and upmendex makes Japanese bibliographies and indexes work. YaTeX also ships a sister mode for HTML, yahtml, in the same distribution, and the yatex package on MELPA is built directly from the author’s own Mercurial repository.
(use-package yatex
:ensure t ; from MELPA, built from the author's repo
:mode ("\\.tex\\'" . yatex-mode)
:config
(setq YaTeX-kanji-code nil ; keep the file's own coding system
tex-command "latexmk" ; or "uplatex", "lualatex -synctex=1"
bibtex-command "upbibtex"
makeindex-command "upmendex"
;; t moves C-c <letter> bindings to C-c C-<letter>.
YaTeX-inhibit-prefix-letter t))Which to choose? AUCTeX and YaTeX are best committed to one or the other rather than mixed. Take AUCTeX if you want the whole suite, preview-latex and RefTeX included. Take YaTeX if you want to write Japanese documents fast with a small, quick set of completion keystrokes. Japanese support itself is in AUCTeX too, as the previous section showed, so the honest way to decide today is not “Japanese, therefore YaTeX” but “this way of typing fits my hands, therefore YaTeX”.
What to settle in the first half hour
- Decide who owns the build first. Either step through with
C-c C-c, or setTeX-command-defaultto"LaTeXMk"and hand the whole chain to latexmk. This comes before themes and colours. - Run the loop once on a small
main.tex. Push it through withC-c C-a; when the PDF opens, label an equation or a figure withC-c (, insert the reference from the prose withC-c ), and jump to the next error withTeX-next-errorwhen one appears. - When it will not work, diagnose from outside. Build the same project once in a terminal. If
latexmkfails there, no amount of editinginit.elwill save it; if it succeeds there, the suspect is the PATH that Emacs inherited. - Read the manual you actually have. To look up what a setting means, open the Info manual of your installed version with
C-h i. The manual on the web can be several versions behind. - Pin the build to the project. Once chapters live in separate files, put a
.latexmkrcat the project root, so that Emacs, another editor and CI all produce the same PDF.