10

I understand that the tex-mode command of Emacs is supposed to try to identify whether a file is TeX, LaTeX or some other TeX-variant when opening a .tex file, and switch automatically into the appropriate mode. But mine is not doing this despite my verifying that tex-default-mode is set to latex-mode. Regardless of what I have in my document.tex file, Emacs loads tex-mode and the status line says "TeX" instead of "LaTeX". If I run latex-mode, it goes into the right mode.

Is there anything I have to do in my .emacs in order to have this recognize properly?

1

4 Answers 4

7

Another option is to write

% Emacs, this is -*-latex-*-

or similar at the top of your file (all that matters is the -*-latex-*- part), or at the bottom you could put

% Local Variables:
% mode: latex
% End:
3

I had the same problem as this. Turned out that putting the document class right at the top of the file was enough to convince Tex mode that it was a latex file rather than a tex file i.e. my documents now start:

\documentclass[11pt]{article}

rather than starting with the title.

0
2

One good option is to use the auto-mode-alist feature and add the following to your .emacs file:

(setq auto-mode-alist (cons '("\\.latex$" . latex-mode) auto-mode-alist))
1
  • 3
    But most people don't name their LaTeX files to end with .latex (almost everyone uses .tex), so this won't be too helpful. I guess you could change .latex in the answer to .tex, though. Apr 20, 2017 at 2:36
1

If you never use plain-TeX you can add this in your emacs.d:

(add-hook 'plain-TeX-mode-hook 'LaTeX-mode)

Each time the plain-TeX mode is used, it is switched to LaTeX mode.

Be aware that it will be harder to go back to plain-TeX mode and it's an hackish solution.

1
  • I think you're mixing Emacs' built-in tex-mode and AUCTeX: the question is about the former, your answer is about the latter.
    – giordano
    Nov 2, 2015 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .