Part I:
Could someone please give me an example of how to configure AUCTeX to use the -output-directory option?
I've tried inserting -output-directory="/tmp" in a variety of ways at different locations, but it's not working -- with two hyphens, with one hyphen, with double quotes, with single quotes, without any quotes, before the %t, after the %t, right before the closing single quote, . . . .
Here is the generic latexmk code for the working directory in my init.el file:
(custom-set-variables
'(TeX-command-list (quote ( ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode) :help "Run LaTeX"))))
)
Part II -- Extra Credit
Then, I'd like to take one step further and copy the PDF back to the working directory with the following example. I'm on OSX with TeX Live, so -aux-directory is not supported.
Configure latexmk so that the command it uses for pdflatex does the ordinary pdflatex command and then copies the output file where you want it. You'd invoke latexmk with the -output-directory option.
An appropriate line in one of latexmk's configuration files is
$pdflatex .= ' && cp "%D" "%R.pdf"';
You could also persuade it to display a message about the copying of the output file:
$pdflatex .= ' && (cp "%D" "%R.pdf"; echo Output file copied from "%D" to "%R.pdf" in current directory)';
(N.B. The second suggestion was all supposed to be on one line.)
Then you invoke latexmk by something like the following:
latexmk -outdir=/tmp
For anyone interested in synctex with the -output-directory option on an OSX box, add -synctex=1 to the line of code proposed by T. Verron in the answer below:
;; use Skim as default pdf viewer
;; Skim's displayline is used for forward search (from .tex to .pdf)
;; option -b highlights the current line; option -g opens Skim in the background
(setq TeX-PDF-mode t)
(setq TeX-view-program-selection '((output-pdf "Skim")))
(setq TeX-view-program-list
'(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n /tmp/%o %b")))
(server-start); start emacs in server mode so that skim can talk to it
EDIT: The following stackoverflow link contains an alternative method of using Emacs and start-process to run latexmk and copy the .pdf file back to the working directory (leaving the auxiliary files in the /tmp folder) -- if the latexmk compilation is successful, then Skim is opened (with forward sync) -- if the latexmk compilation generates errors, then the error buffer is displayed. https://stackoverflow.com/questions/18705774/if-latexmk-finishes-okay-then-show-pdf-else-display-errors
emacsand one aboutlatexmk. For the emacs part, I don't see the difference between "your genericlatexmkcode" and the default option for latex-ing documents. Maybe somewhere else, you have some code which tells auctex to substitute%lwithlatexmkinstead of(pdf)latex? (1/3) – T. Verron May 01 '13 at 22:51latexmk, the-output-directoryoption should be given in the config file forlatexmk, instead of yourinit.el. See this answer for a way of doing it : http://tex.stackexchange.com/a/31253/9517 . In any case, there is good chance that I missed your point, since as I said, I don't understand what is the question. (2/3) – T. Verron May 01 '13 at 22:52emacspart, I would advise to simply use a genericlatexmkentry ( http://tex.stackexchange.com/questions/10561/compile-using-latexmk-in-emacs ), and letlatexmkpass all relevant options topdflatex. About thelatexmkquestion, maybe you could clarify what is the question? Usually, the policy would be to advise you to post different questions in separate threads, but here, I have a feeling you can very well merge both questions into one, directed by your final goal (which is emulating-aux-directorywithlatexmk, if I understand correctly). – T. Verron May 01 '13 at 23:19LaTeXon `file-name' with ``pdflatex --synctex=1 -interaction=nonstopmode "\input" file-name.tex'' This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012) - restricted \write18 enabled. . . . – lawlist May 01 '13 at 23:32-output-directoryoption, but the post doesn't describe how he did it. – lawlist May 02 '13 at 15:03