14

After getting to know org mode here, I tried it out. It seems to be, indeed, very helpful. However, I want it to work smoothly with LaTeX, and as a compiling script I want to use latexmk.

I followed the instruction here trying to make org-mode use latexmk as the compiling engine/script. Unfortunately, this doesn't work for me. The resulting .tex file is perfect and I can manually compile it using latexmk, but it won't work directly.

N.N.
  • 36,163
Dror
  • 22,613
  • @Dror: "After getting to know org mode here" , could you add a link please. I don't know it and like to getting to know it as well. – Martin Scharrer Feb 08 '11 at 09:05
  • @Martin: I added a link. By "here" I meant in this/our community :) – Dror Feb 08 '11 at 09:10
  • @Dror: I thought so but couldn't find it first here on tex.sx. Just a tip: you might call it "Emacs org-mode" in the title and the text to make it more clear. – Martin Scharrer Feb 08 '11 at 09:21
  • There's not really enough information here to help. Maybe Emacs can't find the latexmk binary? Check the value of the load-path Emacs variable. If not, can you see if any external processes are invoked by emacs? – Charles Stewart Feb 08 '11 at 12:56
  • @Charles: I'm afraid that I don't know how to verify this. I added (add-to-list 'load-path "/usr/texbin/") to my .emacs. In this directory there is a link latexmk. How can I check the external process? Thnx!! – Dror Feb 08 '11 at 13:23
  • @Dror: If you have Dtrace or similar on your system, it's very easy, you can log all new processes over a period of time using newproc.d. If not, it can be a bit tricky to catch processes as they are invoked; a trick is to put a wrapperbin directory at the front of load-path which is a wrapper for the binaries you want to log, and which logs a message before and after calling the real executable, e.g., echo "start: $0 $*" >> logfile; /usr/texbin/latexmk "$@"; xstat=$?; echo "end $xstat: $0 $*" >> logfile; exit $xstat as the payload of a shell script called $wrapperbindir/latexmk on Unix. – Charles Stewart Feb 08 '11 at 13:49
  • @Charles: I do have dtrace but I don't know how to use it. However, consider the edit in my question http://tex.stackexchange.com/questions/10561/compile-using-latexmk-in-emacs I guess it means that emacs can find latexmk. The problem is making org-mode find it and use it as well. – Dror Feb 08 '11 at 14:20
  • AFAIK, all Emacs packages that access outside executables use the Elisp primitive call-process, which uses the variable exec-path, and don't fiddle with it, so this should not be the problem. Dtrace will tell you what arguments are passed to latexmk, which is the next thing we want to know: check that you have the newproc.d script, and run it as root in a terminal window. Then invoke export to PDF and look at the output of the newproc.d process. You should see the invocation of latexmk: what arguments are passed? What happens when you run latexmk by hand with these arguments. – Charles Stewart Feb 08 '11 at 14:30
  • @Charles: I'm sorry but I don't know how to implement your tips. I'd be happy to know what org-mode is doing when I hit C-c C-e p. This will probably be helpful. – Dror Feb 08 '11 at 16:13
  • It runs org-export-as-pdf, which calls the commands in the list of strings, org-latex-to-pdf. Maybe changing this variable will work? – Charles Stewart Feb 08 '11 at 16:42
  • 1
    Sorry this isn't as a comment, but I don't have the rep!

    You might be better off asking on the org-mode users mailing list here. They are generally pretty quick to respond with useful information.

    – cm2 Feb 08 '11 at 16:58
  • Thnx! I tried this as well. – Dror Feb 08 '11 at 16:58
  • 2
    When you compile your document in org-mode with "C-c C-e d", Emacs/org-mode should create a buffer in the background called "Org PDF LaTeX Output". This is a log of the compilation process. You should be able to switch to it using C-x b (or just see if it's there in the "Buffers" menu on the menubar). Can you see any error messages in there about where latexmk or some other aspect of the compile process is failing? – Kieran Feb 08 '11 at 19:24
  • There is not C-c C-e d any more in the default org setup. Perhaps now it is C-c C-e l p – Vladimir Nikishkin May 18 '20 at 04:55

2 Answers2

11

The org-mode mailing list was useful! I added (setq org-latex-to-pdf-process (list "latexmk -f -pdf %f")) to my .emacs file and then C-c C-e d worked as expected, producing the PDF using latexmk.

Note if org-mode-version > 8.0 org-latex-to-pdf-process has been renamed to org-latex-pdf-process

costrouc
  • 125
Dror
  • 22,613
9

In Org mode 8, the variable is renamed. As Shitikanth commented, I needed %f, so in org 8:

(setq org-latex-pdf-process (list "latexmk -f -pdf %f"))

jake
  • 223