[Tex/LaTex] AucTeX Emacs Compilation Problems

auctexemacs

I installed emacs23 on my Ubuntu 13.10 64-bit system. I also downloaded the AucTeX tarball and installed it (./configure then make and finally make install). Now I get the LaTeX commands in the menu of emacs and the key-bindings also work well. But I am able to compile only in LaTeX mode. That is, to generate the pdf I have to go the directory and give pdflatex command in the terminal. Secondly, I tried the Other option in the compilation in emacs but pdflatex is not present as a command there. I would like to run pdflatex directly instead of LaTeX compilation so that it modifies my pdf. Secondly, I am not able to run XeLaTeX or LuaTeX in emacs as well. These are the compilation options available for me:

enter image description here
Also, I tried a sample code, I am able to compile and get the pdf in the terminal using latex and pdflatex commands but emacs shows me some error.

enter image description here

Here is the code which I ran:

\documentclass[12pt]{article}
\author{Subham Soni S.}
\date{\today}
\title{Installing a new Kernel(ver. 3.13.3) to the Existing Ubuntu Operating System}
\begin{document}
\maketitle
To replace the existing \textsl{kernel} with a new one, do the following:
\begin{enumerate}
\item Download the latest kernel from  \texttt{www.kernel.org}, the files will be compressed in tarball.
\end{enumerate}
\end{document}

The contents of my .emacs file are as follows:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

I would like to make emacs a complete IDE for LaTeX. What do I need to do?

Best Answer

If you want to get PDF output by default using Emacs, you can add this to your .emacs:

(setq-default TeX-PDF-mode t)

Alternatively, you can declare 'local' variables that are applied per-file. This is done at the end of the file, using a 'Local Variables' block. For example ---

\documentclass{article}
\begin{document}
text
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-mode: t
%%% End:

--- tells Emacs that the major mode is LaTeX-mode and that you want to get PDF output rather than DVI output. (You could also add \pdfoutput=1 in your preamble; but this has nothing to do with Emacs.) This block, by contrast ---

\documentclass{article}
\begin{document}
text
\end{document}

%%% Local Variables:
%%% mode: latex
%%% mode: flyspell
%%% TeX-engine: luatex
%%% End:

--- tells Emacs you want to use LaTeX-mode, the flyspell minor mode, and use LuaTeX as the backend/engine (LuaTeX produces PDF by default). Regarding the engine, you can switch, say, to LuaTeX even after the local variables have been set by using.

M-x TeX-engine-set <RET> luatex <RET>

Or, if you want to switch to XeTeX, then replace luatex with xetex. Note, finally, that we are talking about the engine, so do not use lualatex or xelatex in the above settings. AUCTEX is usually clever enough to figure out which format (TeX, LaTeX, ConTeXt) to use by parsing the file.