【问题标题】:how to have latexmk work with emacs and okular如何让 latexmk 与 emacs 和 okular 一起工作
【发布时间】:2013-04-09 02:51:43
【问题描述】:

我刚开始使用 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.")))))

【问题讨论】:

    标签: emacs pdflatex latexmk


    【解决方案1】:

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

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

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

    【讨论】:

    • 这让我通过了第一个错误,但它仍然无法正常工作。它现在说LaTeX exited abnormally with code 1
    • @dustin 你确定这不是因为pdflatex 失败,即你尝试编译的 LaTeX 文件有错误吗?
    • 在 tex.stackexchange 我问了一个不同的问题,并且做 C-c C-t C-p 会起作用。它做了。如何将其合并到 emacs 中?我一直在阅读关于 tex 的所有帖子,但我似乎无法让 AucTex、Latexmk、Okular 和 Emacs 正常工作。
    • @dustin 尝试使用我从这个答案链接到的帖子,并注意您需要同时使用答案并将它们编辑为用户 okular 而不是 evince。
    • 以下链接与 Evince 无关,因为某些链接指向其他页面。 auctex Emacsauctex Emacs follow uplatex how to call latexmk emacs。有一个问题。它们有不同的功能和不同的latexmkrc。我要遵循什么?
    【解决方案2】:

    我找到了需要做的事情。在这篇 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)))
    

    现在,我只剩下 okular 在完成后生成 pdf 文件了。有人对此有想法吗?

    【讨论】:

      猜你喜欢
      • 2023-02-02
      • 2012-12-09
      • 2014-06-06
      • 2017-01-20
      • 2017-05-08
      • 2014-12-25
      • 2010-09-14
      • 2013-05-15
      • 2015-09-18
      相关资源
      最近更新 更多