TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since I'm used to use latexmk -pvc I'd like to do the following:

  • Run latexmk -pvc (externally) on the _region_.tex file
  • Use AUCTeX to just write the region file instead of compiling.

Is there a way to achieve this?

This way I do not block emacs all the time compiling and if an error occurs I use my standard C-c C-c command.

share|improve this question
up vote 1 down vote accepted

Short answer: yes.

Long answer: I am by no means an elisp hacker, but looking at TeX-command-region I thought that this could help:

(defun TeX-save-region ()
  "Saves the TeX region to the file whose name is defined by TeX-region."
  (and (or (null TeX-command-region-begin)
       (markerp TeX-command-region-begin))
       (TeX-pin-region (region-beginning) (region-end)))
  (let ((begin (or TeX-command-region-begin (region-beginning)))
    (end (or TeX-command-region-end (region-end))))
    (TeX-region-create (TeX-region-file TeX-default-extension)
               (buffer-substring begin end)
               (file-name-nondirectory (buffer-file-name))
               (TeX-current-offset begin))))

(Not that I exactly understand each and every part of this code, but the general idea should be more or less clear.) Now it remains to bind this to your favorite key.

Notice also that compiling with C-c C-r does not "block" emacs, and in my setup I can hit C-c C-r, continue editing the document, and as soon as the compilation finishes, the pdf viewer updates automatically.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.