Emacs + Synctex + Skim:如何正确设置同步? [现有方法没有正常工作] [英] Emacs + Synctex + Skim: How to correctly set up synchronization? [none of the existing methods worked properly]
问题描述
所以我的.emacs包含:
'(LaTeX命令latex -synctex = 1)
(require'tex-site)
(add-hook'TeX-mode-hook
(lambda()
(add-to-list'TeX-output-view-style
'(^ pdf $
/Applications/Skim.app/Contents/SharedSupport/displayline -b%n%o%b)))
)
(服务器启动)$ b $当然,我也设置了Skim(首选项 - >同步 - >选中检查文件更改,并选择了预设:Emacs与命令emacsclient和参数--no-wait +%line%file)
正如你所看到的,我包括 -b
选项进行显示线。我可以从终端调用显示线,并打开.pdf并显示相应的行与黄色/突出显示的条。但是,如果我在Emacs.app中的shell中使用 latexmk -pvc -pdf
编译文档,则不会显示任何内容。
问题1:我如何让这个工作/如何显示当前行?
问题2:是否可能有一个通过单击.tex并跳转到.pdf文档中的相应行进行正确搜索。如何在emacs中点击?标准CMD + shift +点击在emacs中不起作用。
我也尝试过使用...
(setq TeX-source-correlate-method'synctex)
(add-hook'LaTeX-mode-hook'TeX-source-correlate-mode)
...但没有变化。
我可以在CMD + shift +点击。 pdf并跳转到.tex,这样就可以了。
我没有研究的唯一方向是:
-
这是一个乳胶问题吗?很可能没有,因为latexmk显式显示 pdflatex -interaction = nonstopmode -synctex = 1
所以synctex被识别
-
偏移设置是否错误?也许我必须调整emacsclient的参数(?)
解决方案 p>
确实,乳胶是问题。我终于想出了以下设置:
〜/ .emacs
;;通过C-c C-c
;;制作乳胶注意:SyncTeX通过〜/ .latexmkrc(见下文)设置
(add-hook'LaTeX-mode-hook(lambda()
(push
'(latexmklatexmk - pdf%sTeX-run-TeX nil t
:help运行latexmk文件)
TeX-command-list)))
(add-hook'TeX-mode-hook '(lambda()(setq TeX-command-defaultlatexmk)))
;;使用Skim作为默认pdf查看器
;; Skim的显示线用于转发搜索(从.tex到.pdf)
;;选项-b突出显示当前行;选项-g打开背景中的Skim
(setq TeX-view-program-selection'((output-pdfPDF Viewer)))
(setq TeX-view-program-list
'((PDF Viewer/Applications/Skim.app/Contents/SharedSupport/displayline -b -g%n%o%b)))
(server-start);在服务器模式下启动emacs,以便skim可以与它对话
〜/ .latexmkrc
$ pdflatex ='pdflatex -interaction = nonstopmode -synctex = 1%O%S';
$ pdf_previewer ='open -a skim';
$ clean_ext ='bbl rel%R-blx.bib%R.synctex.gz';
这完全允许使用latexck作为Cc Cc和Cc Cc的默认编译Cv Cv在当前行打开Skim这很突出。使用.pdf中的CMD + shift +单击,可以跳转到.tex文件中的相应段落(感谢 server-start
)。
解决方案要启用同步的点击功能,我添加了:
(add-hook'LaTeX-mode-hook
(lambda()(local-set-key(kbd< Ss-mouse-1>)#'TeX-view) )
)
到我的 .emacs
文件。
注意:确保您在 PDF
模式(使用 (setq TeX-PDF-mode t)
)。
I'm working with GNU Emacs 23.3 (9.0) on Mac OS X 10.7.2. I would like to use synctex to jump between .tex and .pdf files. Although there are many different approaches on the web, none worked properly (I tried 8 different approaches...). I finally ended up with the rather simple approach described here: http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=TeX_and_PDF_Synchronization
So my .emacs contains:
'(LaTeX-command "latex -synctex=1")
(require 'tex-site)
(add-hook 'TeX-mode-hook
(lambda ()
(add-to-list 'TeX-output-view-style
'("^pdf$" "."
"/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b")))
)
(server-start)
Of course, I also set up Skim (Preferences -> Sync -> checked "Check for file changes" and chose Preset: Emacs with command emacsclient and arguments --no-wait +%line "%file")
As you can see, I included the -b
option to displayline. I can call displayline from the terminal and it opens the .pdf and displays the corresponding line with a yellow/highlighted bar. Still, nothing is displayed on the current line if I compile the document with latexmk -pvc -pdf
from a shell within Emacs.app.
Question 1: How can I get this to work/How can I display the current line?
Question 2: Is it possible to have a "proper" forward search by clicking the .tex and jumping to the corresponding line in the .pdf document? How can I "click" in emacs? The standard CMD + shift + click does not work in emacs.
I also tried approaches using...
(setq TeX-source-correlate-method 'synctex)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
... but nothing changes.
I can CMD + shift + click in the .pdf and jump to the .tex, so that works.
The only directions which I haven't looked into are:
is this a latexmk problem? Most likely not, since latexmk explicitly displays pdflatex -interaction=nonstopmode -synctex=1
so synctex is recognized
is it a wrong skim preference setting? Maybe I have to adjust the arguments to emacsclient there (?)
Solution
Indeed latexmk is the problem. I finally figured out the following settings:
~/.emacs
;; make latexmk available via C-c C-c
;; Note: SyncTeX is setup via ~/.latexmkrc (see below)
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("latexmk" "latexmk -pdf %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")))
;; use Skim as default pdf viewer
;; Skim's displayline is used for forward search (from .tex to .pdf)
;; option -b highlights the current line; option -g opens Skim in the background
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))
(server-start); start emacs in server mode so that skim can talk to it
~/.latexmkrc
$pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S';
$pdf_previewer = 'open -a skim';
$clean_ext = 'bbl rel %R-blx.bib %R.synctex.gz';
This perfectly allows to compile with latexmk as default on C-c C-c and C-c C-v opens Skim at the current line which is nicely highlighted. With CMD + shift + click in the .pdf, one can then jump back to the corresponding paragraph in the .tex file (thanks to server-start
).
解决方案 To enable the clicking feature of the sync, I added:
(add-hook 'LaTeX-mode-hook
(lambda () (local-set-key (kbd "<S-s-mouse-1>") #'TeX-view))
)
to my .emacs
file.
NOTE: make sure that you are in PDF
mode (use (setq TeX-PDF-mode t)
).
这篇关于Emacs + Synctex + Skim:如何正确设置同步? [现有方法没有正常工作]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!