When Emacs opens a
.tex file, it runs the
tex-mode function, which tries to guess what format the file is for and invokes
If you want to force a specific file to be opened in LaTeX mode, use a file variable. Put this line near the top of your
or these lines near the bottom:
%% Local Variables:
%% mode: latex
This applies to both Emacs's default tex-mode and to AUCTeX. Both use a configuration variable which defaults to LaTeX for an empty file (
tex-default-mode for tex-mode,
TeX-default-mode for AUCTeX). Apart from that, they have similar but not identical heuristics to guess between LaTeX and plain TeX. Both select LaTeX if the first command in the file is an environment or a LaTeX sectioning command. Look at the code of
tex-guess-mode (built-in) or
TeX-tex-mode (AUCTeX) if you want to know the details.
If you want to force all files to use LaTeX mode regardless of content, AUCTeX lets you do that easily with the following line in your init file (you can also use the Customize interface to set this variable):
;; Always use `TeX-default-mode', which defaults to `latex-mode'
(setq TeX-force-default-mode t)
With Emacs's default tex-mode, there's no similar variable. You could instead redefine the
tex-guess-mode function. To systematically force LaTeX mode, you can use
(defalias 'tex-guess-mode 'latex-mode)
Alternatively, for both tex-mode and AUCTeX, you can change the mode associated with
(add-to-list auto-mode-alist '("\\.[tT]e[xX]\\'" . latex-mode))
Auto-complete-latex attaches itself to
LaTeX-mode-hook for AUCTeX, and
yatex-mode-hook for YaTeX), so if your buffer is in LaTeX mode, it should be active.