如何使“latexmk”运行适当的次数

如何使“latexmk”运行适当的次数

系统:

Ubuntu 13.04、Texlive2012、Emacs 24.something,我从终端而不是 GUI 运行 Emacs,并且我在 Emacs 中打开了服务器模式。

在编译我的 latex 文档时,我使用AucTeXinemacs来运行latexmk,但latexmk只运行一次,并会提示你应该再次运行,然后推断它是参考文献还是其他内容。难道从一开始就运行适当的次数latexmk不是重点吗?latexmk

latexmk如果我不需要emacs再次运行它,我该如何做到这一点?

我的乳胶部分.emacs如下,以防我需要添加或删除某些东西以获得所需的结果。

;;============AucTex===========                                                 
(require 'tex-site)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTex t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)

;;============ Latexmk setup==============                                        
(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."))))

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

;; Set okular to open with C-c C-v view option                                      
(defun Okular-make-url () (concat
     "file://"
     (expand-file-name (funcall file (TeX-output-extension) t)
                       (file-name-directory (TeX-master-file))
                       "#src:"
                       (TeX-current-line)
                       (expand-file-name (TeX-master-directory))
                       "./"
                       (TeX-current-file-name-master-relative))))

(add-hook 'LaTeX-mode-hook '(lambda ()
        (add-to-list 'TeX-expand-list
                     '("%u" Okular-make-url))))
(setq TeX-view-program-list
      '(("Okular" "okular --unique %u")))
(setq TeX-view-program-selection '((output-pdf "Okular")))

(custom-set-variables
 ;; custom-set-variables was added by Custom.                                       
 ;; If you edit it by hand, you could mess it up, so be careful.                    
 ;; Your init file should contain only one such instance.                           
 ;; If there is more than one, they won't work right.                               
 '(TeX-PDF-mode t)
 '(TeX-newline-function (quote newline-and-indent))
 '(TeX-source-correlate-method (quote synctex))
 '(TeX-source-correlate-mode t)
 '(TeX-source-correlate-start-server t)
 '(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))) t)
 '(TeX-view-program-selection (quote ((output-pdf "Okular"))) t)
 '(compilation-auto-jump-to-first-error t))

以下是我的.latexmkrc文件

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

编辑

根据 John Collins 的要求,以下是我在运行时收到的消息latexmk

You should run LaTeX again to get references right, {9} pages

尽管它说的是 LaTeX,latexmk但运行这里得到的输出显示如下:

Running `Latexmk' on `TidalForce' with ``latexmk -pdf TidalForce''
Latexmk: This is Latexmk, John Collins, 11 Nov. 2012, version: 4.35.
**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'TidalForce.tex'
------------
Run number 1 of rule 'pdflatex'

.emacs正如约翰·柯林斯 (John Collins) 提到的,这是和文件的更好格式.latexmkrc

;; ============ Latexmk setup ==============                                        
(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 -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."))))

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

.latexmkrc设置:

$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode -file-line-error -synctex=1 %O %S';

答案1

在 命令行定义中latexmk,将其更改%s%O %S。( 和 均为O大写S。)%S是源文件名称的正确占位符, 是可放置在命令行上的%O选项。使用小写字母,不会替换源文件的名称,并且传递给的命令行不是预期的命令行。latexmkslatexmkpdflatex

已添加注释

后来发现上述答案具有误导性/误解性。有一个配置可以正确emacs调用latexmk,还有一个配置可以按 OP 的要求latexmk调用。虽然可以通过其命令行进行配置(在问题中的配置文件中完成) ,但通常在其自己的配置文件中配置更容易、更安全。请参阅pdflatexlatexmkemacs.emacslatexmkTikZ:编译独立图片以获得更好的配置。

相关内容