如何让latexmk使用emacs和okular

时间:2013-04-09 02:51:43

标签: emacs pdflatex latexmk

我刚刚开始使用emacs,所以我不知道我是否正确地执行此操作。 C-c C-c然后提示符为Command [pdflatex]:,我输入latexmk。这甚至是它所期待的吗? 然后我给出了以下错误:

Latexmk: Initialization file '/home/dustin/.latexmkrc' gave an error:
     Substitution pattern not terminated at (eval 10) line 1, <GEN0> chunk 1.

Latexmk: Stopping because of problem with rc file

这是我的.latexmk文件:

$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1' -pdf %s;

这是我的.emacs文件:

(add-to-list 'load-path "~/.emacs.d/plugins")
(setq py-install-directory "~/.emacs.d/plugins")
(require 'python-mode)

;; ========== Prevent Emacs from making backup files ==========                        

(setq make-backup-files nil)

;; ========== Enable Line Numbering ==========                                         

(line-number-mode 1)

;; ========== Set the fill column ==========                                           

(setq default-fill-column 80)

;; ===== Turn on Auto Fill mode automatically in all modes =====                       

;; Auto-fill-mode the the automatic wrapping of lines and insertion of                 
;; newlines when the cursor goes over the column limit.             

;; This should actually turn on auto-fill-mode by default in all major                 
;; modes. The other way to do this is to turn on the fill for specific modes           
;; via hooks.                                                                          

(setq auto-fill-mode 1)

;; ========= Set colours ==========                                                    

;; Set cursor and mouse-pointer colours                                                
(set-cursor-color "white")
(set-mouse-color "goldenrod")

;; Set region background colour                                                        
(set-face-background 'region "blue")

;; Set emacs background colour                                                         
(set-background-color "black")

(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.")))))

2 个答案:

答案 0 :(得分:2)

您得到的错误是由.latexmkrc文件引起的。您可以使用等效配置选项-pdf,而不是提供命令行选项$pdf_mode = 1;。此外,将源文件%s附加到配置文件似乎会混淆latexmk。因此,尝试使用:

$pdf_mode = 1;
$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1';

如果您想将latexmk绑定到Emacs中的某个键并使其显示错误(如果有的话)您可能对this question的答案感兴趣。

答案 1 :(得分:0)

我找到了需要做的事情。在这篇文章how to call latexmk上,我只需要添加

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

现在,我只是在完成后生成了pdf。有没有人对此有所了解?