1.下载并安装Skim
下载链接:https://sourceforge.net/projects/skim-app/
2.配置skim
touch displayfile.txt
open displayfile.txt
在文本中写入:
#!/bin/bash
# displayfile (Skim)
#
# Usage: displayfile [-r] [-g] PDFFILE
#
# Modified from "displayline" to only revert the file, not jump to a given line
#
if [ $# == 0 -o "$1" == "-h" -o "$1" == "-help" ]; then
echo "Usage: displayfile [-r] [-g] PDFFILE
Options:
-r, -revert Revert the file from disk if it was open
-g, -background Do not bring Skim to the foreground"
exit 0
fi
# get arguments
revert=false
activate=true
while [ "${1:0:1}" == "-" ]; do
if [ "$1" == "-r" -o "$1" == "-revert" ]; then
revert=true
elif [ "$1" == "-g" -o "$1" == "-background" ]; then
activate=false
fi
shift
done
file="$1"
#shopt -s extglob
#[ $# -gt 2 ] && source="$3" || source="${file%.@(pdf|dvi|xdv)}.tex"
# expand relative paths
[ "${file:0:1}" == "/" ] || file="${PWD}/${file}"
# pass file arguments as NULL-separated string to osascript
# pass through cat to get them as raw bytes to preserve non-ASCII characters
/usr/bin/osascript \
-e "set theFile to POSIX file \"$file\"" \
-e "set thePath to POSIX path of (theFile as alias)" \
-e "tell application \"Skim\"" \
-e " if $activate then activate" \
-e " if $revert then" \
-e " try" \
-e " set theDocs to get documents whose path is thePath" \
-e " if (count of theDocs) > 0 then revert theDocs" \
-e " end try" \
-e " end if" \
-e " open theFile" \
-e "end tell"
然后保存,继续在命令行输入:
chmod u+x displayfile.txt
mv displayfile.txt displayfile
mv displayfile /usr/local/bin/
3. 配置vscode setting
添加配置:
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.synctex.command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"latex-workshop.view.pdf.external.synctex.args": [
"-r",
"%LINE%",
"%PDF%",
"%TEX%"
],
"latex-workshop.view.pdf.external.viewer.command": "displayfile",
"latex-workshop.view.pdf.external.viewer.args": [
"-r",
"%PDF%"
],
4.配置skim
点击skim,是不会有界面的:
- 在顶部导航栏Skim -> Preferences
- 点开第4个标签Sync,配置如下:
跳转
写完latex文档并且编译完成后从插件这里打开pdf文件:
然后从PDF -> TeX文件:cmd+shift+鼠标左击