5

I am editing my PhD thesis using Emacs & Auctex, but my elisp is quite weak. Additionally, I build my thesis in a subdirectory, using makefiles generated by CMake and the UseLATEX CMake package, which I highly recommend.

I can’t figure out how to tell auctex that when I build the document it should do something like: make -C build/digital and that the pdf file being output is going to be at build/digital/thesis.pdf even though the source is at ./thesis.tex

p.s. I HIGHLY recommend checking out UseLATEX, the CMake package for easily compiling LaTeX documents.

4
  • 1
    I would just as highly recommend using Arara, another TeX automation tool. :) But this is not the question. The support can definitely be added to AUCTeX, though I don't have the environment right now to provide a solution. Nov 10, 2014 at 16:31
  • 1
    M-x compile RET and then you can pass all arguments you want to make.
    – giordano
    Nov 10, 2014 at 16:50
  • 1
    +1 for giordano's suggestion; I would even go further and say to create your own function and let-bind compile-command so you don't have to type it in each session: (defun my:tex-compile () (interactive) (let ((compile-command "make -C build/digital")) (call-interactively #'compile))) But again, this isn't an answer to the question, just a solution to the problem :) Nov 10, 2014 at 17:07
  • Yes, I have been doing M-x compile, but I’d like all the fancy keybindings of AUCTeX to work, especially the viewer and build commands, since I am using synclatex and skim to enable jumping from source-line to output-line (forward search) and vice-versa
    – zbeekman
    Nov 10, 2014 at 19:11

1 Answer 1

7

Add the following code to your init file:

(eval-after-load "tex" '(add-to-list 'TeX-command-list '("Make" "make" TeX-run-compile nil t)))

Then you'll be able to call the make program with C-c C-c Make RET.

Replace the second element of the list with "make -C build/digital" if you want "make -C build/digital" by default, and the fourth element to t instead of nil if you want to have the chance to modify the make command instead of sticking with the default (which you can change interactively with C-u C-c C-c anyway).

10
  • 1
    Currently AUCTeX doesn't support output files with a different name or path than the default one (same path and base name of the master file + proper extension). I worked on it for some time in the past, but didn't complete the task.
    – giordano
    Nov 11, 2014 at 20:08
  • 1
    @Sweeters What you describe is what happens with AUCTeX 11.88.
    – giordano
    Nov 12, 2014 at 20:19
  • 1
    @giordano AUCTeX 11.88 and the elisp code in your answer work like a charm! Thanks
    – Sweeters
    Nov 13, 2014 at 18:50
  • 1
    @giordano Thank you for your answer, it's been useful. Though I'm not sure if something changed since you gave it or if it's something in my settings, but I had to use it with a (eval-after-load "tex" ...) to get it working.
    – gusbrs
    Jun 4, 2018 at 0:26
  • 1
    @gusbrs you're right, that's necessary.
    – giordano
    Jun 8, 2018 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .