I am able to run
tex-file, and the PDF generates just fine. How would I go about automatically opening the resultant PDF file after generation?
you can run
TeX-view (vanilla emacs
C-c C-v), but it might require some configuration to get working as you want it.
something like the following got me going recently:
;; Use emacs' pdf-tools to open PDF files: (setq TeX-view-program-selection '((output-pdf "PDF Tools")) TeX-source-correlate-start-server t) ;; use synctex for click on pdf to jump to that point in tex file, and vice versa: (setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) ;; Update PDF buffers after successful LaTeX runs ;; does this actually work tho? (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)
if you want the pdf display to update on save, you can use
(add-hook 'LaTeX-mode-hook (lambda () (push '("latexmk" "latexmk -pvc -pdf --synctex=1 %s" TeX-run-TeX nil t :help "Run latexmk on file") TeX-command-list))) (add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))
-pvc flag is for continuous (live-updating) preview.
then you need to edit
~/.latexmkrc to tell it to use pdf-tools as your previewer:
$pdf_previewer="emacsclient -e '(find-file-other-window %S)'"; $pdflatex='pdflatex %O -interaction=nonstopmode %S'; $pdf_update_method = 4; $pdf_update_command = "emacsclient -e '(with-current-buffer (find-buffer-visiting %S) (pdf-view-revert-buffer nil t))'";
this presumes you're running emacs in daemon/server mode (
if this works you don't have to haggle with
C-c C-c or
C-c C-a and answer yes three times in order to update your preview.
latexmk need to be installed, but are often bundled with tex packages.
source: some reddit, etc. harvestings i recently did.
disclaimer: i'm not running macOS.