How to call latexmk in emacs, and jump to next-error

前端 未结 3 1804
心在旅途
心在旅途 2020-12-23 18:55

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 `,

相关标签:
3条回答
  • 2020-12-23 18:58

    Adding %(mode) gives latexmk some more options like noninteractive if it is set so in auctex.

    (add-hook 'LaTeX-mode-hook (lambda ()
      (push 
        '("Latexmk" "latexmk -pdf %(mode) %s" TeX-run-TeX nil t
          :help "Run Latexmk on file")
        TeX-command-list)))
    
    0 讨论(0)
  • 2020-12-23 19:13

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

    It might also be wise to add something like

    '("%(-PDF)"
      (lambda ()
        (if (and (not TeX-Omega-mode)
                 (or TeX-PDF-mode TeX-DVI-via-PDFTeX))
            "-pdf" "")))
    

    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.

    0 讨论(0)
  • 2020-12-23 19:21

    It's relatively easy to get AucTeX to run latexmk with C-c C-c. The following will add a Latexmk choice to the list of TeX commands:

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

    The trick is getting next-error to work. If you dig around in the AucTeX sources, you can probably find the regex it uses on TeX output buffers; it's not automatically applied to the buffer created by TeX-run-command. (You might also be able to convince compile mode to use this regex.)

    Another approach is to redefine the variable LaTeX-command. This is a bit iffy because I think a lot of AucTeX functions assume they can tack command-line options onto this string and execute the result.

    0 讨论(0)
提交回复
热议问题