AucTeX Emacs Compilation Problems

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:

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.

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)
(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?

-
This sentence, "But I am able to compile only in LaTeX mode." suggests that you are able to compile, while everything else suggests you can't. The screenshot does not show you trying to do C-c C-c <RET>, which is what normally runs (some form of) LaTeX, BibTeX, Biber, or View. Also, the clause, "emacs shows me some error", is unclear. What error? –  jon Feb 21 at 5:12
The preview stuff is a secondary concern to my mind. Close Emacs; comment out the line (load "preview-latex.el" nil t t) in your .emacs, re-open the test file and try to run latex (use C-c C-c and follow the prompt). If there is an error, C-l will split the buffer and you can browse the details in the newly opened buffer. –  jon Feb 21 at 5:22
You can add the following to your .emacs: (setq-default TeX-PDF-mode t). This will globally use PDF-mode. Alternatively, you can use the 'Local Variables' setting at the end of each file: %%% Local Variables \n %%% mode: latex \n %%% TeX-PDF-mode: t \n %%% End: (where \n = newline; it should not be written explicitly). Similarly, a %%% TeX-engine: luatex among the Local Variables will set, for that file, LuaTeX as the engine. I think something like (setq TeX-engine 'luatex) in your .emacs would set LuaTeX as the default engine for all files, but I'd have to double-check. –  jon Feb 21 at 5:43
@jon is right; use PDF-mode. It's in DVI mode by default; that's why (setq-default TeX-PDF-mode t) is the right line to put into your dotfile. If you want to try out the setting in the current buffer: C-c C-t C-p. Also, please use package.el to install things :) (Just run M-x list-packages) –  Sean Allred Feb 21 at 6:12

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.

-
@subhamsoni -- Yes, with Emacs it is best to tell it which engine you want to use and then compile normally using C-c C-c` (or the menus). By default, it assumes you want to use pdfTeX in DVI-mode. You, reasonably enough, want to change that behaviour. The question becomes which option should be the global default (pdfTeX in PDF-mode?) and which should be changed locally or per-file. E.g., if for some files, you want LuaTeX, for others pdfTeX, and for yet others XeTeX, then it makes sense to use the Local Variables options. –  jon Feb 21 at 6:31