AUCTeX setup SyncTeX with pdf-tools not working


(use-package auctex
  :ensure t
  :no-require t
  :commands (TeX-latex-mode)
  (setq TeX-auto-save t)
  (setq TeX-parse-self t)
  (setq-default TeX-master nil)

  ;; Use `xetex' engine for better TeX compilation for Chinese.
  ;; `TeX-engine-alist', `TeX-engine-in-engine-alist'
  (setq-default TeX-engine 'xetex)
  (with-eval-after-load 'tex-mode
    ;; "latexmk -shell-escape -bibtex -xelatex -g -f %f"
    (add-to-list 'tex-compile-commands '("xelatex %f" t "%r.pdf"))
    (add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
    (setq TeX-command "xelatex"))

  (setq-default LaTeX-command  "latex -shell-escape --synctex=1")

  (setq TeX-show-compilation t)
  ;; view generated PDF with `pdf-tools'. (this is built-in now.)
  (unless (assoc "PDF Tools" TeX-view-program-list-builtin)
    (add-to-list 'TeX-view-program-list-builtin '("PDF Tools" TeX-pdf-tools-sync-view)))
  (unless (equalp "PDF Tools" (car (cdr (assoc 'output-pdf TeX-view-program-selection))))
    (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")))

  ;; [ SyncTeX ] -- Sync (forward and inverse search) PDF with TeX/LaTeX.
  (setq TeX-source-correlate-mode t)
  (setq TeX-source-correlate-method '((dvi . source-specials) (pdf . synctex))) ; default
  ;; [C-c C-g] switch between LaTeX source code and PDF positions.
  (setq TeX-source-correlate-start-server t)
  (TeX-source-correlate-mode t)
  ;; update PDF buffers after successful LaTeX runs.
  (add-hook 'TeX-after-TeX-LaTeX-command-finished-hook #'TeX-revert-document-buffer))

但是按 C-c C-v pdf-tools浏览PDF的时候还是报错:

epdfinfo: Unable to create synctex scanner, did you run latex with `--synctex=1' ?

有谁有设置好的,能看看是什么问题么?猜测好像是latex编译端的命令需要加 --synctex=1 或者 pdf-tools 命令那边。不知道咋搞。

  (add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex --synctex=1%(mode)%' %t" TeX-run-TeX nil t))


@xhcoding 非常感谢啊,问题解决了。嘿嘿