I am using Emacs 25.3 on OS X El capitan. When I do C-c C-c to compile the .tex document I get the following prompt. Every one of these options actually run latexmk but somehow it bothers me that there are lots of prompts of the same name. Also, synctex sometimes stops working. What is going on here?. Should I ask this on emacs stackexchange?

enter image description here

Edit after Arash Esbati's comment: Here is my complete AUCTeX configuration.

;; AucTeX configuration
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)

;; Use Skim as viewer, enable source <-> PDF sync
;; make latexmk available via C-c C-c
;; Note: SyncTeX is setup via ~/.latexmkrc (see below)
(add-hook 'LaTeX-mode-hook (lambda ()
    '("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
      :help "Run latexmk on file")
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))

;; 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-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
      '(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b")))

Here is my .latexmkrc configuration

$recorder = 1;
$pdf_mode = 1;        # tex -> pdf
$pdf_previewer = 'open -a Skim  %O %S';
$bibtex_use = 2;
$pdflatex = 'pdflatex -synctex=1 -interaction=nonstopmode -shell-escape  %O %S';
@generated_exts = (@generated_exts, 'synctex.gz');
$clean_ext = 'synctex.gz synctex.gz(busy) run.xml tex.bak bbl bcf fdb_latexmk run tdo %R-blx.bib';
print("Config file located at $HOME/.latexmkrc\n");
  • This is a totally appropriate question. I would include a mwe also. – A Feldman Dec 8 '17 at 8:42
  • Well, a MWE is not practical here because this in my opinion, has nothing to do with LaTeX markup. It has something to do with latexmk and how it is working internally with emacs. – minibuffer Dec 8 '17 at 21:33
  • Well just because I would do it doesn't make it right for you. Best of luck troubleshooting the problems. – A Feldman Dec 9 '17 at 1:42
  • AUCTeX doesn't support latexmk out of the box. How did you make it available to AUCTeX? What's the value of the variable TeX-command-list? – Arash Esbati Dec 10 '17 at 12:28
  • When I try to do M-x TeX-command-list there is no such option. I have edited my question and added my AucTeX configuration and latexmkrc configuration above. – minibuffer Dec 10 '17 at 15:28

I think the issue is that you put your latexmk entry into TeX-command-list with the function push. It does not check if an entry is already there and just adds it. Hence, an entry is added each time LaTeX-mode-hook is called. You can fix this by using add-to-list instead of push:

(add-hook 'LaTeX-mode-hook
          (lambda ()
            (add-to-list 'TeX-command-list
                         '("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
                           :help "Run latexmk on file"))))

In general, you can check the value of a variable with M-x describe-variable RET var-name RET or C-h v var-name RET for short.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.