Step 1: close Emacs completely and start it up again. This will fix the problem if it was caused by you inadvertently changing some setting/variable.
Step 2: if that didn't work:
comment out everything in your .emacs except for the line loading AUCTeX. In my case, the line is:
(load "auctex.el" nil t t)
The command
M-;
will comment-out everything in the active region. It will also uncomment everything in the region, if it is already commented, so you'll want to use that rather than manually adding a whole pile of ;;.
Following step 2, you should have an unmodified version of Emacs + AUCTeX, so you should have the correct behaviour back. This will confirm that the problem is something in your .emacs file conflicting with AUCTeX. If the problem persists, it may be a bug in AUCTeX, although that seems unlikely for such a commonly-used feature.
Step 3: Uncomment more of your .emacs, and restart. If the problem returns, it was caused by the now-uncommented code. If it doesn't, repeat the process until you find the code that triggers the problem.
Step 4: solve the problem yourself, or ask another question about the specific code that you discovered that caused the conflict.
If you want to use AUCTeX so desperately:
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Latex_outdir" "%`pdflatex --output-directory=/tmp %(mode)%' %t"
TeX-run-TeX nil (latex-mode doctex-mode)
:help "Run pdflatex with output in /tmp")
TeX-command-list)))
The question you linked to in your last comment is still unanswered, and will cause a serious problem with this setup: AUCTeX won't be able to locate your auxiliary files, and thus deduce the next step in the compilation step.
I suggest you use latexmk
for the whole process instead:
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Make" "latexmk -outdir=/tmp %t" TeX-run-TeX nil t
:help "Make pdf output using latexmk.")
TeX-command-list)))
Latexmk is aware of the option outdir
, and will automatically search for the auxiliary files in this directory.
Either way, note the following point (from man latexmk
):
Commonly, the directory specified for output files is a subdirectory of the current working directory. However, if you specify some other directory, e.g., "/tmp/foo" or "../output", be aware that this could cause problems, e.g., with makeindex or bibtex. This is because modern versions of these programs, by default, will refuse to work when they find that they are asked to write to a file in a directory that appears not to be the current working directory or one of its subdirectories. This is part of security measures by the whole TeX system that try to prevent malicious or errant TeX documents from incorrectly messing with a user's files. If for $out_dir or $aux_dir you really do need to specify an absolute pathname (e.g., "/tmp/foo") or a path (e.g., "../output") that includes a higher-level directory, then you need to disable the security measures (and assume any risks). This can be done by temporarily setting the operating system's environment variable openout_any to "a" (as in "all"), to override the default "paranoid" setting.
Another potential problem with this setting is that all your documents will share the same temporary directory, so you will need to make sure they all have different names.
For your cp
step, you can use this line in your .latexmkrc
:
$pdflatex .= ' && cp -v %Z/%D %D';
Note that most of this is untested, please let me know if it doesn't work.
Best Answer
Remove the line
It has a wrong format and anyway is useless if you use a recent AUCTeX version (11.88 or above), Okular is correctly configured out-of-the-box.