auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forward and inverse search integration with latex-preview-pane.


From: Hongyi Zhao
Subject: Re: Forward and inverse search integration with latex-preview-pane.
Date: Mon, 5 Jul 2021 19:05:44 +0800

On Mon, Jul 5, 2021 at 6:33 PM Arash Esbati <arash@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Mon, Jul 5, 2021 at 4:57 PM Arash Esbati <arash@gnu.org> wrote:
> >>
> >> I think pdf-tools is more appropriate for your requirements.
> >>
> >>     https://github.com/politza/pdf-tools
> >>
> >> AUCTeX has support for pdf-tools builtin.
> >
> > Thank you for letting me know this. Then what's the corresponding
> > configuration options for this feature?
>
> Using the Custom-interface and selecting 'PDF Tools' for 'Viewer' for
> 'output-pdf'.  Or if you prefer setting it in your init file with
> something like this:
>
>     (setq TeX-view-program-selection '((output-pdf "PDF Tools")))
>

Thank you very much. Based on your above instructions, I figured out
the following settings to achieve this purpose:

 ;https://github.com/vedang/pdf-tools/
(use-package pdf-tools
  :config
  (pdf-tools-install)
)

;https://www.emacswiki.org/emacs/AUCTeX#h5o-24
;https://www.emacswiki.org/emacs/AUCTeX#h5o-27
;; ##### Always ask for the master file
;; ##### when creating a new TeX file.
(setq-default TeX-master nil)

;; ##### Enable synctex correlation.
;; ##### From Okular just press `Shift + Left click' to go to the good line.
;; ##### From Evince just press `Ctrl + Left click' to go to the good line.
(setq TeX-source-correlate-mode t
      TeX-source-correlate-start-server t)

;; ### Set Okular as the default PDF viewer.
(eval-after-load "tex"
  ;'(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "Okular")
  ;'(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "Evince")
  '(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "PDF Tools")
  )


> Also searching AUCTeX manual for PDF Tools might give you more insights
> (e.g. about using `TeX-after-compilation-finished-hook').

Based on the notes from
<https://www.gnu.org/software/auctex/manual/auctex.html>:

;;;;;;;;;;;;;;;;;;;;;;;;;
5.1 Modes and Hooks

Variable: TeX-after-compilation-finished-hook

Hook which is run after the TeX/LaTeX processor has successfully
finished compiling your document. (See Processing, for finding out how
to compile your document). Each function in the hook is run with the
compiled output document as its argument.

This is useful for automatically refreshing the viewer after
re-compilation especially when using Emacs viewers such as DocView or
PDF Tools. The function TeX-revert-document-buffer can be added to the
hook for this purpose.
;;;;;;;;;;;;;;;;;;;;;;;;;

I tried the following configuration:

;; Update PDF buffers after successful LaTeX runs
(add-hook 'TeX-after-compilation-finished-hook
           #'TeX-revert-document-buffer)

But it seems that only after I switched to or put the cursor in the
pdf-tools' buffer/window, the updated content will be seen in the pdf
file. I mean, when I stay in the tex source buffer/window, even the
generated pdf file has been updated, I still won't see this update.

Regards,
HY

>
> Best, Arash
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



reply via email to

[Prev in Thread] Current Thread [Next in Thread]