2013-04-09 65 views
1

我剛開始使用emacs,所以我不知道我是否正確地做到了這一點。 C-c C-c然後提示說Command [pdflatex]:所以我輸入latexmk。那就是它所期待的? 然後我給下面的錯誤:如何讓latexmk使用emacs和okular

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

回答

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文件。有沒有人有這個想法?

2

你得到的錯誤是由於你的.latexmkrc文件。您可以使用等效配置選項$pdf_mode = 1;,而不是提供命令行選項-pdf。另外,將源文件%s附加到配置文件似乎會混淆latexmk。因此,嘗試使用:

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

如果你想latexmk綁定在Emacs的關鍵,使之出現錯誤,如果有任何你可能會喜歡的答案this question

+1

讓我通過了第一個錯誤,但它仍然無法正常工作。它現在說'LaTeX異常退出代碼1' – dustin 2013-04-09 15:22:21

+0

@dustin您確定這不是由於'pdflatex'失敗,即您嘗試編譯的LaTeX文件中存在錯誤嗎? – 2013-04-09 15:42:24

+0

關於tex.stackexchange我問了一個不同的問題,並做了「C-C C-t C-p」的工作。它做了。我怎樣才能將它納入emacs?我一直在閱讀關於tex的所有帖子,但似乎無法讓AucTex,Latexmk,Okular和Emacs正常工作。 – dustin 2013-04-09 15:44:16