System:
Ubuntu 13.04, Texlive2012, Emacs 24.something, I run Emacs from the terminal and not the GUI, and I have server mode on in Emacs.
When compiling my latex documents, I use AucTeX in emacs to run latexmk but latexmk only runs once and will say you should run latexmk again and then reason whether it be references or something else. Isn't the point of latexmk to run the appropriate amount of times from the get go?
How can I have latexmk do this with out me telling emacs to run it again?
My latex portion of my .emacs is below in case there is something I need to add or remove from it to get the desired results.
;;============AucTex===========
(require 'tex-site)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTex t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
;;============ Latexmk setup==============
(defun run-latexmk ()
(interactive)
(let ((TeX-save-query nil)
(TeX-process-asynchronous nil)
(master-file (TeX-master-file)))
(TeX-save-document "")
(TeX-run-TeX "latexmk"
(TeX-command-expand "latexmk -pdflatex='pdflatex -file-line-error \
-synctex=1' -pdf %s" 'TeX-master-file)
master-file))
(if (plist-get TeX-error-report-switches (intern master-file))
(TeX-next-error t)
(progn
(demolish-tex-help)
(minibuffer-message "latexmk: done."))))
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run Latexmk on file")
TeX-command-list)))
;; Set okular to open with C-c C-v view option
(defun Okular-make-url () (concat
"file://"
(expand-file-name (funcall file (TeX-output-extension) t)
(file-name-directory (TeX-master-file))
"#src:"
(TeX-current-line)
(expand-file-name (TeX-master-directory))
"./"
(TeX-current-file-name-master-relative))))
(add-hook 'LaTeX-mode-hook '(lambda ()
(add-to-list 'TeX-expand-list
'("%u" Okular-make-url))))
(setq TeX-view-program-list
'(("Okular" "okular --unique %u")))
(setq TeX-view-program-selection '((output-pdf "Okular")))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-PDF-mode t)
'(TeX-newline-function (quote newline-and-indent))
'(TeX-source-correlate-method (quote synctex))
'(TeX-source-correlate-mode t)
'(TeX-source-correlate-start-server t)
'(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))) t)
'(TeX-view-program-selection (quote ((output-pdf "Okular"))) t)
'(compilation-auto-jump-to-first-error t))
Below is my .latexmkrc file
$pdf_mode = 1;
$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1';
Edit
Per John Collins' request, here is the message I received when running latexmk
You should run LaTeX again to get references right, {9} pages
Even though it says LaTeX, latexmk was ran here is the output to show this:
Running `Latexmk' on `TidalForce' with ``latexmk -pdf TidalForce''
Latexmk: This is Latexmk, John Collins, 11 Nov. 2012, version: 4.35.
**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'TidalForce.tex'
------------
Run number 1 of rule 'pdflatex'
As John Collins mentioned, here is the better format for the .emacs and .latexmkrc file.
;; ============ Latexmk setup ============== (defun run-latexmk () (interactive) (let ((TeX-save-query nil) (TeX-process-asynchronous nil) (master-file (TeX-master-file))) (TeX-save-document "") (TeX-run-TeX "latexmk" (TeX-command-expand "latexmk -pdf %s" 'TeX-master-file) master-file)) (if (plist-get TeX-error-report-switches (intern master-file)) (TeX-next-error t) (progn (demolish-tex-help) (minibuffer-message "latexmk: done."))))(add-hook 'LaTeX-mode-hook (lambda () (push '("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t :help "Run Latexmk on file") TeX-command-list)))
.latexmkrc setup:
$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode -file-line-error -synctex=1 %O %S';
latexmkrunpdflatexonly once? If you run it another time, do you get an errorAll files are up to date? If yes, the problem is only related toauctex's log parser, not tolatexmk. – T. Verron May 20 '13 at 16:08VimI used to use it until a plugin corrupted everything and removing it didn't fix the problem. Yes it is a perl script and it is supposed to be clever but in my case it has been having learning challenges. – dustin May 20 '13 at 16:14latexmk -pdf bibfrom folder at terminal andbib.pdfshould have right references without any extra latexmk run manually. – texenthusiast May 22 '13 at 02:13latexmk11 Nov. 2012. Version 4.35 it works for me from terminal. Tip: Adding a space by pressing bar on the current.texwill make a new timestamp of.texfile in this waylatexmkdetects for any file changes and run automatically correct number of times. – texenthusiast May 22 '13 at 02:23latexmk. In your definitions of the command lines forlatexmk, change "%s" to "%O %S". (Both the "O" and "S" are upper case.) Try that and see what happens. The "%S" is the correct placeholder for the name of the source file, and the "%O" is for options thatlatexmkmay place on the command line. With the lower case "s" that you have,latexmkwill function incorrectly. Also the output fromlatexmkis severely truncated; there should be a minimum of 3 extra lines. Perhapsauctexis eating them. – John Collins May 29 '13 at 18:31