brew cask install mactex
(文件较大,最好开启代理下载)%!TEX program = xelatex
\documentclass{article}
\usepackage{fontspec, xunicode, xltxtra}
\setmainfont{Hiragino Sans GB} %支持中文
\title{My First Document}
\author{Wilson79}
\date{\today}
\begin{document}
\maketitle{第一章}
\section{Introduction} This is where you will write your content. 这里是是你写代码的内容
\end{document}
Automatic
,然后系统会自动识别你的文件类型,第一次按ctrl + B会让你选一个,如下面第二张图所示,以后该文件类型就都是用这个System build了%!TEX program = xelatex
,那是因为在没设置前,你必须要加这句代码才能进行编译,如果想每次不加这句话也能编译请看下面的设置%!TEX program = xelatex
了,一劳永逸"program" : "xelatex",
"command" : ["latexmk", "-cd", "-e", "$pdflatex = 'xelatex -interaction=nonstopmode -synctex=1 %S %O'", "-f", "-pdf"],
当然如果觉得修改设置看起来很复杂,可以在每篇文档前增加%!TEX program = xelatex,这会强制使用xelatex,也是解决中文的一个方法。
Official Document:https://github.com/James-Yu/LaTeX-Workshop/wiki
知乎——使用VSCode编写LaTeX
Mac系统如何配置VSCode作为LaTex的编译环境
settings.json中的配置文件如下
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
]
常用功能
latex-workshop.latex.autoClean.run 自动清理辅助文件
https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-workshoplatexautocleanrun
在 macOS 上配置 VSCode 与 Skim 的 LaTeX 正反跳转
反向搜索只要按我下面这样配置就行了,不用像上面文章里说的那么复杂地添加displayline 脚本
添加下面代码即可
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.synctex": {
"command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"args": [
"-r",
"%LINE%",
"%PDF%",
"%TEX%"
]
},
设置Skim中Sync为VScode就可以支持反向搜索
Skim:cmd + shift + 鼠标
(PDF->LaTeX)
VScode: cmd + shift + J
(LaTeX->PDF)
Vscode LaTeX 支持鼠标悬停公式预览
安装插件Rainbow Brackets 可以使得公式中的左右括号更加清楚。