2

To enable automatic latex-preview-pane-mode with AUCTex I bound it to a hook:

(add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)

This works.
When I open a *.tex file, then latex-preview-pane-mode gets enabled.

BUT: now when I export a org-mode file via latex to pdf (C-c C-e l o) two times (or more often), then the latex-preview-pane window (aka DocView or pdf-tools) is also opened a second time. My frame then shows on both windows the generated pdf. The bad thing is, it breaks auto-revert of the pdf-preview (the pdf-view does not get updated to changes anymore).

(removing the above hook, repairs org-mode's latex export. But then latex-preview-pane-mode gets not automatic enabled from within AUCTex)

Question: How can I have latex-preview-pane-mode enabled automatically and working with both AUCTex and org-mode's latex export?

Note: I have seen 2 similar named questions here, but those have a complete different topic.
Note: I added (add-to-list 'revert-without-query ".+\\.pdf$") for auto-revert of pdf files to my init.el.

  • Could it be that you mean LaTeX-mode-hook instead of LaTeX-mode? Note that latex-preview-pane-enable sets latex-mode-hook instead. Furthermore could it be that you mean auto-revert-mode instead of auto-reverse? – Tobias Jun 30 '18 at 1:03
  • @Tobias I meant auto-revert. ;-) As of the add-hook line, thats correct (I'm using :hook from use-package, which just looks slightly different) – jue Jun 30 '18 at 7:10
  • Using the latex-mode-hook (instead of LaTeX-mode-hook) by calling latex-preview-pane-enable, or ensuring it is nil, does not change anything on the behavior. – jue Jun 30 '18 at 7:39
0

Not quite the answer I was looking for, but I want to document this as a usable mode of operation.

I completely kicked the package latex-preview-pane-mode.
(For me it now looks like it just adds more complexity.)

Then I found that org-modes latex export works pretty well with pdf-tools and without latex-preview-pane-mode.
(Maybe that is the reason org-modes's export did not work well with latex-preview-pane-mode, and maybe the add-hook mentioned below will fix the revert issue.)

As for LaTex-mode: I can live with preview after compile (TeX-command-run-all or C-c C-a).
To have this properly working I added 3 lines to my init.el:

(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer) ;; revert pdf after compile
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))) ;; use pdf-tools for viewing
(setq LaTeX-command "latex --synctex=1") ;; optional: enable synctex

I got it from this answer.

More Info on synctex (not related to Question, but mentioned for completeness):
ensure that variable TeX-source-correlate-method mentions something like this (pdf . synctex).
and variable TeX-PDF-mode is t, so pdflatex gets called to compile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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