3

I'm using Emacs (26.1, build 1, i686-w64-mingw32) on the latest version of Windows 10. Im looking to turn my Emacs into a LaTeX IDE that has a 'live preview' functionality.

Ideally I would like my latex source code on one side of the screen and the compiled PDF output on the other side of the screen. When I make changes to my source code it will automatically compile and update the PDF output in real time. Here is an illustration of what I mean.

I have already installed AUCTeX, pdf-tools and Latex-preview-pane and I have successfully compiled and previewed a PDF output file from within Emacs. But compilation must be done manually using keybindings.

How would I go about implementing the live preview in real time aspect as described above?

*edit: Apologies. As I am new to Emacs and not a programmer so I was unaware that my question was not specific or narrow enough. I haven't tried anything else other than installing the packages I referred to above. I had naïvely assumed that "latex–preview–pane" had the features I was looking for but that doesn't seem to be the case. I am not even sure what to ask to make this query more specific as I'm not too sure where to go from here. I will try asking the same question on Reddit and see how that goes. I will post back here if I find a solution

2
  • This question seems to broad. Questions here should be specific, preferably showing what you already tried etc. You might instead want to pose this question on a discussion site, such as Reddit.
    – Drew
    Commented Sep 20, 2018 at 18:04
  • AuCTEX doesn't provide live-preview as in the link. It would be possible to implement, but I agree with Drew that how exactly you'd do that is a very broad question. This question has been asked before: emacs.stackexchange.com/questions/32276/… It didn't get an answer then either, as it is a big/broad request
    – Tyler
    Commented Sep 20, 2018 at 19:15

1 Answer 1

0

Ensure that AUCTeX, PDFTools and a working LaTeX distribution are installed and working correctly.

Put the following elisp code in your init file.

;;Eliminates the necessity for the save command before compilation is completed
(setq TeX-save-query nil)

;;Function that combines two commands 1. revert pdfoutput buffer 2. pdf-outline
(defun my-TeX-revert-document-buffer (file)
  (TeX-revert-document-buffer file)
  (pdf-outline))

;; Add custom function to the TeX compilation hook
(add-hook 'TeX-after-compilation-finished-functions #'my-TeX-revert-document-buffer)

The included PDF-outline function is a hack of sorts as it is the only thing I could find that would keep the latex source file buffer as the active window. Other window switching commands such as (other-window 1) would not execute when part of my-TeX-revert-document-buffer

2
  • I think OP wants to have the document automatically compiled whenever it changes, and to have the resulting pdf updated. It looks like your code does the second part, but doesn't actually do anything to get the compilation to happen automatically?
    – Tyler
    Commented Oct 17, 2018 at 14:22
  • Yes, you are right. The code suggested above does not auto compile whenever there is a change to the source file. You do indeed still have to use the compile command when using this code.
    – John Doyle
    Commented Oct 19, 2018 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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