首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让latexmk与emacs和okular一起工作

如何让latexmk与emacs和okular一起工作
EN

Stack Overflow用户
提问于 2013-04-09 10:51:43
回答 2查看 2.6K关注 0票数 1

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

代码语言:javascript
复制
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文件:

代码语言:javascript
复制
$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1' -pdf %s;

下面是我的.emacs文件:

代码语言:javascript
复制
(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.")))))
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-10 00:59:20

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

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

现在,我只需要在完成后使用okular来生成pdf。有人对此有什么想法吗?

票数 0
EN

Stack Overflow用户

发布于 2013-04-09 15:26:30

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

代码语言:javascript
复制
$pdf_mode = 1;
$pdflatex = 'pdflatex -interaction=nonstopmode -file-line-error -synctex=1';

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15892486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档