[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Trigger Tex file compilation with latexmk automatically when its content
From: |
Hongyi Zhao |
Subject: |
Trigger Tex file compilation with latexmk automatically when its content is changed and saved. |
Date: |
Wed, 3 May 2023 11:13:52 +0800 |
Hi here,
For the purpose of automatic compilation in Emacs using AUCTeX and
latexmk on Ubuntu Linux, I've the following configuration:
;;;;;;; begin config here
;; https://tam5917.hatenablog.com/entry/2021/04/10/134230
;; https://lists.gnu.org/archive/html/auctex/2021-10/msg00013.html
(defvar hz/AUCTeX-process nil)
(use-package smart-compile
:init
(declare-function smart-compile-string "smart-compile")
(defun run-latexmk ()
(when (string-match ".tex$" (buffer-file-name))
(unless (and (processp hz/AUCTeX-process)
(eq (process-status hz/AUCTeX-process) 'run))
(let ((buf (get-buffer-create "*Background TeX proccess*")))
(with-current-buffer buf (erase-buffer)) ;; flush previous log
(setq hz/AUCTeX-process
(start-process-shell-command
"Background TeX" buf
;; use an external application as the previewer
(smart-compile-string "latexmk -pv %f")
;; use pdf-tools
;; (smart-compile-string "latexmk %f")
))))))
(define-minor-mode AutoTeX-mode
"Mode for compiling latex sources and creating PDFs after saving."
:global nil
:lighter " Auto"
(if AutoTeX-mode
(add-hook 'after-save-hook 'run-latexmk t t)
(remove-hook 'after-save-hook 'run-latexmk t)))
:hook (LaTeX-mode . (lambda () (AutoTeX-mode 1))))
;;;;;;; end config here
But after the TeX file has been changed and saved, I still haven't
observed the automatic compilation progress. Any tips/comments will be
appreciated.
Regards,
Zhao
--
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
- Trigger Tex file compilation with latexmk automatically when its content is changed and saved.,
Hongyi Zhao <=