Sublime Text是一个优秀的文本编辑器,我喜欢用它来编辑与编译LaTeX文档,用到的插件是LaTeXTools,网络上的配置方法很多,但有一个问题始终困扰着我,使我差点放弃这种TeX文档编辑方式,问题描述如下:
每次编辑完tex文档后用Ctrl+B编译文档,看pdf文档时总会开启一个新的Sublime Text。
查阅了许多中文资料,始终无法找到一个解决方法。
后在查阅LaTeXTools文档的issues时,找到解决办法,问题的描述网址在:
https://github.com/SublimeText/LaTeXTools/issues/1530,
描述问题的原文如下:
I'm on Sublime Text 4113 on Windows 10.
Previously, after I've built my .tex file,
the PDF viewer would become the active window
and then it would switch back to ST being the active window.
However, as of today, after building an entirely new window pops up in ST.
I've noticed with ST 4113 there's an entry "Windows:
Always make a new window when launching main executable on Windows".
With this release being released today I'm not sure if this is an ST or LaTeXTools issue. I'd like for the previous behaviour to be restored,
where the window I am working on becomes the active window after building.
解决方法为:
For me the following fix worked:
- Go into the LaTeX Tools settings (Preferences → Package Settings → LaTeXTools → Settings – User)
- Find the setting "windows" → "sublime_exectuable" and set it to "subl.exe"
也就是在LaTeXTools设置时将网络上介绍的:
"sublime_executable": "C:\\Program Files\\Sublime Text\\sublime_text.exe"
修改为
"sublime_executable": "C:\\Program Files\\Sublime Text\\subl.exe"
后在stackoverflow上查到 sublime_text.exe 与 subl.exe 这两个文件的不同的解释:
subl will focus an existing instance of Sublime and start one if there isn't one running,
while sublime_text will always create a new window.
即 subl.exe 关注已经存在的Sublime实例,而sublime_text总是会创建一个新的窗口。
关于这个问题的描述网址为:
latex - Sublime Text 3 + LatexTool unintentional new window after compilation - Stack Overflow
终于完美的解决这个。
因此在SumatraPDF的选项中设置方向搜索命令行也应为:
"C:\Program Files\Sublime Text\subl.exe" "%f:%l"
注意此处是 subl.exe,而不是 sublime_text.exe
真正完美的解决这个了。