1.安装MacTex:
MacTex一键下载,轻松完成环境配置,整体大小约为4G请配合WI-FI食用。下载链接:
http://www.tug.org/mactex/mactex-download.html
2.安装VS Code:
VS Code是很实用的编辑器,而且有很多插件(强烈推荐background)。支持MacOS/Windows/Linux。主页链接:
3.在VSCode中安装插件:
- LaTeX Workshop
- Chinese Language Pack(这个是中文插件,随便下一个即可)。
安装后重启以启用代码。
4.VS Code插件配置:
LaTeX Workshop默认使用pdfLaTeX进行编译,在这种配置方法下会报错。
所以我们要改为XeLaTeX编译。
修改配置过程如下:
Command+Shift+P打开settings.json
或者手动
settings.json
插入(复制粘贴即可)如下代码:
{
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "xe*2",
"tools": [
"xelatex",
"xelatex"
]
},
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
],
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.view.pdf.viewer": "tab"
}
5.导出pdf:
大家可以用这个简单的测试一下,
新建一个test.tex
% !TEX program = xelatex
\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage{fontspec}
\usepackage{booktabs}
\usepackage{graphicx}
\title{Title}
\author{breeze}
\begin{document}
\maketitle{maketitle}
\section{Introduction}
This is where you will write your content. 在这里写上内容。
\begin{equation}
a+b=\gamma\label{eq}
\end{equation}
\begin{table}[ht]
\caption{示例表格}
\centering
\label{tab}
\begin{tabular}{lcl}
\toprule
A & B & C \\
\midrule
abc & abc & abc \\
abc & abc & abc \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
编译时选择"Recipe: xelatex" 或"Recipe: xe*2"进行编译
6. 预览pdf
7.使用:
现在同学们可以通过下载模版等方式(大佬也可以自己写模版)快乐的写LaTeX啦。
编译快捷键:Command+Option+B
显示快捷键:Command+Option+V
正向搜索:选中代码Command+Option+J
反向搜索:shift+command点击预览PDF
https://zhuanlan.zhihu.com/p/38178015
https://zhuanlan.zhihu.com/p/107393437?utm_source=wechat_session