如何在emacs中调用latexmk,并跳转到下一个错误 [英] How to call latexmk in emacs, and jump to next-error

查看:346
本文介绍了如何在emacs中调用latexmk,并跳转到下一个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 latexmk 来编译我的LaTeX Emacs中的文档。特别是我需要Emacs功能下一个错误,通常用Cx调用,并跳转到文档中的下一个LaTeX错误。

I would like to use latexmk to compile my LaTeX documents in Emacs. Especially I need the Emacs functionality next-error, which is typically called with C-x `, and jumps to the next LaTeX error in the document.

我想使用 Cx编译或AUCTeX <$ c $调用 latexmk c> Cc Cc 。

I would like to call latexmk either using C-x compile or the AUCTeX C-c C-c.

首先,我设置 latexmk 使用

$pdflatex = 'pdflatex -interaction=nonstopmode';

选项1:Cx编译

我按 Cx编译键入 latexmk -pdf foo ,运行 pdflatex 。但是, next-error 不会跳转到错误,即使*编译*缓冲区包含错误:

I press C-x compile and type latexmk -pdf foo, which runs pdflatex. But next-error will not jump to the errors, even if the *compilation* buffer contains errors:

! Paragraph ended before \author was complete.
<to be read again> 
                   \par 
l.48 
[...]
Compilation exited abnormally with code 12 

如何在第48行自动跳转到这个错误?

How can I automatically jump to this error in line 48?

请注意,解析乳胶输出的这个问题什么都没有直接与 latexmk 有关。同样的问题发生在我只做 Cx编译pdflatex -interaction = nonstopmode foo

Note that this question of parsing the latex output has nothing to do with latexmk directly. The same problem occurs when I just do C-x compile pdflatex -interaction=nonstopmode foo.

选项2 :AUCTeX

如何设置AUCTeX调用 latexmk -pdf 而不是<$ c $我的.tex文件上的c> pdflatex 当然,我想要 next-error 也可以在这里工作。

How can I set AUCTeX to call latexmk -pdf instead of pdflatex on my .tex file? Of course, I want next-error to work here too.

更新:我开始了一个赏金,因为如果这样做,这对许多人来说是一个很好的工具。我认为问题回答如果一个解决方案,让我轻松地编译我的LaTeX文档使用Emacs中的 latexmk ,并使用下一个错误跳转到错误(当然,错误可能在包含 .tex文件,不一定在主文件或当前缓冲区中)。

UPDATE: I started a bounty because if this worked it would be a great tool for many people. I consider the question answered if a solution is given that lets me easily compile my LaTeX document using latexmk in Emacs and jump to the errors using next-error (of course, the errors might be in included .tex files, not necessarily in the master file or the current buffer).

更新:感谢Ivan(和Chris)制作AUCTeX + Latexmk的作品。在此期间,我发现使用 Rubber 编译LaTeX也是一个优秀的选择。它将以 gcc 和其他编译器使用的格式显示错误消息,因此它自然适用于Emacs Cx编译例如 Cx编译橡胶--pdf foo ,错误消息被正确解析。

UPDATE: Thanks to Ivan (and Chris) for making AUCTeX+Latexmk work. In the meantime, I found that using Rubber to compile LaTeX is also an excellent choice. It will display error messages in the format used by gcc and other compilers, so it naturally works with Emacs C-x compile, e.g. C-x compile rubber --pdf foo, and the error messages are parsed correctly.

推荐答案

对不起,我没有评论的能力,或者我只是将其添加为评论。克里斯·康威(Chris Conway)的回答是有效的,除了它应该使用 TeX-run-TeX 而不是 TeX-run-command AucTeX知道处理错误消息。

Sorry I don't have the ability to comment, or I would just add this as a comment. Chris Conway's answer works, except that it should use TeX-run-TeX instead of TeX-run-command so that AucTeX knows to process the error messages.

(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)"
  (lambda ()
    (if (and (not TeX-Omega-mode)
             (or TeX-PDF-mode TeX-DVI-via-PDFTeX))
        "-pdf" "")))

TeX-expand-list 并使用latexmk%( - PDF)%s,以便它在两者pdf和dvi模式。就个人而言,我觉得更容易使用,特别是在你尝试时。

to TeX-expand-list and use "latexmk %(-PDF) %s" so that it will work in both pdf and dvi mode. Personally, I find it easier to use customize especially when you are experimenting.

这篇关于如何在emacs中调用latexmk,并跳转到下一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆