我不知道您是否真的想要一个完整的解决方案,或者宁愿自己探索更多,但这里有一些应该有所帮助的事情。如果您遇到困难,请再次发布:
(FWIW,我认为输出 PDF 输出将匹配 TeX-master 而不是当前文件。)
[2011-03-24 编辑 - 提供代码]
这应该适用于具有局部变量块的 TeX 文件,例如
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master"
%%% pdf-copy-path: "/pdf/copy/path"
%%% End:
请注意 TeX-master 值和 pdf-copy-path 值周围的双引号。TeX-master 也可以t
(defun copy-master-pdf ()
"Copies the TeX master pdf file into the path defined by the
file-local variable `pdf-copy-path', given that both exist."
(interactive)
;; make sure we have local variables, and the right ones
(when (and (boundp 'file-local-variables-alist)
(assoc 'pdf-copy-path file-local-variables-alist)
(assoc 'TeX-master file-local-variables-alist))
(let* ((path (cdr (assoc 'pdf-copy-path file-local-variables-alist)))
(master (cdr (assoc 'TeX-master file-local-variables-alist)))
(pdf (cond ((stringp master)
;; When master is a string, it should name another file.
(concat (file-name-sans-extension master) ".pdf"))
((and master (buffer-file-name))
;; When master is t, the current file is the master.
(concat (file-name-sans-extension buffer-file-name) ".pdf"))
(t ""))))
(when (and (file-exists-p pdf)
(file-directory-p path))
;; The 1 tells copy-file to ask before clobbering
(copy-file pdf path 1)))))