修改PDF文件时自动刷新Mac预览

Chi*_*ong 15 pdf macos latex preview

我在Mac机器上编写LaTeX,同时使用Mac的Preview.app进行预览.重新编译LaTeX文件后:

  1. Preview.app不会自动刷新,
  2. 当我单击预览窗口时,它会刷新,但跳转到文档的顶部.

我想知道是否有一种配置方式,所以

  1. 当基础PDF文件发生变化时,Preview.app会自动刷新,
  2. 刷新后,Preview.app停留在同一页面上.

Sig*_*ius 13

我自己也很生气,(不幸的是)我只有一个"黑客"解决方案.

您可以在单页模式(cmd 2)中查看pdf,以便在排版后保持在同一页面上.

我希望有人发布一个永久解决方案,适用于连续滚动.


Mar*_*ell 6

我相信有几种选择......

  1. 安装Skim,请看这里.

  2. fswatch您可以安装的东西放在一起使用,homebrew以提供类似于Linux的东西,inotify并设置运行监视PDF,并在修改一个时,使用一些Applecript刷新预览.

它看起来像这样:

fswatch -iI ./*.pdf | xargs -I{} ./RefreshPreview {}
Run Code Online (Sandbox Code Playgroud)

并且RefreshPreview是这样的:

#!/bin/bash
osascript -e 'tell application "Preview" to quit'
sleep 1
open -a Preview "$1"

# If you don't want Preview to come forwards and get focus, use the following
# open -g -a Preview "$1"
Run Code Online (Sandbox Code Playgroud)

如果您不熟悉脚本,则需要在Terminal中使脚本可执行

chmod +x RefreshPreview
Run Code Online (Sandbox Code Playgroud)

我刚刚发现更简单,更优雅的脚本会更好用:

#!/bin/bash
osascript<<EOF
tell application "Preview" to open POSIX file "$1"
EOF
Run Code Online (Sandbox Code Playgroud)