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 use the
latex-preview-pane-mode included in the
start it whenever you want to see the pdf generated, and then as you type latex and save it you see in the other pane the result
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.
C-c C-vwhich is bound to the function
tex-viewdefined by the function
tex-define-common-keysin the built-in
tex-mode.ellibrary. This comment assumes that you are using a generic version of Emacs for OSX/MacOS without having installed the AUCTeX library. While focus is within the *.tex buffer you can type
C-h mto see some of the bound keyboard shortcuts.